akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
typedef long long ll;
ll n;
string s;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  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;
  }
};
mint p[100010];
void make_p(){
  p[0].x=p[1].x=1;
  for(ll i=2;i<=n;++i){
    p[i] = p[i-1]*i;
  }
}
int main()
{
  
  cin >> n;
  cin >> s;

  make_p();
  ll ss = s.size();
  mint res;
  res.x=1;
  ll h=0;
  rep(i,ss){
    if(s[i]=='B'){
      if(h%2==1){
	res *= h;
	h -= 1;
      }
      else h++;
    }
    else{
      if(h%2==0){
	res *= h;
	h -= 1;
      }
      else h++;
    }
  }
  if(h!=0) cout << 0 << "\n";
  else{
    res *= p[n];
    cout << res.x << "\n";
  }
  return 0;
}


Measured memory_bytes: 1408
n,x=map(int,input().split());a=list(map(int,input().split()));a.sort();ans=0
for i in range(n):
  if a[i]>x:break
  else:
    ans+=1
    x-=a[i]
    if i==n-1 and x!=0:ans-=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	string c;
	while(n)
	{
		c+=n%k;
		n=n/k;
	}
	int num=c.size();
	cout<<num;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    set<char> ans;
    rep(i, (int)s.size()){
        if(ans.find(s[i]) == ans.end()) ans.insert(s[i]);
        else{
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

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

int main()
{
  int X,Y;

  cin >> X >> Y ;
  
  if(X * 2 > Y){
  cout << "No" << endl;
  }else if(X * 4 < Y){
  cout << "No" << endl;
  }else if(Y % 2 == 1){
  cout << "No" << endl;
  }else{
  cout << "Yes" << endl;
  }
 
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
// #define F first
// #define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl //　少数の精度を高くする出力

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int a,b;
    a = A/K;
    b = B/K;
    if (b-a > 0) cout << "OK" << endl;
    else if(A%K==0) cout << "OK" << endl;
    else if (B%K==0) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3632
//
//  main.c
//  Judge Status Summary
//
//  Created by k19031kk on 2020/07/05.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    int scan;
    scanf("%d",&scan);
    
    int ac_count=0,wa_count=0,tle_count=0,re_count=0;
    
    char test[100000];
    
    for(int i=0;i<scan;i++){
        scanf("%s",&test[i]);
        
        if(strcmp(&test[i], "AC") == 0){
            ac_count++;
        }
        
        if(strcmp(&test[i], "WA") == 0){
            wa_count++;
        }
        
        if(strcmp(&test[i], "TLE") == 0){
            tle_count++;
        }
        
        if(strcmp(&test[i], "RE") == 0){
            re_count++;
        }
    }
    
    printf("AC x %d\n",ac_count);
    printf("WA x %d\n",wa_count);
    printf("TLE x %d\n",tle_count);
    printf("RE x %d\n",re_count);
    
    return 0;
}


Measured memory_bytes: 1824
from math import gcd

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
a, b, k = map(int, input().split())
x = gcd(a, b)
l = make_divisors(x)
print(l[-k])

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int ans=T.size();
    for(int i=0;i<=S.size()-T.size();i++){
      int diff=0;
        for(int j=0;j<T.size();j++){
          if(T[j]!=S[i+j])
            diff++;
        }
      ans=min(ans,diff);
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 300000
#define maxn 1000000000
using namespace std;
int tt;
int a[N];
struct ss{int i;long long x;}sum[N];
bool cmp(ss s1,ss s2){if(s1.x!=s2.x)return s1.x<s2.x;return s1.i<s2.i;}
int lbt(int x){return x &(-x);}
long long s[N];
int n,k;
long long ask(int x)
{
    long long ret=0;
   for(int i=x;i;i-=lbt(i))ret+=s[i];
    return ret;
}
void add(int x)
{
    for(int i=x;i<=n;i+=lbt(i))s[i]++;
}
int main()
{
    scanf("%d%d",&n,&k);
    sum[0].x=0;
    
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i]-=k;
        sum[i].x=sum[i-1].x+a[i];
        sum[i].i=i+1;
    }
    n++;
    sum[n].i=1;sum[n].x=0;
    sort(sum+1,sum+n+1,cmp);
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=ask(sum[i].i);
        add(sum[i].i);
    }
    cout<<ans;
}
//a0,a1,a2,a3,a4,a5,a6
//f(a-b)
//(a-b)^(c-b)
/*
 1 2 3 4 5 0 P (p+1,p+q)  p                q
0 1 2 3 4 5 6 1 1 1 1 1 0 0 0 0 0 0 1  1 1 1 1
1 2 3 4 5 6 7 8
...
3 0
1 2
4 5
 */

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
//constexpr int dy[]={0, 1, 0, -1};
//constexpr int dx[]={1, 0, -1, 0};

// 8近傍
//constexpr int dy[]={0,0,1,-1,1,1,-1,-1};
//constexpr int dx[]={1,-1,0,0,1,-1,1,-1};

//constexpr ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
  ll tmp = 1;
  a %= mod;
  if (b > 0) {
    tmp = pow_mod(a, b / 2, mod);
    if (b % 2)
      tmp = (((tmp * tmp) % mod) * a) % mod;
    else
      tmp = (tmp * tmp) % mod;
  }
  return tmp;
}

void solve() {
  int n;
  cin >> n;
  vector<int> t(n);
  for(int i = 0; i < n; i++) cin >> t[i];
  int m;
  cin >> m;
  vector<int> p(m),x(m);
  for(int i = 0; i < m; i++) cin >> p[i] >> x[i];

  for(int i = 0; i < m; i++){
    int cnt = 0;
    for(int j = 0; j < n; j++){
      cnt += (j == p[i] - 1 ? x[i] : t[j]);
    }
    cout << cnt << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef vector<set<int>> Graph;

// false -> "contains cycle"
bool dfs(int now, int start, const Graph &G, vector<bool> &visited) {
    visited[now] = true;
    for (auto nxt : G[now]) {
        if (nxt == start) return false;
        if (!visited[nxt] && !dfs(nxt, start, G, visited)) return false;
    }
    return true;
}

bool isDAG(const Graph &G) {
    int n = G.size();
    rep(i, n) {
        vector<bool> visited(n);
        if (!dfs(i, i, G, visited)) return false;
    }
    return true;
}

bool solve(int n) {
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    Graph G(26);
    rep(l, 10) {
        rep(i, n) {
            rep2(j, i + 1, n) {
                if (s[i].size() >= l && s[j].size() >= l && s[i].substr(0, l) == s[j].substr(0, l)) {
                    if (s[i].size() < l + 1) continue;
                    if (s[j].size() < l + 1) return false;
                    if (s[i][l] == s[j][l]) continue;
                    G[s[i][l] - 'a'].insert(s[j][l] - 'a');
                }
            }
        }
    }

    return isDAG(G);
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        cout << (solve(n) ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    if (N * A >= B)
    {
        cout << B << endl;
    }
    else
    {
        cout << N * A << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;


int main(){
  int n;
  int k;
  int sum=0;
  int max;
  int min;
  while(cin >> n){
    sum = 0;
    if(n == 0){
      break;
    }
    for(int i = 0;i < n;i++){
      cin >> k;
      if(i==0){
        min = k;
        max = k;
      }else if(min > k){
        min = k;
      }else if(max < k){
        max = k;
      }
      sum += k;
    }
    sum = (sum - min - max)/(n-2);
    cout << sum << endl;
  }
}

Measured memory_bytes: 2968
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
#define rep(i,n) for(int i = 0;i<(int)(n);i++)

int main()
{
    string S;
    cin>>S;
    vector<string> W = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    vector<string>::iterator itr;
    itr = find(W.begin(),W.end(),S);
    const int index = distance(W.begin(),itr);
    cout<<7-index<<endl;
    
}

Measured memory_bytes: 256
//D - Alter Altar
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(LL i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;
const int MAXN=2e5+10;

int Red,White,Loc[MAXN],Total,Ans=INF;
char Opt;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int main() {
    //File();
    scanf("%d",&Total);
    Opt=getchar();
    FOR(i,1,Total) {
		Opt=getchar();	
        if(Opt=='W') Loc[i]=0,White++;
        else Loc[i]=1,Red++;
    }
    int New=0,Res=0;
    FOR(i,1,Total) if(Loc[i]==1 && i>Red)  New++;
    printf("%d\n",New);
    //fclose(stdin); fclose(stdout);
   // system("pause");
    return 0;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define inf (1ll<<60)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define MEMSET(a) memset(a,0,sizeof(a))
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
using ll = long long;

signed main(){
    set<int> set;
    int q;
    cin>>q;
    while(q--){
        int y,x;
        cin>>y>>x;
        if(y==0){
            set.insert(x);
            cout<<set.size()<<endl;
        }
        else if(y==1){
            cout<<(set.find(x)!=set.end())<<endl;
        }
        else if(y==2){
            set.erase(x);
        }
        else{
            int z;
            cin>>z;
            for(auto it=set.lower_bound(x);it!=set.upper_bound(z);it++){
                cout<<*it<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12460
import java.util.*;

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

    int N = sc.nextInt();
    int[] a = new int[N + 1];

    for (int i =1; i < N+1; i++) {
      a[i] = sc.nextInt();
    }

    boolean b = true;
    int sq = 0;
    int cr = 1;

    while (b) {
      sq++;
      cr = a[cr];

      if (cr == 2) b = false;
      if (sq == N) {
        sq = 0;
        b = false;
      }
    }

    System.out.println(sq == 0 ? -1 : sq);

  }

}


Measured memory_bytes: 51148
#include <iostream>
using namespace std;
int main(){
int kazu,bangou;
cin >> kazu >> bangou;
  string str;
cin >> str;
if (str.at(bangou-1)=='A'){
str.at(bangou-1)='a';
}
if (str.at(bangou-1)=='B'){
str.at(bangou-1)='b';
}
if (str.at(bangou-1)=='C'){
str.at(bangou-1)='c';
}
cout <<str << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;
int n;
double r;
int t[100];
vector<int> x,y;
int main(){
  while(1){
    cin>>r>>n;
    if(r==0&&n==0)break;
    for(int i=0;i<100;i++)t[i]=0;
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      a+=50,b+=50;
      for(int j=a;j<b;j++)t[j]=max(t[j],c);
    }
    x.clear(),y.clear();
    for(int i=0;i<50;i++){
      x.push_back(50-i-1);
      y.push_back(t[i]);
    }
    for(int i=50;i<100;i++){
      x.push_back(i-50);
      y.push_back(t[i]);
    }
    double ans=(1<<28);
    for(int i=0;i<(int)x.size();i++){
      if(r-0.00000001<x[i])continue;
      double d=y[i]-sqrt(r*r-x[i]*x[i]);
      ans=min(d,ans);
    }
    printf("%.8f\n",ans+r);
  }
  return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using Wbool = std::vector<Vbool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const std::vector<std::pair<int, int>> DXDY = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
constexpr char BR = '\n';

#define DEBUG(x) std::cerr << #x << " = " << x << '\n';
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
#define RSORT(A) std::sort((A).rbegin(), (A).rend())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class S, class T> inline void chmax(S &a, T b){if(a < b) a = b;}
template <class S, class T> inline void chmin(S &a, T b){if(a > b) a = b;}
template <class T> inline void reverseSORT(Vec<T> &Array){
  std::sort(Array.begin(), Array.end(), std::greater<T>());
}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1LL << k;}
inline void putsDouble(double d){printf("%.16lf\n", d);}
inline int toInt(const string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res;
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






int main(void){
    int n; scanf("%d", &n);
    Vec<pii> A(n);
    REP(i, n){
        int a; scanf("%d", &a);
        A[i] = {a, i};
    }
    SORT(A);
    int cnt = 0;
    REP(i, n) if( (A[i].second - i) % 2 != 0) cnt++;
    printf("%d\n", cnt / 2);
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int main() {
  int a, b, n, s, t;
  while (scanf("%d %d %d", &a, &b, &n) == 3) {
    s = 0;
    t = a % b;
    for (int i=0; i<n; i++) {
      t *= 10;
      s += t / b;
      t = t % b;
    }
    printf("%d\n", s);
  }
  return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int tag = t.length();
  for (int i = 0; i < s.length()-t.length()+1; i++) {
    int k = t.length();
    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] == t[j]) k--;
    }
    if (k < tag) tag = k;
  }
  cout << tag;
  system("pasue");
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vi x(n);
    vi l(n);
    vector<pii> vp;
    FOR(i,0,n){
        cin>>x[i]>>l[i];
        int ll=x[i]-l[i];
        int rr=x[i]+l[i];
        vp.emplace_back(rr,ll);
    }
    sort(vp.begin(),vp.end());
    int nw=-mod,ans=0;
    FOR(i,0,n){
        auto pr=vp[i];
        if(pr.ND>=nw){
            nw=pr.ST;
            ans++;
        }
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 2168
import std.stdio,std.string,std.conv;

int main()
{
	int a[10001];
	a[0] = 0;
	a[1] = 2;
	foreach(i;2..10001)
	{
		a[i] = a[i-1] + i;
	}

	string s;
	while((s = readln.chomp).length != 0)
	{
		int n = s.to!int;
		a[n].writeln;
	}
	return 0;
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  string s;
  string t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0, N = s.size(); i < N; i++) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}


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

int main()
{
	int n, m;
	int c[20];
	int t[50001];

	cin >> n >> m;

	for (int i = 0; i < m; i++)
		cin >> c[i];

	for (int i = 1; i <= n; i++)
		t[i] = 500001;
	t[0] = 0;

	for (int j = 0; j < m; j++)
		for (int i = 0; i + c[j] <= n; i++)
			t[i + c[j]] = min(t[i + c[j]], t[i] + 1);

	cout << t[n] << endl;

	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    REP(i, 0, N) {
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        ans += s.size() - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int wa[100010];
bool ac[100010];
signed main(){
  int n,m;cin>>n>>m;
  rep(i,m){
    int x;cin>>x;x--;
    string s;cin>>s;
    if(!ac[x]){
      if(s=="WA")wa[x]++;
      else ac[x]=true;
    }
  }
    int WA=0,AC=0;
    rep(i,n){
      if(ac[i])AC++,WA+=wa[i];
    }
    cout<<AC<<" "<<WA<<endl;
  
  return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        int ans=0;
        mll m;
        rep(i,n){
            cin>>a[i];
            m[i+a[i]]++;
            ans+=m[i-a[i]];
        }
        
        cout<<ans<<endl;
    }
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

typedef pair<int,int> P;

int main2() {
  int N = nextInt();
  vector<P> ps(N);
  REP(i, N) {
    int x = nextInt();
    int y = nextInt();
    ps[i] = {x, y};
  }
  set<P> st(ALL(ps));

  int ans = 0;
  REP(i, N) REP(j, N) if (i != j) {
    int dx = ps[i].first - ps[j].first;
    int dy = ps[i].second - ps[j].second;

    int g = 0;
    REP(k, N) {
      P nxt = { ps[k].first + dx, ps[k].second + dy };
      if (st.count(nxt)) g++;
    }
    chmax(ans, g);
  }
  cout << N - ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int l, r, d;
    cin >> l >> r >> d;

    cout << r / d - (l - 1) / d << "\n";

    return 0;
}


Measured memory_bytes: 3604
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e5+5;
int n,k,m;
ll ans=1e18,sum;
ll dpl[maxn],dpr[maxn],a[maxn],b[maxn];
ll l[maxn],r[maxn];
int q[maxn],maxi[maxn<<2];
int find(int num){
	return lower_bound(q+1,q+m+1,num)-q;
}
void M(int x,int l,int r,int ll,int rr,int num){
	if(l==ll&&r==rr){
		maxi[x]=max(maxi[x],num);
		return;
	}
	if(rr<=mid)M(ls,l,mid,ll,rr,num);
	else if(ll>mid)M(rs,mid+1,r,ll,rr,num);
	else M(ls,l,mid,ll,mid,num),M(rs,mid+1,r,mid+1,rr,num);
}
int Q(int x,int l,int r,int pos){
	if(l==r)return maxi[x];
	if(pos<=mid)return max(Q(ls,l,mid,pos),maxi[x]);
	return max(Q(rs,mid+1,r,pos),maxi[x]);
}
int main(){
	read(n);read(k);
	rep(i,1,n){
		read(a[i]),read(b[i]);
		if(b[i]==1&&2*a[i]>=k+2)return puts("-1"),0;
		sum+=a[i];
		a[i]=(a[i]+a[i-1])%k;
		if(b[i]==2)continue;
		l[i]=((-2*a[i])%k+k)%k;
		r[i]=((-2*a[i-1])%k+k)%k;
		q[++m]=l[i];q[++m]=r[i];
	}
	sort(q+1,q+m+1);m=unique(q+1,q+m+1)-q-1;
	rep(i,1,n)if(b[i]==1){
		int nowl=find(l[i]),nowr=find(r[i]),x;
		x=Q(1,1,m,nowl);
		dpl[i]=!x?0:min(dpl[x]+(l[i]-l[x]+k)%k,dpr[x]+(l[i]-r[x]+k)%k);
		x=Q(1,1,m,nowr);
		dpr[i]=!x?0:min(dpl[x]+(r[i]-l[x]+k)%k,dpr[x]+(r[i]-r[x]+k)%k);
		if(nowl<nowr){
			if(nowl<nowr-1)M(1,1,m,nowl+1,nowr-1,i);
		}else{
			if(nowl<m)M(1,1,m,nowl+1,m,i);
			if(nowr>1)M(1,1,m,1,nowr-1,i);
		}
	}
	memset(maxi,0,sizeof maxi);
	per(i,n,1)if(b[i]==1){
		int nowl=find(l[i]),nowr=find(r[i]);
		if(!Q(1,1,m,nowl))ans=min(ans,dpl[i]);
		if(!Q(1,1,m,nowr))ans=min(ans,dpr[i]);
		if(nowl<nowr){
			if(nowl<nowr-1)M(1,1,m,nowl+1,nowr-1,1);
		}else{
			if(nowl<m)M(1,1,m,nowl+1,m,1);
			if(nowr>1)M(1,1,m,1,nowr-1,1);
		}
	}
	cout<<ans+2*sum<<endl;
	return 0;
}

Measured memory_bytes: 12928
'use strict';

function main(stdin) {
  const input = stdin.split(' ').map(v => parseInt(v, 10));
  const N = input[0];
  let ans = 0;

  for (let i = 1; i <= N; ++i) {
    let str = i.toString(10);
    if (str.length % 2 === 1) {
      ++ans;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
s = input()
n = len(s)
wc = 0
lc = 0
gc = 0
pc = 0
for i in range(n):
    if s[i] == 'g':
        if pc+1 <= gc:
            wc += 1
            pc += 1
        else:
            gc += 1
    else:
        if pc+1 <= gc:
            pc += 1
        else:
            lc += 1
            gc += 1
print(wc-lc)


Measured memory_bytes: 3316
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();
		int W = sc.nextInt();

		if(S <= W) {
			System.out.println("unsafe");
		}
		else {
			System.out.println("safe");
		}


	}
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

using namespace std;

// input
int n,m,r;
vector<int> rs;

int d[200][200];

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

    queue<int> que;

    int a,b,c;

    cin >> n >> m >> r;

    for(int i = 0;i < r;i++){
        int junro;
        cin >> junro;
        junro--;
        rs.push_back(junro);
    }

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

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(i==j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }


    for(int i = 0;i < m;i++){
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k = 0;k < n;k++){
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }


    int ans = INF;

    do{
        int dist = 0;
        for(int i = 1;i < r;i++){
            int from = rs[i-1],to = rs[i];
            dist += d[from][to];
        }
        ans = min(ans,dist);
    }while ( next_permutation(rs.begin(),rs.end()) );

    cout << ans << "\n";
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

string tobin(ll n){
	string out = "";
	ll len = 1;
	ll div = 1;
	while (1){
		if (n / div < 2){
			break;
		}
		len++;
		div *= 2;
	}
	for (ll i = 0; i < len; i++){
		if (n / div >= 1){
			out = out + "1";
			n -= div;
		}
		else{
			out = out + "0";
		}
		div /= 2;
	}
	return out;
}

string multiStr(string a, ll b){
	string result = "";
	for (ll i = 0; i < b; i++){
		result += a;
	}
	return result;
}

int main(){
	ll N;
	vll A;
	ll i, j;
	cin >> N;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	ll le = 0;
	ll ri = 0;
	ll ans = 0;
	vi B(20, 0);
	ll p, q;
	string bia = tobin(A[0]);
	bia = multiStr("0", 20 - bia.length()) + bia;
	//bia = "0"*(20 - bia.length()) + bia;
	for (q = 0; q < 20; q++){
		if (bia[q] == '1'){
			B[q] = 1;
		}
	}
	for (le; le < N; le++){
		ri = max(ri, le);
		bia = tobin(A[le]);
		bia = multiStr("0", 20 - bia.length()) + bia;
		for (q = 0; q < 20; q++){
			if (bia[q] == '1'){
				B[q] = 1;
			}
		}
		for (ll p = ri + 1; p < N; p++){
			//ri = p - 1;
			vi tmpB(20, 0);
			bia = tobin(A[p]);
			bia = multiStr("0", 20 - bia.length()) + bia;
			bool flg = false;
			for (q = 0; q < 20; q++) {
				if (bia[q] == '1'){
					tmpB[q] = 1;
					if (B[q] == 1){
						flg = true;
					}
				}
			}
			if (flg){
				ri = p - 1;
				break;
			}
			for (q = 0; q < 20; q++) {
				B[q] += tmpB[q];
			}
			if (p == N - 1){
				ri = p;
			}
		}
		ans += ri - le + 1;
		//if (ri == N - 1){
		//	break;
		//}
		bia = tobin(A[le]);
		bia = multiStr("0", 20 - bia.length()) + bia;
		for (q = 0; q < 20; q++){
			if (bia[q] == '1'){
				B[q]--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	double N, T, A; cin >> N >> T >> A;
	vector<pair<double, int>> d;
	rep(i, N) {
		int H; cin >> H;
		double a = T - H * 0.006;
		d.push_back(make_pair(abs(A - a), i+1));
	}
	sort(all(d));
	cout << d[0].second << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define all(v) v.begin(),v.end()

int32_t main() {
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    {
	        cin>>a[i][j];
	    }
	}
	for(int i=1;i<n;i++)
	{
	    a[i][0] += max(a[i-1][1],a[i-1][2]);
	    a[i][1] += max(a[i-1][2],a[i-1][0]);
	    a[i][2] += max(a[i-1][0],a[i-1][1]);
	}
	cout<<max({a[n-1][0],a[n-1][1],a[n-1][2]});
	return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<vector<int>> t(n, vector<int>(n, -1));
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    while (x--) {
      int a, b;
      cin >> a >> b;
      t[i][a - 1] = b;
    }
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << n); ++mask) {
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (((mask >> i) & 1) == 0) {
        continue;
      }
      for (int j = 0; j < n; ++j) {
        if (t[i][j] == -1) {
          continue;
        } else if (t[i][j] != ((mask >> j) & 1)) {
          ok = false;
        }
      }
    }
    if (ok) {
      ans = max(ans, __builtin_popcount(mask));
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
import bisect
N=int(input())
As=list(map(int,input().split()))
Bs=list(map(int,input().split()))
Cs=list(map(int,input().split()))
As.sort()
Cs.sort()
pyout=0

for i in range(N):
    num1=bisect.bisect_left(As,Bs[i])
    num2=N-bisect.bisect_right(Cs,Bs[i])
    pyout+=num2*num1
print(pyout)

Measured memory_bytes: 22516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
using Graf_bool=vector<vector<bool>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    rep(i,n)cin >> t[i+1] >> x[i+1] >> y[i+1];
    rep(i,n){
        int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        int timeDist=t[i+1]-t[i];
        if(timeDist<dist){
            No;
            return 0;
        }else{
            if(timeDist%2!=dist%2){
                No;return 0;
            }
        }
    }
    Yes;
}

Measured memory_bytes: 4240
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int l = sc.nextInt();
		int r = sc.nextInt();
		int p = 2019;
		
		boolean flag1 = false;
		if(r - l >= 2019)
			flag1 = true;
		
		int L = l % p;
		int R = r % p;
		if(R - L <= 0)
			flag1 = true;
		
		if(flag1)
			System.out.println(0);
		else {
			long min = 2019;
			for(int i = l ; i < r; i++) {
				for(int j = i + 1; j <= r; j++) {
					long lr =((long)i * j) % p;
					min = Math.min(min, lr);
				}		
			}
		System.out.println(min);
		
		}
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#include<limits.h>
#include<stdbool.h>
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000　+　7  //10億　= 10^9になってる
#define juu 100000 //10万 10e5
#define hyaku 1000000 //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000 //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300]; 
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num){
    int i = 0,kosuu=0;
    while(*(factor+i) != 0){
        while(num % *(factor+i)==0){
            num /= *(factor+i);
            memory[*(factor+i)] +=1;
        }
        if(num==1)break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number){    
    ll tmp=0;
    int flag=0;
    *factor = 2;
    for(int i=3;i <= number;i++){
        flag=0;
        for(int j=0;j <= tmp ;j++){
            if(i % (*(factor+j)) == 0){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        tmp += 1;
        *(factor+tmp) = i;
    }
        return tmp+2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long*a,const long long *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n,int r){
  ll val=1;
  int i;
  if(r==0)return 1;
  for(i=0;i<n-r;i++){
		val *= (n-i);
		val /= (i+1);
	}
  return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n,int r){
  ll val=1;
  int i;
  for(i=0;i<r;i++){
    val *= (n-i);
  }
  return val;
}
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/
int main(){
    ll array[1000];
    ll N,K,i,j;
    scanf("%lld",&N);
    printf("%lld",N*N);
    

    return 0;
}


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

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

    int maxs = 0;
    int x;
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i] == 'I'){
            x++;
            maxs = max(maxs, x);
        }else if( S[i] == 'D'){
            x--;
        }
    }
    cout << maxs << endl;
}

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

	#define mainspring cout<<"mainspring\n";
	#define barrel cout<<"barrel\n";
	#define escapement cout<<"escapement\n";

	#define pb push_back
	#define eb emplace_back
	#define all(v) (v).begin(), (v).end() 
	#define sz(v) (int)((v).size())
	#define fs first
	#define sd second
	#define tik(i,a,b) for(int i = a; i < b; i++)
	#define tok(i,a,b) for(int i = a; i >= b; i--)
	#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

	typedef long long ll;
	typedef unsigned long long ull;

	#define int ll 

	typedef pair < int, int > pi;
	typedef pair < pi, int > ppi;

	typedef vector < int > vi;
	typedef vector < vector < int > > vvi;
	typedef vector < pi > vpi;
	typedef vector < vpi > vvpi;
	typedef vector < ppi > vppi;

	void fast() {
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	}

	void err(istream_iterator<string> it) {cout << endl;}
	template<typename T, typename... Args>
	void err(istream_iterator<string> it, T a, Args... args) {
	    cerr << *it << " = " << a << " ";
	    err(++it, args...);
	}

	ll pow(ll x, ll y) {
		if(y == 0)
		return 1;
		ll temp = pow(x, y/2);
		temp = (temp*temp);
		if(y%2 == 1)
			temp *= x;
		return temp;
	}

	int32_t main() {
		int x;
		cin >> x;
		int res = 1000*(x/500);
		x -= 500*(x/500);
		res += 5*(x/5);
		cout << res;	
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,i,j,k;cin>>n;
  int l=1,r=n,m;
  while(l+1<r){
    m=(l+r)/2;
    if(m*(m+1)/2<=n) l=m;
    else r=m;
  }
  for(i=1;i<=r;i++){
    if(r*(r+1)/2-n!=i) printf("%d\n",i);//cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   int A,B,M;
   cin >> A >> B >> M;
   int a[A],b[B];
   rep(i,A) cin >> a[i];
   rep(i,B) cin >> b[i];
   int minA = *min_element(a, a+A);
   int minB = *min_element(b,b+B);
   int d = minA + minB;
   rep(i,M){
       int x,y,c;
       cin >> x >> y >> c;
       d = min(d,a[x-1]+b[y-1]-c);
   }
   cout << d << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		ArrayList<Program> programs = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int start = sc.nextInt();
			int end = sc.nextInt();
			int channel = sc.nextInt();
			programs.add(new Program(start, end, channel));
		}
		sc.close();
		Collections.sort(programs, new ComparatorStart());
		Collections.sort(programs, new ComparatorChannel());

		for (int i = 1; i < programs.size(); i++) {
			if (programs.get(i).getStart() == programs.get(i - 1).getEnd() && programs.get(i).getChannel() == programs.get(i - 1).getChannel()) {
				programs.get(i - 1).setEnd(programs.get(i).getEnd());
				programs.remove(i);
				i--;
			}
		}

		HashMap<Integer, Integer> timeTable = new HashMap<>();
		int answer = 0;
		for (Program program : programs) {
			for (int d = program.getStart() - 1; d < program.getEnd(); d++) {
				if (timeTable.containsKey(d)) {
					timeTable.put(d, timeTable.get(d) + 1);
					answer = Math.max(timeTable.get(d), answer);
				} else {
					timeTable.put(d, 1);
					answer = Math.max(answer, 1);
				}
			}
		}

		System.out.println(answer);
	}
}

class Program {
	private int start;
	private int end;
	private int channel;
	public Program(int start, int end, int channel) {
		this.start = start;
		this.end = end;
		this.channel = channel;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public int getEnd() {
		return end;
	}
	public void setEnd(int end) {
		this.end = end;
	}
	public int getChannel() {
		return channel;
	}
}

class ComparatorStart implements Comparator<Program> {
	@Override
	public int compare(Program prog1, Program prog2) {
		if (prog1.getStart() < prog2.getStart()) {
			return -1;
		} else if (prog1.getStart() > prog2.getStart()) {
			return 1;
		} else {
			return 0;
		}
	}
}

class ComparatorChannel implements Comparator<Program> {
	@Override
	public int compare(Program prog1, Program prog2) {
		if (prog1.getChannel() < prog2.getChannel()) {
			return -1;
		} else if (prog1.getChannel() > prog2.getChannel()) {
			return 1;
		} else {
			return 0;
		}
	}
}

Measured memory_bytes: 158044
from math import gcd


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

# setwise validation
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)


# pairwise validation
M = 10 ** 6
sieve = [0] * (M + 1)
for a in A:
    sieve[a] += 1

cnt = 0
for i in range(2, M + 1):
    cnt = max(cnt, sum(sieve[j] for j in range(i, M + 1, i)))
isPairwise = (cnt <= 1)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string X = "MARCH" ;
  int S[5] = {} ;
  int n ;
  ll ans = 0LL ;
  string input ;
  scanf("%d",&n) ;

  for(int i =0 ;i<n ;i++){
    cin >> input ;
    auto x = X.find(input[0]) ;
    if(x == string::npos) continue ;
    S[x]++ ;
  }

  for(int i = 0 ;i<5 ; i++){
    for(int j = i+1 ; j<5 ; j++){
      for(int k = j+1 ; k<5 ; k++){
        ans+=(S[i]*1LL*S[j]*S[k]) ;
      }
    }
  }
  cout << ans << endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    cout<<fixed<<setprecision(100);
    int a,b;
    cin>>a>>b;
    cout<<a/b<<" "<<a%b<<" "<<(double)a/b<<endl;

    return 0;

}



Measured memory_bytes: 3260
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final BigInteger MOD = BigInteger.valueOf((long) 1e9 + 7);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int k = in.nextInt();

        for (int i=1; i <= k; i++) {
            out.println(n-k-i+1 < 0 ? 0 : combination(n-k+1, i).mod(MOD).multiply(combination(k-1, i-1)).mod(MOD));
        }
    }

    /**
     * Returns Combination(a, b) = aCb
     * @param a Integer
     * @param b Integer
     * @return Combination
     */

    private static BigInteger combination(int a, int b) {
        BigInteger ret = BigInteger.ONE;
        for (int i=a; i > a-b; i--) {
            ret = ret.multiply(BigInteger.valueOf(i));
        }
        for (int i=1; i <= b; i++) {
            ret = ret.divide(BigInteger.valueOf(i));
        }
        return ret;
    }


}


Measured memory_bytes: 222520
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
  double a,b;
  cin >> a; cin >> b;
  if (a > b){
    cout << "GREATER" << endl;
  }
  if (a < b){
    cout << "LESS" << endl;
  }
  if (a == b){
    cout << "EQUAL" << endl;
  }
  return 0;
}


Measured memory_bytes: 256