akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int x,y,a,b,c;
	std::cin >> x >> y >> a >> b >> c;
	std::vector<int> A(a),B(b),C(c);
	for(auto&i:A) std::cin >> i;
	for(auto&i:B) std::cin >> i;
	for(auto&i:C) std::cin >> i;
	std::sort(all(A),std::greater<>());
	std::sort(all(B),std::greater<>());
	std::sort(all(C),std::greater<>());
	int i=x,j=y,k=0;
	const int INF=1e15;
	while(k<c) {
		int xx=(i==0)?INF:A[i-1];
		int yy=(j==0)?INF:B[j-1];
		int zz=C[k];
		if(zz>xx || zz>yy) {
			if(xx<yy) {
				i--;
				k++;
			} else {
				j--;
				k++;
			}
		} else break;
		if(i==0 && j==0) break;
	}
	int sum=0;
	rep(xx,i) {
		sum+=A[xx];
	}
	rep(xx,j) {
		sum+=B[xx];
	}
	rep(xx,k) {
		sum+=C[xx];
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 100100;
int dp[N];
VI child[N];

const int DEBUG = 0;

void dfs(int v) {
  VI packed;
  for (auto w: child[v]) {
    dfs(w);
    packed.push_back(dp[w]);
  }
  sort(packed.rbegin(), packed.rend());
  int mi = 0;
  REP(i, 0, child[v].size()) {
    mi = max(mi, packed[i] + i + 1);
  }
  dp[v] = mi;
  if (DEBUG) {
    cerr << "dp[" << v << "]=" << mi << endl;
  }
}

int main(void){
  int n;
  cin >> n;
  VI a(n - 1);
  REP(i, 0, n - 1) {
    cin >> a[i];
    a[i]--;
  }
  REP(i, 0, n - 1) {
    child[a[i]].push_back(i + 1);
  }
  if (DEBUG) {
    REP(i, 0, n) {
      cerr << "child[" << i << "]:";
      for (auto j: child[i]) {
	cerr << " " << j;
      }
      cerr << endl;
    }
  }
  dfs(0);
  cout << dp[0] << endl;
}


Measured memory_bytes: 17408
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = list(STR())
t = list(set(s))
u = Counter(s)
v = []
for i in t:
    v.append(u[i] + 1)
ans = 1
for i in range(len(t)):
    ans *= v[i]
    ans %= mod
ans -= 1
print(ans % mod)

Measured memory_bytes: 70764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

int main() {
	string n;
	cin >> n;
	ll ans = 0;
	int k = 0;
	reverse(n.begin(), n.end());
	n += '0';
	vector<vector<int>>dp(n.size() + 1, vector<int>(2));
	for (int i = 0; i < n.size() + 1; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n.size(); i++) {
		for (int j = 0; j < 2; j++) {
			int c = n[i] - '0';
			c += j;
			if (c < 10) {
				dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + c);
			}
			if (c > 0) {
				dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + (10 - c));
			}
		}
	}
	cout << dp[n.size()][0] << endl;
	return 0;
}

Measured memory_bytes: 55940
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int K=1000000007;
int n,ans;
int Pow(int A,int B)
{
	int res=1;
	while (B)
	{
		if (B&1) res=(LL)res*A%K;
		A=(LL)A*A%K;
		B>>=1;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	ans=(Pow(10,n)-Pow(9,n)*2ll+Pow(8,n)+K*2)%K;
	printf("%d\n",ans);
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	int r[n+5],g[n+5],b[n+5];
	r[0]=0;
	g[0]=0;
	b[0]=0;
	for (int i = 0; i < n; ++i)
	{
		r[i+1]=r[i];
		g[i+1]=g[i];
		b[i+1]=b[i];
		if (s[i]=='R')
		{
			++r[i+1];
		}
		else if (s[i]=='G')
		{
			++g[i+1];
		}
		else ++b[i+1];
	}
	long long ans=0;
	for (int i = 1; i < n-1; ++i)
	{
		if (s[i]=='R')
		{
			ans+=g[i]*(b[n]-b[i]);
			ans+=b[i]*(g[n]-g[i]);
		}
		else if (s[i]=='G')
		{
			ans+=b[i]*(r[n]-r[i]);
			ans+=r[i]*(b[n]-b[i]);	
		}
		else
		{
			ans+=r[i]*(g[n]-g[i]);
			ans+=g[i]*(r[n]-r[i]);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int j=0;
		while (1)
		{
			++j;
			if (i+2*j>=n)
			{
				break;
			}
			if (s[i]==s[i+j]) continue;
			if (s[i+j]==s[i+2*j]) continue;
			if (s[i+2*j]==s[i]) continue;
			--ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int k,x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>k>>x;
    for(int i=x-k+1;i<=x;i++)
        cout<<i<<" ";
    for(int i=x+1;i<=x+k-1;i++)
        cout<<i<<" ";
    return 0;
}


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

const int MAX = 100000;
int main() {
	int N;
	static int A[MAX + 2]; // 最初と最後の原点も観光スポットと見做す
	cin >> N;
	for (int i = 1;i <= N;i ++) cin >> A[i];
	A[0] = 0;
	A[N + 1] = 0;
	int sum = 0;
	for (int i = 0;i <= N;i ++) {
		sum += abs(A[i + 1] - A[i]);
	}
	int dif;
	for (int i = 1;i <= N;i ++) {
		dif = abs(A[i + 1] - A[i - 1]) - (abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]));
		cout << sum + dif;
		if (i < N) cout << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

全ての座標について、1個飛ばした時の距離と飛ばさないときの距離の差を覚えておけばいい
後はそれを総和から引けば求まる
*/

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A.begin(), A.end());
	int base = (sum + 4 * M-1) / (4 * M);
	int cnt = 0;
	for (int i = N - 1; i >= 0; --i) {
		if (A[i] >= base) {
			++cnt;
		}
	}
	if (cnt >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
'use strict';

const lines = [];
require('readline').createInterface({ input: process.stdin })
.on('line', function(line) { lines.push(line) })
.on('close', function() {
  function numeric(v) { return +v };
  const k = lines.shift().split(' ').map(numeric)[0];
  const a = lines.shift().split(' ').map(numeric);
  
  var max = k + a[0] - a[a.length - 1];
  for (var i = 0; i < a.length - 1; i++) {
    max = Math.max(max, a[i + 1] - a[i]);
  }
  
  console.log(k - max);
});

Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b,C;
  cin>>a>>b>>C;
  vector<ll>vec(b);
  for(ll i=0;i<b;i++){
    cin>>vec.at(i);
  }
  ll c=0;
  for(ll i=0;i<a;i++){
    ll d=C;
    for(ll j=0;j<b;j++){
      ll e;
      cin>>e;
      d+=e*vec.at(j);
    }
    
    if(d>0){
      c+=1;
    }
  }
  cout<<c<<endl;
      
  return 0;
}


Measured memory_bytes: 3552
text = input()
a_list = []
z_list = []
for i, x in enumerate(text):
    if x == "A":
        a_list.append(i)
    if x == "Z":
        z_list.append(i)

a_z_len = max(z_list) - min(a_list) + 1
print(a_z_len)

Measured memory_bytes: 11172
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), H = cin.getInt();
    let A = new Array(N), B = new Array(N);
    for (let n = 0; n < N; n++) {
        A[n] = cin.getInt();
        B[n] = cin.getInt();
    }
    A.sort((a, b) => b - a);
    B.sort((a, b) => b - a);
    let ans = 0;
    for (let n = 0; n < N && H > 0 && A[0] < B[n]; n++) {
        H -= B[n];
        ans++;
    }
    if (H > 0) ans += Math.ceil(H / A[0]);
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33480
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 200005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

vector<int> g[100005];
vector<bool> visited(100005,false);
vector<int> start(inp,0);


void dfs(int n)
{
    if(visited[n]) return;
    visited[n]=true;
    for(int c:g[n])
    {
        dfs(c);
        start[n]=max(start[n],1+start[c]);
    }
}

int main()
{
    jaldi

    int n,m;
    cin>>n>>m;

    for(int i=1,u,v;i<=m;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
    }

    for(int i=1;i<=n;i++)
    {
        if(!visited[i]) dfs(i);
    }

    for(int i=1;i<=n;i++) visited[i]=false;

    //deb(start);
    // for(int i=1;i<=n;i++)
    // {
    //     if(!visited[i]) dfs(i);
    // }

    // deb(start);

    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,start[i]);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int underR(int y,int x);
int underL(int y,int x);
char maps[260][260];
int check[260][260];
int n;
int gyomax[260]={0};
int gyoans=0;
int gyonum[260]={0};
int retumax[260]={0};
int retuans=0;
int retunum[260]={0};
int ans=0;
main(){
  while(1){
    ans=0;
    memset(check,0,sizeof(check));
    memset(gyomax,0,sizeof(gyomax));
    memset(retumax,0,sizeof(retumax));
    gyoans=0;
    retuans=0;
    memset(gyonum,0,sizeof(gyonum));
    memset(retunum,0,sizeof(retunum));
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>maps[i][j];
	if(maps[i][j]=='1'){
	  gyonum[i]++;
	  gyomax[i]=max(gyomax[i],gyonum[i]);
	  retunum[j]++;
	  retumax[j]=max(retumax[j],retunum[j]);
	}
	else{
	  gyonum[i]=0;
	  retunum[j]=0;
	}
      }
    }
    /*
    for(int i=0;i<n;i++){
      cout<<gyomax[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<n;i++){
      cout<<retumax[i]<<" ";
    }
    cout<<endl;
    */
    gyoans=*(max_element(gyomax,gyomax+n));
    retuans=*(max_element(retumax,retumax+n));
    //cout<<gyoans<<" "<<retuans<<endl;
    ans=max(gyoans,retuans);
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(maps[i][j]=='1'&&check[i][j]==0){
	  check[i][j]=1;
	  ans=max(ans,underR(i,j));
	  ans=max(ans,underL(i,j));
	}
      }
    }
    cout<<ans<<endl;
  }
}
int underR(int y,int x){
  int num=0;
  if(maps[y][x]=='0'){
    return 0;
  }
  else{
    num++;
    if(y+1<n&&x+1<n){
      num+=underR(y+1,x+1);
    }
    return num;
  }
}
int underL(int y,int x){
  int num=0;
  if(maps[y][x]=='0'){
    return 0;
  }
  else{
    num++;
    if(y+1<n&&x-1>=0){
      num+=underL(y+1,x-1);
    }
    return num;
  }
}

Measured memory_bytes: 1500
#include<stdio.h>
#include<stdlib.h>
#define MAX 110

void calc_a();
void calc_b();
void calc_c();
void push(int);
int pop();
int isEmpty();
int isFull();

int top = 0,stack[MAX];

int main(){
  int x,rlt;
  char s[MAX];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      calc_a();
    } else if ( s[0] == '-' ){
      calc_b();
    } else if ( s[0] == '*' ){
      calc_c();
    } else {
      x = atoi(s);
      push(x);
    }
  }
  rlt=pop();
  printf("%d\n",rlt);
  return 0;
}

void calc_a(){
  int x,y,z;
  y = pop();
  x = pop();
  z = x + y;
  push(z);
}

void calc_b(){
  int x,y,z;
  y = pop();
  x = pop();
  z = x - y;
  push(z);
}

void calc_c(){
  int x,y,z;
  y = pop();
  x = pop();
  z = x*y;
  push(z);
}

void push(int x){
  int full;
  full = isFull();
  if(full == 1){
    printf("error_Full\n");
    exit(0);
  }
  top++;
  stack[top] = x;
}

int pop(){
  int empty;
  empty = isEmpty();
  if(empty == 1){
    printf("error_Empty\n");
    exit(0);
  }
  top--;
  return stack[top + 1];
}

int isEmpty(){
  if(top == 0) return 1;
  else return 0;
}

int isFull(){
  if(top >= MAX - 1) return 1;
  else return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>

#define rep(i, s, c) for (int i=s; i<c; ++i)
#define min(a, b) ((a)<(b)) ? (a) : (b)
#define max(a, b) ((a)>(b)) ? (a) : (b)
#define INF 100000005

int A[1000], B[1000];
int dp[10001] = {0};

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

    rep(h, 1, H+1)
        dp[h] = INF;

    rep(h, 1, H+1)
        rep(n, 0, N)
            dp[h] = min(dp[h], B[n] + dp[max(h-A[n], 0)]);

    printf("%d\n", dp[H]);
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int l = S.length() / 2;
  int sum = 0;
  
  for (int i = 0; i < l; i++) {
    if (S.at(i) != S.at(S.length() - i - 1)) sum++;
  }
  
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, x, t;
    scanf("%d%d%d", &n, &x, &t);
    printf("%d\n", n > x ? t * (int)(n * 1.0 / x + 0.5) : t);
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
using namespace std;
int main(void){
#define MAX 500
    int a[MAX], b[MAX]; //午前と午後の入場者数
    string name[9]; //クラス名

    for(int i = 0; i < 9; i++){
        cin >> name[i] >> a[i] >> b[i];
    }

    long int earnings[9]; //料金収入
    int sum_ab[9]; //入場者数の総和

    for(int i = 0; i < 9; i++){
        sum_ab[i] = a[i] + b[i];
        earnings[i] = 200 * a[i] + 300 * b[i];

        cout << name[i] << " " << sum_ab[i] << " " << earnings[i] << endl;
    }
}


Measured memory_bytes: 3160
#include <stdio.h>
using namespace std;

int main() {
    int N;
    scanf("%d\n", &N);
    int A[N];
    for (int i = 0; i < N; ++i) {
      scanf("%d\n", &A[i]);
    }
 
    int ans = 0;
    while (true) {
        bool odd = false;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2) odd = true;
        }
        if (odd) break;
        for (int i = 0; i < N; ++i) {A[i] /= 2;}
        ++ans;
    }
    printf("%d\n", ans);
}

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

using namespace std;

 
int main() {
    int N;
    cin >> N;
    int oturi;
    oturi = N%1000;
    if(oturi == 0)cout << 0 << endl;
    if(oturi != 0){
        cout << 1000 - oturi << endl;
        
    }
}

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

int n, m;
int s[100010], t[100010];
int p[100010];
int a[100010];

int main()
{
	cin >> n >> m, m++;
	for (int i = 0; i < n; i++){
		cin >> s[i] >> t[i];
	}
	for (int i = 1; i < m; i++){
		cin >> p[i];
	}
	sort(p, p + m);
	
	long long res = 0;
	for (int i = 0; i < n; i++){
		if (lower_bound(p, p + m, s[i]) == lower_bound(p, p + m, t[i])){
			res += abs(s[i] - t[i]);
		}
		else if (s[i] < t[i]){
			int l = lower_bound(p, p + m, s[i]) - p - 1;
			int r = lower_bound(p, p + m, t[i]) - p;
			if ((l ^ r) & 1){
				a[l]++;
				a[r + 1]--;
				res -= s[i] - p[l];
				res -= p[r] - t[i];
			}
			else {
				a[l]++;
				a[r]--;
				res -= s[i] - p[l];
			}
		}
		else {
			int l = lower_bound(p, p + m, t[i]) - p - 1;
			int r = lower_bound(p, p + m, s[i]) - p;
			if ((l ^ r) & 1){
				a[l]++;
				a[r + 1]--;
				res -= t[i] - p[l];
				res -= p[r] - s[i];
			}
			else {
				a[l + 1]++;
				a[r + 1]--;
				res -= p[r] - s[i];
			}
		}
	}

	for (int i = 0; i < m; i++){
		a[i + 2] += a[i];
		res += (long long)(p[i + 1] - p[i]) * a[i];
	}

	cout << res << endl;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 100000000
#define MOD 1000000007LL
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define PI acos(-1)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

int dp[1001][20010];

signed main() {
    int h, n;
    cin >> h >> n;
    rep(i, h + 10001) dp[0][i] = INF;
    vi w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    rep(i, n) REP(j, 1, h + 10001) {
        if(j >= w[i]) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
        } else {
            dp[i + 1][j] = dp[i][j];
        }
    }
    int ans = INF;
    // rep(i, n + 1) {
    //     rep(j, 20) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    rep(i, 10001) { chmin(ans, dp[n][h + i]); }
    cout << ans << endl;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int N, M, ans, tmp;
  ans = tmp = 0;
  cin >> N >> M;
  tmp = N * (N - 1);
  tmp /= 2;
  ans = tmp;
  tmp = M * (M - 1);
  tmp /= 2;
  ans += tmp;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int w,h,x,y,r;
scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0)puts("Yes");
else puts("No");
return 0;}

Measured memory_bytes: 584
#include <stdio.h>
#include <string.h>

int main(void) {
    int T; scanf("%d", &T);
    char* btn[] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
    while(T--) {
        int pt = 0;
        int len;
        char s[1025];

        scanf(" %s", s);
        len = strlen(s);

        while(pt < len) {
            int k;
            char c = s[pt++];
            if (c == '0') continue;
            int cnt = 0;
            while(s[pt] != '0') pt++, cnt++;
            pt++;

            k = c - '0' - 1;
            cnt %= strlen(btn[k]);
            putchar(btn[k][cnt]);
        }

        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int sop(int k);
int32_t main()
{
      IOS;
      ll i,n,flag=0,nut=1,jump=1,q,j,cnt=0,cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,m,x,y,h,l,z1
,h1,h2,m1,m2;
      cin>>n;
      float t,sum=0,k;
      while(n--)
      {
          cin>>k;
          t=1/k;
          sum+=t;

      }
     t=1/sum;
     cout<<t;




    return 0;
}


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

using namespace std;
const int maxn = 6e3+5;
string ans,a,orz,now;
int sm[maxn],aw[maxn],bw[maxn],ac,bc;
int dy[maxn];
int n;
bool mark[maxn];
void solve(int l,int r) {
	orz = "";
	if(a[l]=='a') {
		for(int j=l;j<=r;j++) {
			if(a[j]=='a') orz += "ab" , j = dy[j];
		}
		return;
	} else {

		for(int cd=(r-l+1)/2;cd>=1;cd--) {
			now = "";
			int yo = cd;
			for(int i=r;i>=l&&yo;i--) {
				if(a[i]=='b') {
					mark[i] = mark[dy[i]] = 1; yo--;
				}
			}
			for(int i=l;i<=r;i++) {
				if(mark[i]) {
					now += a[i];
					mark[i] = 0;
				}
			}
			orz = max(orz,now);
		}
	}
}
int main() {
	cin>>n>>a;
	a = " "+a;
	for(int i=1;i<=n*2;i++) {
		sm[i] = (a[i]=='a'?1:-1);
		sm[i] += sm[i-1];
		if(a[i]=='a') aw[++ac] = i;
		else bw[++bc] = i;
	}
	for(int i=1;i<=n;i++) dy[aw[i]] = bw[i] , dy[bw[i]] = aw[i];
	int lst = 2*n;
	for(int i=2*n-1;i>=0;i--) {
		if(sm[i]==0) {
			solve(i+1,lst);
			lst = i;
			ans = max(ans,orz+ans);
		}
	}
	cout<<ans;
}

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

int main(void)
{
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 1; i <= n; i++)
  {
    if(0 < i && i < 10)
    {
      cnt++;
    }
    if(99 < i && i < 1000)
    {
      cnt++;
    }
    if(9999 < i && i < 100000)
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int n,m;
vector<int> g[100010];
int kin[100010];
int a,b;
queue<int> q;
int ans[100010];
int main(){
  cin>>n>>m;
  for(int i=0;i<n+m-1;i++){
  	cin>>a>>b;
  	g[a].PB(b);
  	kin[b]++;
  }
  for(int i=1;i<=n;i++)
    if(kin[i]==0){
      q.push(i);
      ans[i]=0;
      break;
	}
  while(!q.empty()){
  	int xx=q.front();
  	q.pop();
  	for(int i=0;i<g[xx].size();i++){
  	  kin[g[xx][i]]--;
  	  if(kin[g[xx][i]]==0){
  	    q.push(g[xx][i]);
  	    ans[g[xx][i]]=xx;
	  }
	}
  }
  for(int i=1;i<=n;i++)
    cout<<ans[i]<<"\n";
  return 0;
}

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

int main() {
string s;cin>>s;
int lo = s.size();
bool big = 1;
for(int i = 1;i<lo;i++){
    if(s[i]!='9')big = 0;
}
int ans = 0;
if(big==1){
ans = (s[0]-'0')+(lo-1)*9;
}
else{
    ans = (s[0]-'0'-1)+(lo-1)*9;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		char l;
		cin>>l;
		if(l<='Z')
		{
			cout<<'A';
		}
		else
		{
			cout<<'a';
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	IOS;
	ll n,m;
	string s,t;
	cin >> n >> m >> s >> t;
	ll ans = lcm(n,m);
	bool ok = true;
	ll a = ans / n;
	ll b = ans / m;
	ll tmp = gcd(n,m);
	REP(i,n){
		ll x = i * a;
		if(x % b == 0){
			ll y = x / b;
			if(s[i] != t[y])ok = false;
		} 
	}
	dump(ok ? ans : -1);
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    char s [1000];
    char c;
    int i = 0;
    while ((c=getchar()) != '\n') s [i++] = c;
    for(int j = 0; j < i; j++) putchar (s[j]);
    if (s[i-1] == 's') printf ("es");
    else printf("s");
    return 0;
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define ll long long  int
#define N 1000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

int main()
{
    int a[32]={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};

    int k;
    cin >>   k;

    cout <<  a[k-1] ;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[12]:


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


# In[14]:


ans = (N-1)//(K-1) + min(1, (N-1)%(K-1))
print(ans)


# In[ ]:






Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}
int main() {
    string S;
    cin >> S;
    vector<vector<long long>> dp(S.size()+1, vector<long long>(13, 0));
    dp[0][0] = 1;
    for (int i = 0; i < S.size(); ++i) {
        for (int j = 0; j < 13; ++j) {
            if (S[i] == '?') {
                for (int k = 0; k < 10; ++k) {
                    add(dp[i+1][(j*10+k)%13], dp[i][j]);
                }
            }
            else {
                int k = S[i] - '0';
                add(dp[i+1][(j*10+k)%13], dp[i][j]);
            }
        }
    }
    cout << dp[S.size()][5] << endl;
}


Measured memory_bytes: 13696
import sys
rl = sys.stdin.readline


def solve():
    H, W, K = map(int, rl().split())
    S = [[] for _ in range(H)]
    for i in range(H):
        S[i] = list(map(int, list(input())))
    
    ans = 10 ** 6
    for s in range(1 << (H - 1)):
        pop_cnt = 0
        for i in range(H - 1):
            if s >> i & 1:
                pop_cnt += 1
        
        tmp = pop_cnt
        b = [0] * (tmp + 1)
        flg = True
        for i in range(W):
            j = 0
            for k in range(H):
                if S[k][i]:
                    b[j] += 1
                if s >> k & 1:
                    j += 1
            
            flg = True
            for bi in b:
                if K < bi:
                    flg = False
            
            if not flg:
                tmp += 1
                b = [0] * (pop_cnt + 1)
                j = 0
                for k in range(H):
                    if S[k][i]:
                        b[j] += 1
                    if s >> k & 1:
                        j += 1
                
                flg = True
                for bi in b:
                    if K < bi:
                        flg = False
        
        if flg:
            ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49084
#include <iostream>
    #include <cstdio>
    #include <vector>
    #include <map>
    #include <queue>
    #include <string>
    #include <set>
    #include <algorithm>
    #include <utility>
    #include <cstring>
    #include <cmath>
    #include <cassert>
    using namespace std;
    //#define int64_t long long
    //constexpr int64_t MOD=1e9+7;
    long long a,b,c,d;
    long long gcd(long long a,long long b){
        if(b>a)swap(a,b);
        if(b==0)return a;
        return gcd(b,a%b);
    }
    long long f(long long a){
        return a/c+a/d-a/(c*d/gcd(c,d));
    }
    int main() {
        cin>>a>>b>>c>>d;
        cout<<(b-a+1-f(b)+f(a-1))<<endl;
        return 0;
    }

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ECommonSubsequence
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var m = inputs[1];

            var sNumbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var tNumbers = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var dp = new mInt[n + 1, m + 1];
            for (var i = 0; i < n + 1; i++) dp[i, 0] = new mInt(1);
            for (var i = 0; i < m + 1; i++) dp[0, i] = new mInt(1);

            for (var i = 1; i < n + 1; i++)
            {
                for (var j = 1; j < m + 1; j++)
                {
                    dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    if (sNumbers[i - 1] != tNumbers[j - 1]) dp[i, j] -= dp[i - 1, j - 1];
                }
            }

            // 解答の出力
            Console.WriteLine(dp[n, m].X);
        }

        struct mInt
        {
            const int M = 1000000007;
            public int X { get; }

            public mInt(int x)
            {
                X = x % M;
            }

            public static mInt operator +(mInt a, mInt b)
            {
                return new mInt(a.X + b.X);
            }
            public static mInt operator +(mInt a, int num)
            {
                return new mInt(a.X + num);
            }

            public static mInt operator -(mInt a, mInt b)
            {
                var diff = a.X - b.X;
                while (diff < 0) diff += M;
                return new mInt(diff);
            }
        }
    }
}


Measured memory_bytes: 28512
import heapq
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    Q = []
    for _ in range(N):
        a, b = map(int, input().split())
        Q.append([a, b])
    heapq.heapify(Q)
    
    ans = 0
    cnt = 0
    while cnt<M:
        a, b = heapq.heappop(Q)
        ans += a * min(b, M-cnt)
        cnt += b

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19672
//by spli
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;

int pri[100010],cnt;
bool vis[100010];
int s[100010];
int T,x,y;

void getpri(){
	vis[1]=1;
	for(int i=2;i<=100005;++i){
		if(!vis[i]) pri[++cnt]=i;
		for(int j=1;j<=cnt&&(long long)pri[j]*i<=100005;++j){
			vis[pri[j]*i]=1;
			if(i%pri[j]==0) break;
		}
	}
	//for(int i=1;i<=20;++i) cout<<pri[i]<<" ";cout<<endl;
}

int main(){
	getpri();
	for(int i=2;i<=100005;++i){
		s[i]=s[i-1];
		if(!vis[i]&&!vis[(i+1)>>1]) s[i]++;
	}
	scanf("%d",&T);
	while(T--){
		scanf("%d%d",&x,&y);
		if(x==0) printf("%d\n",s[y]);
		else printf("%d\n",s[y]-s[x-1]);
	}
	return 0;
}



















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

int main() {
	int N,T,A;
	cin >> N >> T >> A;
	vector<double> H(N);
	rep(i,N) cin >> H[i];

	double mn = 99999;
	int index = 1000;
	rep(i,N){
		double diff = abs(A - (T - H[i] * 0.006));
		mn = min(mn,diff);
		if(mn == diff) index = i;
	}
	cout << index + 1 << endl;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
Max = 0
for i in range(N):
    if i == N-1:
        Max = max(Max, (K - A[i]) + A[0])
    else:
        Max = max(Max, A[i+1] - A[i])
print(K - Max)


Measured memory_bytes: 26100
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N;
  string s; cin>>N>>s;
  ll ans = 0;
  ll buf = 0;
  REP(start,N){
    char ca = s[start];
    char cb,cc;
    if(ca=='R'){ cb = 'G'; cc = 'B';}
    else if(ca=='G'){ cb = 'B'; cc = 'R'; }
    else if(ca=='B'){ cb = 'R'; cc = 'G'; }
    int num_b = 0;
    int num_c = 0;
    for(int i = start+1;i<N;++i){
      if(s[i]==cb){
        ++num_b;
        if(i+i-start<N &&  s[i+(i-start)]==cc){ ++buf;}
      }
      else if(s[i]==cc){
        ++num_c;
        if(i +i-start<N && s[i+(i-start)]==cb){ ++buf;}
      }
    }
    ans += num_b*num_c;
  }
  
  ans -= buf;
  cout << ans <<"\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string s, t, u;
  	int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u){
    a--;
  }
  else{
    b--;
  }
  printf("%d %d\n", a, b);

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//以下回答
int main(){
    ll A,B,N;
    cin>>A>>B>>N;
    ll ans;
    if(N>=B-1){
    ans=(A*(B-1)/B);
    }else{
        ans=A*N/B-A*(N/B);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A[200010] = {}; 
	int B[200010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		B[A[i]] = i; 
	}
	set<int> used {0, N + 1}; 
	long long int ans = 0; 
	for(int i = 1; i <= N; i++){
		auto it = used.lower_bound(B[i]); 
		long long int R = *it - B[i]; 
		it --; 
		long long int L = B[i] - *it; 
		used.insert(B[i]); 
		ans += (long long) i * R * L; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 11136
#include <stdio.h>
int main(void){
	int i,x;		//i,x?????£?¨?
	i = 1;//?????????????????????

	while (1){//???????????????
		scanf("%d", &x);//?¨??????\????????????????????????????????£???x????????????
		if(x == 0){
			/*???????????????????????????????????? x = 0
			????????????x = 0???????????¨???x???0?????£??\?????????(x = 0)??????????????????true????????§??????if??\?????????????????????*/
			break;//while??????????????±???
		}
		printf("Case %d: %d\n" ,i,x);//??????
		i++;//???????????????1?????????
		
	}//4???????????????	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int X, ans = 1,temp;
    cin >> X;
    if (X == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 2; i<=(int)sqrt(X); i++) {
        for (int j=2; ; j++) {
            temp = pow(i, j);
            if (temp > X) {
                break;
            }
            if (temp > ans) {
                ans = temp;
            }
        }
    }
    cout << ans << endl;
}


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


int main() {
  
  int N;
  cin  >> N;
  
  vector<int> a(N);
  
  rep(i,N){
    cin >> a.at(i);
  }
    sort(a.begin(), a.end()); // {1, 2, 2, 5}
    reverse(a.begin(), a.end()); // {5, 2, 2, 1}
  
  int sumA=0;

    for (int i = 0; i < N; i++) {
      if(!(i%2))
        sumA+=a.at(i);
      else
        sumA-=a.at(i);
      
    }
  
  cout <<sumA <<endl;
}

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

using namespace std;

int main()
{
  string N;
  
  cin >> N;
  
  if(N[0] == N[1] && N[0] == N[2]){
    cout << "Yes" << endl; 
  }
  else if(N[1] == N[2] && N[1] == N[3]){
    cout << "Yes" << endl; 
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int a[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i]; 
    }
    int gl[n+1];
    gl[0] = 0;
    for (int i = 1; i <= n; i++) {
        gl[i] = gcd(gl[i-1], a[i]);
    }

    int gr[n+2];
    gr[n+1] = 0;
    for (int i = n; i >= 1; i--) {
        gr[i] = gcd(gr[i+1], a[i]);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, gcd(gl[i-1], gr[i+1]));
    }

    cout << ans << endl;

    return 0;
}

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

/*ALDS1_1_A:   Insertion Sort*/

void InsertionSort(int A[], int N);
void printArray(int A[], int N);

int main(void){
    // Here your code !
    int N;
    int A[1000];
    
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    printArray(A, N);
    InsertionSort(A, N);
    

}

void InsertionSort(int A[], int N){
    for (int i=1; i<N; i++){
        int v = A[i];
        int j= i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        
        printArray(A, N);
    }
}

void printArray(int A[], int N){
    for(int i=0; i<N; i++){
        cout << A[i];
        if ( i < N-1 ) cout << " ";
        else cout << "\n";
    }
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int res=0,i;
    string ss;
    cin>>ss;
    for(i=0;i<ss.size();i++)
    {
        if(ss[i]=='+')res++;
        else res--;
    }
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int k;
vi ans;
void solve(int x, int cur, int last) {
  if (cur == 11) {
    if (!x) return;
    ans.eb(x);
    if (ans.size() == 1e5) {
      sort(all(ans));
//      for (int i = 0; i < 10; ++i) cerr << ans[i] << " ";
      cout << ans[k - 1];
      exit(0);
    }
    return;
  }
  if (last == -1) {
    solve(x, cur + 1, -1);
  }
  fo(i, 0, 9, 1) if (abs(i - last) <= 1 and last != -1 || last == -1 and i) solve(x * 10 + i, cur + 1, i);
}
main() {
  file("threesum");
  ios;
  cin >> k;
  solve(0, 1, -1);
  return 0;
}
/**
12
21
22
23
*/


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>>time(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    time[i]=make_pair(b,a);
  }
  sort(time.begin(),time.end());
  long long ans=0;
  bool judge=true;
  for(int i=0;i<n;i++){
    ans+=time[i].second;
    if(ans>time[i].first){
      judge=false;
      break;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	long long int n,i,m;
	scanf("%lld", &n);
	m = n;

	for (i=2; i <= n&&m!=1; i++) {
		if (m%i == 0) {
			n = n*(i - 1) / i;
			while(m%i==0) m /= i;
		}
	}

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

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> d(n+1,-1); for(int i = 1;i<=n;i++) cin >> d[i];

  sort(d.begin(),d.end());
  /*cout << "sorted" << endl;
  for(int i = 1;i<=n;i++) cout << d[i] << " ";
  cout << endl;*/
  
  int left = d[n/2];
  int right = d[n/2+1];
  int ans = right-left;
  
  //printf("l: %d r: %d\n",left,right);
  cout << ans << endl;
  
  return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin>>n;
string dic = "abcdefghijklmnopqrstuvwxyz";
vector<char> encode;
string ans="";

int digit=1;
ll tmp=26;
while(tmp < n) {
    digit++;
    tmp+=powl(26,digit);
}
ll _n=n-(tmp/26);
rep(i,digit){
    int j=_n%26;
    _n/=26;
    encode.pb(dic[j]);
}
reverse(encode.begin(),encode.end());
for(auto c:encode){
    ans=ans+c;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3688