akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<char>> df(N, vector<char>(M));
  string s;
  for (int i = 0; i < N; i++){
    cin >> s;
    for (int j=0;j<M;j++){
      df.at(i).at(j) = s.at(j);
    }
  }
  //cout << df[0][0] << endl;
  int next_h, next_w;
  vector<vector<int>> memory_h(1), memory_w(1);
  vector<vector<char>> next_df(N, vector<char>(M));
  
  while (true){
    next_h = 0, next_w = 0;
    memory_h[0] = {};
    memory_w[0] = {};
    for (int i=0;i<N;i++){
      for (int j=0;j<M;j++){
        if (df.at(i).at(j) == '#'){
          memory_h[0].push_back(i);next_h++;break;
        }
      }
    }
    
    for (int j=0;j<M;j++){
      for (int i=0;i<N;i++){
        if (df.at(i).at(j) == '#'){
          memory_w[0].push_back(j);next_w++;break;
        }
      }
    }
    
    
    if (N==next_h && M==next_w){break;}

    
    for (int i=0;i<next_h;i++){
      for (int j=0;j<next_w;j++){
        next_df.at(i).at(j) = df.at(memory_h[0].at(i)).at(memory_w[0].at(j));
      }
    }

    df = next_df;
    N = next_h; M = next_w;
    
  }
  
  
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      cout << df[i][j];
    }
    cout << endl;
  }
  
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 20


struct Node{
  int key;
  struct Node *next,*prev;
};

struct Node *nil;

struct Node* listS(int key){
  struct Node *cu = nil->next;
  while(cu != nil && cu->key!= key){
    cu = cu->next;
  }
  return cu;
}

void ini(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}


void pr_l(){

  struct Node *cu = nil->next;
  int isf = 0;
  while(1){
    if(cu == nil) break;
    if(isf++>0)
      printf(" ");
    printf("%d",cu->key);
    cu = cu->next;
  }
  printf("\n");
}

void del(struct Node *s){
  if(s == nil) return;
  s->prev->next = s->next;
  s->next->prev = s->prev;
  free(s);
}
void delF(){
  del(nil->next);
}

void del_L(){
  del(nil->prev);
}

void delK(int key){
  del(listS(key));
}


void insert(int a){
  struct Node *z = (struct Node *)malloc(sizeof(struct Node));
  z->key =a;

  z->next = nil->next;
  nil->next->prev = z;
  nil->next = z;
  z->prev = nil;
}
  


int main(){
  int k,i,l;
  int s = 0,np = 0,nd = 0;
  char c[M];

  scanf("%d",&l);
  ini();
  for(i = 0;i<l;i++){
    scanf("%s%d",c,&k);
    if(c[0] == 'i'){
      insert(k);
      np++;s++;
    }
    else if(c[0] == 'd'){
      if(strlen(c) >6){
	if(c[6] == 'F') delF();
	else if(c[6] == 'L') del_L();
      }else{
	delK(k);
	nd++;
      }
      s--;
    }
  }
  pr_l();

  return 0;
}


Measured memory_bytes: 33024
n,m = map(int,raw_input().split())
a = []
b = []
 
for i in range(n):
  a.append(map(int, raw_input().split()))
for i in range(m):
  b.append(input())
for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
  print ans

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

int main()
{
    int a,b;
    cin >> a >> b;

    int r = (a * 2 - 1), n = (a + b), s = (b * 2 - 1);

    cout << max(r, max(n, s)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    string s;
    cin>>s;
    int len=s.size();
    int sum1=0,sum2=0;
    for(int i=1;i<len;i++)
    {
        if(s[i]==s[i-1])
        {
            if(s[i]=='0')
                s[i]='1';
            else
            s[i]='0';
            sum1++;
        }

    }
    for(int i=len-1;i>0;i--)
    {
        if(s[i]!=s[i-1])
        {
            if(s[i]=='0')
                s[i]='1';
            else
            s[i]='0';
             sum2++;
        }
    }
    cout<<min(sum1,sum2)<<endl;
    return 0;
}


Measured memory_bytes: 512
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  if a[i-1]+a[i] > x:
    ans += a[i-1]+a[i]-x
    if a[i]  >= a[i-1]+a[i]-x:
      a[i] = x-a[i-1]
    else:
      a[i-1] = x
      a[i] = 0
print(ans)



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const ll MAX_N = 105;
ll N, x;
ll a[MAX_N];

void solve()
{
	ll ans = 0;
	sort(a,a+N);
	if(accumulate(a,a+N,0LL) == x) ans = N;
	else{
	    int i=0;
	    for(;i<N;++i){
		    if(a[i] <= x){
			    ans++;
			    x-=a[i];
		    }else{
		        break;
		    }
	    }
	    if(i==N && x && ans) ans--;
	}
	cout << ans << endl;
}

int main()
{
	cin >> N >> x;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
string S(ll n) {stringstream ss; string s; ss << n; ss >> s; return s;}
ll dp[11][11];
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    int n = readint();
    repd(i, 1, n)
    {
        string str = S(i);
        dp[str[0] - '0'][str[sz(str) - 1] - '0']++;
    }
    ll ans = 0ll;
    repd(i, 1, 9)
    {
        repd(j, 1, 9)
        {
            ans += dp[i][j] * dp[j][i];
        }
    }
    printf("%lld\n", ans );
    return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <set>

using namespace std;

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

  int N;
  cin >> N;

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

    auto iter = numbers.find(a);
    if(iter != numbers.end()){
      numbers.erase(iter);
    }else{
      numbers.insert(a);
    }
  }

  cout << numbers.size() << endl;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main()
{

    char a[11],b[11],c[11];
    int x , y, t;

    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    x=strlen(a)-1;
    y=strlen(b)-1;
    t=strlen(c)-1;

        if((a[x]==b[0])&&(b[y]==c[0]))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }

    return 0;
}

Measured memory_bytes: 1632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,ac=0,ad=0,bc=0,bd=0,high=0,high1=0,maximum=0;
    cin>>a>>b>>c>>d;
    ac=a*c;
    ad=a*d;
    bc=b*c;
    bd=b*d;
    high=max(ac,ad);
    high1=max(bc,bd);
    maximum=max(high,high1);
    cout<<maximum<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
 
int main(){
	string s;
	cin >> s;
	if(s.substr(0, 4) == "YAKI"){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    s <- getLine
    putStr $ take (k - 1) s
    putChar . toLower . head $ drop (k - 1) s
    putStrLn $ drop k s

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    int n;
    cin >> n;

    vector<vecl> adj(n,vecl(n));
    vector<veci> t(n,veci(n,1));
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            cin >> adj[i][j];
        }
    }

    bool res = true;
    for (int k=0; k<n; ++k) {
        for (int i=0; i<n; ++i) {
            if (k==i)
                continue;
            for (int j=i+1; j<n; ++j) {
                if (k==j)
                    continue;
                if (adj[i][j]>adj[i][k]+adj[k][j]) {
                    res = false;
                    goto out;
                } else if (adj[i][j]==adj[i][k]+adj[k][j]) {
                    t[i][j] = 0;
                }
            }
        }
    }

out:
    if (res) {
        ll sum = 0;
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                if (t[i][j])
                    sum += adj[i][j];
            }
        }
        cout << sum << endl;
    } else {
        cout << -1 << endl;
    }
}}

Measured memory_bytes: 1280
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int a,b,c;
int get(vector<int> &v,vector<int> &use){
	int na=0,nb=0,nc=0;
	int ans=0;
	int n=sz(v);
	For(i,0,n-1){
		switch(use[i]){
			case 1:
				ans+=(na==0?0:10);
				na+=v[i];
				break;
			case 2:
				ans+=(nb==0?0:10);
				nb+=v[i];
				break;
			case 3:
				ans+=(nc==0?0:10);
				nc+=v[i];
				break;
		}
	}
	ans+=abs(a-na)+abs(b-nb)+abs(c-nc);
	if(na==0 || nb==0 || nc==0) ans=INF;
	//for(auto &i:use) cout<<" "<<i;
	//cout<<"    = "<<ans<<"\n";
	return ans;
}

int go(vector<int> &v,vector<int> &use,int now){
	if(now==sz(v)){
		return get(v,use);
	}
	int ans=INF;
	For(i,0,3){
		use.emplace_back(i);
		ans=min(ans,go(v,use,now+1));
		use.pop_back();
	}
	return ans;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n>>a>>b>>c;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	vector<int> use;
	cout<<go(v,use,0)<<"\n";
	return 0;
}





























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

int main(){
    int a,b;
    cin>>a>>b;
    int ans;
    bool can;
    can=true;
    for(long double i=12;i<1251;i++){
      if(floor(i*0.08)==a && floor(i*0.1)==b){
          ans=i;
          can=true;
          break;
      }
      else can=false;
    }
    if(can)cout<<ans<<endl;
    else cout<<"-1"<<endl;
}

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

typedef long long ll;

using namespace std;

int main() {
	long double N, K, res = 0.0, A, ten;
	cin >> N >> K;
	A = 1.0 / N;
	for (int i = 1; i <= N; i++)
	{
		double cunt = 0;
		ten = (double)i;
		while (ten < K)
		{
			ten = ten * 2.0;
			cunt++;
		}
		res = res + A * pow(1.0 / 2.0, cunt);
	}
	cout << setprecision(12) << res << endl;
}

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

int main(){
  int n,k=0;
  cin >> n;
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  sort(b.begin(), b.end());
  for(int i=1;i<n;i++){
    if(b.at(i-1)==b.at(i)){
      k++;
    }
  }
  if(k>0)cout<<"NO";
  else{
    cout<<"YES";
  }
}


Measured memory_bytes: 1024
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N, D = map(int, input().split())
    p = []
    for i in range(N):
        p.append(list(map(int, input().split())))
    for i in range(N):
        for j in range(i, N):
            temp = 0
            for k in range(D):
                temp += (p[i][k]-p[j][k])**2
            if temp != 0 and float.is_integer(temp**0.5):
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def main():

    N = int(input())
    A = [i for i in map(int, input().split())]
    B = [i for i in map(int, input().split())]
    C = [i for i in map(int, input().split())]
    satisf = 0
    for i in range(N):
        satisf += B[A[i] - 1]
    for i in range(N - 1):
        if A[i + 1] == A[i] + 1:
            satisf += C[A[i] - 1]
    print(satisf)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,b,ans=0;
    cin>>n>>b;
    while(n>=b)
    {
        n=n/b;
        ans++;
    }
    if(n%b==0)
    cout<<ans;
    else
    {
        cout<<ans+1;
    }
    
}

Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Lower
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int hs[MAX_N];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", hs + i);

  int maxl = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && hs[j - 1] >= hs[j]) j++;
    setmax(maxl, j - i - 1);
    i = j;
  }

  printf("%d\n", maxl);
  return 0;
}


Measured memory_bytes: 640
n = int(input())

resultNum = 0
for i in range(1,n+1):
  if i % 2 != 0:
      count = 0
      for j in range(1,i+1):
        if i % j == 0:
          count+=1
      if count == 8:
        resultNum += 1

print(resultNum)
  

Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define RANGE(a, l, r) lower_bound(a, a + N, r) - lower_bound(a, a + N, l)
using namespace std;
typedef int ll;

ll N, A[200000], B[200000];
ll pow2[31], l1[29], r1[29], l2[29], r2[29];
ll moda[29][200000], modb[29][200000];

int main(void) {
  scanf("%d", &N);
  REP(i, 0, N) scanf("%d", &A[i]);
  REP(i, 0, N) scanf("%d", &B[i]);

  REP(i, 0, 31) pow2[i] = (1 << i);
  REP(i, 0, 29) {
    l1[i] = pow2[i];
    r1[i] = pow2[i + 1];
    l2[i] = pow2[i + 1] + pow2[i];
    r2[i] = pow2[i + 2];
  }
  REP(i, 0, 29) REP(j, 0, N) moda[i][j] = A[j] % pow2[i + 1];
  REP(i, 0, 29) {
    REP(j, 0, N) modb[i][j] = B[j] % pow2[i + 1];
    sort(modb[i], modb[i] + N);
  }

  ll ans = 0;
  REP(i, 0, N) {
    REP(k, 0, 29) {
      ll cnt = 0;
      cnt += RANGE(modb[k], l1[k] - moda[k][i], r1[k] - moda[k][i]);
      cnt += RANGE(modb[k], l2[k] - moda[k][i], r2[k] - moda[k][i]);
      if(cnt & 1) ans = ans ^ pow2[k];
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 46976
#include<iostream>
#include<string>
using namespace std;
long N,M;
string S,T;
long i,k;
bool good;
long ans;
int main(){
  cin >> N >> M >> S >> T;
  for (i=1;i<=N;i++){
    if (N%i!=0){continue;}
    k = N/i;
    if (M%k==0){break;}
  }
  good = true;
  for (i=0;i<k;i++){
      if (S[(N/k)*i]!=T[(M/k)*i]){good = false;}
  }
  if (good){ans = N*M/k;}
  else{ans = -1;}
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 888
//file_name:ABC105_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


// 105,135,165,189,195,


int main() {
    int n;
    scanf("%d",&n);

    int ans = 0;

    if(n>=105)ans++;
    if(n>=135)ans++;
    if(n>=165)ans++;
    if(n>=189)ans++;
    if(n>=195)ans++;

    cout << ans << endl;

    return 0;
}



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


int main(int argc, char** argv){
  int N;
  int maxnum = -1;
  int sum = 0;
  cin >> N;
  for(int cnt0=0; cnt0<N; cnt0++){
	int tmp;
    cin >> tmp;
    sum += tmp;
    maxnum = max(maxnum, tmp);
  }
  if(maxnum < sum - maxnum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split(' ')))

L.sort()
#print(L)

cnt = 0
order =0
for i in range(N-2):
    highJ = 0
    for j in range(i+1,N-1):
        tmphighJ = max(j,highJ)
        for k in range(max(j+1,highJ+1),N):
            order+=1
            if L[k] < L[i]+L[j]:
                tmphighJ = k
            else:
                break
        highJ = max(j,tmphighJ)
        cnt+= highJ - j
        #print(i,j,highJ,cnt)

print(cnt)
#print(order)


Measured memory_bytes: 45020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  int a, b; cin >> a >> b;
  if (a >= 10 || b >= 10) cout << -1 << endl;
  else cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	n--;
	ll ans = n;
	for(int i=2; i<=n; i++) {
		ans += n/i;
	}
	cout<<ans;
 	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int limN = 1e5 + 5;

int crg[limN];

int main() {
    int N, T;
    int ans = 0;
    scanf("%d%d", &N, &T);
    for(int i=0, a, b; i<N; i++) {
        scanf("%d%d", &a, &b);
        crg[a]++;
        crg[b]--;
    }
    for(int i=0, s=0; i<=T; i++) {
        s += crg[i];
        ans = max(ans, s);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<(a); i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pow2(x) (1ll<<(x))
 
using namespace std;
 
const int Mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int n,u,v;
	cin >> n >> u >> v;
	int e[n-1][2];
	loop(n-1) cin >> e[i][0] >> e[i][1];
	vector<int> adj[n+1];
	loop(n-1){
		adj[e[i][0]].push_back(e[i][1]);
		adj[e[i][1]].push_back(e[i][0]);
	}
	queue<int> q;
	int dist[n+1],dist2[n+1];
	bool visited[n+1];
	loop(n+1) visited[i]=false;
	q.push(u);
	dist[u]=0;
	visited[u]=true;
	int ind,ind2;
	while(!q.empty()){
		ind=q.front();
		loop(adj[ind].size()){
			ind2=adj[ind][i];
			if(visited[ind2]) continue;
			visited[ind2]=true;
			q.push(ind2);
			dist[ind2]=dist[ind]+1;
		}
		q.pop();
	}
	loop(n+1) visited[i]=false;
	q.push(v);
	dist2[v]=0;
	visited[v]=true;
	while(!q.empty()){
		ind=q.front();
		loop(adj[ind].size()){
			ind2=adj[ind][i];
			if(visited[ind2]) continue;
			visited[ind2]=true;
			q.push(ind2);
			dist2[ind2]=dist2[ind]+1;
		}
		q.pop();
	}
	int ans;
	ans=0;
	loop(n+1){
		if(i==0) continue;
		if(dist[i]<dist2[i]){
			ans=max(ans,dist2[i]);
		}
	}
	cout << ans-1 << "\n";
	return 0;
}


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

typedef long long llong;
// -2.1e-9 <= int <= 2.1e9

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

    sort(A.begin(), A.end());
    string judge = "YES";
    for (size_t i=0; i <= (A.size()-2); i++) {
        if (A[i] == A[i+1]) {
            judge = "NO";
            break;
        }
    }
    cout << judge << endl;
}


Measured memory_bytes: 1024
package main

import "fmt"
var N, M int
var u, w, v int
var dp, arr []int
var DP, mat [][]int
var vis, dist []int
var indeg, outdeg []int
const (
	MaxInt = 1<<31 - 1
	MinInt = -MaxInt - 1
	MOD = int(1e9) + 7
)

func buildMatrix(mat *[][]int, size int) {
	for i := range *mat {
		(*mat)[i] = make([]int, size)
	}
}

func addSelf(a *int, b int) {
	*a += b
}

func subSelf(a *int, b int) {
	*a -= b
}

func mul(a, b int) int {
	return (a%MOD)*(b%MOD)%MOD
}

func addSelfMOD(a *int, b int) {
	addSelf(a, b)
	if *a > MOD {
		*a -= MOD
	}
}

func subSelfMOD(a *int, b int) {
	subSelf(a, b)
	if *a < 0 {
		*a += MOD
	}
}

func max(a, b int) int {
	if a > b { return a }
	return b
}

func min(a, b int) int {
	if a < b { return a }
	return b
}

func abs(a int) int {
	if a < 0 { return -a }
	return a
}

// color: 0->w, 1->b
func dfs(u, parent int) (int, int) {
	w,b := 1,0 // -> children are white or it is black
	for _, e := range mat[u] {
		if e != parent {
			wc, bc := dfs(e, u)
			tmp := w
			w = mul(bc,w)
			b = (mul(tmp, wc) + mul(b, bc+wc))%MOD
		}
	}
	return w, (w+b)%MOD
}

func main() {
	_,e := fmt.Scanf("%d", &N)
	if e != nil { return }
	mat = make([][]int, N+1)
	dp = make([]int, N+1)
	outdeg = make([]int, N+1)
	buildMatrix(&mat, 0)
	for i:=1; i<N;i++ {
		_,e := fmt.Scanf("%d%d", &u, &v)
		if e != nil { return }
		mat[u] = append(mat[u], v)
		mat[v] = append(mat[v], u)
	}
	w,b := dfs(1,-1)
	fmt.Println((w+b)%MOD)
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    int left = 0;
    for (int i = 0; i < H; i++) {
        if (i < B) {
            for (int j = 0; j < W; j++) {
                if (j < A)cout << 0;
                else cout << 1;
            }
        }
        else {
            for (int j = 0; j < W; j++) {
                if (j < A)cout << 1;
                else cout << 0;
            }
        }
        cout << endl;

    }
    
}


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

int main() {
    string a, b;
    int ia, ib;

    cin >> a >> b;

    ia = atoi(a.c_str());
    ib = atoi(b.c_str());
    string as = "";
    string bs = "";
    string tmp = "";
    for(int i = 0; i < ib; i++) {
        as = as + a;
    }

    for (int i = 0; i < ia; i++) {
        bs = bs + b;
    }
    if (as < bs) {
        cout << as << endl;
    } else {
        cout << bs << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	vector<int> s(n);
	int sum = 0, modcnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
		if (s[i] % 10 == 0) modcnt++;
	}
	if (modcnt == n) cout << 0;
	else {
		if (sum % 10 != 0) cout << sum;
		else {
			ssort(s);
			for (int i = 0; i < n; i++) {
				if (s[i] % 10 != 0) {
					sum -= s[i];
					break;
				}
			}
			cout << sum;
		}
		
	}

	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n,m; cin >> n >> m;
    int k[m], s[m][n]; rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    int p[m]; rep(i,m) cin >> p[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); ++bit){
        bool isOK = true;
        rep(i,m){
            int tmp = 0;
            rep(j,k[i]){
                if(bit & (1 << s[i][j])) tmp++;
            }
            if(tmp%2 != p[i]) isOK = false;
        }
        if(isOK) ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  n <- readInteger
  let l = calcLog n
  print $ 2 ^ (l + 1) - 1

calcLog 1 = 0
calcLog x = 1 + calcLog (x `div` 2)


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll c = 1000;
  ll f = -1;
  for(int i = (int)s.size() - 1;i >= 0;i--)if(s[i] == 'C')c = i;
  for(int i = 0;i < (int)s.size();i++)if(s[i] == 'F')f = i;
  if(c < f)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
<?php
  
list($n, $a, $b) = explode(' ', trim(fgets(STDIN)));

if (($b-$a)%2 == 0){
  $ans = ($b-$a)/2;
} else {
  if ($a-1 <= $n-$b){
    $f = $a;
    $b - $f > 1? $s = (($b-$f) - 1)/2 : $s = 0;
  } else {
    $f = $n-$b + 1;
    $n - ($a+$f) > 1? $s = ($n - ($a+$f))/2 : $s = 0;
  }
  $ans = $f+$s;
}

echo $ans;
   
?>

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

long long int dp[101][100001];
vector <pair<int,int>> v;
int n,w,a,b;

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

	cin >> n >> w;
	for(int i=0;i<n;i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}

	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=w;j>=0;j--)
		{
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(dp[i][j]!=-1)
			{
				if(j + v[i].first <= w)
				{
					dp[i+1][j + v[i].first] = max(dp[i+1][j + v[i].first],dp[i][j] + v[i].second);
				}
			}
		}
	}

	long long int res = 0;
	for(int i=w;i>=0;i--)
	{
		res = max(res,dp[n][i]);
	}

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


Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	string s, s1;
	cin >> s >> s1;
	if (s[0] == s1[2] && s[1] == s1[1] && s[2] == s1[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll N = 2e5 + 200 ;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     ll n;
     cin>>n;
     vector<ll> a;
     for( ll i = 0 ; i<N ; i++ )
     {
         a.push_back( modexp(2ll,i) );
     }
     ll k = inf-1 ;
     map<pair<ll,ll>,pair<ll,ll>> mp;
     for( ll i = 0 ; i<n ; i++ ){
        ll x,y;
        cin>>x>>y;
        if( x==0 && y==0 ) { k++; continue ; }
        if( make_pair(x,y) < make_pair(0ll,0ll) ) { x=-x; y=-y;  }
        ll g = gcd( abs(x) , abs(y) );
        x /= g ; y /= g ;
        if(y>0) { mp[{x,y}].first++ ; }
        else { mp[{-y,x}].second++ ; }
     }
     ll r = 1 ;
     for( auto p : mp )
     {
         r = r *( a[p.second.second] + a[p.second.first] - 1)%inf ;
     }
     cout<<(k+r)%inf;
  }
  return 0;

}


Measured memory_bytes: 20188
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int N;
int A[1005];
bool check(){
    for(int i = 0; i < N; i++){
        if(A[i]%2 == 0){
            if(A[i]%3 != 0 && A[i]%5 != 0){
                return false;
            }
        }
    }
    return true;
}
int main(){
    cin >> N;
    
    for(int i = 0; i < N; i++) cin >> A[i];

    if(check()){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

}


Measured memory_bytes: 256
class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
max_A = max(A)

st = SegmentTree([N] * (max_A + 1), min, N)
edge = [set() for _ in range(N)]
for i, a in enumerate(reversed(A)):
    j = N - 1 - i
    p1 = st.get(a, min(max_A + 1, a + K + 1))
    if p1 < N:
        edge[j].add(p1)
    p2 = st.get(max(0, a - K), a)
    if p2 < N:
        edge[j].add(p2)
    p0 = st.get(a, a + 1)
    if p0 < N:
        edge[j].add(p0)
    st.update(a, j)

dp = [1] * N
for i in range(N - 1):
    here = dp[i]
    for ni in edge[i]:
        if ni < N:
            dp[ni] = max(dp[ni], dp[i] + 1)

print(max(dp))


Measured memory_bytes: 187312
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

#define WALL '#'
#define PATH '.'

int main(void) {
	int h,w; cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vvi dp(h,vi(w,INF));
	if(s[0][0]==WALL) dp[0][0] = 1; else dp[0][0] = 0;
	rep(i,h)rep(j,w){
		if(i>=1) dp[i][j] = min(dp[i][j], dp[i-1][j] + (s[i-1][j]==PATH&&s[i][j]==WALL) );
		if(j>=1) dp[i][j] = min(dp[i][j], dp[i][j-1] + (s[i][j-1]==PATH&&s[i][j]==WALL) );
	}
/* 	
	rep(i,h){
		rep(j,w) cout << dp[i][j] << "";
		cout << endl;
	}
	 */
	 cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 256
L = input()

def calc(L):
    result = 0
    for i in range(0, L + 1):
        for j in range(0, L - i + 1):
            if i + j == i ^ j:
                result += 1
    return result

#for i in range(33):
#    print(i, bin(i), calc(i))

M = 10**9+7

def solve(L):
    if L == 0:
        return 1
    result = 1
    t = 0
    for c in L:
        if c == "1":
            t += 1
            result = (result * 3) % M
        else:
            result = (result * 3 - 2 ** t * 2) % M

    return result

print(solve(L))



Measured memory_bytes: 42684
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,ans=0;
  cin>>a>>b;
  if(a==1){
    ans+=300000;
  }else if(a==2){
    ans+=200000;
  }else if(a==3){
    ans+=100000;
  }
  if(b==1){
    ans+=300000;
  }else if(b==2){
    ans+=200000;
  }else if(b==3){
    ans+=100000;
  }
  if(a==1 && b==1) ans+=400000;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
    if(A.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  rep(i, N){
    if(ans > 1000000000000000000 / A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    ans *= A.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3976
using System;

class Program
{
    static void Main(string[] args)
    {
        var xyzk = Console.ReadLine().Split();
        var x = int.Parse(xyzk[0]);
        var y = int.Parse(xyzk[1]);
        var z = int.Parse(xyzk[2]);
        var k = int.Parse(xyzk[3]);

        var A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var B = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var C = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

        var AB = new long[x * y];
        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < y; j++)
            {
                AB[i * y + j] = A[i] + B[j];
            }
        }

        Array.Sort(AB);

        var ABC = new long[k * z];
        for (int i = 0; i < Math.Min(x * y, k); i++)
        {
            for (int j = 0; j < z; j++)
            {
                ABC[i * z + j] = AB[x * y - i - 1] + C[j];
            }
        }

        Array.Sort(ABC);

        for (int i = 0; i < k; i++)
        {
            Console.WriteLine(ABC[k * z - i - 1]);
        }
    }
}


Measured memory_bytes: 44768
// atcoder/abc133/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n, a, b;
  while (cin >> n >> a >> b) {
    cout << min(n * a, b) << endl;
  }

  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vl a(n);
    rep(i,0,n-1)
    {
        cin>>a[i];
    }
    ll minn=MOD;
    ll sum=0;
    ll m=0;
    rep(i,0,n-1)
    {
        sum+=abs(a[i]);
        if(a[i]<0)
        {
            m++;
        }
        minn=min(minn,abs(a[i]));

    }
    if(m%2==0)
    {
        cout<<sum<<"\n";
    }
    else
    {
        cout<<sum-2*minn<<"\n";
    }
    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto& in:a) cin >> in;
    ll res = LINF;
    vector<ll> cusum(N,0);
    cusum[0] = a[0];
    for(int i = 1; i < N;i++){
        cusum[i] = cusum[i-1] + a[i];
    }
    for(int i = 0; i < N-1;i++){
        res = min(res,abs(cusum[i] - (cusum[N-1] - cusum[i])));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    scanf("%d",&n);
    map<int,int> mp;
    int tmp;
    while(n--){
        scanf("%d", &tmp);
        mp[tmp-1]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x.second);
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int l, r, result = 0;
  for (int i = 0; i < N; ++i) {
    cin >> l >> r;
    result += (r - l + 1);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define max 4000
#define score 1000000

long long int id[max],raw[max];

int main(){
  long long int num,sale,deal;
  int n,i,j,count,k,l,m;
  
  while(1)
    {
      scanf("%lld",&n);

      for (k=0;k<=max;k++)
      {
	id[k] = 0;
      }

      if(n==0)
	{
	  break;
	}

      else
	{
	  count = 0;
	  for(i=1;i<=n;i++)
	{
	  scanf("%lld %lld %lld",&num,&sale,&deal);
	  id[num] = id[num] + (sale * deal);
	  raw[i] = num;
	}
	  for(l=0;l<max;l++)
	    {
		  for(m=l+1;m<=max;m++)
		    {
		      if(raw[l]==raw[m])
			{
			  raw[m]=0;
			}
		    }
	    }
	  for(j=1;j < max;j++)
	{
       	  if(id[raw[j]] >=  score)
	  {
	      printf("%lld\n",raw[j]);
	      count++;
	  }
	}
	  if(count==0)
	    {
	 printf("NA\n");
	    }
	  
	}
    }
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l,r,d,ans=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
import java.io.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        int x, ans;
     
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(br.readLine());
         
        ans = x*x*x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 24408