akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        Integer n = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
        ArrayList<String> ss = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            ss.add(s);
        }

        V v1 = new V(A, "A");
        V v2 = new V(B, "B");
        V v3 = new V(C, "C");

        boolean ok = true;
        ArrayList<String> ans = new ArrayList<>();
        n = ss.size();
        for (int i = 0; i < n - 1; i++) {
            switch (ss.get(i)) {
                case "AB":
                    if (ss.get(i + 1).contains("A")) {
                        ok &= update(v2, v1, ans);
                    } else {
                        ok &= update(v1, v2, ans);
                    }
                    break;
                case "AC":
                    if (ss.get(i + 1).contains("A")) {
                        ok &= update(v3, v1, ans);
                    } else {
                        ok &= update(v1, v3, ans);
                    }
                    break;
                case "BC":
                    if (ss.get(i + 1).contains("B")) {
                        ok &= update(v3, v2, ans);
                    } else {
                        ok &= update(v2, v3, ans);
                    }
                    break;
            }
            if (!ok) {
                break;
            }
        }

        switch (ss.get(n - 1)) {
            case "AB":
                ok &= update(v1, v2, ans);
                break;
            case "AC":
                ok &= update(v1, v3, ans);
                break;
            case "BC":
                ok &= update(v2, v3, ans);
                break;
        }

        if (ok) {
            out.println("Yes");
            for (String s : ans) {
                out.println(s);
            }
        } else {
            out.println("No");
        }

        out.flush();
    }

    boolean update(V X, V Y, ArrayList<String> ans) {
        if (X.X == 0 && Y.X == 0) {
            return false;
        } else if (X.X == 0) {
            ans.add(X.s);
            X.X++;
            Y.X--;
        } else if (Y.X == 0) {
            ans.add(Y.s);
            X.X--;
            Y.X++;
        } else {
            ans.add(Y.s);
            Y.X++;
            X.X--;
        }
        return true;
    }

    class V {
        int X;
        String s;

        V(int X, String s) {
            this.X = X;
            this.s = s;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 64424
#include <iostream>
using std::cin;
using std::cout;
 
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
 
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
 
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) ++gap_num;
 
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
 
  cout << (gap_num+1) << '\n';
 
  for(; gap_num; gap_num--) cout << gaps[gap_num] << ' ';
  cout << gaps[0] << '\n';
 
  cout << count << '\n';
}
 
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m;
	map<string, ll> ma;
	ll ans = 0;

	cin >> n;

	REP(i, n) {
		string a;
		cin >> a;
		ma[a]++;
	}

	cin >> m;

	REP(i, m) {
		string b;
		cin >> b;
		ma[b]--;
	}

	map<string, ll>::iterator it;

	for (it = ma.begin(); it != ma.end(); it++) {
		if (it->second > ans) {
			ans = it->second;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <cmath>
#define int long long

const int maxn = 200005;

int n,A[maxn],cnt;
std::map<int,int> count;

inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9' || ch<'0'){
		if(ch=='-')
		f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*f;
}


signed main(){
	n=read();
	for(int i=1;i<=n;++i){
		A[i]=read();
		if(i-A[i]>=0)
		++count[i-A[i]];
	}
	for(int i=1;i<=n;++i)
	cnt+=count[i+A[i]];
	printf("%lld\n",cnt);
	return 0;
}

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

int solve(int sx, string &S, string &T, int W, int dir) {

    int N = S.size();

    int l = 0, r = W - 1;
    for(int i = N - 1; i >= 0; i--) {
        if (dir == 0) {
            if (T[i] == 'L') r++;
            if (T[i] == 'R') l--;
            if (r >= W - 1) r = W - 1;
            if (l < 0) l = 0;
            
            if (S[i] == 'L') l++;
            if (S[i] == 'R') r--;
            if (l > r) return 0;
            
        } else {
            if (T[i] == 'U') r++;
            if (T[i] == 'D') l--;
            if (r >= W - 1) r = W - 1;
            if (l < 0) l = 0;
            
            if (S[i] == 'U') l++;
            if (S[i] == 'D') r--;
            if (l > r) return 0;
        }
    }
    
    return l <= sx && sx <= r;
}

void solve() {
    int H, W, N;
    cin >> H >> W >> N;
    int sy, sx;
    cin >> sy >> sx;
    sy--, sx--;
    string S, T;
    cin >> S >> T;
    int r1 = solve(sx, S, T, W, 0);
    int r2 = solve(sy, S, T, H, 1);

    if (r1 && r2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 920
import math

n, a, b = map(int, input().split(" "))

h = []
for i in range(n):
    h.append(int(input()))

h.sort(reverse=True)


def check(count_target, h, a, b):
    count = 0

    for i in h:
        if i >= count_target * b:
            count += math.ceil((i - count_target * b) / (a - b))
    return count_target - count


l = 1
r = math.ceil(h[0] / b)


while r - l > 1:
    mid = math.floor(l + (r - l) / 2)

    if check(mid, h, a, b) < 0:
        l = mid
    else:
        r = mid


if check(l, h, a, b) < 0:
    print(int(r))
else:
    print(int(l))

Measured memory_bytes: 7400
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        long X = scanner.nextLong();
        long price = 100;
        int count = 0;

        while (X > price) {
            price *= 1.01;
            count++;
        }

        System.out.println(count);
    }
}

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

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for(int i=0;i<n;i++) cin >> s[i];

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

	for(int i=0;i<n;i++) cout << s[i];

	cout << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
ab = [[int(_) for _ in input().split()] for _ in range(N)]
ab = sorted(ab, key=lambda x: x[0])
tmp = 0

for i in ab:
    tmp += i[1]
    if tmp >= K:
        ans = i[0]
        break
print(ans)

Measured memory_bytes: 23640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll x,ans = 0,ex;
cin >> x;
ans += (x / 500) * 1000;
ex = x % 500;
ans += (ex / 5) * 5;
cout << ans << endl;


//////////////////////////////////////////////////////
return 0;}

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

int main()
{
    int n;
    cin >> n;
    int num = 1;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(a == num) num++;
        else ans++;
    }
    if(ans == n) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    char A,B;
    while(cin >> A >> B)
    {
        if(A>B)
            cout << ">" << endl;
        else if(A==B)
            cout << "=" << endl;
        else
            cout << "<" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

int n, m, q, res;
vector<int> a, b, c, d;

void dfs(vector<int> A, int pos){
    int sum = 0;
    if(pos == n+1) pos = 1;

    rep(i,q){
        if(A[b[i]] - A[a[i]] == c[i]){
            sum += d[i];
        }
    }
    chmax(res, sum);

    if(pos == 0) return;

    while(A[pos] < m && A[pos] < A[pos+1]){
        A[pos]++;
        dfs(A, pos-1);
    }
}

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> q;

    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    vector<int> A(n+2, 1);
    A[n+1] = INF;

    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(A, n);
    
    cout << res << '\n';

    return 0;
}

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

int main(){

    int N,K;
    string S;

    cin >> N >> S >> K;

    char tmp = S[K-1];

    for(int i=0;i<N;i++){
        if(S[i]!=tmp){
            S[i] = '*';
        }
    }

    cout << S << endl;


    return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void check(int n, int x) {
	int cnt = 0;
	for (int i = 1; i <= n - 2; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (i + j + k == x) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

int main() {
	while (1) {
		int n, x;
		cin >> n >> x;
		if (n == 0 and x == 0) {
			break;
		}
		check(n, x);
	}
	return 0;
}



Measured memory_bytes: 3080
A = int(input())
B = int(input())
C = int(input())
X = int(input())
sum=0
count=0
for i in range(A+1):
    for n in range(B+1):
        for m in range(C+1):
            if(i*500+n*100+m*50 == X):
                count+=1
                sum=0
print(count)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int N; cin >> N;
  vi A(N+2); repf(i,1,N+2) cin >> A.at(i);
  
  vi L(N+2), R(N+2);
  // L.at(0)=0; R.at(N+1)=0;
  rep(i,N+1) {
    L.at(i+1) = gcd(L.at(i),A.at(i));
  }
  repr(i,N,0) {
    R.at(i) = gcd(R.at(i+1),A.at(i));
  }
  
  vi M(N+2);
  repi(i,1,N) {
    M.at(i) = gcd(L.at(i),R.at(i+1));
  }
  
  cout << *max_element(all(M)) << endl;
}

Measured memory_bytes: 1792
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  const int INF=2000000000;
  int n,i,dp[100010];
  scanf("%d\n",&n);
  vector<int> x(n);
  for(i=0;i<n;i++){
    scanf("%d\n",&x[i]);
  }
  reverse(x.begin(),x.end());
  for(i=0;i<=n;i++){
    dp[i]=INF;
  }
  for(i=0;i<n;i++){
    int min=-1,max=n,mid;
    while(abs(min-max)>1){
      mid=(min+max)/2;
      if(x[i]<dp[mid]){
        max=mid;
      }
      else{
        min=mid;
      }
    }
    dp[max]=x[i];
  }
  for(i=0;i<n;i++){
    if(dp[i]==INF){
      break;
    }
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    cin >> n;

    vector<string> s;
    for (int i = 0; i < n; i++) {
        string temp;
        cin >> temp;
        s.push_back (temp);
    }

    sort(ALL(s));
    s.push_back (" ");

    vector<string> ans;
    ll ct = 0;
    ll max_ct = 0;

    for (int i = 0; i < n+1; i++) {
        if (i == 0) {
            ct++;
            continue;
        }
        if (s[i-1] != s[i]) {
            if (max_ct == ct) {
                ans.push_back(s[i-1]);
            } else if (max_ct < ct) {
                max_ct = ct;
                ans.resize(0);
                ans.push_back(s[i-1]);
            }
            ct = 0;
        }
        ct++;
    }

    // cout << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 15344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int n;
 string s,t;
 cin>>n>>s>>t;

 for (int i = 0; i < n; i++)
 {
   cout << s.at(i);
    cout << t.at(i);
 }

}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
     
    static int count = 0;
     
    static int gcd(int a,int b){
        count++;
        int r = a%b;
        if(r == 0) {
            return b;
        }else {
            return gcd(b,r);
        }
    }
 
 
    void main() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a + b == 0) break;
            if(a<b) {
                int temp = a;
                a = b;
                b = temp;
            }
            int ans = gcd(a,b);
            System.out.println(ans +" " + count);
            count = 0;
        }
         
    }
 
    public static void main(String[] args) {
        new Main().main();
    }
 
}


Measured memory_bytes: 33772
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  if(N == 1 || N == 2 || N == 3 || N == 5 || N == 6 ||N == 9 || N == 10 || N == 13 || N == 17){
    cout << "No"<< endl;
  }
  else cout << "Yes" << endl;
}

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int res = 0;
  res += a[0] == b[0];
  res += a[1] == b[1];
  res += a[2] == b[2];
  
  cout << res << endl;
}

Measured memory_bytes: 256
import collections


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
for i in range(Q):
    B.append(list(map(int, input().split())))

sum = sum(A)
count = collections.Counter(A)

for x, y in B:
    change = y - x
    if x in count:
        sum += change * count[x]
        if y in count:
            count[y] += count[x]
        else:
            count[y] = count[x]

        del count[x]
    print(sum)

Measured memory_bytes: 37424
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,n,sum_S=0;
  int time[1000];
  string str[1000];
  string name_X;
  cin >> n;
  for(i = 0;i<n;i++){
    cin >> str[i];
    cin >> time[i];
  }
  cin >> name_X;
  for(i = 0;i<n;i++){
    if(name_X.compare(str[i]) == 0){
      break;
    }
  }
  for(j = i + 1;j < n;j++){
    sum_S += time[j]; 
  }
  cout << sum_S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 小数点以下5桁まで
  cout << fixed << setprecision(7);
  double k,l,m,n;
  cin>>n;
  int nn;
  nn=n;
  if(nn%2==0){
  l=1;
  m=2;
  k=l/m;
  cout<<k;
  }
  else{
   k = ((n+1)/2)/n;
    cout<<k;
  }
    
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n,k,q;
    cin3(n,k,q);
    lli a[q];
    ncin1(q,a);
    map<lli,lli> m;
    bool is_yes[n];
    REP(i,0,q) {
        m[a[i]]++;
    }
    REPE(i,1,n) {
        if (k - q + m[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	s.at(k-1)+=('a'-'A');
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n ,m;
long long t[100010];
long long p;
struct p{
	long long x,y;
}he[100010]; 
int main(){
	cin>>n;
	for(int i=1; i<=n;i++){
		cin>>t[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>he[i].x>>he[i].y;
	}
	for(int i=1;i<=m;i++){
		long long sum=0;
		for(int j=0;j<he[i].x;j++){
			sum+=t[j];
		}
		sum+=he[i].y;
		for(int j=he[i].x+1;j<=n;j++){
			sum+=t[j];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//C - Attack Survival
//2019/9/20

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int num,k_point,quiz,ans_per,*people,i;
    scanf("%d %d %d",&num,&k_point,&quiz);
    people=malloc(sizeof(int)*num);
    for (i=0;i<num;i++) {
        people[i]=0;
    }
    for (i=0;i<quiz;i++) {
        scanf("%d",&ans_per);
        people[ans_per-1]++;
    }
    for (i=0;i<num;i++) {
        if (k_point-quiz+people[i]>0) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    free(people);
    return 0;
}

Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++	) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int a = p[n/2];
		int b = p[n/2-1];
		if (a == b) {
			System.out.println(0);
		} else {
			System.out.println(a-b);
		}
	}
}

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

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

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

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

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

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

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

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

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

#define ll long long

void solve(){
	int n = 5;
	for(int i = 1; i<=n; i++){
		int a;cin>>a;
		if(a == 0){
			cout<<i<<endl;
			return;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3652
(* mod *)
(*
let internal moda = 1

let internal ( +% ) x y = 
  ((x + y) % moda)
let internal ( *% ) x y = 
  ((x * y) % moda)

let internal ( ^% ) x y = 
  let rec loop x y result =
    match y with
    | 0L -> result
    | _ -> 
      loop x (y - 1L) ((result * x) % moda)
  loop x y 1L
*)

(* Standard Input *)
let readSplit elementFun=
  stdin.ReadLine().Split()
  |> Array.map elementFun

let read elementFun =
  stdin.ReadLine() |> elementFun

let readMap H =
  [|for i in 1..H -> stdin.ReadLine()|]
  |> Array.map(fun line ->
    line.ToCharArray()
  )
  |> array2D

(* Main *)
let S = (read id).ToCharArray()
if S.[2] = S.[3] && S.[4] = S.[5] then "Yes" else "No"
|> printfn "%s"


Measured memory_bytes: 11984
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        int num = readInt() * 100 + readInt() * 10 + readInt();
        out.println(num % 4 == 0 ? "YES" : "NO");
    }


}

Measured memory_bytes: 23248
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int n,m;
ll ans=0; 
int main()
{
	cin>>n>>m;
	ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $N);
$line = array_map('intVal', explode(' ', trim(fgets(STDIN))));

rsort($line);

$other_sum = 0;
for ($i = 1; $i <= $N-1; ++$i) {
    $other_sum += $line[$i];
}

if ($line[0] < $other_sum) {
    echo 'Yes';
} else {
    echo 'No';
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll dp[60][30][2];
bool is_pal[60][30][30];

string s[60];
int c[60];

struct st{
	ll a;int b;ll c,d;
};
bool operator<(st a,st b){
	return a.d>b.d;
}
int main(){
	int n;cin>>n;
	rep(i,n)cin>>s[i]>>c[i];
	memset(dp,0x3f,sizeof(dp));
	priority_queue<st>que;
	rep(i,n)rep(j,2){
		dp[i][s[i].size()][j]=c[i];
		que.push({i,(int)s[i].size(),j,c[i]});
	}
	rep(i,n){
		for(int l=0;l<=s[i].size();l++)for(int r=l;r<=s[i].size();r++){
			is_pal[i][l][r]=true;
			for(int j=l;j<r;j++){
				if(s[i][j]!=s[i][r-(j-l)-1])is_pal[i][l][r]=false;
			}
		}
	}
	while(!que.empty()){
		st p=que.top();que.pop();
		if(dp[p.a][p.b][p.c]!=p.d)continue;
		if(p.c==0){
			rep(i,n){
				bool ok=true;
				rep(j,min(p.b,(int)s[i].size())){
					if(s[p.a][s[p.a].size()-p.b+j]!=s[i][s[i].size()-j-1])ok=false;
				}
				if(!ok)continue;
				if(p.b<s[i].size()){
					if(dp[i][s[i].size()-p.b][!p.c]>p.d+c[i]){
						dp[i][s[i].size()-p.b][!p.c]=p.d+c[i];
						que.push({i,s[i].size()-p.b,!p.c,p.d+c[i]});
					}
				}
				else{
					if(dp[p.a][p.b-s[i].size()][p.c]>p.d+c[i]){
						dp[p.a][p.b-s[i].size()][p.c]=p.d+c[i];
						que.push({p.a,p.b-s[i].size(),p.c,p.d+c[i]});
					}
				}
			}
		}
		else{
			rep(i,n){
				bool ok=true;
				rep(j,min(p.b,(int)s[i].size())){
					if(s[p.a][p.b-j-1]!=s[i][j])ok=false;
				}
				if(!ok)continue;
				if(p.b<s[i].size()){
					if(dp[i][s[i].size()-p.b][!p.c]>p.d+c[i]){
						dp[i][s[i].size()-p.b][!p.c]=p.d+c[i];
						que.push({i,s[i].size()-p.b,!p.c,p.d+c[i]});
					}
				}
				else{
					if(dp[p.a][p.b-s[i].size()][p.c]>p.d+c[i]){
						dp[p.a][p.b-s[i].size()][p.c]=p.d+c[i];
						que.push({p.a,p.b-s[i].size(),p.c,p.d+c[i]});
					}
				}
			}
		}
	}
	ll Min=INFL;
	rep(i,n)rep(j,s[i].size()+1)rep(k,2){
		if(k==0&&is_pal[i][s[i].size()-j][s[i].size()])Min=min(Min,dp[i][j][k]);
		if(k==1&&is_pal[i][0][j])Min=min(Min,dp[i][j][k]);
	}
	if(Min==INFL)puts("-1");
	else cout<<Min<<endl;
}
/*
4
abac 5
cbac 6
cab 7
cacba 8
*/

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
int main(){
    ll n;cin >> n;
    vector<vl> p(n,vl(2));
    vector<ll> zzz(n);
    rep(i,n)cin >> p[i][0]>> p[i][1] >> zzz[i] ;
    vector<ll> ans(n+1,INF);
    vvl dpx(n,vl(1<<n)),dpy(n,vl(1<<n));
    rep(bit,1<<n){
        rep(i,n){
            ll ret=abs(p[i][0]);
            ll rey=abs(p[i][1]);
            rep(j,n){
                if(bit&(1<<j)){
                    chmin(ret,abs(p[i][0]-p[j][0]));
                    chmin(rey,abs(p[i][1]-p[j][1]));
                }
            }
            dpx[i][bit]=ret*zzz[i];
            dpy[i][bit]=rey*zzz[i];
        }
    }
    rep(bit,1<<n){
        ll t=__builtin_popcount(bit);
        vector<ll> use;
        rep(i,n){
            if(bit&(1<<i))use.pb(i);
        }
        rep(cit,1<<t){
            ll ret=0;
            ll x=0,y=0;
            rep(i,t){
                if(cit&(1<<i)){
                    x+=(1<<use[i]);
                }
                else{
                    y+=(1<<use[i]);
                }
            }
            rep(i,n){
                ret+=min(dpx[i][x],dpy[i][y]);
            }
            chmin(ans[t],ret);
        }
    }
    rep(i,n+1){
        cout << ans[i] <<endl;
    }
} 

Measured memory_bytes: 11260
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    int N;
    int ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A[i];
        //dp[A[i]] = true;
    }
    sort(A.begin(), A.end());
    vector<bool> dp(A[N-1]+1, false);
    for (int i=0; i<N; i++){
        dp[A[i]] = true;
    }
    for (int i=0; i<N; i++){
        if(dp[A[i]]){
            int j = 2;
            while (A[i] * j <= A[N-1]){
                dp[A[i]*j] = false;
                j += 1;
            }
        }
    }
    int a = -1;
    for (int i=0; i<N; i++){
        if (a != A[i]){
            a = A[i];
        }else{
            dp[A[i]] = false;
        }
    }
    ans = count(dp.begin(), dp.end(), true);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4296
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = sorted([I() for _ in range(5)])
    r = (n+a[0]-1) // a[0]

    return r + 4

print(main())




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

#define mp make_pair
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> ii;

const int N = 1e5 + 10;
const int INF = 1e9 + 10;

int n;
ii a[N];
ll ans[N];

int main(){
    if (fopen("inp.txt", "r")){
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    FOR(i, 1, n){
        cin >> a[i].X;
        a[i].Y = i;
    }
    sort(a + 1, a + 1 + n, greater<ii>());

    ll cur = INF;
    ll minPos = n + 1;
    FOR(l, 1, n){
        int r = l;
        ans[minPos] += (cur - a[l].X) * (ll) (l - 1);
        cur = a[l].X;
        while (a[l].X == a[r].X && r <= n){
            minPos = min(a[r].Y, minPos);
            r++;
        }
        l = r - 1;
    }
    if (cur > 0)
        ans[1] += cur * (ll) n;

    FOR(i, 1, n)
        cout << ans[i] << endl;

    return 0;
}



Measured memory_bytes: 3456
# AOJ 0053: Sum of Prime Numbers
# Python3 2018.6.15 bal4u

MAX = 104729  # 10000th prime
SQRT = 323    # sqrt(MAX)

prime = [True for i in range(MAX+2)]
def sieve():
	for i in range(2, MAX, 2):
		prime[i] = False
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False

sieve()
sum = [0 for i in range(MAX+2)]
j = 2
sum[1] = 2;
for i in range(3, MAX+1, 2):
	if prime[i] is True:
		sum[j] = sum[j-1] + i
		j += 1

while True:
	n = int(input())
	if n == 0: break
	print(sum[n])


Measured memory_bytes: 7428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 998244353;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

vector<vector<ll>> g;

mint dfs(ll v, ll p = -1) {
    mint ans = 1;
    for(auto u : g[v]) {
        if (u == p) continue;
        ans *= dfs(u, v);
    }
    return ans + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xd(n);
    rep(i, n) cin >> xd[i].first >> xd[i].second;
    sort(all(xd));
    set<pair<ll, ll>> s;
    g.resize(n);
    rrep(i, n) {
        ll x = xd[i].first, d = xd[i].second;
        while((sz(s) > 0) && (s.begin()->first < (x + d))) {
            g[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.insert(make_pair(x, i));
    }
    mint ans = 1;
    for(auto x : s) {
        ans *= dfs(x.second);
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 26880
program aaa
implicit none
integer(8) :: i,j,k,n
double precision :: beauty,m,d
read(*,*) n,m,d

if(d == 0 ) then
	beauty = (m-1)/n
else
	beauty = 2*(n-d)/(n**2) *(m-1)
endif
write(*,*) beauty

end program

Measured memory_bytes: 768
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn
    replicateM_ n $ do
        [n, d] <- map read.words <$> getLine :: IO [Int]
        print $ solve n d

mask :: Int
mask = 0x7f

solve :: Int -> Int -> Int
solve n d = (n - 1) * mask + bool d (xor d mask)(even n)

Measured memory_bytes: 1020
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String [] args){
     Scanner sc=new Scanner(System.in);
     int n=sc.nextInt();
     int k=sc.nextInt();
     long [] arr=new long[n];
     
     for(int i=0;i<n;i++)arr[i]=sc.nextLong();

     long [] dp=new long[n];

     dp[0]=0;
    
     for(int i=1;i<n;i++){

       long min=Integer.MAX_VALUE;

       for(int j=i-1;j>=i-k && j>=0;j--){

         min=Math.min(min,dp[j]+Math.abs(arr[i]-arr[j]));

       }
       dp[i]=min;
     }

     System.out.println(dp[n-1]);

    }
   }
 

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  string s, t;
  cin >> s;
  cin >> t;
  int mn = 1001001001;
  int sl = s.size();
  int tl = t.size();
  for (int i = 0; i < sl-tl+1; ++i) {
    int x = 0;
    for (int j = 0; j < tl; ++j) {
      if (s[i+j] != t[j]) ++x;
    }
    mn = min(mn, x);
  }
  cout << mn << endl;
}

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


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;
const long long MOD = 1000000007;
map<int, int> prime;

void prime_fuctor(int N)
{
    for (int i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            prime[i]++;
            N /= i;
        }
    }
    if (N != 1) prime[N]++;
}
int main()
{
    int N;
    cin >> N;
    repd(i, 2, N + 1) {
        prime_fuctor(i);
    }

    ll ans = 0;
    for (auto itr = prime.begin(); itr != prime.end(); itr++) {
        if (ans == 0) {
            ans = (itr->second + 1);
        }
        else {
            ans *= (itr->second + 1);
        }
        ans %= MOD;
    }

    if (N == 1) ans = 1;
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> words = new HashSet<>();
        
        boolean isOK = true;
        char last = '0';
        for(int i = 0; i < N; i++){
            String W = sc.next();
            
            if(words.contains(W)){
                isOK = false;
                break;
            }
            
            words.add(W);
            
            if( i > 0 && last != W.charAt(0) ){
                isOK = false;
                break;
            }
            
            last = W.charAt(W.length()-1);
        }

        System.out.println( isOK ? "Yes" : "No" );
    }
}


Measured memory_bytes: 23252