akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define NIL -1
#define N 100006



struct Node{
  int p,l,r;
};
struct Node A[N];

int deep(int);
int child(int);


main()
{


  int i,j;
  int n,id,deg,c,k;



  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].l = NIL;
   A[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d",&id,&deg);
    for(j = 0; j < deg; j++){
      scanf("%d",&c);
      
      A[c].p = id;
      
      if(j == 0){
	A[id].l = c;
      }
      else {
	A[k].r = c;
      }
      k = c;
    }
  }

  for(i = 0; i < n; i++){

    printf("node %d: parent = %d, depth = %d, ",i,A[i].p,deep(i));
    
   
    if(A[i].p == NIL){
      printf("root, [");
    }
    else if(A[i].l == NIL){
      printf("leaf, [");
    }
    else {
	printf("internal node, [");
    }
    child(A[i].l);
    printf("]\n");
  }
  return 0;
}


int deep(int s)
{
  int a;
  
  if(A[s].p == NIL){
    return 0;
  }
  else {
    a = deep(A[s].p) + 1;
    return a;
  }
}

int child(int s)
{
  if(s == NIL){
    return 0;
  }
  else {
    if(A[s].r == NIL){
      printf("%d",s);
    }
    else {
      printf("%d, ",s);
      child(A[s].r);
    }
  }
}

Measured memory_bytes: 1784
#include<stdio.h>
#include<string.h>
int N,l,m;
char S[1026],*p,C[11][9]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main()
{
	for(scanf("%d\n",&N);N--;)
	{
		gets(S);
		for(p=strtok(S,"0");p;p=strtok(0,"0"))
		{
			l=strlen(p);
			m=p[0]=='1'?5:p[0]=='7'||p[0]=='9'?4:3;
			if(l!=0)
				putchar(C[p[0]-48][(l-1)%m]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <cstring>

using namespace std;

int dp[4000];

int main(){
    memset(dp,0,sizeof(dp));
    for(int i=0; i<=1000; i++){
        for(int j=0; j<=1000; j++){
            dp[i+j]++;
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; i<=n; i++){
            ans += dp[i]*dp[n-i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			String sum = String.valueOf(a+b);
			System.out.println(sum.length());
		}
	}
}

Measured memory_bytes: 20440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void) {
    int k; cin >> k; k--;
    cout << x[k];
}


Measured memory_bytes: 764
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int h,w;
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			if (h == 0 && w == 0) break;
			
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if ( i == 0 || i == h - 1 || j == 0 || j == w - 1)
						System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34448
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define int long long
using namespace std;
typedef long long ll;
//using pii pair<int,int>;
typedef pair<int, int> pii;
//using ll long long;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

//=============================================================
int K,S;

int ans=0;



void solve()
{
  rep(i,K+1){
    rep(j,K+1){
      int k = S-i-j;
      if (k >= 0 && k <= K){ans++;}
    }
  }
  cout<<ans<<endl;

}

signed main()
{
  cin>>K>>S;
  solve();

  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;

void dump(vector<int> d)
{
    rep(i, d.size())
    {
        printf("%d ", d[i]);
    }
    cout << endl;
}

int main()
{
    int N;
    string S;
    cin >> N >> S;
    // cout << N
    //      << endl;
    // cout << S
    //      << endl;

    char x;
    int count = 0;
    rep(i, N)
    {
        if (x != S.at(i))
            count++;
        x = S.at(i);
        // cout << S.at(i) << endl;
    }
    cout << count << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        char data[][] = new char[n][n];
        for (int i = 0; i < n; i++) {
            data[i] = sc.next().toCharArray();
        }

        int cnt = 0;
        for (int b = 0; b < n; b++) {
            if (check(data, b, n)) {
                cnt += n;
            }
        }

        System.out.println(cnt);
    }

    private boolean check(char data[][], int b, int n) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (data[i][(j + b) % n] != data[j][(i + b) % n]) {
                    return false;
                }
            }
        }

        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 26844
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define gcd(a,b) __gcd(a,b)
#define all(a) a.begin(),a.end()
#define in(a) insert(a)
#define sz() size()
#define endl '\n'
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
ll val[maxn],k,n,p1,p2;
ll check(ll a)
{
	ll ret=0;
	if(a>=0)
    {
		for(int i=1;i<=n;i++)
		{
			if(val[i]<0)
			{
				ll tmp=lower_bound(val,val+n+2,a/val[i])-val;
				if(tmp>=i)
                    continue;
				ret +=(i-tmp);
			}
			else if(val[i]==0)
				ret+=i-1;
			else
			{
				ll tmp=upper_bound(val,val+n+2,a/val[i])-val-1;
				ret+=min(tmp,(ll)i-1);
			}
		}
	}
	else
		for(int i=1;i<=n;i++)
		{
			if(val[i]<=0)
                continue;
			ll tmp=upper_bound(val,val+n+2,(a-val[i]+1)/val[i])-val;
			ret +=tmp-1;
		}
	return ret;
}
int main()
{
	cin>>n>>k;
	ll l=-1e18,r=1e18;
	for(int i=1;i<=n;i++)
        cin>>val[i];
	val[0]=-1e18;
	val[n+1]=1e18;
	p1=lower_bound(val+1,val+n+1,0)-val;
	p2=upper_bound(val+1,val+n+1,0)-val;
	sort(val+1,val+n+1);
	while(l!=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid)>=k)
           r=mid;
		else
            l=mid+1;
	}
    cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7;
struct matrix{
	ll M[50][50],n;
	matrix operator*(const matrix &x)const{
		matrix re;
		MEM(re.M,0),re.n=n;
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				for(int k=0;k<n;++k)
					re.M[i][j]=(re.M[i][j]+M[i][k]*x.M[k][j])%MOD;
		return re;
	}
}ma,ans;

int main()
{jizz
	ll k,out=0;
	cin >> ma.n >> k,ans.n=ma.n;
	for(int i=0;i<ma.n;ans.M[i][i]=1,++i)
		for(int j=0;j<ma.n;++j)
			cin >> ma.M[i][j];
	for(;k;k>>=1,ma=ma*ma)
		if(k&1) ans=ans*ma;
	for(int i=0;i<ma.n;++i)
		for(int j=0;j<ma.n;++j)
			out=(out+ans.M[i][j])%MOD;
	cout << out << "\n";
}

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

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll N, X;
    cin >> N >> X;
    vector<ll> x(N + 1);
    rep(i, N) cin >> x[N - i];
    rep(i, N) x[i + 1] += x[i];
    ll ans = inf;
    FOR(k, 1, N + 1) {
        ll cost = (N + k) * X;
        for(ll i = 0; i * k < N; i++) {
            cost += (x[min((i + 1) * k, N)] - x[i * k]) * max(2 * i + 3, 5LL);
            if(cost >= ans) break;
        }
        chmin(ans, cost);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc143/tasks/abc143_ahttps://atcoder.jp/contests/abc143/tasks/abc143_a
//Width of window: a
//two curtains each of width b
#include <iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a-2*b > 0) {
        cout << a-2*b;
    }
    else
        cout << 0;
    return 0;
}


Measured memory_bytes: 256
#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() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n) {
        int cnt = 0;
        rep(j,m) {
            int a;
            cin >> a;
            cnt += a*b[j];
        }
        cnt += c;
        if (cnt > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a[9];
    int n;
    int tmp;
    string ans = "No";
    for(int i = 0; i < 9; i ++){
        cin >>a[i];
    }
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> tmp;
        for(int j = 0; j < 9; j ++){
            if(a[j] == tmp) a[j] = -1;
        }
    }
    if(a[0] == -1 && a[1] == -1 && a[2] == -1) ans = "Yes";
    if(a[3] == -1 && a[4] == -1 && a[5] == -1) ans = "Yes";
    if(a[6] == -1 && a[7] == -1 && a[8] == -1) ans = "Yes";
    if(a[0] == -1 && a[3] == -1 && a[6] == -1) ans = "Yes";
    if(a[1] == -1 && a[4] == -1 && a[7] == -1) ans = "Yes";
    if(a[2] == -1 && a[5] == -1 && a[8] == -1) ans = "Yes";
    if(a[0] == -1 && a[4] == -1 && a[8] == -1) ans = "Yes";
    if(a[2] == -1 && a[4] == -1 && a[6] == -1) ans = "Yes";

    cout << ans;
    return 0;
}

Measured memory_bytes: 3560
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map{};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]

Measured memory_bytes: 36220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n , m , k;
    cin >> n >> m >> k;
    
    
    vector<string> grid(n);
    for(auto &str : grid)cin >> str;    
 
    int ans = 0;
    for(int mskR = 0 ; mskR < (1 << n) ; mskR++){
            for(int mskC = 0 ; mskC < (1 << m) ; mskC ++){
                    int cnt = 0;
                    for(int i = 0 ; i < n ; i++){
                          for(int j = 0 ; j < m ; j++){
                               if((mskR >> i)&1)continue;
                              if((mskC >> j)&1)continue;
                               cnt += (grid[i][j] == '#');
                          }
                    }
                    ans += (cnt == k);
            }

    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int a[] = new int[2019];
        a[0] = 1;
        String s = in.next();
        int len = s.length(), x = 0, n = 1, ans = 0;
        for (int i = len - 1; i >= 0; i--) {
            x = (x + (s.charAt(i) - '0') * n) % 2019;
            ans += a[x];
            a[x]++;
            n = (n * 10) % 2019;
        }
        System.out.println(ans);
    }

}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    ll N = s.size();
    vector<ll> cnt(256);
    for (int i = 0; i < N; i++) {
        cnt[s[i]]++;
    }

    ll ans = N * (N - 1) / 2;
    for (int i = 'a'; i <= 'z'; i++) {
        ans -= cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans + 1 << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
int a,b,c; cin>>a>>b>>c;
  if (a==b && a!=c) out("Yes");
  if (a==c && a!=b) out("Yes");
  if (b==c && b!=a) out("Yes");
  out("No");
  
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define lim (ll)(1e10)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5 + 5)

bool fn(string arr[],int n,int m,int k,int r,int c)
{
    set<int> rr,cc;

    int x=r, y=c ,i=0;

    while(x)
    {
        if(x&1)
            rr.insert(i);
        x>>=1;
        i++;
    }

    i = 0;
    while(y)
    {
        if(y&1)
            cc.insert(i);
        y>>=1;
        i++;
    }

    int cnt = 0;
    for(i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(arr[i][j] == '#' && rr.find(i)==rr.end() && cc.find(j)==cc.end())    cnt++;

        }
    }

    return (cnt == k);

}

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;

    string arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    int ln = (1<<n) , lm = (1<<m),ans = 0;
    for(int i=0;i<ln;i++)
    {
        for(int j=0;j<lm;j++)
        {
            if(fn(arr,n,m,k,i,j))
                ans++;
        }
    }

    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  string s;
  cin >> s;
  int n,ret = 0;
  cin >> n;
  for(int i = 0 ; i < n ; i++ ){
    string buff;
    cin >> buff;
    buff += buff + buff + buff + buff;
    if(buff.find(s) != string::npos) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1212
<?php

$cnt = intval(fgets(STDIN));
$inputData = array_map('intval', explode(" ", fgets(STDIN)));
$absMin = array_fill(0, $cnt-1, 0);

for($n=1; $n<$cnt; $n++){
	$s1 = 0;
	$s2 = 0;
	for($i=0; $i<$n; $i++){
		$s1 += $inputData[$i];
	}

	for($i=count($inputData); $i>$n; $i--){
		$s2 += $inputData[$i-1];
	}

	$absMin[$n-1] = abs($s1 - $s2);

}

echo min($absMin);
?>

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


typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
ull gcd(ull a,ull b){
	while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
int main(){
	int checkd=1, checkn=1;
	ull A,B,k=0,N;
	ull C,D,countc=0,countd=0;
	cin >> A>> B>>C>>D;
	if(C>D){
		swap(C,D);
	}
	N=C*D/gcd(C,D);
	if(D%C==0){
		countc=B/C-(A-1)/C;
	}else{
		countc=B/C+B/D-(A-1)/C-(A-1)/D;
		countd=B/N-(A-1)/N;
	}
	cout << B-A+1-(countc-countd)<<endl;
	return 0;
}

Measured memory_bytes: 256
a = [int(input()) for i in range(5)]
b = []
low = a[0]

for i in a:
  x = i % 10
  if (x != 0) & (x < low % 10):
    low = i
  
a.remove(low)
a.append(low)

o = [-(i // -10) * 10 for i in a]
o[4] = ((a[4] // 10) * 10) + (a[4] % 10)

print(sum(o))

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

using namespace std;

int main() {
    int N;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        int num_div = 0;
        while (a % 2 == 0) {
            a /= 2;
            num_div++;
        }
        ans += num_div;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
const int maxn=1e5+5;
 
int n,rk,L,T;
int pos[maxn];
 
int read() {
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}
 
int main() {
    n=read(),L=read(),T=read();
    for(int i=1;i<=n;i++) {
        int x=read(),w=read();
        if(w==2)pos[i]=x-T;
        else pos[i]=x+T;
        rk+=pos[i]/L;
        if(pos[i]%L<0)rk--;
        pos[i]=(pos[i]%L+L)%L;
    }
    sort(pos+1,pos+n+1);
    rk=(rk%n+n)%n;
    for(int i=rk+1;i<=n;i++)
        printf("%d\n",pos[i]);
    for(int i=1;i<=rk;i++)
        printf("%d\n",pos[i]);
    return 0;
}

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


int main() {string s;
cin >> s;
long last = s.size() - 1;
string ans = "NO";
while(last >= 4){
  if(last >= 6){
    if(s.substr(last - 4, 5) == "dream") last = last - 5;
    else if(s.substr(last - 4, 5) == "erase") last = last - 5;
    else if(s.substr(last - 5, 6) == "eraser") last = last - 6;
    else if(s.substr(last - 6, 7) == "dreamer") last = last - 7;
    else break;
  }
  else if(last == 5){
    if(s.substr(last - 4, 5) == "dream") last = last - 5;
    else if(s.substr(last - 4, 5) == "erase") last = last - 5;
    else if(s.substr(last - 5, 6) == "eraser") last = last - 6;
    else break;
  }
  else if(last == 4){
    if(s.substr(last - 4, 5) == "dream") last = last - 5;
    else if(s.substr(last - 4, 5) == "erase") last = last - 5;
    else break;
  }

}
if(last == -1) ans = "YES";

// string x = "aiueo";
// x = x - 'ue';

cout << ans << endl;
  return 0;
 
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int A[3];
for(int i=0;i<3;i++)cin>>A[i];
sort(A,A+3);
int sum=0;
for(int i=1;i<3;i++){
    sum+=abs(A[i]-A[i-1]);
}
cout<<sum;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
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();
      int D = sc.nextInt();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  }
      }
      System.out.println(count);
	}
	}

Measured memory_bytes: 23764
import java.math.BigDecimal;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigDecimal a = sc.nextBigDecimal(), b = sc.nextBigDecimal();

    System.out.println(a.multiply(b).toBigInteger());
  }
}


Measured memory_bytes: 37496
from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    H, W = map(int, input().split())
    S = stdin.read().splitlines()

    maze = ['#' * (W + 2)]
    for s in S:
        maze.append('#' + s + '#')
    maze.append('#' * (W + 2))

    def func(sx, sy):
        c1 = deque([(sx, sy)])
        c2 = [[None for _ in range(W + 1)] for _ in range(H + 1)]
        c2[sx][sy] = 0
        ret = 0
        while c1:
            x, y = c1.popleft()
            for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                if '.' in maze[x+i][y+j] and c2[x+i][y+j] is None:
                    c1.append((x+i, y+j))
                    c2[x+i][y+j] = c2[x][y] + 1
                    ret = max(ret, c2[x+i][y+j])
        return ret

    ans = 0
    for i, a in enumerate(maze[1:-1], start=1):
        for j, b in enumerate(a[1:-1], start=1):
            if b == '.':
                ans = max(ans, func(i, j))
    print(ans)


main()


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

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

    k -= 400;
    k /= 200;

    cout << 8 - k << endl;

    return 0;
}

Measured memory_bytes: 3556
def isok(f,p):
  s=0
  if not f and p==0:return 1
  for i,j in enumerate(f):
    s+=j
    if s>=p:break
  else:return 0
  for j in f[i+1:]:
    if s>=p:s-=j
    else:s+=j
  return s==p
s=input()
x,y=map(int,input().split())
f=list(map(len,s.split('T')))
x-=f[0]
x,y=abs(x),abs(y)
xf=sorted(f[2::2])[::-1]
yf=sorted(f[1::2])[::-1]
print(['No','Yes'][isok(xf,x) and isok(yf,y)])

Measured memory_bytes: 65568
import itertools
import os
import sys
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 998244353

N = int(sys.stdin.readline())


@lru_cache(maxsize=None)
# @debug
def is_ok(s):
    if len(s) == 0:
        return True
    if len(s) == 2:
        return s not in ['AB', 'BA']
    for i in range(len(s) - 2):
        if s[i:i + 2] not in ['AB', 'BA'] and is_ok(s[:i] + s[i + 2:]):
            return True
    return False


def test(N):
    ret = 0
    for s in itertools.product('ABC', repeat=N):
        s = ''.join(s)
        ret += is_ok(s)
    return ret


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


# print(test(N))
# N = 10 ** 7

# 解説AC
# 偶数番目のAとBを反転して、AAとBB以外を取り除く
# AまたはBが半分より多いときダメなので全体から引く
ans = pow(3, N, MOD)

invs = mod_invs(max=N, mod=MOD)
ncr = 1  # NCr
p2r = 1  # pow(2, N - r, MOD)
for r in range(N, N // 2, -1):
    # ans -= comb.ncr(N, r) * pow(2, N - r, MOD) * 2 % MOD
    ans -= ncr * p2r * 2 % MOD
    ans %= MOD
    ncr *= r * invs[N - r + 1]
    ncr %= MOD
    p2r *= 2
    p2r %= MOD
print(ans)


Measured memory_bytes: 118636
#include<iostream>
using namespace std;
int main(){
	int n,x,a=0;
	for(;;){
		cin>>n>>x;
		if(n==0&&x==0){
			break;
		}
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){
					if((i+j+k)==x){
						a++;
					}
				}
			}
		}
		cout<<a<<endl;
		a=0;
	}
	return 0;
}



Measured memory_bytes: 3096
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	static int m;
	static int n;
	static int [] map;
	static List<Integer> list;
	static boolean [] stepExistence;
	public static void main(String[]args){
		Scanner scan = new Scanner (System.in);
		n = scan.nextInt();
		m = scan.nextInt();
		map = new int [n+1];
		list = new ArrayList<Integer>();
		stepExistence = new boolean[n+1];
		for(int i = 0;i < n+1;i++) {
			map[i] = -1;
			stepExistence[i] = true;
		}
		for(int i = 0; i < m;i++) {
			list.add(scan.nextInt());
			stepExistence[list.get(i)] = false;
		}
		map[0] = 1;
		map[1] = 1;
		int ans = downSteps(n);
		System.out.println(ans%1000000007);
	}
	public static int downSteps (int Step) {
		if(map[Step] > -1) {
			return map[Step];
		}
		int nextStep = Step-1;
		int twoDownStep = Step-2;
		int pattern = 0;
		if(stepExistence[nextStep]) {
			pattern = downSteps(nextStep);
			if(stepExistence[twoDownStep]) {
				pattern += downSteps(twoDownStep);
			}
		}else if(stepExistence[twoDownStep]) {
			pattern = downSteps(twoDownStep);
		}
		pattern = pattern % 1000000007;
		map[Step] = pattern;
		return pattern;
	}
}


Measured memory_bytes: 60644
def main():
    S = input()

    def an_area(S):
        ans = 0
        stack_in = []
        stack_out = []
        for i,ch in enumerate(S):
            if ch == '\\':
                stack_in.append(i)
            elif stack_in and ch == '/':
                j = stack_in.pop()
                cur =  i - j
                stack_out.append((j,i,cur))
                ans += cur
        return ans,stack_out

    ans, l = an_area(S)
    if ans == 0:
        print(ans)
        print(len(l))
        return

    l.sort()
    pre_le, pre_ri = l[0][0], l[0][1]
    pre_ar = 0
    areas = []
    for le,ri,ar in l:
        if pre_le <= ri <= pre_ri:
            pre_ar += ar
        else:
            areas.append(pre_ar)
            pre_ar = ar
            pre_le, pre_ri = le, ri
    else:
        areas.append(pre_ar)
    
    print(ans)
    print(len(areas),*areas)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6928
#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(void){
    int n;
    cin >> n;
    set<string> str;
    rep(i, n){
        string s;
        cin >> s;
        str.insert(s);
    }
    cout << str.size() << endl;
    return 0;
}

Measured memory_bytes: 19212
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
int32_t main()
{
    int n; cin >> n;
    cout << 10 - n/200;		
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

const int MAXM = 1e5+3;
const ll inf = 1e15;

ll arr[MAXM];

int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int cnt = 0, maxcnt = 0;
	for (int i=1;i<=n;i++){
		if (arr[i] > arr[i-1]){
			maxcnt = max(maxcnt, cnt);
			cnt = 0;
		} else {
			cnt++;
		}
	}
	maxcnt = max(maxcnt, cnt);
	cout << maxcnt << endl;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)

D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(5000):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)


Measured memory_bytes: 81104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

const std::string way = "LRDU";
constexpr int INF = 1 << 30;

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::vector<std::pair<int, int>>> ps(4);
    while (n--) {
        int x, y;
        char c;
        std::cin >> x >> y >> c;

        x *= 10;
        y *= 10;

        for (int i = 0; i < 4; ++i) {
            if (c == way[i]) ps[i].emplace_back(x, y);
        }
    }

    int ans = INF;
    for (int q = 0; q < 2; ++q) {
        std::map<int, std::vector<std::pair<int, int>>> yps;
        for (int i = 0; i < 2; ++i) {
            for (auto p : ps[i]) {
                yps[p.second].emplace_back(p.first, i);
            }
        }

        for (auto& p : yps) {
            auto& xis = p.second;
            std::sort(xis.begin(), xis.end());

            int rmax = -INF;
            for (auto [x, t] : xis) {
                if (t == 0) {
                    if (rmax == -INF) continue;
                    ans = std::min(ans, (x - rmax) / 2);
                } else {
                    rmax = x;
                }
            }
        }

        for (auto& v : ps) {
            for (auto& p : v) std::swap(p.first, p.second);
        }
        std::rotate(ps.begin(), ps.begin() + 2, ps.end());
    }

    for (auto& v : ps) {
        for (auto& p : v) {
            int x = p.first + p.second,
                y = p.first - p.second;
            p = std::make_pair(x, y);
        }
    }

    for (int q = 0; q < 2; ++q) {
        std::map<int, std::vector<std::pair<int, int>>> yps;
        for (int i = 0; i < 4; ++i) {
            for (auto p : ps[i]) {
                yps[p.second].emplace_back(p.first, i);
            }
        }

        for (auto& p : yps) {
            auto& xis = p.second;
            std::sort(xis.begin(), xis.end());

            int rmax = -INF, umax = -INF;
            for (auto [x, t] : xis) {
                if (t == 0) {
                    if (umax == -INF) continue;
                    ans = std::min(ans, (x - umax) / 2);
                } else if (t == 1) {
                    rmax = x;
                } else if (t == 2) {
                    if (rmax == -INF) continue;
                    ans = std::min(ans, (x - rmax) / 2);
                } else {
                    umax = x;
                }
            }
        }

        for (auto& v : ps) {
            for (auto& p : v) std::swap(p.first, p.second);
        }
        std::swap(ps[2], ps[3]);
    }

    if (ans == INF) {
        std::cout << "SAFE\n";
    } else {
        std::cout << ans << "\n";
    }
}

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

    solve();

    return 0;
}


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

int main(){
    long long int n,r;
    cin>>n>>r;
    if(n<10){
    	cout<<r+100*(10-n)<<endl;
    }
    else{
    	cout<<r<<endl;
    }
    return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

const ll N=5e5+5,mod=1e9 + 7;
ll fct[N],inv[N],invfct[N];
void init(){
    fct[0]=fct[1]=1;
    inv[1]=1;
    invfct[0]=invfct[1]=1;
    for(ll i=2;i<N;i++){
        fct[i]=i*fct[i-1]%mod;
        inv[i]=(ll)(mod-inv[mod%i])*(mod/i)%mod;
        invfct[i]=(ll)(inv[i])*invfct[i-1]%mod;
    }
}
ll ncr(ll n,ll r){
    if(n<0 || r<0 || n-r<0)return 0;
    ll ans = fct[n]*invfct[r];
    ans%=mod;
    ans = ans * invfct[n-r];
    ans%=mod;
    return ans;
}

void doit(){
    ll n, i, ans = 0, k;
    cin >> n >> k;
    vector< ll >v(n);
    for(i = 0; i < n; i++)cin>>v[i];
    sort( v.begin(), v.end() );
    rep(i,0,n-k+1){
        ll c = ncr(n-i-1,k-1);
        ll va = (v[i] + mod) % mod;
        va *= c;
        va %= mod;
        ans += (-va + mod);
        ans %= mod;
    }
    rep(i,k-1,n){
        ll c = ncr(i,k-1);
        ll va = (v[i] + mod) % mod;
        va *= c;
        va %= mod;
        ans += va;
        ans %= mod;
    }
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    init();
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  //入力終わり

  //各色のi番目までの登場回数
  //0で初期化
  int rn[N], gn[N], bn[N];
  rep(i, N){
    rn[i] = 0; gn[i] = 0; bn[i] = 0;
  }

  //各色のi番目までの登場回数を計算
  for(int i=0; i<N-1; i++){
    if(S[i] == 'R')
      rn[i]++;
    else if(S[i] == 'G')
      gn[i]++;
    else
      bn[i]++;
    rn[i+1] = rn[i];
    gn[i+1] = gn[i];
    bn[i+1] = bn[i];
  }
  //N番目は別で見る
  if(S[N-1] == 'R')
    rn[N-1]++;
  else if(S[N-1] == 'G')
    gn[N-1]++;
  else if(S[N-1] == 'B')
    bn[N-1]++;

  //各色に数字を割り当てる
  //あとで判定に使う
  map<char, int> m;
  m['R'] = 0; m['G'] = 1; m['B'] = 2;
  
  long long ans = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      //条件1を満たさない
      if(S[i] == S[j])
	continue;
      
      int k = j+(j-i);
      //i番目のとj番目でRとGを選んだとき
      if(m[S[i] ] + m[S[j] ] == 1){
	//j+1番目以降のBの数を加算
	ans = ans + bn[N-1] - bn[j];
	//条件2を満たさない
	if(k<N && S[k] == 'B')
	  ans--;
      }
      //GB(上と同じ処理)
      else if(m[S[i] ] + m[S[j] ] == 3){
	ans = ans + rn[N-1] - rn[j];
	if(k<N && S[k] == 'R')
	  ans--;
      }
      //BR(上と同じ処理)
      else if(m[S[i] ] + m[S[j] ] == 2){
	ans = ans + gn[N-1] - gn[j];
	if(k<N && S[k] == 'G')
	  ans--;
      }
    }
  }

  //解答
  cout << ans << endl;

  return 0;
}


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

void f(int x, int &a, int &b) {
  a = x % 10;
  b = 0;
    while (x > 0) {
      b = x;
      x /= 10;
    }
  return;
}

int main() {
  int n;
  cin >> n;
  
  vector<vector<int>> c(10, vector<int>(10, 0));
  for (int i = 1; i <= n; i++) {
    int a, b;
    f(i, a, b);
    c.at(a).at(b) += 1;
  }
  
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += c.at(i).at(j) * c.at(j).at(i);
    }
  }
  
  cout << ans << endl;
}


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int counter = 0;
  for (int i = 0; i <= a; i++) {
    if (500 * i > x)
      break;
    for (int j = 0; j <= b; j++) {
      if (500 * i + 100 * j > x)
        break;
      for (int k = 0; k <= c; k++) {
        int total = 500 * i + 100 * j + 50 * k;
        if (total > x)
          break;
        if (x == total) {
          counter++;
        }
      }
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
  string s;
  cin >> s;
  int n = sz(s);
  vi pos[26];
  rep(i,0,n) pos[s[i]-'a'].pb(i);
  int odd = 0;
  rep(i,0,26) odd+=sz(pos[i])&1;
  if(odd == 0 || (odd == 1 && (n & 1))) {
    vector<pii> v;
    vi permu(n , 0);
    rep(i,0,26) {
      vi&p=pos[i];
      if(sz(p)&1) {
        int mid = sz(p) / 2;
        permu[p[mid]] = n / 2;
        p.erase(p.begin() + mid);
      }
      rep(i,0,sz(p)/2) v.pb(mp(p[i],p[sz(p)-1-i]));
    }
    sort(all(v));
    rep(i,0,n/2) {
      int j=n-1-i;
      permu[v[i].fi] = i;
      permu[v[i].se] = j;
    }
    vi fen(n + 1 , 0);
    ll ans = 0;
    rep(i,0,n) {
      ans += i;
      for(int j = permu[i] + 1;j >= 1;j &= j - 1)
        ans -= fen[j];
      for(int j = permu[i] + 1;j <= n;j += j & -j)
        fen[j] ++;
    }
    cout << ans << endl;
  } else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 4088
k,n = map(int,input().split())
a = list(map(int,input().split()))
dist = []
kankaku_max = 0
for i in range(n-1):
  dist.append(a[i+1]-a[i]) 
dist.append(a[0]+(k-a[-1]))
for i in dist:
  kankaku_max = max(kankaku_max,i)
print(k-kankaku_max)

Measured memory_bytes: 26444
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]
 
def main():
    n = inp()
    LR = []
    for _ in range(n):
        x,l = inpm()
        LR.append((x-l,x+l))
    LR.sort()
    ans = 1
    index = 1
    l,r = LR[0]
    while index < n:
        if LR[index][0] < r and l < LR[index][1]:
            r = min(r,LR[index][1])
            index += 1
        else:
            ans += 1
            [l,r] = LR[index]
            index += 1
    print(ans)

if __name__ == "__main__":
    main()

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

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

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


   System.out.println(serchcount);
  }
}

Measured memory_bytes: 24288
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,t,ans;

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

main(){
    ans=1;
    cin>>n;
    rep(i,n){
        cin>>t;
        ans=ans/gcd(ans,t)*t;
    }
    dans;
}



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

int main() {
  string s;
  cin >> s;
  bool flag = true;
  if(s[2] != s[3]) flag = false;
  if(s[4] != s[5]) flag = false;
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        if not isOk:
            break
        p = int(pm[li])
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    res = 10**20
    for i in range(1, N-1):
        res = min(K-(a[i+1]-a[i]), K-(a[i]-a[i-1]), res)
    res = min(K-(a[1]-a[0]), res, a[N-1]-a[0])
    res = min(res, K-(a[N-1]-a[N-2]))
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 25432
#include <iostream>

using namespace std;

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int sol = 0;
    a = min(a, k);
    sol += a;
    k -= a;
    b = min(b, k);
    k -= b;
    c = min(c, k);
    sol -= c;
    cout << sol;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n=SIZE(s);

    deque<char> q;
    REP(i,n){
        if(s[i]=='0' || s[i] == '1'){
            q.push_back(s[i]);
        }
        else {
            if(!q.empty()){
                q.pop_back();
            }
        }
    }
    while(!q.empty()){
        cout<<q.front();
        q.pop_front();
    }
    cout<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> count(200000);
  for(int i = 0;i < (int)count.size();i++)count[i] = 0;
  ll res = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    count[a[i]]++;
    res += a[i];
  }
  ll q;
  cin >> q;
  for(int i = 0;i < q;i++){
    ll a,b;
    cin >> a >> b;
    res -= count[a] * a;
    res += count[a] * b;
    count[b] += count[a];
    count[a] = 0;
    cout << res << endl;
  }
}

Measured memory_bytes: 5544
// https://beta.atcoder.jp/contests/abc068

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

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

    int ans;
    int max_div = -1;
    for (int i = 1; i <= n; ++i) {
        int x = i;
        int div = 0;
        while (x % 2 == 0) {
            div++;
            x /= 2;
        }

        if (max_div < div) {
            max_div = div;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256