akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int a = sc.nextInt();
        int b = sc.nextInt();


        if (a >= 13) Console.WriteLine(b);
        else if (a >= 6) Console.WriteLine(b / 2);
        else Console.WriteLine(0);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

#define ll long long

int main() {
  int N; 
  cin >> N;
  
  vector<ll> A(81, 0);
  
  ll ans = 1000;
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  A[N] = 0;
  
  ll count = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= A[i+1]) {
      if (count) {
        ans += A[i] * count;
        count = 0;
      }
    } else {
      if (count) continue;
      
      count += ans / A[i];
      ans -= count * A[i];
    }
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  int sum = 0;
  for (int i = 1; i <= m; ++i) {
    int x;
    scanf("%d", &x);
    sum += x;
  }
  if (sum > n) {
    printf("-1\n");
  }
  else {
    printf("%d\n", n - sum);
  }
  return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int x,n,i,j,k,ans,solved,flag=0,p[110]={};
    scanf("%d %d",&x,&n);
    if(n==0){
        printf("%d",x);
        return 0;
    }
    for(i=0; i<n; i++){
        scanf("%d",&p[i]);
    }
    j=x;
    k=x-1;
    solved=0;
    while(1){
        for(i=0; i<n; i++){
            if(p[i]==j)flag=1;
        }
        if(flag==0){
            solved=1;
            ans=j;
        }
        if(flag==1){
            j++;
        }
        flag=0;
        if(solved==1){
            printf("%d",ans);
            return 0;
        }
        for(i=0; i<n; i++){
            if(p[i]==k)flag=1;
        }
        if(flag==0){
            solved=1;
            ans=k;
        }
        if(flag==1)k--;
        flag=0;
        if(solved==1){
            printf("%d",ans);
            return 0;
        }
    }
}

Measured memory_bytes: 1728
n, x = map(int, input().split())
l = list(map(int, input().split()))

count = 0
d = 0

for i in range(n):
  d += l[count]
  count += 1
  if d >= x:
    if d == x:
      count += 1
    break

print(count) if d>=x else print(count+1)

Measured memory_bytes: 3060
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

struct Point {
public:
  int y, x;
  Point(int y, int x): y(y), x(x) { }
  Point() { }
};

/// BEGIN //////////////////////////////////////////////////////////

int solve(int n) {
  if (n < 2) {
    return 0;
  }

  int score = INF;
  return 1 + solve((n + 2) / 3);
}

int main() {
  int N = Scanner::nextInt();
  int ans = solve(N);

  PRINT(ans);

  return 0; 
}

/// END   //////////////////////////////////////////////////////////

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long long int a,b,c,k; cin>>a>>b>>c>>k;
    long long int sum=0;
    if(a<=k) {k-=a; sum+=a;}
    else {sum+=k; k=0;}
    if(k>0 && b<=k){k-=b;}
    else k=0;
    if(k>0 && c<=k){sum-=c;}
    else sum-=k;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C =  sc.nextInt();
		if (A==B) {
			System.out.println(C);
		} else if (B==C) {
			System.out.println(A);
		} else {
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
int n;
int mas[2][222];
bool used[2][222];
struct P{int a,b,c;};  //a=棟 b=階 c=cnt
int bfs();
int main(){
  while(1){
    memset(mas,0,sizeof(mas));
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++)
      cin >> mas[0][i];
    for(int i=0;i<n;i++)
      cin >> mas[1][i];
    memset(used,0,sizeof(used));
    int k=bfs();
    if(k==-1)cout << "NA" << endl;
    else cout << k << endl;
  }
}
int bfs(){
  queue<P> que;
  P p={0,0,0};
  que.push(p);
  p.a=1;
  que.push(p);
  while(!que.empty()){
    P p=que.front();

    for(;;p.b++){
      if(!(mas[p.a][p.b]==1 && mas[p.a][p.b+1]==1))break;
    }
    for(;;p.b--){
      if(!(mas[p.a][p.b]==2))break;
    }

    if(p.b==n-1)return p.c;
    que.pop();
    if(used[p.a][p.b]++)continue;
    for(int i=0;i<3;i++){
      if(p.b+i<n){
	P HM={(p.a==0?1:0),p.b+i,p.c+1};
	que.push(HM);
      }
    }
  }
  return -1;
}

Measured memory_bytes: 1216
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

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

#処理内容
def main():
	N, M = getlist()
	G = Graph()
	for i in range(M):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	DP = [[-1] * N for i in range(11)]
	Q_C = []
	Q = int(input())
	for i in range(Q):
		u, d, c = getlist()
		u -= 1
		Q_C.append(c)
		DP[10 - d][u] = i

	Q_C.append(0)

	#DP更新
	for i in range(10):
		for j in range(N):
			DP[i + 1][j] = max(DP[i + 1][j], DP[i][j])
			for k in G.graph[j]:
				DP[i + 1][k] = max(DP[i + 1][k], DP[i][j])
	
	for i in range(N):
		ind = DP[10][i]
		print(Q_C[ind])

if __name__ == '__main__':
	main()

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

public class Main {

  static FastScanner sc = new FastScanner();

  public static void main(String[] args) {

    int N = sc.nextInt();

    Hint[] hints = new Hint[N];
    for (int i=0; i<N; i++) {
      hints[i] = new Hint(sc.nextInt(), sc.nextInt(), sc.nextInt());
    }

    for (int cx = 0; cx<=100; cx++) {
      for (int cy = 0; cy<=100; cy++) {
        int H = 0;
        for (int i=0; i<N; i++) {
          if (hints[i].h > 0) {
            H = hints[i].h + Math.abs(hints[i].x - cx) + Math.abs(hints[i].y - cy);
            break;
          }
        }
        boolean correct = true;
        for (int i=0; i<N; i++) {
          int h = Math.max(H - Math.abs(hints[i].x - cx) - Math.abs(hints[i].y - cy), 0);
          if (h != hints[i].h) {
            correct = false;
            break;
          }
        }
        if (correct) {
          System.out.println(cx + " " + cy + " " + H);
          return;
        }
      }
    }

    System.out.println("-1 -1 -1");

  }

  static class Hint {
    int x, y, h;
    Hint(int x, int y, int h) {
      this.x = x;
      this.y = y;
      this.h = h;
    }
  }

  static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      return (int) nextLong();
    }
  }

}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var sum = 0L;
            var skip = 0L;
            var last = 0L;
            for (var i = 1; i <= N; i++)
            {
                sum += i;
                if (sum >=N)
                {
                    skip = sum - N;
                    last = i;
                    break;
                }
            }

            for (var i = 1; i <= last; i++)
            {
                if (i == skip) continue;
                else Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 11220
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
A = list(map(int, input().split()))

count = [0] * 50

for i in range(N):
    a = A[i]
    j = 0
    while a:
        if a % 2 == 1:
            count[j] += 1
        j += 1
        a //= 2

B = [0] * 60
k = K
j = 0
while k:
    if k % 2 == 1:
        B[j] = 1
    j += 1
    k //= 2

under = [-1] * (j + 1)
just = [0] * (j + 1)
# print (j)

tmp = 0
for i in range(49, j - 1, -1):
    tmp += pow(2, i) * count[i]

for i in range(j - 1, -1, -1):
    tmp1 = count[i] #1の数
    tmp0 = N - tmp1 #0の数
    if B[i] == 0:
        just[i] = just[i + 1] + pow(2, i) * tmp1
        if under[i + 1] >= 0:
            under[i] = under[i + 1] + pow(2, i) * max(tmp1, tmp0)
    else: #B[i] == 1
        just[i] = just[i + 1] + pow(2, i) * tmp0
        if under[i + 1] == -1:
            under[i] = just[i + 1] + pow(2, i) * tmp1
        if under[i + 1] >= 0:
            under[i] = under[i + 1] + pow(2, i) * max(tmp1, tmp0)
            under[i] = max(under[i], just[i + 1] + pow(2, i) * tmp1)


print (max(under[0], just[0]) + tmp)

# print ('count', count)
# print ('B', B)
# print (under)
# print (just)
# print (tmp)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> c(n);
    vector <int> s(n);
    vector <int> f(n);
    for(int i=0;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=0;i<n-1;i++){
        int ans=0;
        ans+=s[i]+c[i];
        for(int j=i+1;j<n-1;j++){
            if(ans>=s[j]&&ans%f[j]==0){
                ans+= c[j]; continue;
            }else if(ans>=s[j]&&ans%f[j]!=0){
                ans += f[j]- (ans%f[j]);
                ans+=c[j]; continue;
            }else if(ans<s[j]){
                ans=s[j];
                ans+=c[j];
            }
        }
        cout<<ans<<endl;
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int A;
  cin >> A;
  if(N%500 > A) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

class Scanner {
    BufferedReader br;
    StringTokenizer st;
    Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }
    void eat(String s) {
        st = new StringTokenizer(s);
    }
    String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new IOError(e);
        }
    }
    boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }
    String next() {
        hasNext();
        return st.nextToken();
    }
    int nextInt() {
        return Integer.parseInt(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') cnt++;
        }
        System.out.println(cnt);
    }

    static public void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 21204
#include <cstdint>
#include <iostream>

using namespace std;

int64_t Gcd(int64_t a, int64_t b)
{
    if (b == 0) {
        return a;
    }
    return Gcd(b, a % b);
}

int64_t Lcm(int64_t a, int64_t b)
{
    return a / Gcd(a, b) * b;
}

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

    int64_t res = 1;
    for (auto i = 0; i < n; i += 1) {
        int64_t period;
        cin >> period;
        res = Lcm(res, period);
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    let a: Vec<_> = (0..3)
        .map(|_| {
            buf.clear();
            stdin.read_line(&mut buf).unwrap();
            buf.split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect::<Vec<u32>>()
        })
        .collect();
    buf.clear();
    stdin.read_line(&mut buf).unwrap();
    let n: u32 = buf.trim_right().parse().unwrap();
    let mut hori = [0; 3];
    let mut vert = [0; 3];
    let mut diag = [0; 2];
    for _ in 0..n {
        buf.clear();
        stdin.read_line(&mut buf).unwrap();
        let x: u32 = buf.trim_right().parse().unwrap();

        for i in 0..3 {
            for j in 0..3 {
                if x == a[i][j] {
                    hori[i] += 1;
                    vert[j] += 1;
                    if i == j {
                        diag[0] += 1;
                    }
                    if i == 2 - j {
                        diag[1] += 1;
                    }
                }
            }
        }
    }
    println!(
        "{}",
        if hori
            .iter()
            .chain(vert.iter())
            .chain(diag.iter())
            .any(|x| x == &3)
        {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int dfs(int v, int p, int d, const vector<vi> &tree){
  if(d<0) return 0;

  int ans = 1;
  for(int u : tree[v]){
    if(u == p) continue;
    ans += dfs(u,v,d-1,tree);
  }
  return ans;
}

int solve(int v, int k, const vector<vi> &tree){
  int l = k/2, h = k-l;
  vi f,c;
  for(int u : tree[v]){
    f.pb(dfs(u,v,l-1,tree));
    c.pb(dfs(u,v,h-1,tree));
  }

  int sum = accumulate(all(f),0);
  int ans = 0;
  rep(i,c.sz){
    chmax(ans, sum + c[i] - f[i]);
  }
  return ans+1;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<vi> tree(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b; a--; b--;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  int ans = n-1;
  for(int v=0;v<n;v++){
    chmin(ans, n-solve(v,k,tree));
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
N, Y = map(int, input().split())
for a in range(N + 1):
    for b in range(N + 1 - a):
        c = N - a - b
        if a * 10000 + b * 5000 + c * 1000 == Y:
            print("{0} {1} {2}".format(a, b, c))
            exit()
print("-1 -1 -1")

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

ll x = 1e9 + 7; 

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  printf("%d %d %d\n", z, x, y);
  return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define MP make_pair
#define PB push_back
#define REP(i,n)  for(int i=0;i<(n);++i)
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,w,h;
	vector<P> vw,vh;
	cin>>n>>w>>h;
	REP(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		vw.PB(MP(a-c,a+c));
		vh.PB(MP(b-c,b+c));
	}
	sort(vw.begin(),vw.end());
	sort(vh.begin(),vh.end());
	int maxw=0,maxh=0;
	bool f=true;
	REP(i,vw.size()){
		if(vw[i].first>maxw){
			f=false;
		}
		maxw=max(maxw,vw[i].second);
	}
	if(f&&maxw>=w){
		cout<<"Yes"<<endl;
		return 0;
	}
	f=true;
	REP(i,vh.size()){
		if(vh[i].first>maxh){
			f=false;
		}
		maxh=max(maxh,vh[i].second);
	}
	if(f&&maxh>=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 4728
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	vector<char>S(s.size());
	vector<char>T(t.size());
	for (int i = 0; i < s.size(); i++) {
		S[i] = s[i];
	 }
	for (int i = 0; i < t.size(); i++) {
		T[i] = t[i];
	}
	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	string Sp, Tp;
	for (int i = 0; i < s.size(); i++) {
		Sp += S[i];
	}
	for (int i = t.size() - 1; i >= 0; i--) {
		Tp += T[i];
	}
	if (Sp < Tp) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int x, y, z; readV(x, y, z);
  writeln((x-z)/(y+z));
}


Measured memory_bytes: 372
#include <cstdio>

using namespace std;

const int MAXN = 100000;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int a[MAXN + 5][5], f[MAXN + 5][5];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j < 4; ++ j) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j < 4; ++ j) {
			for (int k = 1; k < 4; ++ k) {
				if (j ^ k) {
					f[i][j] = max(f[i][j], f[i - 1][k] + a[i][j]);
				}
			}
		}
	}
	int maxn = max(max(f[n][1], f[n][2]), f[n][3]);
	printf("%d\n", maxn);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 1e9+7; // 998244353;
const ll INF = 1e18;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int n; cin >> n;
   vpi p(n);
   for (pi &i : p)
      cin >> i.f >> i.s;
   pi big1 = p.ft, small1 = p.ft;
   pi big2 = p.ft, small2 = p.ft;
   for (pi &i : p) {
      if (i.f + i.s > big1.f + big1.s) big1 = i;
      if (i.f + i.s < small1.f + small1.s) small1 = i;
      if (i.f - i.s > big2.f - big2.s) big2 = i;
      if (i.f - i.s < small2.f - small2.s) small2 = i;
   }
   cout << max(abs(big1.f - small1.f) + abs(big1.s - small1.s), abs(big2.f - small2.f) + abs(big2.s - small2.s));
   return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

string h = "hon", p = "pon", b = "bon";
string a[10] = {p, p, h, b, h, h, p, h, p, h};

int main(){
	int n; scanf("%d", &n);
	printf("%s\n", a[n%10].c_str());
}


Measured memory_bytes: 3692
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int B = s.nextInt();
		int C = s.nextInt();
		int T = 0;
		int t = 0;
		while(C>T){
			t++;
			if(t%7 == 0){
				T += B;
			}
			T += A;
		}
		System.out.println(t);
	}
}


Measured memory_bytes: 26512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,k,s;
    cin>>n>>k>>s;
    vector<ll> v;
    rep(i,k){
        v.push_back(s);
    }

    rep(k,n){
        if(s==1e+9){
            v.push_back(1);
        }else{
           v.push_back(s+1);
        }
    }

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


    
return 0;
}


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

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

  sort(A.begin(), A.end());

  long long ans = 1;
  int cnt = 1, mul = 0;
  for (int i = N - 2; i >= 0; i--) {
    if (A[i] == A[i + 1]) cnt++;
    else cnt = 1;

    if (cnt == 2) {
      ans *= A[i];
      mul++;
      cnt = 0;
    }

    if (mul == 2) break;
  }

  if (ans == 1) ans = 0;
  cout << ans << endl;

  return 0;
}

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

int main() {
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	if(c > d) {
		// 抜かす。O*3
		for (size_t i = b; i < d; i++)
		{
			if(s[i] == '#' && s[i+1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		for (size_t i = a; i < c; i++)
		{
			if(s[i] == '#' && s[i+1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		// if(d+1 != c) {
			for (size_t i = b-2; i < d-1; i++)
			{
				if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
					cout << "Yes" << endl;
					return 0;
				}
			}
			cout << "No" << endl;
		// } else {
			// for (size_t i = b-2; i < c-2; i++)
			// {
			// 	if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
			// 		cout << "Yes" << endl;
			// 		return 0;
			// 	}
			// }
			// cout << "No" << endl;
		// }
	} else {
		for (size_t i = b; i < d; i++)
		{
			if(s[i] == '#' && s[i+1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		for (size_t i = a; i < c; i++)
		{
			if(s[i] == '#' && s[i+1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin >> n >> m;
  vector<int> g[100005];
  vector<int> h(n),ans(n);
  for(int i=0;i<n+m-1;i++){
    int a,b;cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    h[b]++;
  }
  int rt=-1;
  for(int i=0;i<n;i++){
    if(h[i]==0){
      rt=i;
    }
  }
  queue<int> q;
  q.push(rt);
  ans[rt]=0;
  while(!q.empty()){
    int v=q.front();
    q.pop();
    for(auto x:g[v]){
      h[x]--;
      if(h[x]==0){
        ans[x]=v+1;
        q.push(x);
      }
    }
  }
  for(auto x:ans){
    cout << x << endl;
  }
}

Measured memory_bytes: 7040
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
ans = 0
for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Measured memory_bytes: 31176
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    int ans = a.at(n-1)/2;
    for(int i=0;i<n-1;i++){
         ans += a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut s: f64 = 0.0;
    for _ in 0..n {
        let a: f64 = sc.cin();
        s += 1.0 / a;
    }
    put!(1.0 / s);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c; cin >> a >> b >> c;
    cout << set<int>({a, b, c}).size() << endl;

    return 0;
}


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(ba))

signed main() {
    int n; cin >> n;
    cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[100100],b[100100];
ll suma=0,sumb=0;
ll k=0;

int main(){
	cin>>n;
	REP(i,n){
		cin>>a[i];
		suma+=a[i];
	}
		
	REP(i,n){
		cin>>b[i];
		sumb+=b[i];
	}
	
	REP(i,n){
		if(a[i]<b[i]){
			k+=(((b[i]-a[i])+1)/2);
		}
	}
	
	if(sumb-suma>=k){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}
	
	

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,y,i,ans=0;
	cin>>x>>y;
	i=x;
	while(i<=y)
	{
	ans++;
	i*=2;	
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for (int i=0; i<n; i++) cin >> a.at(i);
    for (int i=0; i<n; i++) cin >> f.at(i);
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<int>());
    ll ok = 1e12, ng = -1;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll cnt = 0;
        for (int i=0; i<n; i++) {
            cnt += max(0LL, a.at(i) - mid / f.at(i));
        }
        if (cnt <= k) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
}

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

    solve();

    return 0;
}


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

int main() {
  string s;
  int i, a, b;
  cin >> s;
  
  for(i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      a = i;
      break;
    }
  }
  
  for(i = s.size() - 1; i >= 0; i--){
    if(s.at(i) == 'Z'){
      b = i;
      break;
    }
  }
  
  cout << b - a + 1 << endl;
}


Measured memory_bytes: 640
'''                                               
  2xy + x + y = z                                 
  (2x + 1) (2y + 1) = 2z + 1                      
  x' * y' = z'                                    
  check z' for prime number.                      
'''                                               
                                                  
prime = dict()                                    
prime_nums = list()                               
                                                  
MAXIMUM = 2**16                                   
def get_prime():                                  
    for i in range(2, MAXIMUM):                   
        if prime.get(i, True):                    
            prime_nums.append(i)                  
            for j in range(i * 2, MAXIMUM, i):    
                prime[j] = False                  
                                                  
                                                  
def check(x):                                     
    x = 2*x + 1                                   
    for prime in prime_nums:                      
        if prime **2 > x:                         
            break                                 
        if x % prime == 0:                        
            return False                          
    return True                                   
                                                  
                                                  
get_prime()                                       
n = int(input())                                  
count = 0                                         
for _ in range(n):                                
    if check(int(input())):                       
        count += 1                                
print(count)                                      

Measured memory_bytes: 13488
import sys
sys.setrecursionlimit(10 ** 8)

N, Ma, Mb = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]
memo = {i : {} for i in range(N)}

def dfs(i, a, b):
    if b > 0 and a / b == Ma / Mb:
        return 0
    elif i == N:
        return float('inf')
    elif (a, b) in memo[i]:
        return memo[i][(a, b)]
    else:
        ans = min(dfs(i + 1, a, b), dfs(i + 1, a + A[i][0], b + A[i][1]) + A[i][2])
    memo[i][(a, b)] = ans
    return ans

if dfs(0, 0, 0) == float('inf'):
    print(-1)
else:
    print(dfs(0, 0, 0))

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

int main() {

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

    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    cout << c << " " <<  a << " " << b;



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a, b, c;
	int k;
	int n;
	scanf("%d %d %d",&a,&b,&c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}



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

map<ll, ll> primeFactor(ll n) {
    map<ll, ll> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {
    int n;
    cin >> n;
    auto mp = primeFactor(n);
    cout << n << ":";
    for (auto p : mp) {
        for (int i = 0; i < p.second; ++i) {
            cout << " " << p.first;
        }
    }
    cout << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    int N; cin>>N;
  if(N==22) Out("Christmas Eve Eve Eve");
  if(N==23) Out("Christmas Eve Eve");
  if(N==24) Out("Christmas Eve");
  if(N==25) Out("Christmas");
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(W, H, P, Q):
    E = [(0, p) for p in P] + [(1, q) for q in Q]
    E.sort(key=lambda x: x[1])
    cost = 0
    R = [H + 1, W + 1]
    for d, c in E:
        cost += c * R[d]
        R[d ^ 1] -= 1
    print(cost)

if __name__ == '__main__':
    input = sys.stdin.readline
    W, H = map(int, input().split())
    P = [int(input()) for _ in range(W)]
    Q = [int(input()) for _ in range(H)]
    main(W, H, P, Q)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int n;
pair<long long, long long> p[N];

void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", &p[i].first, &p[i].second);
    p[i].first -= p[i].second-1;
    p[i].second = p[i].first+p[i].second*2-1;
  }
  sort(p, p+n, [](const pair<int, int> &a, const pair<int, int> &b) {
    return a.second < b.second;
  });
  long long prev = p[0].second;
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (p[i].first > prev) {
      prev = p[i].second;
      ++ans;
    }
  }
  printf("%d\n", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 1792
use std::str::FromStr;

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

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let v : Vec<i32> = get_vec();
    let h = v[0];
    let a = v[1];
    println!("{}", (h+a-1) / a);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main() {
	ll A[10101];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (((A[2] - A[1]) + (A[2] - A[0])) % 2 == 0)
		cout << ((A[2] - A[1]) + (A[2] - A[0])) / 2 << endl;
	else
		cout << ((A[2] - A[1]) + (A[2] - A[0])) / 2 + 2 << endl;
	return 0;
}

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



bool is_prime(int x){
    if(x<=1) return false;
    for(int i = 2; i*i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    while (!is_prime(x)){
        x++;
    }
    cout << x << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		for(int i=0;i<h;i++) {
			String s = sc.next();
			System.out.println(s);
			System.out.println(s);
		}

	}

}

Measured memory_bytes: 24020