akhauriyash/Code-Regression huggingface dataset:
a,b = map(int,input().split())
from fractions import gcd
max = gcd(a,b) 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

div_list = make_divisors(max)

count = 1
for i in range(len(div_list)):
#     print(div_list[i])
#     print(is_prime(div_list[i]))
    if is_prime(div_list[i]):
        count += 1

print(count)

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

typedef long long ll;
#define INF 2000000000
#define MAX 500000

int L[MAX /2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    //L[n1],R[n2]を生成
    for(int i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = INF;
    R[n2] = INF;

    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int A[], int left, int right){
    if(left + 1 < right){
        int mid = (left +right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    int n, A[MAX];
    cnt = 0;

    cin >> n;

    rep(i,n) cin >> A[i];

    mergeSort(A, 0, n);

    rep(i,n){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll powmod(ll a, ll n, ll m = MOD) {
    ll ret = 1;
    for (; n > 0; n >>= 1, a = a * a % m) {
        if (n % 2 == 1) {
          ret = ret * a % m;
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    
    ll a = powmod(10, n);
    ll b = powmod(9, n);
    ll c = powmod(8, n);
    ll ans = a - b * 2 + c;
    ans = ((ans % MOD) + MOD) % MOD;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3628
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll int n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;

     return EXIT_SUCCESS;
}



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

int main() {
  double l;
  double a,p;
  cin >> l;
  a =(double)l/3;
  p = a*a*a;
  cout << fixed << setprecision(8) << endl;
  cout << p <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 105
#define WHITE 0
#define GRAY 1
#define BLACK 2

int d[N],f[N];
int n;
int color[N],t,a[N][N];

void dfs();
void visit(int);

int main(){
  int id,v,k;
  int i,j;

  scanf("%d",&n);
  for(i=1; i <= n; i++){
    for(j=1; j <=n; j++){
      d[i]=0;
      f[i]=0;
    a[i][j]=0;
  }
  }

 for(i=1; i <= n; i++){
    scanf("%d%d",&id,&k);
    for(j=1; j <=k; j++){
      scanf("%d",&v);
      a[id][v]=1;
    }
  }
    dfs();

  return 0;
}

void dfs(){
  int i;

  for(i=1; i <=n; i++){
    color[i]=WHITE;
  }
  t=0;
  for(i=1; i <=n; i++){
    if(color[i]==WHITE) visit(i);
  }
  for(i=1; i <=n; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
}
}

void visit(int u){
  int i;
  color[u]=GRAY;
  d[u]=++t;
  for(i=1; i <= n; i++){
    if(a[u][i]==0) continue;
      if(color[i]==WHITE){
	visit(i);
      }
  }
      color[u]=BLACK;
      f[u]=++t;
}

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


int main() {
  string a, b;
  cin >> a >> b;
  if (a == b) cout << "H" << endl;
  else cout << "D" << endl;
  return 0;
}

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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = 1145141919;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vll = vector<ll>;
using vbool = vector<bool>;

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

    vbool isprime(60000, true);
    vector<vint> mod5(5, vint());
    // a[i]%5==2 for any i => (a[p]+a[q]+a[r]+a[s]+a[t])%5==0
    for (int i = 2; i < 60000; i++) {
        if (isprime[i]) {
            for (int j = i; j < 60000; j += i) {
                isprime[j] = false;
            }
            mod5[i % 5].pb(i);
        }
    }
    // REP(i, 5) {
    //     cout << mod5[i].size() << endl;
    // }
    REP(i, N) {
        if (i)
            cout << " ";

        cout << mod5[1][i];
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int n; cin >> n;
    rep(i,3){
        int a=0;
        a = n%10;
        if(a==7){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    double D = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            D += sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
        }
    }

    printf("%.8lf\n", 2*D/N);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n/100==1){
    cout<<9;
    n-=100;
    if(n/10==1){
      cout<<9;
      n-=10;
      if(n==1){
        cout<<9;
      }
      else if(n==9){
        cout<<1;
      }
    }
    else if(n/10==9){
      cout<<1;
      n-=90;
      if(n==1){
        cout<<9;
      }
      else if(n==9){
        cout<<1;
      }
    }
  }
  else if(n/100==9){
    cout<<1;
    n-=900;
    if(n/10==1){
      cout<<9;
      n-=10;
      if(n==1){
        cout<<9;
      }
      else if(n==9){
        cout<<1;
      }
    }
    else if(n/10==9){
      cout<<1;
      n-=90;
      if(n==1){
        cout<<9;
      }
      else if(n==9){
        cout<<1;
      }
    }
  }
  return 0;
}

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

int main(){
    string S;
    cin>>S;
    int size=S.size();
    int count01=0;
    int col=0;
    int B=count(S.cbegin(),S.cend(),'0');
    int halfsize;
    for(int i=0;i<size;i+=2){
        if(S[i]=='0'){
            count01+=1;
        }
    }
    if(size%2==0){
        halfsize=size/2;
    }else{
        halfsize=(size+1)/2;
    }
    cout<<min(B+halfsize-2*count01,size-halfsize-B+2*count01)<<endl;

}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	var n int
	fmt.Scan(&n)
	sc.Split(bufio.ScanWords)
	b := nextInts(n - 1)

	res := make([]int, n)
	res[0], res[1] = b[0], b[0]
	for i := 1; i < n-1; i++ {
		if res[i] > b[i] {
			res[i] = b[i]
		}
		res[i+1] = b[i]
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += res[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let mut ok = true;
    for i in 1 .. s.len() {
        if s[i-1] == s[i] {
            ok = false;
        }
    }
    if ok {
        println!("Good");
    } else {
        println!("Bad");
    }
}

Measured memory_bytes: 4352
#include<stdio.h>

void insertionSort(int *,int,int);
void shellSort(int *,int);
int cnt,mcnt=0;
int main(){

  int i,n;
  int A[2000000];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  shellSort(&A[0],n);

  for(i=0;i<n;i++)printf("%d\n",A[i]);

  return 0;
}

void shellSort(int *A,int n){
  int m,i,j;
  int G[100];
  cnt=0;
  m=99;
  for(i=m;i>=0;i--) {
    G[i]=1+(m-i)*6;
    if(G[i]<=n)mcnt++;
  }
    
  
  for(i=0;i<m+1;i++) insertionSort(A,n,G[i]);
    
  printf("%d\n",mcnt);
  for(i=m-mcnt+1;i<m;i++) printf("%d ",G[i]);
  printf("%d\n%d\n",G[i],cnt);
}

void insertionSort(int *A,int n,int g){
  int v,j,i;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}



Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; string s;
    cin >> n >> s;
    int nw = 0, mn = 0;
    for (int i = 0; i < n; ++ i) {
        nw += s[i] == '(' ? 1 : -1;
        mn = min(mn, nw);
    }
    cout << string(-mn, '(') + s + string(nw - mn, ')') << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	string S;
	cin>>S;
	int A=(S[0]-'0')*10+(S[1]-'0');
	int B=(S[2]-'0')*10+(S[3]-'0');
	bool a=false;
	bool b=false;
	if(A<=12&&0<A){
		a=true;
	}
	if(B<=12&&0<B){
		b=true;
	}
	if(a==true&&b==true){
		cout<<"AMBIGUOUS"<<endl;
	}
	if(a==false&&b==true){
		cout<<"YYMM"<<endl;
	}
	if(a==true&&b==false){
		cout<<"MMYY"<<endl;
	}
	if(a==false&&b==false){
		cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <map>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    std::vector<int> distanceTable(5);
    for (auto i=0; i<5; ++i)
        std::cin >> distanceTable[i];

    int k;
    std::cin >> k;

    for (auto from=0; from<5; ++from)
    {
        for (auto to=0; to<5; ++to)
        {
            if (from == to)
                continue;

            if (k < std::abs(distanceTable[from] - distanceTable[to]))
            {
                std::cout << ":(" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yay!" << std::endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = sc.nextLong();
        out.println((1000 - n % 1000) % 1000);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32824
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
double dis[1005];
vector<vector<pair<ll,double> > > g(1005);
void dijkstra(ll start){
    for(int i=0;i<1005;i++)dis[i]=1e18;
    dis[start]=0.0;
    multiset<pair<double,ll> > ms;
    ms.insert(make_pair(0.0,start));
    pair<ll,double> niko;
    pair<double,ll> p;
    ll maki;
    while(!ms.empty()){
        p=*(ms.begin());
        ms.erase(ms.begin());
        if(dis[p.second]<p.first)continue;
        maki=g[p.second].size();
        for(int i=0;i<maki;i++){
            niko=g[p.second][i];
            if(dis[niko.first]>dis[p.second]+niko.second){
                dis[niko.first]=dis[p.second]+niko.second;
                ms.insert(make_pair(dis[niko.first],niko.first));
            }
        }
    }
    return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    ll n;
    cin>>n;
    double x[n+2],y[n+2],r[n+2];
    x[0]=a;y[0]=b;x[n+1]=c;y[n+1]=d;r[0]=r[n+1]=0.0;
    for(int i=1;i<=n;i++){
    	cin>>x[i]>>y[i]>>r[i];
    }
    for(int i=0;i<=n+1;i++){
    	for(int j=0;j<=n+1;j++){
    		if(i==j)continue;
    		g[i].push_back({j,max(0.0,sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))-r[i]-r[j])});
    	}
    }
    dijkstra(0);
    doublecout(dis[n+1]);

    return 0;
}


Measured memory_bytes: 32128
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,k; cin >> n >> k;
  ll r,s,p; cin >> r >> s >> p;
  string t; cin >> t;
  vector<char> rev(n);
  
  
  ll ans=0;
  rep(i,n){
    char ch;
    if(t[i]=='r') ch = 'p';
    else if(t[i]=='s') ch = 'r';
    else ch = 's';
    
    rev[i] = ch;
    
    ll val;
    if(ch=='p') val = p;
    else if(ch=='r') val = r;
    else val = s;
    
    if(i<k){
      ans += val;
    }else if(rev[i-k]!=ch){
      ans += val;
    }else{
      rev[i] = '0';
    }
  }
  
  cout << ans << endl;
  
  return 0;
}










Measured memory_bytes: 512
package main

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

func main() {
	io := NewIo()
	defer io.Flush()

	n, k := io.NextInt(), io.NextInt()

	if n%k == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(n % k)
	}
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

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

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

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

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

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


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

int main(){
    int k, a, b, count=0;
    long long int ans=1;
    cin >> k >> a >> b;
    while(count<k){
        while(ans>=a){
            if(a+2<=b && count+2<=k){
                ans-=a;
                ans+=b;
                count+=2;
            }
            else{
                break;
            }
        }
        if(count+1<=k){
        count++;
        ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	vector<ll> t(N);
	rep(i, N) {
		cin >> s[i] >> t[i];
	}
	string X;
	cin >> X;
	ll ans = 0;
	bool P = 0;
	rep(i, N) {
		if (P)
			ans += t[i];
		if (s[i] == X)
			P = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let s = o.s();
  let n = Number(s[s.length-1]);
  if(n==2||n==4||n==5||n==7||n==9){
    o.o('hon');
  }else if(n==3){
    o.o('bon')
  }else{
    o.o('pon')
  }
}
m();

Measured memory_bytes: 29544
import java.util.*;

public class Main {
	int N;
	int base = -1;
	boolean enable;
	int[][] array;

	private Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		in.close();
		int sum = 0;
		for (int i = 1; i < 100000; ++i) {
			sum += i;
			if (sum == N) {
				enable = true;
				base = i - 1;
				break;
			}
			if (sum > N) {
				enable = false;
			}
		}
		if (enable) {
			array = new int[base + 1][base + 1];
			int val = 1;
			for (int i = 0; i < base + 1; ++i) {
				array[0][i] = val;
				array[i][0] = val;
				val += i + 1;
			}
			for (int i = 1; i < base + 1; ++i) {
				for (int j = 1; j <= i; ++j) {
					array[i][j] = array[i][j - 1] + 1;
					array[j][i] = array[j - 1][i] + 1;
				}
			}
			for (int i = 1; i < base + 1; ++i) {
				for (int j = i + 1; j < base + 1; ++j) {
					array[i][j] = array[i - 1][j] + 1;
					array[j][i] = array[j][i - 1] + 1;
				}
			}
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		if (!ins.enable) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
			System.out.println(ins.array.length + 1);
			for (int i = 0; i < ins.array.length; ++i) {
				System.out.print(ins.array[i].length);
				for (int j = 0; j < ins.array[i].length; ++j) {
					System.out.print(" " + ins.array[i][j]);
				}
				System.out.println("");
			}
			System.out.print(ins.array.length);
			for (int i = 0; i < ins.array.length; ++i) {
				System.out.print(" " + ins.array[i][i]);
			}
			System.out.println("");
		}
	}

}

Measured memory_bytes: 41640
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, XYZ):
    g = defaultdict(dict)
    for x, y, z in XYZ:
        g[x][y] = z % 2
        g[y][x] = z % 2

    ans = 0
    done = set()
    for i in range(1, N+1):
        if i in done:
            continue
        ans += 1
        q = deque([i])
        while q:
            u = q.popleft()
            done.add(u)
            for v in g[u]:
                if v not in done:
                    q.append(v)
                    done.add(v)
    return ans


def main():
    # N = read_int()
    N, M = read_int_n()
    XYZ = [read_int_n() for _ in range(M)]
    print(slv(N, M, XYZ))

    # N = 10**5
    # XYZ = [random.randint()]


if __name__ == '__main__':
    main()


Measured memory_bytes: 83824
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin>>n;
	int ans[100];
    for(int i = 0;i < n;i++)
	  scanf("%d",&ans[i]);
	ans[n++] = 0;
	int cnt[20],ab[25];
	memset(cnt,0,sizeof(cnt));
	bool flag = false;
	for(int i = 0;i < n;i++)
	 {
	 	cnt[ans[i]]++;
	    if(cnt[ans[i]] >= 3)
	    flag = true;
	 }
	 if(cnt[0] >= 2)flag = true;
	 if(flag)
	   cout<<"0"<<endl;
	 else 
	 {  int minn = 0;
	 	for(int i = 0;i < (1<<13);i++)
	 	{   
	 	    memset(ab,0,sizeof(ab));
	 	    bool f = false;
	 	  	for(int j = 0;j <= 12;j++)
	 	  	{
	 	  	   if(i&(1<<j))
	 	  	   {
	 	  	   	 if(cnt[j]==1)
	 	  	   	   ab[(24-j)%24] = 1;
			     else if(cnt[j] == 2)
				   ab[j] = ab[(24-j)%24] = 1;
			   }
			   else 
			   {
			   	   if(cnt[j]==2)
			   	   {
			   	   	f = true;
				   }
				   else if(cnt[j] == 1)
				   ab[j] = 1;
			   }
			}
			if(!f)
			{
				int id = 0;
			    int maxx = 1e9;
			    for(int j = 1;j <= 23;j++)
			    {   
			    	if(ab[j])
			    	maxx = min(maxx,j-id),id = j;
				}
				maxx = min(maxx,(24-(id - 0))%24);	
				minn = max(maxx,minn);
			}
		}
		cout<<minn<<endl;
	 }
	return 0;
}

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

using namespace std;

int N;

int check[10000007];

vector<long long int> p;

int v[10000007];


long long int calc(long long int K) {

	long long int num = 1;

	long long int tmp = K;

	for (int i = 0; ; i++) {
		if (p[i] * p[i] > K) { break; }
		long long int cnt = 0;
		while ((tmp%p[i]) == 0) {
			tmp /= p[i]; cnt++;
		}

		num *= (cnt + 1);

	}

	if (tmp > 1) { num *= 2; }
	return num;

}

long long int F[10000007];
long long int INF = 10000000;


int main(void) {

	cin >> N;

	check[1] = 1;
	for (int i = 2; i <= 10000000; i++) {
		if (check[i] ==0) {
			for (int j = i * 2; j <= 10000000; j += i) {
				check[j] = 1;
			}
		}
	}

	

	for (int i = 2; i <= 10000000; i++) {
		if (check[i] == 0) { p.push_back(i); }
	}

	F[1] = 1;

	for (int i = 0; i < (int)p.size(); i++) {
		long long int tmp = 1; int cnt = 1;
		while (1) {
			tmp *= p[i]; if (tmp > INF) { break; }
			cnt++;
			F[tmp] = cnt;
			//cout << tmp << endl;
		}

	}

	for (int i = 1; i <= INF; i++) {
		if (F[i] > 0) { continue; }
		int y;
		for (int j = 0; j < (int)p.size(); j++) {
			if (i%p[j] == 0) { y = (int) p[j]; break; }
		}

		int cnt = 1;

		int tmp = i;
		while (tmp%y == 0) {
			tmp /= y; cnt++;
		}

		F[i] = F[tmp] * cnt;
	}
	


	long long int ans = 0;

	for (long long int k = 1; k <= (long long int) N; k++) {
		
		ans += k*F[k];
	}

/*	for (int i = 1; i <= 20; i++) {
		cout << "F[" << i << "]= " << F[i] << endl;
	}*/

	cout << ans << endl;


	return 0;
}

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

const ll INF = 1e17;

struct edge {
	int to;
	ll cost;
	edge(int t, ll c) : to(t), cost(c) {}
};

using edges = vector<edge>;
using graph = vector<edges>;

struct dijk {
	int v;
	ll dist;
	dijk(int v, ll d) : v(v), dist(d) {}
	bool operator>(const dijk& that) const {
		return dist > that.dist;
	}
};

int main()
{
	int N, M;
	ll C;
	cin >> N >> M >> C;
	ll sum = 0;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int A, B, D;
		cin >> A >> B >> D; A--, B--;
		G[A].emplace_back(B, D);
		G[B].emplace_back(A, D);
		sum += D * 2;
	}
	ll res = INF;
	vector<ll> d(N, INF);
	vector<ll> dec(N);
	priority_queue<dijk, vector<dijk>, greater<>> pq;
	pq.emplace(0, 0);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		ll dist = p.dist;
		int v = p.v;
		if (d[v] != INF) continue;
		sum -= dec[v];
		d[v] = dist;
		for (auto e : G[v]) {
			if (d[e.to] == INF) {
				dec[e.to] += e.cost;
				pq.emplace(e.to, dist + e.cost);
			}
			else {
				sum -= e.cost;
			}
		}
		res = min(res, dist * C + (sum + 1) / 2);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 19168
import Control.Monad
import Control.Applicative
import Data.Array

eps :: Double
eps = 1.0e-8

data Point = Point (Double, Double) deriving (Show)
add (Point (x1, y1)) (Point (x2, y2)) = Point (x1 + x2, y1 + y2)
sub (Point (x1, y1)) (Point (x2, y2)) = Point (x1 - x2, y1 - y2)
mul (Point (x, y)) s = Point (x * s, y * s)
det (Point (x1, y1)) (Point (x2, y2)) = x1 * y2 - y1 * x2
nrm (Point (x, y)) = Point (x / n, y / n) where n = sqrt $ (x * x + y * y)
dst (Point (x, y)) = sqrt $ (x * x + y * y)

getX (Point (x, _)) = x
getY (Point (_, y)) = y

parsePoint :: String -> Point
parsePoint str =
    let [x, y] = map read $ words str
    in Point (x, y)

calcCenter :: Point -> Point -> (Point, Point)
calcCenter a b =
    let m = (a `add` b) `mul` 0.5
        d = sqrt (1.0 - ((dst $ a `sub` m) ** 2.0))
        e = a `sub` b
        n = nrm $ Point (negate $ getY e, getX e)
        c1 = m `add` (n `mul` d)
        c2 = m `sub` (n `mul` d)
    in (c1, c2)

solve' :: [Point] -> Int
solve' pts =
    let np    = length pts
        parr  = listArray (0, np-1) pts
        pairs = [ (parr ! i, parr ! j) | i <- [0..np-1], j <- [i+1..np-1] ]
    in if null pairs
        then 1
        else maximum $ map countUp pairs where
            countUp (p, q) =
                if (dst $ p `sub` q) >= (2.0 - eps)
                    then 1
                    else
                        let (c1, c2) = calcCenter p q
                            m1 = length $ filter (\p -> (dst $ p `sub` c1) <= 1.0 + eps) pts
                            m2 = length $ filter (\p -> (dst $ p `sub` c2) <= 1.0 + eps) pts
                        in (max m1 m2)

solve :: [String] -> [Int]
solve []   = []
solve cont =
    let n           = read (head cont) :: Int
        (crds, rst) = splitAt n (tail cont)
        pts         = map parsePoint crds
    in if n == 0 then []
                 else (solve' pts) : solve rst

main :: IO ()
main = do
    contents <- getContents
    mapM_ print $ solve $ lines contents

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

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

		 //br.readline(); = 入力された１行分を日本語変換して返してくれる。
		 String str = br.readLine();

		 /*配列の型(intとかStringとか) [] 配列名 = 配列を用意
		  *今回はstrAryって配列にstrを入れてる。
		  *str.split = splitってのはString内に用意されてるメソッド
		  *文字列を分割するときに使用。今回は空白で区切ってって仕様なので
		  *split(" ")としてます。*/
		 String[] strAry = str.split(" ");

		 /*おなじみの文字列から数値への変換。
		  *ただし今回は指定先が配列の何番って風になってる。*/
		 int a = Integer.parseInt(strAry[0]);
		 int b = Integer.parseInt(strAry[1]);

		 int d =	a / b;		//d(a÷bの整数を表示)
		 int r =	a % b;		//r(a÷bの余りを表示)
		 double f = (double)a / (double)b;	//f(a÷bの浮動小数点を表示)

		 /*今回は桁数出すためprintfを使用
		  * % = 文字表示用
		  * d = 10進数の整数
		  * %d = 10進数の整数を文字表示、みたいな使い方
		  * .7で小数点以下を７桁表示してる
		  * \nは改行用
		  */
		 System.out.printf("%d %d %.7f\n", d, r, f);

    }
}

Measured memory_bytes: 17084
#include<stdio.h>

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


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
  	cin >> s.at(i);
  }
  sort(ALL(s));
  int count=0;
  int max=0;
  rep(i,n-1){
    if(s.at(i)==s.at(i+1)){
      count++;
    }else{
      if(count>max){
        max=count;
      }
      count=0;
    }
  }
  if(count>max){
    max=count; 
  }
  count=0;
  rep(i,n-1){
    if(s.at(i)==s.at(i+1)){
      count++;
    }else{
      if(count==max){
        cout << s.at(i) << endl;
      }
      count=0;
    }
  }
  if(count==max){
    cout << s.at(n-1) << endl;
  }
}




Measured memory_bytes: 14208
# coding: utf-8
import math
import itertools

n = int(input())

ans = [0] * n

for x, y, z in itertools.product(range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n)))):
    idx = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if idx <= n:
        ans[idx-1] += 1

print(*ans, sep="\n")

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;




int main(){
int a;
  cin>>a;
int b;
  cin>>b;
  string c;
cin>>c;
  char k=c.at(0);
  int t=0;
  for(int i=1;i<a;i++)
  {
if(k!=c.at(i)) {
  k=c.at(i);
  t=t+1;
}
  
  }
  int d;
  d=a-1-t;
  for(int i=0;i<b;i++)
  {
  if(d<a-2) d=d+2;
    else if(d=a-2) d=d+1;
    else if(d=a-1) break;
  
  }
  cout<<d;
}
 


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

int main() {
  string S;
  cin >> S;
  for(int i=0 ; i<S.size() ; i++){
    if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C')
      S.at(i)='T';
    else
      S.at(i)='F';
  }
  if(S.find("TTTTTTTTTT") < 20 )
    cout << 10 << endl;
  else if(S.find("TTTTTTTTT") < 20 )
    cout << 9 << endl;
  else if(S.find("TTTTTTTT") < 20 )
    cout << 8 << endl;
  else if(S.find("TTTTTTT") < 20 )
    cout << 7 << endl;
  else if(S.find("TTTTTT") < 20 )
    cout << 6 << endl;
  else if(S.find("TTTTT") < 20 )
    cout << 5 << endl;
  else if(S.find("TTTT") < 20 )
    cout << 4 << endl;
  else if(S.find("TTT") < 20 )
    cout << 3 << endl;
  else if(S.find("TT") < 20 )
    cout << 2 << endl;
  else if(S.find("T") < 20 )
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
     
    typedef long long ll;
     
    int main(){
        ll N,M;
        cin>>N>>M;
        
        vector<ll> a(M);
        for(ll i=0;i<M;i++){
            cin>>a.at(i);
        }
        
        map<ll,ll> mp2;
        for(ll i=1;i<=N;i++){
            mp2[i]=0;
            //壊れていたら1をかえす
        }
        for(ll i=0;i<M;i++){
            mp2[a.at(i)]=1;
        }
     
        map<ll,ll> mp;
        for(ll i=1;i<=N;i++){
            mp[i]=0;
        }
        if(N==1){
            cout<<1<<endl;
        }
        if(N==2){
            if(M==1){
                cout<<1<<endl;
            }
            else{
                cout<<2<<endl;
            }
        }
        if(N>2){
            if(M==0){
                mp[1]=1;
                mp[2]=2;
            }
            if(M==1){
                if(a.at(0)==1){
                    mp[1]=0;
                    mp[2]=1;
                }
                else if(a.at(0)==2){
                    mp[1]=1;
                    mp[2]=0;
                }
                else{
                    mp[1]=1;
                    mp[2]=2;
                }
            }
            if(M>1){
                if(a.at(0)==1 && a.at(1)==2){
                    mp[1]=0;
                    mp[2]=0;
                }
                else if(a.at(0)==1){
                    mp[1]=0;
                    mp[2]=1;
                }
                else if(a.at(0)==2){
                    mp[1]=1;
                    mp[2]=0;
                }
                else{
                    mp[1]=1;
                    mp[2]=2;
                }
            }
            for(ll i=3;i<=N;i++){
                if(mp2[i]==0 && mp2[i-1]==0 && mp2[i-2]==0){
                    mp[i]=mp[i-1]+mp[i-2];
                }
                else if(mp2[i]==1){
                    mp[i]=0;
                }
                else if(mp2[i-1]==1 && mp2[i-2]==1){
                    mp[i]=0;
                    break;
                }
                else if(mp2[i-1]==1){
                    mp[i]=mp[i-2];
                }
                else if(mp2[i-2]==1){
                    mp[i]=mp[i-1];
                }
                mp[i]%=1000000007;
            }
            cout<<mp[N]%1000000007<<endl;
        }
    }
    /*
    メモ書き
    mp[i]=mp[i-1]+mp[i-2](条件によって片方消えたりなんたり)に落とし込みたい
    初期値を与える必要
    条件を処理する必要
    M=0をいかに処理するか
    そもそもM=0のときvector a(M)ってどうなる？
    mp2[]を作って壊れた階段をキーに壊れた階段には特定の値を入れることで階段数から壊れているかの処理できそう
    */

Measured memory_bytes: 13568
import sys
import copy
N=int(input())
H = [int(x) for x in input().split()]

if N==1:
    print(H[0])
    sys.exit()

cnt=0
while True:
    f=True
    for h in H:
        if h!=0:
            f=False
            break
    if f:
        break

    H_new = copy.copy(H)
    if H[0]!=0:
        if H[0]!=0:
            cnt+=1
        H_new[0]-=1
    for i in range(1,len(H)):
        if H[i-1]==0 and H[i]!=0:
            cnt+=1
        if H_new[i]!=0:
            H_new[i]-=1
    H = copy.copy(H_new)


print(cnt)


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main(){
    int a,b;
    int ans=0;
    cin>>a>>b;
    rep(i,a,b+1){
        string s=to_string(i);
        bool f=true;
        rep(i,0,s.length()/2){
            if(s[i]!=s[s.length()-i-1])f=false;
        }
        if(f)ans++;
    }
    cout<<ans<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m>>cnt;
    cnt=abs(m-cnt);
    rep(i,n-1){
        cin>>ans;
        cnt=gcd(abs(ans-m),cnt);
    }
    cout<<cnt;
}

Measured memory_bytes: 10496
#include<stdio.h>

int se(int X[],int num,int bn){
  int i=0;
  X[num] = bn;
  
  while(X[i] != bn){
    i++;
  }
  return i != num;
}

int main(){
  int i,num,An[10000+1],Bn,num2,S=0;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&An[i]);
  }

  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&Bn);
    if(se(An,num,Bn)){
      S++;
    }
  }

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

    return 0;
	  	 
}



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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++)
  {
    if(i%k == 0){
      puts("OK");
      return 0;
    }
  }
  puts("NG");  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int maxn=100+5;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    printf("%d\n",a[n-1]-a[0]);
    return 0;
}


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

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

    int A;
    map<int, int> number;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if (number.count(A) > 0)
        {
            number.erase(A);
        }
        else
        {
            number[A] = 1;
        }
    }
    cout << number.size() << endl;
}


Measured memory_bytes: 4864
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    VPII AA;
    REP(i,N){
        int x,l;
        R(x,l);
        AA.PB({x+l,x-l});
    }
    sort(ALL(AA));
    int now=-2e9;
    int an=0;
    REP(i,SZ(AA)){
        if(AA[i].S>=now){
            an++;
            now=AA[i].F;
        }
    }
    W(an);
    return 0;
}


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

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3 = x2 + y1 - y2;
  y3 = y2 - x1 + x2;
  x4 = x1 + x3 - x2;
  y4 = y1 + y3 - y2;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 2e5 + 7;
int n, m, k, p[N];

int main() {
	rd(n, m, k);
	for (int i = 1; i <= n; i++) p[i] = m + 1;
	for (int i = 1, x, y; i <= k; i++)
		rd(x, y), p[x] = min(p[x], y);
	for (int i = 2, r = 1; i <= n; i++)
		if (r >= p[i]) return print(i - 1), 0;
		else if (r + 1 < p[i]) ++r;
	print(n);
	return 0;
}

Measured memory_bytes: 6420