akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <bitset>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
#define	pr_line(arr,s,e) for(ll abc = s;abc < e;abc++){ if(abc != s) printf(" ");cout << arr[abc];}puts("");
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rui(n) scanf("%u",&n)
#define rui2(a,b) scanf("%u %u",&a,&b)
#define rui3(a,b,c) scanf("%u %u %u",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define debug(str,x) cout << str << ":" << x << endl
#define ll long long
#define int64 __int64
#define ui unsigned int

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-9-29 
//Author：HarryBlackCat

string str;

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	while(cin >> str){
		int ans = 0;
		for(int i = 0;i < str.size();i++){
			ans = ans * 10 + str[i] - '0';
		}
		
		int tp = 111;
		for(int i = 1;i <= 9;i++){
			if(tp * i >= ans){
				pr(tp * i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
num = input()
N, M = [int(x) for x in num.split()]

dic = []
for n in range(N):
    num = input()
    a, b = [int(x) for x in num.split()]
    dic.append((a, b))

sort = sorted(dic, key=lambda x: x[0])
count = 0
money = 0
ind = 0
while count < M:

    if (M - count) > sort[ind][1]:
        money += sort[ind][0] * sort[ind][1]
        count += sort[ind][1]
    else:
        money += sort[ind][0] * (M - count)
        count += (M - count)

    ind += 1
print(money)


Measured memory_bytes: 18892
#include<iostream>
#include<set>
using namespace std;
multiset<string> s;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	while(x--)s.insert("a");
	while(y--)s.insert("b");
	while(z--)s.insert("c");
	while(s.size()>1)
	{
		string x=*s.begin()+*--s.end();
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(x);
	}
	cout<<*s.begin()<<endl;
	return 0;
}


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

int main() {
    string S[3];
    rep(i, 3) cin >> S[i];

    int idx[3] = {};
    int turn = 0;
    while (idx[turn] < S[turn].size()) {
        int now = idx[turn];
        idx[turn]++;
        if (S[turn][now] == 'a') turn = 0;
        else if (S[turn][now] == 'b') turn = 1;
        else turn = 2;
    }

    string ans;
    if (turn == 0) ans = "A";
    else if (turn == 1) ans = "B";
    else ans = "C";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn*10];
map<int,int>m;
bool judge[maxn*10];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,temp;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	sort(a+1,a+1+n);
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		if (judge[a[i]]==1)   continue;
		ans++;
		if (m[a[i]]>=2)
		{
			judge[a[i]]=1;
			ans--;
		}
		int j=2*a[i];
		while (j<=a[n])
		{
			judge[j]=1;
			j+=a[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13996
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   string S;
   cin>>S;
   int count0=0;int count1=0;
   for(int i=0;i<S.size();i++){
      if(S[i]=='0'){count0++;}
      if(S[i]=='1'){count1++;}
   }
   cout<<min(count0,count1)*2<<endl;
return 0;}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);

    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) {
        cin >> B[i];
    }
    rep(i, N - 1) {
        cin >> C[i];
    }

    int ans = 0;
    rep(i, N) {
        ans += B[A[i] - 1];
        if(i > 0 && A[i] - A[i - 1] == 1) {
            ans += C[A[i - 1] - 1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> a(N);
	rep(i, N) cin >> a[i];

	bool allzero = true;
	rep(i, N){
		if(a[i] != 0) allzero = false;
	}

	if(allzero){
		cout << "Yes" << endl;
		return 0;
	}

	if(N % 3 > 0) {
		cout << "No" << endl;
		return 0;
	}

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

	int k = N / 3;
	if(a[0] == 0){
		if(a[k-1] == 0 && a[k] == a[N-1]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if(a[k-1] == a[0] && a[2*k-1] == a[k] && a[N-1] == a[2*k]){
			if((a[0] ^ a[k]) == a[2*k]){
				cout << "Yes" << endl;
			}else{
				cout << "No" <<endl;
			}
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 200000;
typedef pair<int,int> P;
int main()
{
  int n,i,t=0;
  P a[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i].second >> a[i].first;
  sort(a,a+n);
  for(i=0;i<n;i++){
    t+=a[i].second;
    if(t>a[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;


int main(){
    ll n;
    cin >> n;
    
    ll ans = 1;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i]==0) {
            cout << "0" << endl;
            return 0;
        }
    }
    
    rep(i, n) {
        ll x = a[i];
        
        if (__int128(ans)*x>INF) {
            cout << "-1" << endl;
            return 0;
        }
        ans *= x;
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4044
n = int(input())
s = [int(input()) for i in range(n)]

sum_s = sum(s)
if sum_s % 10 != 0:
    print(sum_s)
    exit()

if all([1 if x % 10 == 0 else 0 for x in s]):
    print(0)
else:
    for i in range(n):
        if s[i] % 10 == 0:
            s[i] = 101
    s.sort()
    ans = sum_s - s[0]
    print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int r;
int main(){
	scanf("%s",&s);
	int len=strlen(s);
	r=len;
	for(int i=0;i<=len-1;i++)
		if(s[i]!=s[i+1])
			r=min(r,max(i+1,len-i-1));
	cout<<r<<endl;
	return 0;
} 

Measured memory_bytes: 384
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
#la = [li[0]][li[1]]

cnt = 0

for i in range(n):
    a = list(map(int, input().split()))
    tmp = c
    for j in range(0, m):
        tmp += a[j] * b[j]
    if (tmp > 0):
        cnt += 1

print(cnt)

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

const ll INF = 1001001001;

const double PI=3.141592653;

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}





int main(){
  int r; cin>>r;
  cout<<fixed<<setprecision(5);
  cout<<2*PI*r<<endl;
  return 0;
  
}



Measured memory_bytes: 3776
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = (int) 1e5;

struct edge
{
	int u, v;

	edge() { }
	edge(int _u, int _v): u(_u), v(_v) { }
};

int n;

edge A[MAXN + 5], B[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i) A[i].u = read<int>(), A[i].v = read<int>();
	for(int i = 1; i < n; ++i) B[i].u = read<int>(), B[i].v = read<int>();
}

namespace SET
{
	int fa[MAXN + 5];

	inline void init(int N) { for(int i = 1; i <= N; ++i) fa[i] = i; }
	inline int get_fa(int u) { return u == fa[u] ? u : fa[u] = get_fa(fa[u]); }
	inline void set_fa(int u, int v) { fa[get_fa(u)] = get_fa(v); }
}

inline void solve()
{
	static queue<pii> q;
	static unordered_map<int, int> adj[MAXN + 5];

	auto add_edge = [&] (int u, int v)
	{
		++adj[u][v];
		++adj[v][u];
		if(adj[u][v] == 2) q.emplace(u, v);
	};

	auto erase_edge = [&] (int u, int v)
	{
		if(SZ(adj[u]) < SZ(adj[v])) swap(u, v);
		SET::set_fa(v, u);
		for(auto it : adj[v]) if(it.snd == 1)
			if(SET::get_fa(it.fst) != u) add_edge(u, SET::get_fa(it.fst));
		adj[v].clear();
	};

	for(int i = 1; i < n; ++i) add_edge(A[i].u, A[i].v);
	for(int i = 1; i < n; ++i) add_edge(B[i].u, B[i].v);

	SET::init(n);
	int cnt = 0;
	while(!q.empty())
	{
		auto it = q.front();
		q.pop();
		it.fst = SET::get_fa(it.fst);
		it.snd = SET::get_fa(it.snd);
		if(it.fst != it.snd) ++cnt, erase_edge(it.fst, it.snd);
	}
	puts(cnt == n - 1 ? "YES" : "NO");
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 29196
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
   char s[200001];
   scanf("%s",s);
   long long int count[26];
   for(int i=0;i<26;i++)
   {
   	count[i]=0;
   }
   long long int n = strlen(s);
   for(int i=0;s[i]!='\0';i++)
   {
   	count[s[i]-'a']++;
   }
   long long int ans=0,l=0;
   for(int i=0;i<26;i++)
   {
   	l = l+((count[i]*(count[i]-1))/2);
   }
   ans = ((n*(n-1))/2);
   ans = 1+ans - l;
   cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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



struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main(){
  int n; cin >> n;
  int m; cin >> m;
  priority_queue<int>a;
  int sum = 0;
  REP(i, n) {
    int x; cin >> x; a.push(x); sum += x;
  }

  bool flag = true;
  REP(i, m) {
    int x = a.top(); a.pop();
    if(4 * m * x < sum){
      flag = false;
      break;
    }
  }
  flag ? yes : no;
  return 0;
}

Measured memory_bytes: 256
S  = input()
if (int(S[:2]) == 0 or int(S[:2]) >= 13) and 1 <= int(S[2:]) <= 12:
    print('YYMM')
elif (int(S[2:]) == 0 or int(S[2:]) >= 13) and 1 <= int(S[:2]) <= 12 :
    print('MMYY')
elif 1 <= int(S[2:]) <= 12 and 1 <= int(S[:2]) <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		boolean prime[] = new boolean[1000000];
		for(int i=0;i<prime.length;i++)prime[i]=true;
		prime[0]=false;prime[1]=false;
		for(int s=0;s<prime.length;s++){
			if(prime[s])
				for(int i=s+s;i<prime.length;i+=s)prime[i]=false;
		}
		while(in.hasNext()){
			int n = in.nextInt(),cnt=0;
			for(int i=0;i<=n;i++)if(prime[i])cnt++;
			System.out.println(cnt);
		}
	}
}

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

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int T=0, H=0, n=0;
		String[] animal = new String[2];
		n = Integer.parseInt(br.readLine());

		for(int i=0; i<n; i++)
		{
			animal = br.readLine().split(" ");
			if(animal[0].compareTo(animal[1]) == 0)
			{
				T++;
				H++;
			}
			else if(animal[0].compareTo(animal[1]) > 0)	T = T + 3;
			else if(animal[0].compareTo(animal[1]) < 0)	H = H + 3;
		}
		System.out.println(T + " " + H);
	}
}



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

using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

int main() {
	FAST_IO();
	int n;
	cin >> n;
	vector<int> c(n),v(n);
	
	for(int i = 0; i < n; ++i)cin >> v[i];
	for(int i = 0; i < n; ++i)cin >> c[i];
	
	int max = 0;
	for(int i = 0; i < (1<<n); ++i){
		int x = 0;
		int y = 0;
		for(int j = 0; j < n; ++j){
			if((i>>j)&1){
				x += v[j];
				y += c[j];
			}
		}
		max = std::max(max, x-y);
	}
	
	cout << max << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=200;
const int W=1000000000;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	vector<string> v;
	int lmax=0,l=0;
	cin >> s >> t;
	string sb;
	int i,ok,okk=0;
	for(i=s.size()-t.size();i>=0;i--){
		sb = s.substr(i,t.size());
		ok=1;
		for(int j=0;j<t.size();j++){
			if(sb[j]!=t[j] && sb[j]!='?'){
				ok=0;
			}
		}
		if(ok==1){
			okk=1;
			string k;
			k=s;
			for(int j=0;j<s.size();j++){
				if(j>=i && j+1<=i+t.size()){
					k[j] = t[j-i];
				}else{
					if(s[j]=='?'){
						k[j] = 'a';
					}else{
						k[j] = s[j];
					}
				}
			}
			v.push_back(k);
		}
	}
 
	if(okk==0){
		cout << "UNRESTORABLE" << endl;
	}else{
		string ans;
		ans = v[0];
		for(i=1;i<v.size();i++){
			if(ans>v[i])ans=v[i];
		}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>s;
    if(n%2==1)
    {
        cout<<"No\n";
    }
    else
    {
        for(i=0,j=n/2;j<n;i++,j++)
        {
            if(s[i]!=s[j])
            {
                cout<<"No\n";
                return 0;
            }
        }
        cout<<"Yes\n";
    }
    return 0;
}



Measured memory_bytes: 256
s = input()

a=int(s[0]+s[1])
b=int(s[2]+s[3])

if not(0<a<=12) and not(0<b<=12):
    print('NA')
elif not(0<a<=12) and 0<b<=12:
    print('YYMM')
elif 0<a<=12 and not(0<b<=12):
    print('MMYY')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ans = 0;
        int[] a = new int[n+1];
        for(int i = 1; i <= n; i+=2){
            for(int j = 1; j <= n/2; j++){
                if(i%j==0){a[i]++;}
            }
            if(a[i] == 7){ans++;}
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
//#include <complex>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e9;
//const ll MOD = 1e9 + 7;
//const double EPS = 1e-9;
//const double PI = acos(-1);
 
void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll> a(n + 1);
    for (int i = 0; i < n + 1; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i) {
        ll b;
        cin >> b;
        ll k = min(b, a[i]);
        ans += k;
        b -= k;
        k = min(b, a[i + 1]);
        a[i + 1] -= k;
        ans += k;
    }
    cout << ans;
}   
 
 
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout); 
    solve();
}

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

int main() {
  int n;
  cin>>n;
  long long ans = 0;
  for (int x=1; x<=n; x++) {
    int cnt = n / x;
    ans += 1LL * cnt * (cnt + 1) / 2 * x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
	int n;
	sd(n);
	if(n<1000)printf("ABC\n");
	else printf("ABD\n");
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys

    readline = sys.stdin.readline

    s1 = readline().rstrip()
    s2 = readline().rstrip()

    ls1 = len(s1)
    ls2 = len(s2)

    # 配るDP
    # dp[i][j]はi文字目までの文字列s1とj文字目までの文字列s2の編集距離
    inf = 10 ** 3
    dp = [[inf] * (ls2 + 1) for _ in [0] * (ls1 + 1)]
    for i in range(ls1 + 1):
        dp[i][0] = i
    for j in range(ls2 + 1):
        dp[0][j] = j

    for i in range(ls1):
        for j in range(ls2):
            res = 0 if s1[i] == s2[j] else 1
            dp[i + 1][j + 1] = min(dp[i][j + 1] + 1,
                                   dp[i + 1][j] + 1,
                                   dp[i][j] + res)
    print(dp[ls1][ls2])


main()



Measured memory_bytes: 43088
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n, t;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		vector<pair<ll, ll>> v;
		for (ll i = 1; i <= n&&cin >> t; ++i)
			v.emplace_back(t, i);
		sort(v.begin(), v.end());
		for (auto i : v)
			cout << i.second << ' ';
		cout << endl;
	}
}
/*
3
2 3 1

5
1 2 3 4 5

8
8 2 7 3 4 5 6 1
*/

Measured memory_bytes: 2544
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val monsterHitPoint = sc.nextInt()
    val servalAttackPoint = sc.nextInt()

    val ans =
      Math.ceil(monsterHitPoint.toDouble / servalAttackPoint.toDouble).toInt

    println(s"$ans")
  }
}


Measured memory_bytes: 27452
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

c=Counter(a)
ans=1
if n%2==1:
    for i in range(n):
        if i%2==1 and c[i]>0:
            ans=0
            break
        elif i%2==0 and c[i]==2:
            ans*=2
            ans%=1000000007
        if i==0 and c[i]!=1:
            ans=0
            break
else:
    for i in range(n):
        if i%2==0 and c[i]>0:
            ans=0
            break
        elif i%2==1 and c[i]==2:
            ans*=2
            ans%=1000000007
print(ans)

Measured memory_bytes: 93612
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n, k; cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2) {
    cout << -1 << '\n'; return 0;
  }

  int diff = (n - 1) * (n - 2) / 2 - k;
  cout << n - 1 + diff << '\n';
  for (int i = 2; i <= n; ++i) {
    cout << 1 << " " << i << '\n';
  }

  if (diff == 0) {
    return 0;
  }
  for (int i = 2; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      cout << i << " " << j << '\n';
      --diff;
      if (diff == 0) {
        return 0;
      }
    }
  }

  return 0;
}

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();
        if (x == 3 || x == 5 || x == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
    for (T &i : v) os << i << ' ';
    return os;
}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n, m;
    cin >> n >> m;
    scc_graph scc(n);
    while (m--) {
        ll a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }

    auto v = scc.scc();
    co(v.size());
    for (auto &i : v) co(i.size(), i);

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n, x, y;
    cin >> n >> x >> y;

    cout << (n + x - 1) / x * y;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	ll n;
 	cin >> n;
 	ll minn = 1e18;
 	for(ll x=1;x<=sqrt(n);x++)
 	{
 		if(n%x) continue;
 		ll y = n / x;
 		minn = min(minn,x+y-2);
 	}
 	cout << minn;
	return 0;
}


Measured memory_bytes: 256
X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(X[K-1])

Measured memory_bytes: 3060
/**
 *		author:  zvm
 *		created: 25.09.2020 17:23:20
**/

#include <bits/stdc++.h>

using namespace std ;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);	

	string s ;
	cin >> s ;

	auto evaluate = [&]( string s ) {
		stringstream ss{s};
		char op ;
		int val, res = 0 ;
		while( ss >> op >> val ) {
			res = ( op == '+' ? res+val : res-val );
		}
		return res == 7 ;
	};

	for( int i = 0 ; i < 8 ; ++i ) {
		string t = "+" + s.substr(0,1) ;
		for( int j = 0 ; j < 3 ; ++j ) {
			if( i&(1<<j) ) {
				t += "-" ;
			}
			else {
				t += "+" ;
			}
			t.push_back(s[j+1]);
		}
		if( evaluate(t) ) {
			cout << t.substr(1) << "=7" << endl ;
			return 0 ;
		}
	}

	assert(false);
}


Measured memory_bytes: 3620
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n,k;
   cin >> n >> k;
   vector<int> a(n),w(n);
   for(int i=0; i<n; i++){
       cin >> a[i] >> w[i];
   }
   int dp[n+1][k+1]={0};
   for(int i=0; i<=n; i++){
       for(int j=0; j<=k; j++){
           if(i==0 || j==0)dp[i][j]=0;
           else{
               if(a[i-1]<=j){
                   dp[i][j]=max(w[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j]);
               }
               else{
                   dp[i][j]=dp[i-1][j];
               }
           }
       }
   }
//   for(int i=0; i<=n; i++){
//         for(int j=0; j<=k; j++)cout << dp[i][j] << " ";
//         cout << endl;
//   }
    cout << dp[n][k] << endl;

   return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int ans;
  cin >> s;
  ans = 0;
  for(int i=0;i<6;i++){
    if(s.at(i)=='1'){
      ans += 1;
    }
  }
    cout << ans << 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 n = Integer.parseInt(sc.next());
        Integer[] h = new Integer[n];
        int maxHeight = 0;
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
            maxHeight = Math.max(maxHeight, h[i]);
        }

        int result = 0;
        for (int j = 0; j < maxHeight; j++) {
            boolean edgeFlag = true;
            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    h[i]--;
                    edgeFlag = false;
                } else if (!edgeFlag) {
                    result++;
                    edgeFlag = true;
                }
            }
            if (!edgeFlag) {
                result++;
            }
        }

        System.out.println(result);
    }
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int n,m;
	int x[E5];
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> x[i];
	}
	sort(x,x+m);
	int v[E5];
	for (int i = 0; i < m-1; ++i) {
		v[i] = x[i+1]-x[i];
	}
	sort(v,v+m-1);
	int ans = 0;
	for (int i = 0; i < m-n; ++i) {
		ans += v[i];
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

const int mod = 998244353, maxn = 3000010;
long long n, a, b, k, ans;

inline long long fpow(long long a, long long x){
    long long ret = 1;
    while (x) {
        if (x & 1) ret = ret * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return ret;
}

long long inv[maxn], fac[maxn];

inline void init() {
	fac[0] = 1;
	for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;
    inv[maxn - 1] = fpow(fac[maxn - 1], mod - 2);
    for (int i = maxn - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}

long long C(long long n, long long m) {
    if (n < m) return 0;
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	init();
	scanf ("%lld %lld %lld %lld", &n, &a, &b, &k);
	for(int i = 0; i <= n; i++) {
        if ((k - a * i < 0) || ((k - a * i) % b != 0)) continue;
        long long x = (k - a * i) / b;
        if (x > n) continue;
        ans = (ans + C(n, i) * C(n, x) + mod) % mod;
    }
    printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll a,b,n;
    cin >> a >> b >> n;
    if(n >= b-1){
        cout << floor(a * (b - 1)/b) << endl;
    }
    else
    {
        cout << floor(a * n/b) << endl;
    }
}



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

using namespace std;

const int MAXN = 2E5;
vector<int> adjList[MAXN + 10];
int cnt[MAXN + 10];
int ans[MAXN + 10];

void solve(int root, int sum, int par)
{
    ans[root] = sum + cnt[root];
    for (int adj : adjList[root])
    {
        if (adj != par)
        {
            solve(adj, sum + cnt[root], root);
        }
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    for (int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        cnt[p] += x;
    }
    solve(1, 0, -1);
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 27136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi h(n); rep(i, n) cin >> h[i];
	vector<ll> dp(n, 1e18);
	dp[0] = 0;
	rep(i, n){
		if(i) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1408
sx,sy,tx,ty = gets.split.map(&:to_i)

puts 'R'*(tx - sx).abs +
  'U'*(ty - sy).abs +
  'L'*(tx - sx).abs +
  'D'*(ty - sy + 1).abs +
  'R'*(tx - sx + 1).abs +
  'U'*(ty - sy + 1).abs +
  'LU' +
  'L'*(tx - sx + 1).abs +
  'D'*(ty - sy + 1).abs +
  'R'


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    int N = S.size()+1;
    int mode=0; // up
    int cnt=0;
    vi vec;
    rep(i,N-1){
        if (mode==0 && S[i]=='<') cnt++;
        else if(mode==1 && S[i]=='>') cnt++;
        else if(mode==0 && S[i]=='>') vec.pb(cnt), cnt=1, mode=1;
        else if(mode==1 && S[i]=='<') vec.pb(cnt), cnt=1, mode=0;
    }
    vec.pb(cnt);
    int V = vec.size();
    ll ans=0;
    int now=0;
    rep(i,V){
        if (i&1){
            now = max(now,vec[i]);
            ans+=now;
            ans+=(ll)(vec[i]-1)*vec[i]/2;
            now=0;
        }else{
            ans+=(ll)(now+vec[i]-1)*vec[i]/2;
            now+=vec[i];
        }
    }
    ans+=now;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4852
A, B, C, D, E, F = map(int, input().split())

def check_weight(a, b, c, d):
    if 100*A*a + 100*B*b + C*c + D*d <= F:
        return True
    else:
        return False

def check_conc(a, b, c, d):
    if C*c + D*d <= E * (A*a + B*b):
        return True
    else:
        return False

def check(a, b, c, d):
    if check_weight(a, b, c, d) and check_conc(a, b, c, d):
        return True
    else:
        return False

max_conc = 0
max_sugar_water = 0
max_sugar = 0

for a in range(F//(100*A) + 1):
    for b in range((F - 100*A*a)//(100*B) + 1):
        for c in range((F - 100*A*a - 100*B*b)//C + 1):
            for d in range((F - 100*A*a - 100*B*b - C*c)//D + 1):
                sugar = C*c + D*d
                water = 100*A*a + 100*B*b
                if water + sugar == 0:
                    continue
                if check(a, b, c, d) and max_conc <= 100*sugar/(water + sugar):
                    max_conc = 100*sugar/(water + sugar)
                    max_sugar = sugar
                    max_sugar_water = water + sugar

print(max_sugar_water, max_sugar)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h, "");
    for(int i=0; i<h; i++){cin >> s[i];}

    int cnt=0;
    rep(sr, (1<<h))rep(sc, (1<<w)){
        int ecnt=0;
        // 1マスずつ探索
        rep(i, h)rep(j, w){
            // それぞれの行、列のビットが立っているか確認
            // 立っていればcontinue、すなわちそのマスを削除して他のマスをカウント
            if(sr >> i & 1) continue;
            if(sc >> j & 1) continue;
            if(s[i][j]=='#') ecnt++;
        }
        if(ecnt==k) cnt++;
    }
    out(cnt);

}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,a,b;
    lli ans=0;
    lli mem,now;
    cin>>n>>a>>b;
    cin>>mem;
    rep(i,n-1){
        cin>>now;
        if((now-mem)*a>b){
            ans+=b;
        }
        else{
            ans+=(now-mem)*a;
        }
        mem=now;
    }
    out(ans);
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N = iin()
XL = sorted([iln() for _ in range(N)], key=lambda x:x[0]+x[1])

prev_r = XL[0][0]+XL[0][1]
ans = 1
for i in range(1, N):
    if prev_r <= XL[i][0]-XL[i][1]:
        ans += 1
        prev_r = XL[i][0]+XL[i][1]
print(ans)



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

int main() {
  string S;
  cin >> S;
  int COUNT = 0;
  int ZANTEI = 0;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'A'|| S.at(i) == 'C'||
        S.at(i) == 'G'|| S.at(i) == 'T')
      COUNT++;
    else {
      ZANTEI = max(ZANTEI,COUNT);
      COUNT = 0;
    }
  }
  cout << max(ZANTEI,COUNT) << endl;      
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  int tmp;
  rep(i,N){
    cin >> tmp;
    mp[tmp]++;
  }
  vector<int> nums;
  for(auto m:mp){
    nums.pb(m.second);
  }
  sort(all(nums),greater<int>());
  int oksum = 0;
  rep(i,min(K,(int)nums.size())){
    oksum += nums[i];
  }
  cout << N - oksum << endl;

  return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

bool comp(pair<int,int> u, pair<int,int> v) {
    return (u.second - u.first) < (v.second - v.first);
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;

    for (int i = 0; i < N - 2; i++) {
        if (S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
int a[1050], cnt[1050], n, m, b;
int main(){
    cin >> n >> m;
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int j = 0;j < m;j++){
	cin >> b;
	for(int i = 0;i < n;i++){
	    if(a[i] <= b){
		cnt[i]++;
		break;
	    }
	}
    }
    cout << max_element(cnt, cnt + n) - cnt + 1 << endl;
    return 0;
}

Measured memory_bytes: 1168