akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;

vector<ll> a;
void dfs(int keta, string s, int m){
    if(keta==m){
        int seven = 0, five = 0, three = 0;
        rep(i,m){
            if(s[i]=='7') seven++; 
            else if(s[i]=='5') five++; 
            else if(s[i]=='3') three++; 
        }
        if(seven && five && three){
            a.push_back(atoll(s.c_str()));
        }
        return;
    }
    dfs(keta+1,s+'3',m);
    dfs(keta+1,s+'5',m);
    dfs(keta+1,s+'7',m);
}

int main(){
    ll n;
    cin >> n;
    if(n < 356){
        cout << 0 << endl;
        return 0;
    }
    int keta = to_string(n).length();
    for(int i=1; i<=keta+1; i++) dfs(0,"\0",i);
    sort(a.begin(),a.end());
    rep(i,(int)a.size()){
        if(n < a[i]){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4360
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

const int INF = 999999999;

void Solve(){
	int n,k;	cin >> n >> k;
	int arr[n],dp[n];
	Rep(i,0,n){
		cin >> arr[i];
		//dp[i] = INF;
	}
	dp[0] = 0;
	Rep(i,1,n){
		dp[i] = INF;
		for(int j = 1; (j <= k && i-j >= 0); ++j){
			dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout << dp[n-1] << endl;
}

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

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

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

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'I')
      cnt++;
    else if (S.at(i) == 'D')
      cnt--;
    ans = max(ans, cnt);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    if(a == 111) cout << "999" << endl;
    if(a == 119) cout << "991" << endl;
    if(a == 191) cout << "919" << endl;
    if(a == 199) cout << "911" << endl;
    if(a == 911) cout << "199" << endl;
    if(a == 919) cout << "191" << endl;
    if(a == 991) cout << "119" << endl;
    if(a == 999) cout << "111" << endl;
    return 0;
}

Measured memory_bytes: 256
n,p = map(int,input().split())
s = input()

def solve():
    if p in [2,5]:
        ret = 0
        for i in range(n):
            d = ord(s[n-1-i])-ord('0')
            if d % p == 0: ret += n-i
        return ret
    val = [0]*p
    ten = 1
    cur = 0
    val[cur] += 1
    for i in range(n):
        d = ord(s[n-1-i])-ord('0')
        cur = (cur + d * ten) % p
        ten = ten * 10 % p
        val[cur] += 1
    ret = 0
    for i in range(p): ret += val[i] * (val[i]-1)//2
    return ret

print(solve())

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

int main() {
  int N, K, x, middle, distance = 0;

  cin >> N;
  cin >> K;

  middle = (K + 1) / 2; //中点のx座標
  
  for (int i = 0; i < N; i++){
    cin >> x;

    if (x <= middle){
      distance += 2 * x; //中点以下のときの1つのボールを取りにいたときの移動距離 
    }
    else{
      distance += 2 * (K - x); //中点より大きいときの移動距離
    }
  }
  cout << distance << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long A, B, C, D;
		A = Long.parseLong(sc.next()) - 1;
		B = Long.parseLong(sc.next());
		C = Long.parseLong(sc.next());
		D = Long.parseLong(sc.next());
		
		int count = 0;
		long lcm = C * D / gcd(C, D);
		
		long tmpAC = A / C;
		long tmpBC = B / C;
		long tmpAD = A / D;
		long tmpBD = B / D;
		
		long tmpACD = A / lcm;
		long tmpBCD = B / lcm;
		
		long ans = tmpBC - tmpAC + tmpBD - tmpAD - (tmpBCD - tmpACD);
		
		ans = B - (A + 1) + 1 - ans;
		
		
		System.out.println(ans);

	}
	
	private static long gcd(long m, long n) {
		long tmp;
		while (m % n != 0) {
			tmp = n;
			n = m % n;
			m = tmp;
		}
		return n;
	}

}


Measured memory_bytes: 22736
from math import gcd
from itertools import combinations_with_replacement

k = int(input())
lst = [i for i in range(1,k+1)]
itr = combinations_with_replacement(lst, 3)
ans = 0

for i in itr:
  st = set(i)
  num = len(st)
  if num == 1:
    ans += i[0]
  elif num == 2:
    a,b = st
    ans += gcd(a,b) * 3
  else:
    ans += gcd(gcd(i[0],i[1]), i[2]) * 6

print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  using D = double;
  D a,t,r;
  cin>>a>>t>>r;
  cout<<(t/a*r)<<endl;
  return 0;
}



Measured memory_bytes: 3280
#include <stdio.h>

int main(void){
  int n,k,d,aa,a[101];
  scanf("%d",&n);
  scanf("%d",&k);
  for(d=0;d<=n;d++){
    a[d]=0;
  }
  while(k>0){
    scanf("%d",&d);
    while(d>0){
      scanf("%d",&aa);
      a[aa]=1;
      d--;
    }
    k--;
  }
  k=0;
  for(d=1;d<=n;d++){
    if(a[d]==0){
      k++;
    }
  }
  printf("%d",k);
  return 0;
}
  

Measured memory_bytes: 1728
#include <iostream>
#include <set>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

int main()
{
	int N, K,temp,min = INT32_MAX;
	vector<int> heights;
	cin >> N >> K;
	for (int i = 0; i < N; i++) 
	{
		cin >> temp;
		heights.push_back(temp);
	}
	sort(heights.begin(), heights.end());

	for (int i = 0; i <= (N - K); i++) 
	{
		if (heights[i + (K-1)] - heights[i] < min)
			min = heights[i + (K-1)] - heights[i];
	}
	cout << min;
}

Measured memory_bytes: 892
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    int c = 0;
    for (int i = 0; i < 2; i++) {
        if (a >= b) {
            c += a;
            a--;
        }
        else {
            c += b;
            b--;
        }
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int s = Math.abs(x-a);
		int t = Math.abs(x-b);
		
		if(Math.min(s,t)==s){
			System.out.println("A");
		}else{
			System.out.println("B");
		}
		sc.close();
	}
}

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

int main() {
	string S, T; cin >> S >> T;
	bool exist = false;
	int T_head = 0;

	for (int i = S.size()-T.size(); i >= 0; i--) {
		//cout << S[i] << endl;
		for (int j = 0; j < T.size(); j++) {
			if (S[i + j] != T[j] && S[i + j] != '?') break;
			if (j == T.size() - 1) exist = true;
		}
		if (exist) {
			T_head = i;
			break;
		}
	}

	if (exist) {
		for (int i = 0; i < S.size();i++) {
			if (i == T_head) {
				cout << T;
				i += T.size() - 1;
			}
			else if (S[i] == '?') cout << 'a';
			else cout << S[i];
		}
		cout << endl;
	}
	else cout << "UNRESTORABLE" << endl;

	//system("pause");
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, m = map(int, input().split()) # 入力が複数
d = []
for _ in range(n):
    food = set(input().split()[1:])
    d.append(food)

s = d[0]
for i in range(n):
    s = s & d[i]
print(len(s))

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

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int main()
{
	long long res = 0;
	long long n, x;
	cin >> n >> x;
	long long ans = 1;
	for (int i = 1; i <= n; i++)
	{
		int l;
		cin >> l;
		res += l;
		if (res <= x)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  bool can = false;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i*j == n){
         can = true;
         break;
      }
    }
  }
  if(can) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


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

int main() {
  int  k,x; cin>>k>>x;
  if(500*k>=x)cout<<"Yes";
  else{cout<<"No";}
}

Measured memory_bytes: 256
N = int(input())

num_a = 0
num_b = 0
ab = 0
count = 0

for i in range(N):
    s = input()
    if s[0] == 'B':
        num_b += 1
    
    if s[-1] == 'A':
        num_a += 1
    
    if s[0] == 'B' and s[-1] == 'A':
        count += 1
    
    ab += s.count('AB')

if num_a == num_b and num_a == count:
    if count == 0:
        print(ab)
    else:
        print(ab + num_a - 1)
else:
    if num_a >= num_b:
        print(ab + num_b)
    
    else:
        print(ab + num_a)


Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#define INF 1e9
#define MAX_V 100001
using namespace std;
typedef pair<int,int> P;

struct edge{int to,cost;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> >que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int a,b,c;
int main(){
	cin>>a>>b;
	c=(a+b)/2;
	if((a+b)%2==1) c++;
	cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long ans=0;
	for (int i=1; i<=n; i++){
		if (i % 5 != 0 && i % 3 != 0 && i % 15 != 0 )
			ans += i;
	}

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

Measured memory_bytes: 3188
n=int(input())-1
tmp=input()
wordset={tmp}
#print(wordset)
for i in range(n):
  w=input()
  if w in wordset or w[0]!=tmp[-1]:
    print('No')
    exit()
  else:
    wordset=wordset|{w}
    tmp=w
  #print(wordset)
print('Yes')


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

using namespace std ;

const int MAX = 110 ;

int arr[MAX] ;
int n , k ;

long long dp[MAX][MAX][2];

vector<int>v ;

long long calc(int idx , int dig , bool Less)
{
	if(dig > k)
		return 0 ;
	if(idx == v.size())
	{
		if(dig == k)
			return 1ll ;
		else
			return 0ll ;
	}
	long long &ret = dp[idx][dig][Less] ;
	if(ret != -1)
		return ret ;
	int LMT ;
	if(Less == 0)
		LMT = v[idx] ;
	else
		LMT = 9 ;
	ret = 0 ;
	for(int i = 0 ; i <= LMT ; ++i)
	{
		bool nLess = Less ;
		int ndig  = dig ;
		if(i < LMT)
			nLess = 1 ;
		if(i != 0)
			ndig++ ;
		ret += calc(idx+1 , ndig , nLess) ;
	}
	return ret ;
}

long long solve(string s)
{
	memset(dp , -1 , sizeof(dp)) ;
	for(int i = 0 ; i < s.size() ; ++i)
		v.push_back((s[i] - '0')) ;
	return calc(0 , 0 , 0) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	string n ;
	cin>>n ;
	cin>>k ;
	return cout<<solve(n)<<"\n" , 0 ;
}		

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  int ans = n-k;
  if(k == 1) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    ans = 1000-int(int(input())%1000)
    if ans == 1000:
        print(0)
    else:
        print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 73024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void)
{int n,k;
  scanf("%d%d",&k,&n);
  int a[n];
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
}
  int max=k-a[n-1]+a[0];
for(int i=0;i<n-1;i++){
  int l=a[i+1]-a[i];
  if(l>max)
    max=l;
 
}
  	 		
  printf("%d",k-max);

    return EXIT_SUCCESS;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }else if(a==c){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

struct data {
  llong place;
  llong cost;
  llong before;

  data() {};
  data(llong place, llong cost, llong before) :
    place(place),
    cost(cost),
    before(before)
  {}

  bool operator<(const data &ri) const {
    return cost < ri.cost;
  }
  bool operator<=(const data &ri) const {
    return cost <= ri.cost;
  }
  bool operator>(const data &ri) const {
    return cost > ri.cost;
  }
};

vector<vector<data> > edges;

vector<data> dijkstra(int start) {
  priority_queue<data, vector<data>, greater<data> > que;
  vector<data> dis(edges.size(), data(-1, inf<llong>, -1));
  dis[start] = data(start, 0, -1);

  que.push(dis[start]);
  while (que.size()) {
    data now = que.top();
    que.pop();
    if (dis[now.place] < now) continue;

    for (auto &edge: edges[now.place]) {
      data next(edge.place, now.cost + edge.cost, now.place);
      if(dis[next.place] <= next) continue;
      dis[next.place] = next;
      que.push(next);
    }
  }

  return dis;
}


int main() {
  llong N, M;
  vector<lpair> query;
  cin >> N;
  edges.resize(N + 1);
  for (int i = 0; i < N - 1; ++i) {
    llong a, b;
    cin >> a >> b;
    edges[a].push_back(data(b, 1, -1));
    edges[b].push_back(data(a, 1, -1));
  }
  cin >> M;
  query.resize(M);
  for (auto &in: query) {
    cin >> in.first >> in.second;
  }

  vector<vector<data>> distance(N + 1);
  for (int i = 1; i <= N; ++i) {
    distance[i] = dijkstra(i);
  }

  vector<llong> edge_bits(M + 1, 0);
  map<lpair, llong> ids;
  for (int i = 0; i < M; ++i) {
    data now = distance[query[i].first][query[i].second];
    while (now.before != -1) {
      lpair edge(min(now.place, now.before), max(now.place, now.before));
      if (ids.count(edge) == 0) {
        ids[edge] = ids.size();
      }
      edge_bits[i] |= 1ll << ids[edge];
      now = distance[query[i].first][now.before];
    }
  }

  vector<llong> nibeki(N, 1);
  for (int i = 1; i < N; ++i) {
    nibeki[i] = nibeki[i - 1] * 2;
  }
  llong ans = 0;
  for (llong i = 1; i < (1l<<M); ++i) {
    llong res = 0;
    for (llong j = 0; j < M; ++j) {
      if ((i >> j) & 1) {
        res |= edge_bits[j];
      }
    }

    ans += nibeki[N - 1 - __builtin_popcountll(res)] * (__builtin_parityll(i) ? 1 : -1);
  }

  cerr << ans << endl;
  cout << nibeki[N - 1] - ans << endl;

  return 0;
}

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

vi g[5];

int ans = 1;

void dfs(int v, int p){
    if(sz(g[v]) > 2) ans = 0;
    for(int u : g[v]){
        if(u == p)continue;
        dfs(u, v);
    }
}

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n, k;
    cin >> n >> k;
    g[n].pb(k);
    g[k].pb(n);
    cin >> n >> k;
    g[n].pb(k);
    g[k].pb(n);
    cin >> n >> k;
    g[n].pb(k);
    g[k].pb(n);
    ans = 0;
    for (int i = 1;i <= 4; ++i) {
        if(sz(g[i]) == 1){
            ans = 1;
            dfs(i, -1);
            break;
        }
    }
    if(ans == 1) cout << "YES";
    else cout << "NO";
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
 * */

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;
int x;

int main() {
    scanf("%d", &x);
    x = 1 - x;
    printf("%d\n", x);

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

struct Point {
	int x,o,a;
	bool operator < (const Point& p) const {
		if (x!=p.x) return x<p.x;
		else return o<p.o;
	}
};

const int N = 1<<18;
ll t[2*N], z[2*N];
ll dp[N];

void push(int i) {
	if(z[i]) {
		z[2*i] += z[i];
		z[2*i+1] += z[i];
		t[2*i] += z[i];
		t[2*i+1] += z[i];
		z[i] = 0;
	}
}

void update(int l, int r, ll v, int i=1, int s=0, int e=N-1) {
	if(r<s||e<l) return;
	if(l<=s&&e<=r) {
		t[i] += v;
		z[i] += v;
		return;
	}
	push(i);
	int m = (s+e)/2;
	update(l,r,v,2*i,s,m);
	update(l,r,v,2*i+1,m+1,e);
	t[i] = max(t[2*i],t[2*i+1]);
}

ll query(int l, int r, int i=1, int s=0, int e=N-1) {
	if(r<s||e<l) return -INFLL;
	if(l<=s&&e<=r) {
		return t[i];
	}
	push(i);
	int m = (s+e)/2;
	return max(query(l,r,2*i,s,m),query(l,r,2*i+1,m+1,e));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n, m;
	cin >> n >> m;
	vector<Point> p;
	for(int i=0;i<m;i++) {
		int l,r,a;
		cin >> l >> r >> a;
		p.push_back({l,-2,a});
		p.push_back({r,l,a});
	}
	for (int i=1;i<N;i++) {
		p.push_back({i,-1});
	}
	sort(p.begin(),p.end());

	for(const Point& it:p) {
		if(it.o==-2) {
			update(0, it.x-1, it.a);
		} else if(it.o==-1) {
			dp[it.x] = query(0, it.x-1);
			update(it.x, it.x, dp[it.x]);
		} else {
			update(0, it.o-1, -it.a);
		}
	}

	ll ans = 0;
	for(int i=0;i<N;i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << nl;

	return 0;
}


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

if n == 1:
    print('1')
    exit(0)

sum_n = int((1 + n) / 2 * n)
n3 = n // 3
n5 = n // 5
n15 = n // 15

sum_n3 = int((1 + n3) / 2 * n3) * 3
sum_n5 = int((1 + n5) / 2 * n5) * 5
sum_n15 = int((1 + n15) / 2 * n15) * 15

res = sum_n - sum_n3 - sum_n5 + sum_n15
print(res)


Measured memory_bytes: 9128
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	for ( int i = 0; i < S.length()-8; i++ ) {
	    System.out.print(S.charAt(i));
	}
	System.out.println();
    }
}


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

using namespace std;
typedef long long ll;


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

    int cnt[500001];
    for (int i = 0; i < 500000; i++)
        cnt[i] = 0;

    ll s = 0LL;

    for (ll i = 0, x; i < n; i++) {
        cin >> x;
        s+=x;
        cnt[x]++;
    }

    int q;
    cin >> q;

    while (q--) {
        ll a, b;
        cin >> a >> b;

        s-=a*cnt[a];
        s+=b*cnt[a];

        cnt[b]+=cnt[a];
        cnt[a] = 0;

        cout << s << endl;
    }


    return 0;
}


Measured memory_bytes: 5528
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[50001];
ll ans = 1;
const ll mod = 1e9 + 7;

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


	int N = getint();
	if (N & 1) {
		rep(i, N) {
			int a = getint();
			if (a & 1) {
				printf("0");
				return 0;
			}
			A[a / 2]++;
		}
		if (A[0] != 1) {
			printf("0");
			return 0;
		}
		rep1(i, N / 2) {
			if (A[i] != 2) {
				printf("0");
				return 0;
			}
			ans = ans << 1;
			if (ans >= mod) ans -= mod;
		}
		printf("%lld", ans % mod);
	}
	else {
		rep(i, N) {
			int a = getint();
			if (!(a & 1)) {
				printf("0");
				return 0;
			}
			A[a / 2]++;
		}
		rep(i, N / 2) {
			if (A[i] != 2) {
				printf("0");
				return 0;
			}
			ans = ans << 1;
			if (ans >= mod) ans -= mod;
		}
		printf("%lld", ans % mod);
	}

	Would you please return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int a[50];
inline bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	for(int i=0;i<k;i++)
		ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int res=0;
  rep(i,n)
  {
    int l,r;
    cin>>l>>r;
    res+=r-l+1;
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char ans[2010];
int f(int A,int B,int d=0){
	if(d&&A>B)std::swap(A,B);
	return(B+A)/(A+1);
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int Q=gi();
	while(Q--){
		int A=gi(),B=gi(),C=gi(),D=gi(),a=f(A,B,1);
		if(a==1){
			int st=A>=B;
			for(int i=C;i<=D;++i)putchar('A'+((i-st)&1));
			puts("");
			continue;
		}
		int l=0,r=A+B,mid;
		while(l<r){
			mid=(l+r)>>1;
			int cA=A-mid/(a+1)*a-mid%(a+1),cB=B-mid/(a+1);
			if(cB<=1ll*cA*a)l=mid+1;else r=mid;
		}
		for(int i=C;i<=D;++i){
			if(i<=l)putchar('A'+(i%(a+1)==0));
			else putchar('B'-((A+B-i)%(a+1)==a));
		}puts("");
	}
	return 0;
}


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

typedef unsigned long long ull;
static const int MAX_N = 110;
static const int MAX_W = 100010;
int W[MAX_N];
int V[MAX_N];
ull DP[MAX_N][MAX_W];

int main()
{
  int n, w;
  cin >> n >> w;
  for (int i = 0; i < n; ++i)
  {
    cin >> W[i + 1] >> V[i + 1];
  }

  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; j <= w; ++j)
    {
      if (j < W[i])
      {
        DP[i][j] = DP[i - 1][j];
      }
      else
      {
        DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - W[i]] + V[i]);
      }      
    }
  }

  cout << DP[n][w] << endl;

  return 0;
}


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

	char s[1003];
	char a[] = "s";
	char b[] = "es";

	scanf("%s", s);

	if (s[strlen(s) - 1] == 's')
		strcat(s, b);
	else
		strcat(s, a);

	printf("%s", s);

	return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>
int main(){
  int a,b;
  char c;

  while(1){
    scanf("%d %c %d",&a,&c,&b);
    switch(c){
    case '+':
      printf("%d\n",a+b);
      break;
    case '-':
      printf("%d\n",a-b);
      break;
    case '*':
      printf("%d\n",a*b);
      break;
    case '/':
      printf("%d\n",a/b);
      break;
    default: break;
    }
    if(c == '?') break;
  }
  return 0;
}



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

int main(){
	int r, d, x;
	cin >> r >> d >> x;
	for(int i = 1; i < 11; i++){
		x = r*x-d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# import single number
def import_number():
    return int(input())

# import n line int
def import_int(n):
    return [int(input()) for i in range(n)]

N = import_number()
sum = (1 + N) * N / 2

tmp = int(N / 3)
sum -= (1 + tmp) * tmp / 2 * 3

tmp = int(N / 5)
sum -= (1 + tmp) * tmp / 2 * 5

tmp = int(N / 15)
sum += (1 + tmp) * tmp / 2 * 15

print(int(sum))

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;

  string result = "Good";
  char tmp = 'x';
  for (char c : s) {
    if (c == tmp) {
      result = "Bad";
      break;
    }
    tmp = c;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
 
int main(){
  int N;
  cin>>N;
  int a=N/100;
  int b=(N%100)/10;
  int c=N%10;
  if(a==7||b==7||c==7){
  cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;}
    }


Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 1
	mx := 0
	for i := 1; i <= n; i++ {
		t := i
		c := 0
		for t%2 == 0 {
			c++
			t /= 2
		}
		if mx < c {
			mx = c
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  long long int a[n],i,k=0;
  vector<long long int>b;
  for(i=0;i<n;i++)
  {

      cin>>a[i];
      if(a[i]%2==0)
        b.push_back(a[i]);
  }
  for(i=0;i<b.size();i++)
  {
      if(b[i]%3==0 || b[i]%5==0)
      {
          k+=1;
      }
  }
  if(k==b.size())
    cout<<"APPROVED";
  else
    cout<<"DENIED";
}



Measured memory_bytes: 256
arr = []
n= int(input())
temp=n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])

if temp!=1:
    arr.append([temp, 1])

if arr==[]:
    arr.append([n, 1])

k=[]
for a,s in arr:
    k+=[a]*s
print(str(n)+":",*k,sep=" ")


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll x, a, b;
  cin >> x >> a >> b;
  int exp = a - b;
  if (exp < 0) {
    cout << (-exp > x ? "dangerous" : "safe") << '\n';
  } else {
    cout << "delicious" << '\n';
  }
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void){
    char S[200001];
    char T[200001];

    int num = 0;

    scanf("%s", S);
    scanf("%s", T);

    int i = 0;
    while(*(S+i)!='\0'){
        if(*(S+i)!=*(T+i)){
            num++;
        }
        i++;
    }

    printf("%d\n",num);

    return 0;
}

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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i <= k)
        {
            ans += x;
        }else{
            ans += y;
        }
        
    }
    cout << ans << endl;
}

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

int main() {
    int a, b, k; cin >> a >> b >> k;
    int cnt = 0;
    for (int d = min(a, b); d >= 1; d--) {
        if (a % d == 0 && b % d == 0) {
            if (++cnt == k) {
                cout << d << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, k string
	fmt.Scan(&n, &k)

	c, _ := strconv.Atoi(n)
	s := newSlice(0, c, 1)

	p := 0
	intK, _ := strconv.Atoi(k)
	i := 0
	for i < len(s) {
		if i+intK <= len(s) {
			p++
		}
		i++
	}
	fmt.Println(p)
}

func newSlice(start, count, step int) []int {
	s := make([]int, count)
	for i := range s {
		s[i] = start
		start += step
	}
	return s
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

int main(){
  int n, m;
  std::cin >> n >> m;

  map<int, char> sc;
  for(int cnt = 0; cnt < m; cnt++){
    int idx;
    char str;
    std::cin >> idx >> str;
    if(sc.find(idx - 1) != sc.end()){
      if(sc.at(idx - 1) != str){
        std::cout << -1 << '\n';
        return 0;
      }
    }
    sc.insert(make_pair(idx - 1, str));
  }

  string ans = "-1";
  for(int num = 999; num >= 0; num--){
    string s = to_string(num);
    bool ok_flag = true;
    for(auto idx = sc.begin(); idx != sc.end(); idx++){
      try{
        if(s.at(idx->first) != idx->second){
          ok_flag  = false;
        }
      }catch(out_of_range e){
        ok_flag = false;
      }
    }
    if(s.size() != n) ok_flag = false;
    if(ok_flag) ans = s;
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//Range Sum Query
class Lz_segtree{
public:
    int n;
    ll e=0;
    ll init=0;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,e);
        lz.resize(n*2,init);
    }
    void update_f(ll& d,ll x){
        d+=x;
    }
    ll dat_propergate(ll l,ll r){
        return l+r;
    }
    void lz_propergate(ll& l,ll& r,ll x){
        l+=x,r+=x;
    }
    void eval(int len,int k){
        if(lz[k]!=init) update_f(dat[k],lz[k]);
        if(len>1){
            lz_propergate(lz[k*2+1],lz[k*2+2],lz[k]/2);
        }
        lz[k]=init;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],(r-l)*x);
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat[k]=dat_propergate(dat[2*k+1],dat[2*k+2]);
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return e;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return dat_propergate(vl,vr);
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s-1,t,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s-1,t);
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

int main(){
  int N,T;
  cin>>N>>T;
  
 int res=10000;
  
  for(int i=0;i<N;i++){
    int c,t;
    cin>>c>>t;
    
    if(t<=T)
      res=min(res,c);
  }
  
  if(res==10000)
    cout<<"TLE";
  
  else
    cout<<res;
}
  
  

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

int K;

int main(){
  cin >> K;
  int X = 0;
  int ans = 0;
  int cnt = 1;

  if (K % 2 == 0) ans = -1;
  else{
      rep(i, K){
        X = (X*10 + 7) % K;
      if (X % K == 0) {
        ans = cnt;
        break;
      }
      cnt ++;
    }
  }
  if (X % K == 0)  cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3640
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let a = input.next_i64();
    let b = input.next_i64();

    if a * b <= 0 {
        println!("Zero");
    } else if a > 0 {
        println!("Positive");
    } else if (b - a) % 2 == 0 {
        println!("Negative");
    } else {
        println!("Positive");
    }
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }

    fn next_i64(&mut self) -> i64 {
        return self.next().parse::<i64>().unwrap();
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

#define N_MAX 1000

bool is_combosite[N_MAX + 1];
bool is_prime (long n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (is_combosite[n]) return false;

  long sqrtn = ceil(sqrt(n));

  for (long i = 2; i <= sqrtn; i++) {
    if (n % i == 0) {
      is_combosite[n] = true;
      return false;
    }
  }

  return true;
}

int count_factors (int n, int p) {
  int x = n;
  int count = 0;
  while (x % p == 0) {
    x /= p;
    count++;
  }
  return count;
}

void factorize_and_count (int m, vector<vector<int>> & table) {
  for (int i = 1; i <= m; i++) {
    if (m % i == 0 && is_prime(i)) table.at(m).at(i) = count_factors(m, i);
  }
}

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

  vector<vector<int>> table(N_MAX + 1, vector<int>(N_MAX + 1, 0));

  for (int i = 1; i <= N; i++) {
    factorize_and_count(i, table);
  }

  mp::cpp_int answer = 1;
  for (int i = 1; i <= N; i++) {
    int s = 0;
    for (int j = 1; j <= N; j++) {
      s += table.at(j).at(i);
    }
    answer *= mp::cpp_int(1 + s);
  }

  cout << (answer % mp::cpp_int(1'000'000'007)) << "\n";
}


Measured memory_bytes: 4224
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    read2(n,k);
    int ans=0;
    fr(i,n){
        read(x);
        if(x>=k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int tmp_len = 0;
  int max_len = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'I') {
      tmp_len++;
    } else {
      tmp_len--;
    }
    max_len = max(max_len, tmp_len);
  }
  cout << max_len << endl;
  return 0;
}


Measured memory_bytes: 3556
N = int(input())
a = tuple(map(int, input().split()))

n = max(a)
r = 0
M = 0
mid = n / 2
diff = 1000000000
for x in a:
    if x == n:
        continue
    if diff > abs(mid - x):
        diff = abs(mid - x)
        r = x

print(n, r)


Measured memory_bytes: 14184
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 13:58:43 2020

@author: 藤原聖士
"""

A=int(input())
B=int(input())
C=int(input())
X=int(input())

A_count=0
B_count=0
count=0

while X-(500*A_count)>=0:
    while X-(500*A_count)-(100*B_count)>=0:
        if (X-(500*A_count)-(100*B_count))/50<=C:
            count+=1
        B_count+=1
        if B_count>B:
            break
    A_count+=1
    if A_count>A:
        break
    B_count=0

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;
typedef long long ll;

int N, M;
bool used[10] = {};//used[i]: iを使う
int cost[10] = { 0,2,5,5,4,5,6,3,7,6 };
string n_to_s = "0123456789";
string dp[10001];//dp[i]:i本の中で作れる数の各桁の数字の内訳

bool comp_str(string a, string b) {
	//aがbより大きい数字を作れるのならtrue そうでないのならfalse
	int cnt_a[10] = {}, cnt_b[10] = {};
	for (int i = 0; i < a.size(); i++) {
		cnt_a[a[i] - '0']++;
	}
	for (int i = 0; i < b.size(); i++) {
		cnt_b[b[i] - '0']++;
	}

	if (a.size() > b.size())return true;
	else if (a.size() < b.size())return false;

	for (int j = 9; j >= 0; j--) {
		if (cnt_a[j] == 0 && cnt_b[j] == 0) {
			continue;
		}
		else if (cnt_a[j] > cnt_b[j])return true;
		else if (cnt_a[j] < cnt_b[j])return false;
	}

	return true;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		used[a] = true;
	}

	for (int i = 0; i <= N; i++) {
		if (dp[i] == "" && i != 0)continue;
		for (int j = 1; j <= 9; j++) {
			if (used[j] && i + cost[j] <= N) {
				if (dp[i + cost[j]] == "") {
					dp[i + cost[j]] = dp[i] + n_to_s[j];
				}
				else {
					if (!comp_str(dp[i + cost[j]], dp[i] + n_to_s[j])) {
						dp[i + cost[j]] = dp[i] + n_to_s[j];
					}
				}
			}
		}
	}

	//出力
	int cnt[10] = {};
	for (int i = 0; i < dp[N].size(); i++) {
		cnt[dp[N][i] - '0']++;
	}
	for (int i = 9; i >= 1; i--) {
		for (int j = 0; j < cnt[i]; j++) {
			cout << i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 45568
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    int x; cin>>x;

    int g=gcd(x,360ll);
    cout<<360/g<<endl;
    
    
    
    
}




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

Measured memory_bytes: 3612
#include<cstdio>
#include<cstdlib>
#include<cstring>

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

using namespace std;

int mat[625][626];

bool solve(int n){
	bool used[625]={};
	rep(j,n){
		int i;
		for(i=0;i<n;i++) if(!used[i] && mat[i][j]==1) break;
		if(i<n){
			used[i]=true;
			rep(k,n) if(i!=k && mat[k][j]==1) {
				rep(l,n+1) mat[k][l]=(mat[k][l]+mat[i][l])&1;
			}
		}
	}

	rep(i,n) if(!used[i] && mat[i][n]==1) return false;

	return true;
}

int main(){
	for(int m,n,d;scanf("%d%d%d",&n,&m,&d),m;){
		int a[25][25];
		rep(i,m) rep(j,n) scanf("%d",a[i]+j);

		memset(mat,0,sizeof mat);
		rep(i,m) rep(j,n) {
			mat[i*n+j][i*n+j]=1;
			rep(ii,m) rep(jj,n) if(abs(ii-i)+abs(jj-j)==d) {
				mat[ii*n+jj][i*n+j]=1;
			}
			mat[i*n+j][m*n]=a[i][j];
		}

		puts(solve(m*n)?"1":"0");
	}

	return 0;
}

Measured memory_bytes: 2268
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut a_s = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<std::collections::BinaryHeap<_>>();

    for _ in 0..m {
        let max_a = a_s.pop().unwrap();
        a_s.push(max_a/2);
    }

    println!("{}", a_s.iter().fold(0, |s, &x| s+x));
}


Measured memory_bytes: 8444
#include <cstdio>
#include <set>

using namespace std;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  set<int> d[ 2 ];
  int s;
  int i;

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    s = 0;
    d[ 0 ].clear ( ); d[ 1 ].clear ( );
    for ( i = 0; i < n; ++i )
    {
      int t;

      scanf ( "%d", &t );
      d[ 0 ].insert ( t );
    }
    for ( i = 1; i <= n * 2; ++i )
    {
      if ( d[ 0 ].find ( i ) != d[ 0 ].end ( ) ) continue ;

      d[ 1 ].insert ( i );
    }

    i = *( d[ 0 ].begin ( ) );
    d[ 0 ].erase ( d[ 0 ].begin ( ) );
    for ( s = 1; !d[ 0 ].empty ( ) && !d[ 1 ].empty ( ); s = !s )
    {
      set<int>::iterator it = d[ s ].upper_bound ( i );

      if ( it == d[ s ].end ( ) )
      {
        i = 0;
        continue ;
      }

      i = *it;
      d[ s ].erase ( it );
    }

    printf ( "%zu\n%zu\n", d[ 1 ].size ( ), d[ 0 ].size ( ) );
  }

  return ( 0 );
}

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

int main(){
    int N;
    long long sum=0;
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        if(i%3!=0 && i%5 !=0){
            sum+=i;
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1732