akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
  
public class Main {
    public static void main(String[] args) throws Exception {
        int count = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
          
        int[] array = new int[n];
            for(int i = 0; i<n; i++){
                array[i] = sc.nextInt();
            }
        for(int i=0; i<array.length-1; i++){
            int min =i;
            for(int j = i+1; j<array.length; j++){
                if(array[j] < array[min]){
                    min = j;
                }
            }
             if(i != min){
                int tmp = array[i];
                array[i] = array[min];
                array[min] = tmp;
                count += 1;
}
        }
        for(int k=0; k<array.length-1; k++){
            int number = array[k];
            System.out.print(number + " ");
        }
        System.out.println(array[array.length-1]);
        System.out.println(count);
          
    }
}

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

Measured memory_bytes: 1024
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    rest = B[i]
    use_i = min(rest, A[i])
    rest -= use_i
    ans += use_i
    use_ii = min(rest, A[i+1])
    ans += use_ii
    A[i+1] -= use_ii
print(ans)


Measured memory_bytes: 19648
#include<stdio.h>

int main()
{
	int a[100][100];
	int b[100];
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	
	for(int i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}
	
	int c[100]={0};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			c[i] += a[i][j] * b[j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d\n", c[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2764
#include <iostream>
#include "stdio.h"
//#include "math.h"

using namespace std;

int main(){
	double a,b,c,d,e,f,x,y;
	while(cin.eof()==false){
//		break;
	a=10000;
	cin >> a >> b >> c >> d >> e >> f;
	if (a==10000){
		break;
	}

	double under = a*e-b*d;
	if((c*e-b*f)/under<0.0005 && (c*e-b*f)/under>-0.0005){
		x=0;
	}
	else{
		x=(c*e-b*f)/under;
	}
	if((a*f-c*d)/under<0.0005 && (a*f-c*d)/under>-0.0005){
		y=0;
	}
	else{
		y=(a*f-c*d)/under;
	}

//	cout << (c*e-b*f)/under << " " << (a*f-c*d)/under << endl;
	printf("%.3f %.3f\n",x,y);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

ll solve(const int N) {
    ll ans = 0;

    // [begin, end)
    int begin = 0;
    int end = 0;
    int acc = 0;

    while (begin < N) {
        end = max(begin, end);

        while (true) {
            if (end < N && (acc + as[end]) == (acc ^ as[end])) {
                acc ^= as[end];
                end++;
                // printf("%d\n", acc);
            } else {
                break;
            }
        }

        ans += end - begin;
        // printf("2. begin: %d, end: %d, acc: %d, ans: %lld\n", begin, end, acc, ans);

        acc ^= as[begin];
        begin++;
    }

    return ans;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    cout << solve(N) << endl;

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while (C>0&&A>0) {
    C-=B;
    if (C<=0) {
      cout << "Yes" << endl;
    }
    else {
      A-=D;
      if (A<=0) {
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 3624
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn main() {
    input! {
        n:usize,
        k:usize,
        mut p:[i32;n],
    }
    p.sort();
    let ans: i32 = (0..k).map(|i| p[i]).sum();
    println!("{}", ans);
}

Measured memory_bytes: 2196
#include <stdio.h>

void rec(int bw[], int w, int bw_w[]);

int main(void)
{
	int w;
	int i, k;
	int bw_flag[10];
	int bw_w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	
	while (scanf("%d", &w) != EOF){
		for (i = 0; i < 10; i++){
			bw_flag[i] = 0;
		}
		
		rec(bw_flag, w, bw_w);

		k = 9;
		while (bw_flag[k] != 1){
			k--;
		}
		for (i = 0; i <= k - 1; i++){
			if (bw_flag[i] == 1){
				printf("%d ", bw_w[i]);
			}
		}
		printf("%d\n", bw_w[k]);
	}
	return (0);
}
void rec(int bw[], int w, int bw_w[])
{
	int i;
	
	for (i = 9; i >= 0; i--){
		if (w - bw_w[i] >= 0){
			w -= bw_w[i];
			bw[i] = 1;
		}
	}
}

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

long long n, z, h, i;
vector <int> a, b, c;

int main() {
	cin >> n;
	for(i=0;i<n;i++){cin>>h;a.push_back(h);}sort(a.begin(),a.end());
	for(i=0;i<n;i++){cin>>h;b.push_back(h);}sort(b.begin(),b.end());
	for(i=0;i<n;i++){cin>>h;c.push_back(h);}sort(c.begin(),c.end());
	for(i=0;i<n;i++){
		long long x = lower_bound(a.begin(), a.end(), b[i])-a.begin();
		long long y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		z += x*y;
	}
	cout << z << '\n';
}

Measured memory_bytes: 4572
import java.util.Arrays;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), q = scanner.nextInt();
			Data[] datas = IntStream.range(0, n).mapToObj(i -> {
				int s = scanner.nextInt(), t = scanner.nextInt(), x = scanner.nextInt();
				return new Data(s - x, t - x, x);
			}).sorted((x, y) -> Integer.compare(x.x, y.x)).toArray(Data[]::new);
			SortedMap<Integer, Integer> map = new TreeMap<>();
			IntStream.range(0, q).forEach(i -> map.put(scanner.nextInt(), i));
			int[] result = new int[q];
			Arrays.fill(result, -1);
			for (Data data : datas) {
				SortedMap<Integer, Integer> subMap = map.subMap(data.s, data.t);
				subMap.entrySet().stream().forEach(entry -> result[entry.getValue()] = data.x);
				subMap.clear();
				if (map.isEmpty()) {
					break;
				}
			}
			StringBuilder sb = new StringBuilder();
			Arrays.stream(result).forEach(i -> sb.append(i).append("\n"));
			System.out.print(sb.toString());
		}
	}

	/**
	 * s,t,xを表すクラス
	 */
	private static class Data {
		/** 工事開始時間 */
		int s;
		/** 工事終了時間 */
		int t;
		/** 工事座標 */
		int x;

		Data(int s, int t, int x) {
			super();
			this.s = s;
			this.t = t;
			this.x = x;
		}
	}
}


Measured memory_bytes: 83900
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
void push(int, int,int []);
int pop(int, int[]);

int main() {
	char array[1000000];
	char *pt=array,*tok;
	int top=0,result[N],num,a,b;
	scanf("%[^\n]*s", pt);
	tok = strtok(pt, " ");
	while (tok!=NULL) {
		if (*tok == '+') {
			a = pop(--top, result);
			b = pop(--top, result);
			push(a + b, top++, result);
		}

		else if (*tok == '-') {
			b = pop(--top, result);
			a = pop(--top, result);
			push(a - b, top++, result);
		}
		
		else if (*tok == '*') {
			a = pop(--top, result);
			b = pop(--top, result);
			push(a * b, top++, result);
		}

		else {
			num = atoi(tok);
			push(num, top++, result);
		}
		tok = strtok(NULL, " ");
	}
	printf("%d\n",pop(--top,result));
	return 0;
}

void push(int n, int t, int a[]){
	if (t >= N) printf("Over flow\n"),exit(1);
	a[t] = n;
}

int pop(int t, int a[]){
	if (t < 0) printf("Under flow\n"),exit(1);
	return a[t];
}

Measured memory_bytes: 552
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
double x,h,s,b;
int main(){
    for(;;){
        cin>>x>>h;
        if(x==0||h==0)break;
        b=h*h+x*x/4;
        double d=sqrt(b);
        b=x*d/2;
        x=x*x;
        s=x+b*4;
        printf("%f\n",s);
    }
return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(void)
{
	int a,b;

	scanf("%d%d",&a,&b);

	if(a == b ){
	printf("a == b\n");
        }
	else if(a > b){
	printf("a > b\n");
	}
        else{
	printf("a < b\n");
        }
	return 0;
}

Measured memory_bytes: 580
let s = read_line()

let rec f i b =
  try
    let c = s.[i] in
    if b then
      begin
        if c <> 'h' then "No"
        else f (i+1) false
      end
    else
      if c = 'i' then f (i+1) true
      else "No"
  with Invalid_argument _ -> if b then "Yes" else "No"

let () = print_endline (f 0 true)


Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
void get_permutation(vs& perm, string s){
    vector<char> vc;
    for (char c : s) vc.push_back(c);

    sort(vc.begin(), vc.end());
    do {
        string t = "";
        for (char c : vc) t += c;            
        perm.push_back(t);      
    } while (next_permutation(vc.begin(), vc.end()));
}
#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N = 3;
    vi A(N); REP(i, N) cin >> A[i];

    vs pm;
    get_permutation(pm, "012");
    
    int ans = INF;
    for(string s : pm) {
        int sum = 0;
        FOR(i, 1, N) sum += abs(A[s[i]-'0'] - A[s[i - 1]-'0']);

        ans = min(ans, sum);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

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

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int n; cin>>n;
	cout<<n*(n-1)/2;
	
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
  
int main(int argc, const char * argv[]) {
  int w, h, x, y, r;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
  if(x + r <= w)
    if(r <= x)
      if(y + r <= h)
        if(r <= y){
          printf("Yes\n");
          return 0;
        }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 584
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

type Edge struct {
	x, y int
}

type Edges []Edge

func (a Edges) Len() int      { return len(a) }
func (a Edges) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Edges) Less(i, j int) bool {
	if a[i].y == a[j].y {
		return a[i].x < a[j].x
	}
	return a[i].y < a[j].y
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const inf = 1000000

	_, m := nextInt(), nextInt()
	edges := make(Edges, m)
	for i := 0; i < m; i++ {
		edges[i] = Edge{nextInt() - 1, nextInt() - 1}
	}
	sort.Sort(edges)

	ans := 0
	end := 0
	for i := 0; i < m; i++ {
		if edges[i].x >= end {
			end = edges[i].y
			ans++
		}
	}

	puts(ans)
}


Measured memory_bytes: 3584
import java.util.Scanner;
import java.math.BigInteger;

class Main
{
	public static void main (String [] args)
	{
		Scanner sc = new Scanner(System.in);
		
		while( sc.hasNextBigInteger() ){
			BigInteger a = sc.nextBigInteger();
			BigInteger b = sc.nextBigInteger();
			
			BigInteger gcd = a.gcd(b);
			BigInteger lcm = a.multiply(b).divide(gcd);
			
			System.out.println(gcd + " " + lcm);
		}
	}
}

Measured memory_bytes: 17288
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    for(int i=0;i<n-k;++i){
        if(a[i]<a[i+k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4832
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int a[100][100][100];

void solve(int n,int m){
    map<int,int> mp;
    int x=0,y=0,z=0;
    rep(i,n){
        string s;cin>>s;
        int c=0;
        while(c<s.size()&&s[c]=='.')++c;
        mp[10000*x+100*y+z]=c;
        rep(j,s.size()){
            if(s[j]=='(')++x;
            if(s[j]==')')--x;
            if(s[j]=='{')++y;
            if(s[j]=='}')--y;
            if(s[j]=='[')++z;
            if(s[j]==']')--z;
        }
    }
    vector<int> P,Q,R;
    REP(i,1,21)REP(j,1,21)REP(k,1,21){
        bool ok=true;
        for(auto p : mp){
            if(i*(p.first/10000)+j*(p.first/100%100)+k*(p.first%100)!=p.second)ok=false;
        }
        if(ok){
            P.push_back(i);
            Q.push_back(j);
            R.push_back(k);
        }
    }
    x=0,y=0,z=0;
    rep(i,m){
        string s;
        cin>>s;
        if(mp.count(10000*x+100*y+z))cout<<mp[10000*x+100*y+z];
        else {
            set<int> st;
            rep(j,P.size()){
                st.insert(x*P[j]+y*Q[j]+z*R[j]);
            }
            if(st.size()==1)cout<<*st.begin();
            else cout<<-1;
        }
        rep(j,s.size()){
            if(s[j]=='(')++x;
            if(s[j]==')')--x;
            if(s[j]=='{')++y;
            if(s[j]=='}')--y;
            if(s[j]=='[')++z;
            if(s[j]==']')--z;
        }
        if(i!=m-1)cout<<" ";
        else cout<<endl;
    }
}
int main(){
    int n,m;
    while(cin>>n>>m,n)solve(n,m);
    return 0;
}


Measured memory_bytes: 3344
#include <iostream>
#include <queue>

using namespace std;

struct process{
    string name;
    int time;
    process(const string &name, int time) : name(name), time(time) {}
};

int main(){
    string s;
    queue<process> q;
    int n, t, total = 0;
    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        string name;
        int time;
        cin >> name >> time;
        q.push(process(name,time));
    }
    while(q.size() > 0){
        process p = q.front();
        q.pop();
        if (p.time <= t){
            cout << p.name << " " << total + p.time << endl;
            total += p.time;
        } else {
            p.time -= t;
            q.push(p);
            total += t;
        }

    }

    return 0;
}

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

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

    map<int, int> M;
    for (int i = 0; i < 3; ++i) {
        int tmp;
        cin >> tmp;
        ++M[tmp];
    }

    if (M[5] == 2 && M[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MAX_N = 100;
ll M[MAX_N],A[MAX_N];
P K[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
	}
	M[0] = 1000;
	K[0] = P(1000/A[0],1000%A[0]);
	rep(i,N-1)
	{
		M[i+1] = max(M[i],K[i].first*A[i+1] + K[i].second);
		K[i+1] = max(K[i],P(M[i]/A[i+1],M[i]%A[i+1]));
	}
	cout << M[N-1] << endl;
	return 0;
}

Measured memory_bytes: 3624
object Main extends App {
  val n = scala.io.StdIn.readInt()
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  var count = 0
  (0 to (array.size - 3)).foreach { i =>
    val slice = array.slice(i, i + 3)
    if (slice.distinct.count(_ > slice(1)) == 1){
      count = count + 1
    }

  }
  println(count)
}

Measured memory_bytes: 25540
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 (b < a) { a = b; return 1; } return 0; }

#define ketasitei setprecision(15) //15桁表示



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

	ll n;
	cin >> n;
	vector<pair<ll, pair<ll, ll>>> x(n);
	vector<ll> ans(n);

	rep(i, n)
	{
		cin >> x[i].second.first >> x[i].second.second;
		x[i].first = x[i].second.first + x[i].second.second;
	}
	sort(x.begin(), x.end());
	ll sum = 0;
	ll t = 0;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			t = x[i].first;
			sum++;
		}
		if (t<=x[i].second.first-x[i].second.second)
		{
			t = x[i].first;
			sum++;
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n = 4;
  vector<int> deg(n);
  for (int k = 1; k < n; ++k) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    deg[x]++;
    deg[y]++;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (deg[i] % 2) ++cnt;
  }
  if (cnt > 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char> >s(H,vector<char>(W));
    vector<vector<int> >ans(H,vector<int>(W,0));
    vector<int> key;
    rep(i,H) rep(j,W) cin >> s[i][j];
    
    rep(i,H)
    {
        int tmp = -1;
        rep(j,W) if(s[i][j] == '#') tmp = j;
        key.push_back(tmp);
    }
    /*
    cout << endl;
    rep(i,H)
    {
        rep(j,W) cout << s[i][j];
        cout << endl;
    }
    */
    
    int stop = 0;
    for(int i = key.size()-1;i >= 0;i--)
    {
        if(key[i] != -1)
        {
            stop = i;
            break;
        }
    }

    int cnt = 1; 
    rep(i,H)
    {
        rep(j,W)
        {
            if(s[i][j] == '#')
            {
                //cout << "test" << endl;
                for(int l = i;l >= 0;l--)
                {
                    if(ans[l][j] != 0) break;
                    for(int k = j;k >= 0;k--)
                    {
                        if(ans[l][k] != 0)break;
                        ans[l][k] = cnt;
                    }
                }
                //右側
                if(key[i] == j)
                {
                    for(int l = i;l >= 0;l--)
                    {
                        if(ans[l][j+1] != 0) break;
                        for(int k = j+1;k < W;k++) ans[l][k] = cnt;
                    }
                    if(i == stop)
                    {
                        for(int l = i+1;l < H;l++)
                        {
                            for(int k = j;k < W;k++)
                            {
                                ans[l][k] = cnt;
                            }
                        }
                    } 
                }
                if(i == stop)
                {
                    for(int l = i+1;l < H;l++)
                    {
                        for(int k = j;k >= 0;k--)
                        {
                            if(ans[l][k] != 0 && ans[l][k] != cnt)
                            {
                                //cout << ans[l][k] << endl;
                                break;
                            }
                            ans[l][k] = cnt;
                        }
                    }
                }
                cnt++;
            }
            /*
            cout << endl;
            rep(i,H)
            {
                rep(j,W) cout << ans[i][j];
                cout << endl;
            }
            */

        }    
    }


    cout << endl;
    rep(i,H)
    {
        rep(j,W)
        {
            cout << ans[i][j];
            if(j != W-1) cout << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 1280
#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>;


int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x, ans, ansA, ansB;
  ansA = (A * N) / B - A * (N / B);
  x = (N / B) * B - 1;
  ansB = (A * x) / B - A * (x / B);
  ans = max(ansA, ansB);
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  int a,b;
  cin>>a>>b;
  cout<<(a+(b-a%b)%b)/b<<endl;
}

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

signed main(){
    ll k;
    cin >> k;
    vector<ll> a(10);
    iota(a.begin(), a.end(), 0);
    for(ll i = 1; a.size() <= k; i++){
        ll last = a[i] % 10, next = a[i] * 10 + last;
        if(last) a.push_back(next - 1);
        a.push_back(next);
        if(last < 9) a.push_back(next + 1);
    }
    cout << a[k] << endl;
}

Measured memory_bytes: 1656
#include <stdio.h>
 
void era_transform(int year, int month, int day);
 
int main(void)
{
    int year, month, day;
    while (scanf("%d %d %d",&year, &month, &day) != EOF) {
        era_transform(year, month, day);
    }
    return 0;
}
 
void era_transform(int year, int month, int day)
{
    int z = year * 10000 + month * 100 + day;// 時代判定用関数
    if (z <= 18680907) {
        printf("pre-meiji\n");
    } else if (z <= 19120729) {
        printf("meiji %d %d %d\n", year - 1867, month, day);
    } else if (z <= 19261224) {
        printf("taisho %d %d %d\n", year - 1911, month, day);
    } else if (z <= 19890107) {
        printf("showa %d %d %d\n", year - 1925, month, day);
    } else {
        printf("heisei %d %d %d\n", year - 1988, month, day);
    }
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#define llong long long
#define f first
#define s second
#define false true

using namespace::std;

int N, M, Q;
int MAXN = 1e5 + 5;
int MAXM = 1e5 + 5;
int MAXQ = 1e5 + 5;

struct node {
    int col, pri;
};

vector<vector<int> > adj(MAXN, vector<int>(0));
vector<vector<node> > val(MAXN, vector<node>(11, {0, -1}));

int main()
{
    ifstream fin("input.txt");
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int v, d, c;
        cin >> v >> d >> c;
        val[v][d] = {c, q};
    }
    for (int k = 10; k >= 1; k--) {
        for (int i = 1; i <= N; i++) {
            if (val[i][k].pri != -1) {
                if (val[i][k - 1].pri < val[i][k].pri) {
                    val[i][k - 1] = val[i][k];
                }
                for (auto neigh : adj[i]) {
                    if (val[neigh][k - 1].pri < val[i][k].pri) {
                        val[neigh][k - 1] = val[i][k];
                    }
                }
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << val[i][0].col << "\n";
    }
}


Measured memory_bytes: 18168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<int> v(n), u(n);
        for (int i = 0; i < m; ++i) {
            int s, k;
            scanf("%d %d", &s, &k);
            if(k == 1){
                int x;
                scanf("%d", &x);
                v[x-1] += s;
            }else {
                for (int j = 0; j < k; ++j) {
                    int x;
                    scanf("%d", &x);
                    u[x-1] += s;
                }
            }
        }
        vector<int> vv(v);
        sort(vv.begin(),vv.end());
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            ans = max(ans, v[i]+u[i]-(vv[0] == v[i] ? vv[1] : vv[0])+1);
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3328
#line 1 "test/aoj/1562.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1562"
#line 1 "test/aoj/../../math/divisor.cpp"
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

vector<ll> divisor(ll n) { 
  vector<ll> ret;
  for (ll i = 1; (ll)i*i <= n; ++i) { 
    if (n % i == 0) {
      ret.push_back(i);
      if (i*i != n) { ret.push_back(n/i); }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
};
#line 3 "test/aoj/1562.test.cpp"


int main() {
  int n; cin >> n;
  for (int i = 1; i <= (1<<n); ++i) {
    vector<ll> divs = divisor(i);
    if (divs.size() == n) {
      cout << i << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 3164
x = int(input())
c = [100, 101, 102, 103, 104, 105]
INF = float("inf")
 
dp = [INF]*(x+1)
dp[0] = 0
 
for i in range(len(c)):
    for j in range(x+1):
        if j - c[i] < 0:
            continue
        else:
            dp[j] = min(dp[j], dp[j - c[i]] + 1)
if dp[x] == INF:
    print(0)
else:
    print(1)

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

#define pb              push_back
#define pi              acos(-1.0)
#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define ll              long long int
#define ff              first
#define ss              second
#define pii             pair<ll,ll>
#define sc1(a)          scanf("%d",&a)
#define sc2(a,b)        scanf("%d %d",&a,&b)
#define sc3(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define all(v)          v.begin(),v.end()
#define ms(a,b)         memset(a,b,sizeof a)
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define fileout         freopen("output.txt","w",stdout)
#define filein          freopen("input.txt","r",stdin)
#define inf             2e9+5
#define Q               int q;cin>>q;while(q--)
#define check           cout<<"HI"<<endl;

//int x[]= {-1,0,0,1};
//int y[]= {0,-1,1,0};

using namespace std;

int main()
{
    int n,m=0;

    cin >> n;
    int a[n+5];
    loop(i,0,n)cin>>a[i];

    int fr[n+5],bk[n+5];
    fr[0]=a[0];
    loop(i,1,n)fr[i]=__gcd(a[i],fr[i-1]);
    bk[n-1]=a[n-1];
    rloop(i,n-2,0)bk[i]=__gcd(a[i],bk[i+1]);
    int ans=max(bk[1],fr[n-2]);

    loop(i,1,n-1)
    {
        int tmp=__gcd(fr[i-1],bk[i+1]);
        ans = max(ans,tmp);
    }

    cout<<ans<<endl;

}













Measured memory_bytes: 4808
num_input = int(input())
input_arr = [int(x) for x in input().split()]

max_input = max(input_arr)
count = 0
second_arr =[]
first_arr = []
sorted_arr = sorted(input_arr)
ans = sorted_arr[int(num_input/2)] - sorted_arr[int(num_input/2)-1]
print(ans)

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

using namespace std;

int main() {
	int n, m1 = -1, m2 = -1, p;
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		int val;
		cin >> val;
		if(val > m1) {
			p = i;
			m2 = m1;
			m1 = val;
		}
		else if(val > m2) m2 = val;
	}
	
	for(int i = 1; i <= n; i++) {
		if(i == p) cout << m2;
		else cout << m1;
		cout << "\n";
	}
}

Measured memory_bytes: 1664
s = input()
k = int(input())
v = list(s)
n = len(s)
a = [0 for i in range(n)]

for i in range(n):
  a[i] = (123 - ord(s[i]))%26
  if k == 0:
    break
  if k >= a[i]:
    v[i] = 'a'
    k -= a[i]

if k > 0:
  k %= 26
  v[n-1] = chr(ord(v[n-1])+k)
print (''.join(v))

Measured memory_bytes: 10916
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,q = readInts()
    S = input()
    # A があって C がある、その次の場所を + 1してあげるよ。
    AC = [0] * n
    for i in range(1,n):
        if S[i - 1] == 'A' and S[i] == 'C':
            AC[i] = AC[i-1] + 1
        else:
            AC[i] = AC[i-1]
    #print(AC)
    for i in range(q):
        l,r = map(lambda x:int(x) - 1,input().split())
        print(AC[r] - AC[l])
if __name__ == '__main__':
  main()


Measured memory_bytes: 6188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> x(n+1);
  REP(i,n) cin >> x[i];
  
  int ans = 10000000;

  REP(i,100){
    int y = 0;
    REP(j,n){
      y += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans,y);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3632
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;

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

    uli n, k, ans = 0;
    cin >> n >> k;

    cout << min(n % k, k - (n % k)) << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int w, a, b;
  cin >> w >> a >> b;
  cout << max(max(b - (a + w), a - (b + w)), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  cout << 180*(n-2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A=in(),B=in();
	
	cout << (max(A,B)>8 ? ":(" : "Yay!") << endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())


ans = 0
commands = [''] * N
for i, t in enumerate(T):
    if t == 'r':
        command = 'p'
        point = P

    elif t == 's':
        command = 'r'
        point = R

    elif t == 'p':
        command = 's'
        point = S

    if (i - K >= 0) and (commands[i -  K] == command):
        command = ''
        point = 0

    ans += point
    commands[i] = command

print(ans)

Measured memory_bytes: 4792
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e5+5;

int n,m;
vector<int> G[MAX_N];
map<int,int> val[MAX_N];
ll tot[MAX_N];
ll ans[MAX_N];

void pre_calc(int now, int pa)
{
	tot[now]=1;
	for(auto &i:G[now])
	{
		if(i==pa) continue;
		pre_calc(i,now);
		tot[now]=(tot[now]*(tot[i]+1))%m;
	}
}
void old_update(int pre, int nxt)
{
	tot[pre]=1;
	for(auto &i:G[pre])
	{
		if(i==nxt) continue;
		tot[pre]=(tot[pre]*(tot[i]+1))%m;
	}
}
void update(int pre, int nxt)
{
	if(val[pre].empty())
	{
		vector<ll> l(1,1), r(1,1);
		for(int i=0;i<(int)G[pre].size()-1;i++)
			l.emplace_back(l.back()*(tot[G[pre][i]]+1)%m);
		for(int i=(int)G[pre].size()-1;i>0;i--)
			r.emplace_back(r.back()*(tot[G[pre][i]]+1)%m);
		reverse(r.begin(),r.end());
		for(int i=0;i<(int)G[pre].size();i++)
			val[pre][G[pre][i]]=l[i]*r[i]%m;
	}
	tot[pre]=val[pre][nxt];
}
void dfs(int now, int pa)
{
	ans[now]=1;
	for(auto &i:G[now])
		ans[now]=(ans[now]*(tot[i]+1))%m;
	for(auto &i:G[now])
	{
		if(i==pa) continue;
		update(now,i);
		dfs(i,now);
		update(i,now);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,t1,t2;i<n;i++)
	{
		scanf("%d%d",&t1,&t2);
		G[t1].emplace_back(t2);
		G[t2].emplace_back(t1);
	}
	pre_calc(1,-1);
	dfs(1,-1);
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}



Measured memory_bytes: 25472
/*
*
*Problem Link : https://atcoder.jp/contests/abc167/tasks/abc167_d
*Platform: atcoder
*Status: correct
*Author: Mayukh Chakrabarti
*
*/

#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define booster cout.tie(NULL)
#define endl "\n"

typedef long long int lld;

#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

#define mod 1000000007
const lld inf= 1e12;

using namespace std;


int main(){
	speed;
	
	lld N,K;
	cin>>N>>K;
	
	unordered_map<lld,lld> adj;
	
	for(lld i=1 ; i<=N ; i++){
		lld x;
		cin>>x;
		adj[i] = x; 
	}
	
	bool vis[N+1] = {0};
	
	lld i = 1;
	lld total_length = 0;
	while(!vis[i]){
		vis[i] = true;
		total_length++;
		i = adj[i];
	}
	
	lld cycle_vertex = i; //i now contains the cycle starting vartex
	
	memset(vis,0,sizeof vis);
	lld cycle_length = 0;
	while(!vis[i]){
		vis[i] = true;
		cycle_length++;
		i = adj[i];
	}
	
	lld m = 0;//this will store the moded value with K
	if(total_length-cycle_length == 0)
		m = K % cycle_length;
	else {
		lld dif= total_length - cycle_length ;
		if(K <= dif){
			lld v = 1;
			while(K--)
				v = adj[v] ;
				
			cout<<v<<endl;
			return 0;
		}
		else {
			K = K - dif ;
			m = K % cycle_length ;
			
		}
	}
	
	i = cycle_vertex;
	memset(vis,0,sizeof vis);
	while(m--)
		i = adj[i] ;
		
		
	cout<<i<<endl;
	
	return 0;
}



Measured memory_bytes: 11672
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int64_t dp[2001][2001] = {0};

static const int64_t kRem = 1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m; cin >> n >> m;
	vector<int> ss(n + 1);
	FOR_LE(i, 1, n) {
		cin >> ss[i];
	}
	ss[0] = -1;
	vector<int> ts(m + 1);
	FOR_LE(i, 1, m) {
		cin >> ts[i];
	}
	ts[0] = -2;

	FOR_LE(i, 0, n) {
		dp[i][0] = 1;
	}
	FOR_LE(j, 0, m) {
		dp[0][j] = 1;
	}

	FOR_LE(i, 1, n) {
		FOR_LE(j, 1, m) {
			int64_t val = dp[i][j - 1];
			if (ss[i] == ts[j]) {
				val += dp[i - 1][j - 1];
			}
			val += (dp[i - 1][j] - dp[i - 1][j - 1]);

			val %= kRem;
			if (val < 0) val += kRem;
			dp[i][j] = val;
		}
	}

	cout << dp[n][m] << endl;

	return 0;
}

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

int pop();
void stack(int);

int i=0;
int N[100];
int main(){

  int n1,n2;
  char s[10];

  while(scanf("%s",s)!=EOF){
 
    if(s[0]=='+'){
      stack(pop()+pop());
	}
    
    else if(s[0]=='-'){
      n1=pop();
      n2=pop();
      stack(n2-n1);
    }
    else if(s[0]=='*'){
      stack(pop()*pop());
    }
	
    else N[i++]=atoi(s);
  }
  printf("%d\n",N[0]);
  return 0;
}
  
int pop(){
  return N[--i];
}
void stack(int x){
  N[i++]=x;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define ll long long int
#define Mm 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=250001;

ll func(ll A,ll B,ll M)
{
	if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    return (B / M) - (A / M);
}

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll a1=func(a,b,c);
    ll b1=func(a,b,d);
    ll gcd=__gcd(c,d);
    gcd=(c*d)/gcd;
    ll c1=func(a,b,gcd);
    ll d1=a1+b1-c1;
    cout<<(b-a+1)-d1;

	return(0);
}


Measured memory_bytes: 256
n = gets.chomp
ndigit = n.length
n = n.to_i
ans = 0
if n < 10000 then
  (1..n).each do |m|
    x = 0
    while m > 0
      x += m%10
      m /= 10
    end
    ans = [ans, x].max
  end
else
  (0..9).each do |i|
    (0..9).each do |j|
      (0..9).each do |k|
        (0..9).each do |l|
          if "#{i}#{j}#{"9"*(ndigit - 4)}#{k}#{l}".to_i <= n
            x = i + j + 9 * (ndigit - 4) + k + l
            ans = [ans, x].max
          end
        end
      end
    end
  end
end
puts ans

Measured memory_bytes: 3964
import itertools
N = int(input())
SK = {"M":0,"A":1,"R":2,"C":3,"H":4}
SD = [0]*5
del_list = []
A = ["M","A","R","C","H"]
for x in range(N):
    tmp = str(input())
    if tmp[0] in A:
        SD[SK[tmp[0]]] +=1
C = 0
for x in range(5):
    if SD[x] == 0 :
        del_list.append(x)
        C +=1
del_list.reverse()
for x in del_list:
    SD.pop(x)
    
if C >2:
    print(0)
else:
    Z = 5-C
    k = itertools.combinations(range(Z), 3)
    ans = 0
    for x in k:
        ans += SD[x[0]]*SD[x[1]]*SD[x[2]]
    print(ans)

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

int main()
{
    int n;
    const double PI=3.14159265358979323846;
    cin>>n;

    double ans;

    ans = (double) n * 2 * PI;

    cout << fixed << setprecision(20);
    cout << ans <<endl;
    
    return 0;
}

Measured memory_bytes: 3776
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 507;
const LD EPS = 1e-7;

string P[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int h, w;
	cin >> h >> w;
	REP(i, h)
		cin >> P[i];
	REP(i, h)
	{
		REP(j, w)
			cout << (j != w - 1 && (j == 0 || (i & 1) == 0 || P[i][j] == '#') ? '#' : '.');
		cout << '\n';
	}
	cout << '\n';
	REP(i, h)
	{
		REP(j, w)
			cout << (j && (j == w - 1 || (i & 1) || P[i][j] == '#') ? '#' : '.');
		cout << '\n';
	}
	//cout << endl; system("pause");
	return 0;
}

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

int main() {
    int x;cin>>x;
    if(x==1){
        cout<<1<<endl;
        return 0;
    }
    
    while(true){
        int q = sqrt(x);
        for(int i = q;i>1;--i){
        int t=x;
        while(t>1){
            if(t%i==0)t/=i;
            else break;
            
            if(t==1){
                cout<<x<<endl;
                return 0;
            }
        }
        }
        --x;
        }
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	ll o=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		o^=arr[i];
	}
	for(ll i=0;i<n;i++)
	{
		cout<<(arr[i]^o)<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<int, pii> viii; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef vector<vector<vl>> vvvl; 

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int i,j,n=s.length(),m=t.length();
    int minn=m;
    for(i=0;i<=n-m;i++){
        int count=0;
        for(j=0;j<m;j++){
            if(s[i+j]!=t[j])count++;
        }
        minn=min(minn, count);
    }
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 3652
n, y = map(int, input().split())
for i in range(n + 1):
    if 10000*i > y:
        print("-1 -1 -1")
        exit()
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
using namespace std;
int main()
{
    int N;
    cin>>N;
    string S;
    cin>>S;
    int counter=0;
    for (int i=0;i<N;++i){
        if (S[i]=='A'&& S[i+1]=='B'&& S[i+2]=='C'){
                counter++;
            }
        }
    cout<<counter<<endl;
}


Measured memory_bytes: 256