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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int n; cin >> n;
    vector<int> a(n);
    for (auto& x : a) cin >> x;

    ll total = 0;
    map<int, int> mp;
    for (auto x : a) mp[x]++;

    for (auto x : mp) total += (ll) x.first * (ll) x.second;


    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        ll a, b;
        cin >> a >> b;
        total -= a * mp[a];
        total += mp[a] * b;
        mp[b] += mp[a];
        mp[a] = 0;
        cout << total << endl;
    }




    return 0; 
}



Measured memory_bytes: 8088
use proconio::{input,fastout};

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
    c: isize,
    b: [isize; m],
  }
  let mut ans: usize = 0;
  for _ in 0..n {
    input! {
      a: [isize; m],
    }
    let mut tmp: isize = c;
    for i in 0..m {
      tmp += a[i] * b[i];
    }
    if tmp > 0 {
      ans += 1;
    }
  }
  
  println!("{}",ans);
}


Measured memory_bytes: 2184
#include <iostream>
#include <string>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')
	{
		for(int i=0;i<s.size();i++)
		{
			cout<<s[i];
		}
		cout<<"es";
	}else{
		for(int i=0;i<s.size();i++)
		{
			cout<<s[i];
		}
		cout<<"s";
	}
	return 0;
}

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
const int P = 1e9 + 7;
vector<int> G[N];
int ans = 1, n, k;

void dfs(int u, int fa)
{
	int cnt;
	if (fa) cnt = 2; else cnt = 1;
	for (int v : G[u]) if (v != fa) 
		ans = 1LL * ans * (k - cnt) % P, ++cnt;
	for (int v : G[u]) if (v != fa) dfs(v, u);
}

int main()
{
	n = read();
	k = read();
	for (int i = 1; i < n; ++i)
	{
		int u = read();
		int v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	dfs(1, 0);
	
	printf("%d\n", 1LL * ans * k % P);
	return 0;
}


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

int main(){
    int n, i;
    while( cin >> n, n ){
        vector<int> v(n);
        for(i=0;i<n;i++){
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        int t = v[n/2], count = 1;
        for(i=n/2-1;i>=0;i--){
            if( v[i]-t ) break;
            count++;
        }
        for(i=n/2+1;i<n;i++){
            if( v[i]-t ) break;
            count++;
        }
        if( count > n/2 ){
            cout << t << endl;
        }else{
            cout << "NO COLOR" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6452
#include<iostream>
#include<math.h>
using namespace std;
typedef long long int llint;
int main() {
	llint n;
	cin >> n;
	llint a = sqrt(n);
	llint ans;
	for (llint i = 1;i <= a;i++) {
		if (n%i == 0) {
			ans = n / i;
		}
	}
	int ans_ = 1;
	while (10 <= ans) {
		ans /= 10;
		ans_++;
	}
	cout << ans_ << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    bool ans = true;
    int n = s.size();
    string r =s.substr(0,(n-1)/2);
    string l =s.substr((n+3)/2-1,n);
    if(r==l)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

int compare (const void * a, const void * b)
{
	unsigned int x = *(unsigned int *)a;
	unsigned int y = *(unsigned int *)b;
	if (x < y) {
		return -1;
	}
	else if (x == y) {
		return 0;
	}
	else {
		return 1;
	}
}

int main(int argc, char * argv[])
{
	unsigned int w = 0;
	unsigned int h = 0;

	while (cin >> w >> h) {
		unsigned int cost_w[w];
		unsigned int cost_h[h];

		for (unsigned int i = 0; i < w; ++i) {
			cin >> cost_w[i];
		}
		for (unsigned int i = 0; i < h; ++i) {
			cin >> cost_h[i];
		}

		qsort(cost_w, w, sizeof(unsigned int), compare);
		qsort(cost_h, h, sizeof(unsigned int), compare);

		unsigned int number_w = 0;
		unsigned int number_h = 0;
		unsigned long total = 0;
		for (unsigned int i = 0; i < w + h; ++i) {
			unsigned long count = 0;
			unsigned long cost = 0;

			if (number_w < w && number_h < h) {
				if (cost_w[number_w] <= cost_h[number_h]) {
					count = h + 1 - number_h;
					cost = cost_w[number_w];
					++number_w;
				}
				else {
					count = w + 1 - number_w;
					cost = cost_h[number_h];
					++number_h;
				}
			}
			else if (number_w < w) {
				count = h + 1 - number_h;
				cost = cost_w[number_w];
				++number_w;
			}
			else {
				count = w + 1 - number_w;
				cost = cost_h[number_h];
				++number_h;
			}
			total += count * cost;
		}
		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 1464
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        String[] aryData = Console.ReadLine().Split(' ');

        double lengthA = int.Parse(aryData[0]);
        double lengthB = int.Parse(aryData[1]);
        double raji = int.Parse(aryData[2]) * Math.PI / 180;

        double height = lengthB * Math.Sin(raji);
        double triangleArea = lengthA * height / 2;

        double x = lengthB * Math.Cos(raji);
        double y = lengthA - x;

        double L = lengthA + lengthB + Math.Sqrt(height * height + y * y);

        Console.WriteLine("{0} {1} {2}", string.Format("{0:f8}", triangleArea), string.Format("{0:f8}", L), string.Format("{0:f8}", height));

    }
}

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 1000000
#define md 998244353
 
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/

int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	vector<pii>v;
	for(int i=0;i<k;i++){
		int x,y;cin>>x>>y;
		v.pb({x,y});
	}
	
	ll dp[n+1],pre[n+2];mem(dp,0);
	dp[1]=1;
	pre[2]=1;
	pre[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=0;j<k;j++){
			int u=i-v[j].ff;
			int l=i-v[j].ss;
			if(u<1)continue;
			dp[i]=(dp[i]+pre[u+1]-(l>=1?pre[l]:0)+md)%md;
		}
		pre[i+1]=(pre[i]+dp[i])%md;
	}
	cout<<dp[n]%md;
	
}

Measured memory_bytes: 6732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int ball[100000];
int flag[100000];
int main(void)
{
	int n,m,x,y,ans=0,i; 
	scanf("%d%d",&n,&m);
	FOR(i,0,n) ball[i]=1;
	flag[0]=1;
	FOR(i,0,m){
		scanf("%d%d",&x,&y);
		ball[--x]--,ball[--y]++;
		if(flag[x]) flag[y]=1;
		if(ball[x]==0) flag[x]=0;
	}
	FOR(i,0,n){
		if(ball[i]&&flag[i]) ans++;
	}
	printf("%d\n",ans);
	return 0;
}
    
    


Measured memory_bytes: 896
import numpy as np
import fractions

N = int(input())
A = [int(i) for i in input().split()]


gcd_left = [0]
gcd_right = [0]
for i in range(N):
    gcd_left.append(fractions.gcd(gcd_left[i], A[i]))
    gcd_right.append(fractions.gcd(gcd_right[i], A[-(i+1)]))

gcd_right = gcd_right[::-1]

value = []
for i in range(N):
    value.append(fractions.gcd(gcd_left[i], gcd_right[i+1]))

print(max(value))

Measured memory_bytes: 24252
#include <iostream>
using namespace std;
int main(){

  int small[1000][1000]={};
  int a[1000],b[1000],n,m,i,j;

  cin>>n>>m;
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<m;i++) cin>>b[i];
  small[0][0]=a[0]*b[0];
  for(i=1;i<m;i++) small[0][i]=min(a[0]*b[i],small[0][i-1]);
  for(i=1;i<n;i++) for(j=i;j<m;j++){
      small[i][j]=small[i-1][j-1]+a[i]*b[j];
      if(i!=j && i!=n-1) small[i][j]=min(small[i][j],small[i][j-1]);
    }
  for(i=n-1;i<m-1;i++) small[n-1][i+1]=min(small[n-1][i],small[n-1][i+1]);  
  cout<<small[n-1][m-1]<<endl;
  return 0;
}

Measured memory_bytes: 6980
N, M = map(int, input().split())
num = ['']*N
valid = True
#create number from input
for i in range(M):
  s, c = map(int, input().split())
  if (num[s-1] == ''):
    num[s-1] = c
  elif (num[s-1] != c):
    valid = False
    break
#check whether 0 is at front
if (N > 1):
  if (num[0]==0):
    valid = False
  
if valid:
  #fill the blank parts
  for i in range(N):
    if (num[i] == ''):
      if (i == 0):
        if (N == 1):
          num[i] = 0
        else:
          num[i] = 1
      else:
      	num[i] = 0
  #convert list to number
  answer = 0
  for i in range(N):
    answer *= 10
    answer += num[i]
  print(answer)
else:
  print(-1)
  
  


Measured memory_bytes: 62004
#include <cstdio>
#include <cstring>

char S[1024];
int  D[256];
int main() {
    scanf("%s", S);
    memset(D, 0, sizeof D);
    for (int i = 0; S[i]; i++)
        D[S[i]] = 1;
    if (D['W'] != D['E'] || D['N'] != D['S'])
        printf("No\n");
    else 
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using vi=vector<int>;
using pi=pair<int,int>;
using vpi=vector<pi>;
using ll=long long int;
ll xorsigma(ll n){
  ll ans= 0;
  ans |= ((n+1)&2)>>1; // 1st bit
  FOR(i,1,60){
    if((n>>i)&1){
      ll bit=!(n&1);
      ans |= bit<<i;
    }else ans |= 0;
  }
  return ans;
}
int main() {
  ll A,B;
  cin>>A>>B;
  ll ans=xorsigma(A) xor xorsigma(B) xor A;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
ll ans;
ll a[N];
ll pref[N];
int n;
ll L;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%lld%d", &L, &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (int i = 0; i < n; i++)
		pref[i + 1] = pref[i] + a[i];
	ans = 0;
	for (int i = 0; i < n; i++) {
		int k = min(i, n - 1 - i);
		ll cur = a[i];
		cur += 2 * (pref[i] - pref[i - k]);
		if (i + k + 1 < n) k++;
		cur += 2 * (k * L - pref[i + k + 1] + pref[i + 1]);
		ans = max(ans, cur);
	}
	for (int i = 0; i < n; i++) {
		int k = min(i, n - 1 - i);
		ll cur = L - a[i];
		cur += 2 * (k * L - pref[i + k + 1] + pref[i + 1]);
		if (i > k) k++;
		cur += 2 * (pref[i] - pref[i - k]);
		ans = max(ans, cur);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3328
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		string a, b;
		cin >> a;
		if (a == ".") return 0;
		cin >> b;
		int ok = 1;
		vector<string> gogo[2][2];
		string now = "";
		int bad = 0;
		for (int i = 0; i < a.length(); ++i) {
			if (a[i] == '"') {
				gogo[0][bad].push_back(now);
				now = "";
				bad = (bad + 1) % 2;
			}
			else {
				now.push_back(a[i]);
			}
		}
		gogo[0][bad].push_back(now);
		now = "";
		for (int i = 0; i < b.length(); ++i) {
			if (b[i] == '"') {
				gogo[1][bad].push_back(now);
				now = "";
				bad = (bad + 1) % 2;
			}
			else {
				now.push_back(b[i]);
			}
		}
		gogo[1][bad].push_back(now);
		if (gogo[0][0] != gogo[1][0]||gogo[0][1].size() != gogo[1][1].size()) {
			cout << "DIFFERENT" << endl;
			continue;
		}
		int choice = 0;
		for (int q = 0; q < gogo[1][1].size(); ++q) {
			if (gogo[0][1][q] != gogo[1][1][q]) choice++;
		}
		if (choice == 0) {
			cout << "IDENTICAL" << endl;
		}
		else if (choice == 1) {
			cout << "CLOSE" << endl;
		}
		else cout << "DIFFERENT" << endl;
	}
}



Measured memory_bytes: 3176
#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;
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;
	cin>>N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	int L = 0;
	int R = 0;
	LL ans = 0;//MAX:N(N+1)/2
	int mask = 0;
	
	while(R<N){
		while( L<N && (mask& A[L]) == 0){
			mask |= A[L];
			++L;
		}
		ans += (L-R);
		
		mask ^= A[R];
		++R;
	}
	cout << ans << 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: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,*A = map(int,read().split())

MOD = 10 ** 9 + 7

lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)

answer = sum(lcm//x for x in A)
answer %= MOD
print(answer)


Measured memory_bytes: 6008
n, q = map(int, raw_input().split())
s = str(raw_input())
t = [0] * (n + 1)
for i in range(n):
	t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
	l, r = map(int, raw_input().split())
	print t[r-1] - t[l-1]

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int N;
  cin >> N;
  vector<int> a(N + 1), b(N + 1), c(N + 1);
  rep(i, N) cin >> a[i + 1] >> b[i + 1] >> c[i + 1];

  vector<vector<int>> dp(N + 1, vector<int>(3));
  rep(i, N) rep(j, 3) dp[0][j] = 0;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 3; j++) {
      if (j == 0) dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
      if (j == 1) dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
      if (j == 2) dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
    }
  }
  int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9848
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define NIL -1
typedef struct node{
  int parent;
  int right;
  int left;
}Tree;
Tree T[N];
int n,cnt[N];
void print(int u);
void rec (int u,int p){
  cnt[u]=p;
  if(T[u].right!=NIL){
    rec(T[u].right,p);
  }
  if(T[u].left!=NIL){
    rec(T[u].left,p+1);
  }

}
int main(){
  int i,j,d,k,children,number,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;

  }


  for(i=0;i<n;i++){
    scanf("%d%d",&number,&d);
    for(j=0;j<d;j++){
      scanf("%d",&children);
      if(j==0){
        T[number].left=children;
      }
      else {
        T[l].right=children;
      }
      l=children;
      T[children].parent=number;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL){
      r=i;
    }
  }

  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",cnt[u]);

  if(T[u].parent==NIL){
    printf("root, ");
  }
  else if(T[u].left==NIL){
    printf("leaf, ");
  }
  else {printf("internal node, ");
  }
  printf("[");


  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i){
      printf(", ");
    }
    printf("%d",c);
  }
  printf("]\n");
}

Measured memory_bytes: 5296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
      
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		
		int ans = Math.min( B / A , C );
		System.out.println(ans);
	}
}

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

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

    //good luck kittu!
    int n; cin>>n;
    int ans = 1000*(n/500);
    n = n%500;
    ans += 5*(n/5);
    cout<<ans<<"\n";
    return 0;
}

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

int top(int n) {
  int ret = 0;
  while(n) { ret = n % 10; n = n / 10; }
  return ret;
}

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  map <int, int> m;
  for (int i = 1; i <= n; i++) {
    int atop = top(i);
    int alast = i%10;
    if ((m[atop * 10 + alast]) == -1) continue;
    if ((m[atop * 10 + alast]) == 0) {
      ll tmp = 0;
      for (int j = 1; j <= n; j++) {
        int btop = top(j);
        int blast = j%10;
        if (atop == blast && alast == btop) tmp++;
      }
      if (tmp == 0) {
        m[atop * 10 + alast] = -1;
      } else {
        m[atop * 10 + alast] = tmp;
        ans += tmp;
      }
    } else {
      ans += m[atop * 10 + alast];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            Map<String, Long> out = new HashMap<>();
            for (int i=1; i <= n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                String e = st.nextToken();
                long p = Long.parseLong(st.nextToken());
                long q = Long.parseLong(st.nextToken());
                long total = data.merge(e, p * q, Long::sum);
                if (total >= 1_000_000L) {
                    if (out.putIfAbsent(e, total) == null) {
                        System.out.println(e);
                    }
                }
            }
            if (out.size() == 0) {
                System.out.println("NA");
            }
        }
    }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A.at(i);
		if (i != N - 1)
		{
			cout << A.at(i) << ' ';
		}
		else
		{
			cout << A.at(i) << endl;
		}
	}

	for (int i = 1; i < N; i++)
	{
		for (int j = i - 1; j >= 0; j--)
		{
			if (A.at(j) > A.at(j + 1))
			{
				swap(A.at(j), A.at(j + 1));
			}
			else
			{
				break;
			}
		}
		for (int j = 0; j < N - 1; j++)
		{
			cout << A.at(j) << ' ';
		}
		cout << A.at(N - 1) << endl;
	}
}


Measured memory_bytes: 3108
gg=[]
bb=[]
n,m=gets.split(" ").map{|v|v=v.to_i}
1.upto(n){|a|
  g=gets.split(" ").map{|v|v=v.to_i}
  gg.push(g)
}
1.upto(m){|c|
  b=gets.to_i
  bb.push(b)
}
sum=[]
0.upto(n-1){|d|
  s=[]
  0.upto(m-1){|e|
    s.push(gg[d][e]*bb[e])
  }
sum.push(s.inject(:+))
}
puts sum
    

Measured memory_bytes: 6148
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, b, n;
        if(!(cin >> a >> b >> n))
            return 0;

        int ret = 0;
        for(int i=0; i<n; ++i){
            a %= b;
            a *= 10;
            ret += a / b;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
S = list(input())
pattern = [[str(i % 2) for i in range(len(S))], [str((i+1) % 2) for i in range(len(S))]]
count = float('inf')
for pattern in pattern:
    c = 0
    for (s, p) in zip(S, pattern):
        if s != p:
            c += 1
    count = min(count, c)
print(count)

Measured memory_bytes: 16556
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int N=in.nextInt();
			for(int i=0;i<N;i++)
			{
				int n=in.nextInt();
				int cnt=0;
				boolean loop=false;
				HashSet<Integer>HS=new HashSet<Integer>();
				while(n>10)
				{
					if(HS.contains(n))
					{
						loop=true;
						break;
					}
					HS.add(n);
					++cnt;
					int max=-1;
					String st=n+"";
					for(int j=1;j<st.length();j++)
					{
						String x=st.substring(0, j);
						String y=st.substring(j, st.length());
						int mul=Integer.valueOf(x)*Integer.valueOf(y);
						max=Math.max(max,mul);
					}
					n=max;
				}
				System.out.println(loop ? -1:cnt);
			}
		}
	}
	
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23368
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[55][55][55][55][2][3];//スコアの最大値

int a[50],b[50];
int n, m;

// in stack [a1,a2)
//  a1 … a2 - 1 (if a1 == a2 then empty)
//  b1 … b2 - 1 (if b1 == b2 then empty)

int dfs(int a1, int a2, int b1, int b2, int turn, int pass, int asum, int bsum){
    if(pass == 3){
        return 0;
    }
    if(dp[a1][a2][b1][b2][turn][pass] != -INF){

        return dp[a1][a2][b1][b2][turn][pass];
    }
    if(turn){//b

        int ret = INF;//最小化
        ret = min(ret, dfs(a2,a2,b2,b2,0,pass+1,0,0)+asum-bsum);//pass
        if(b2 < m){//カードを出す
            if(b[b2] == -1){//妨害カードを出す
                ret = min(ret, dfs(a1,a2,b1,b2+1,0,0,0,bsum));
            }else{//普通のカードを出す
                ret = min(ret, dfs(a1,a2,b1,b2+1,0,0,asum,bsum+b[b2]));
            }
        }
        dp[a1][a2][b1][b2][turn][pass] = ret;

        return ret;
    }else{//a

        int ret = -INF;//最大化
        ret = max(ret, dfs(a2,a2,b2,b2,1,pass+1,0,0)+asum-bsum);//pass
        if(a2 < n){//カードを出す
            if(a[a2] == -1){//妨害カードを出す
                ret = max(ret, dfs(a1,a2+1,b1,b2,1,0,asum,0));
            }else{//普通のカードを出す
                ret = max(ret, dfs(a1,a2+1,b1,b2,1,0,asum+a[a2],bsum));
            }
        }
        dp[a1][a2][b1][b2][turn][pass] = ret;

        return ret;
    }
}

signed main(void) {

    cin >> n >> m;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }

    rep(i,55)rep(j,55)rep(k,55)rep(l,55)rep(x,2)rep(y,3)
        dp[i][j][k][l][x][y] = -INF;

    cout << dfs(0,0,0,0,0,1,0,0) << endl;

}



Measured memory_bytes: 217592
x, y, a, b, c = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i).max(x)
qs = gets.split.map(&:to_i).max(y)
rs = gets.split.map(&:to_i).sort!.reverse!

pqs = [*ps, *qs].sort!
ans = pqs.inject(:+)

counts = pqs.count <= rs.count ? pqs.count : rs.count

counts.times do |i|
  ans += rs[i] - pqs[i] if rs[i] >= pqs[i]
end
puts ans


Measured memory_bytes: 27236
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
vector<int>prime;
bool sv[M+10];
void sieve()
{    prime.push_back(2);
     int i,j;
     for(i=4;i<=M;i=i+2)
    {
           sv[i]=1;
    }
    for(i=3;i*i<=M;i=i+2)
    {
        if(sv[i]==0)
        {
              for(j=i*i;j<=M;j=j+2*i)
              {
                  sv[j]=1;
              }
        }
    }
    for(i=3;i<M;i=i+2)
    {
        if(sv[i]==0)
        {
            prime.push_back(i);
        }
    }
}
 main()

{
    fast
    sieve();
    int n;
    cin>>n;
    int ses=*lower_bound(prime.begin(),prime.end(),n);
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

ll power_mod(ll k, int n, int mod){
  if(n == 0) return 1;
  ll tmp = power_mod(k, n / 2, mod);
  tmp = (tmp * tmp) % mod;
  if(n % 2 == 0) return tmp;
  return (k * tmp) % mod;
}

ll v_p(int n, int p){
  int res = 0;
  while(n >= p){
    res += (n / p);
    n /= p;
  }
  return res;
}

void dpp(vi &h, vi &dp, int k){
  if(k == 0){
    dp.at(0) = 0;
    return;
  }
  if(k == 1){
    dpp(h, dp, 0);
    dp.at(1) = abs(h.at(0) - h.at(1));
    return;
  }
  if(dp.at(k - 1) != -1 && dp.at(k - 2) != -1) return;
  dpp(h, dp, k - 1);
  int p, q;
  p = abs(h.at(k) - h.at(k - 1)) + dp.at(k - 1);
  q = abs(h.at(k) - h.at(k - 2)) + dp.at(k - 2);
  dp.at(k) = MIN(p, q);
  //cout << "Done of " << k << "\n";
  return;
}


int main(){
  int n; cin >> n;
  vi h(n); REP(i, n) cin >> h.at(i);
  vi subDP(n, -1);
  dpp(h, subDP, n - 1);
  cout << subDP.at(n - 1) << "\n";
  return 0;
}

Measured memory_bytes: 5760
import java.util.*;

class Graph{
    private int V, E;
    private LinkedList<LinkedList<Integer>> adjLists; 
    private int[] status;
    public Graph(int v, int e){
        V = v; E = e;
        status = new int[v];
        adjLists = new LinkedList<>();
        for(int i = 0; i < V; i++){
            adjLists.add(new LinkedList<>());
        }
        for(int i = 0; i < V; i++){
            status[i] = 0;
        }
    }
    public void addEdge(int s, int t){
        adjLists.get(s).add(t);
    }
    public void print(){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < adjLists.get(i).size(); j++){
                System.out.print(adjLists.get(i).get(j) + " ");
            }
            System.out.println();
        }
    }
    private boolean dfsUtil(int u){
        if(status[u] == 1)
            return false;
        LinkedList<Integer> adjList = adjLists.get(u);
        status[u] = 1;
        for(int i = 0; i < adjList.size(); i++){
            int v = adjList.get(i);
            if(status[v] != 2 && dfsUtil(v) == false)
                return false;
        }
        status[u] = 2;
        return true;
    }
    public boolean dfs(){
        for(int i = 0; i < V; i++){
            if(status[i] == 0 && dfsUtil(i) == false)
                return false;
        }
        return true;
    }
}

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int V, E;
        V = sc.nextInt(); E = sc.nextInt();
        Graph g = new Graph(V, E);
        for(int i = 0; i < E; i++){
            int s, t;
            s = sc.nextInt(); t = sc.nextInt();
            g.addEdge(s, t);
        }
        System.out.println(g.dfs()? 0: 1);
    }
}



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

using namespace std;

string str;

bool caesar()
{
	bool flag = false;

	for (int i=0; i<(int)str.size() - 2; i++)
	{
		if(str[i] == 't' && str[i+1] == 'h') {
			if(str[i+2] == 'e' && (str[i+3] == ' ' || str[i+3] == '\0' || str[i+3] == '.')) {
				flag = true;
				break;
			}
			if(str[i+2] == 'i' && str[i+3] == 's' && (str[i+4] == ' ' || str[i+4] == '\0' || str[i+4] == '.')) {
				flag = true;
				break;
			}
			if(str[i+2] == 'a' && str[i+3] == 't' && (str[i+4] == ' ' || str[i+4] == '\0' || str[i+4] == '.')) {
				flag = true;
				break;
			}
		}
	}

	return flag;
}


int main()
{
	while(getline(cin, str))
	{
		for (int i=0; i<26; i++)	//0〜25文字ずれるまで繰り返す
		{
			if(caesar()) {
				cout << str << endl;
			}

			//cout << str << endl;	//Debug

			for (int j=0; str[j] != '\0'; j++) {
				if(str[j] != ' ' && str[j] != '.') {
					if(str[j] == 'z') {
						str[j] = 'a';
					}
					else {
						str[j]++;
					}
				}
			}
		}
	}

	return 0;
}

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

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

  int sunuke[N] = {0};
  
  for(int i=0;i < K; i++){
    int D;
    cin >> D;
  	for(int s=0;s < D; s++){
      int kashi;
      cin >> kashi;
      sunuke[kashi - 1] = 1;
    }
  }
  int sum=0;
  for(int s=0;s < N; s++){
  	sum += sunuke[s];
  }
  cout << N - sum;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=998244353;
typedef long long ll;
int main()
{
	ll n,c,sum,ans;
	ll a[100006],vis[100006];
	scanf("%lld",&n);
	memset(vis,0,sizeof(vis));
	c=-1;
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(c<a[i])
		{
			c=a[i];
		}
	}
	for(ll i=1;i<=n;i++)
	{
		vis[a[i]]++;
		if(i==1)
		{
			if(a[i]>0)
			{
				printf("0\n");
				return 0;
			}
		}
		else
		{
			if(a[i]==0)
			{
				printf("0\n");
				return 0;
			}
		}
	}
	for(ll i=1;i<=c;i++)
	{
		if(i==1)
		{
			sum=1;
		}
		else
		{
			ans=1;
			for(ll j=1;j<=vis[i];j++)
			{
				ans=ans*vis[i-1]%maxn;
			}
			sum=sum*ans%maxn;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
while(1)
{
c-=b;
if(c<=0)
{
cout<<"Yes"<<endl;
break;
}
a-=d;
if(a<=0)
{
cout<<"No"<<endl;
break;
}

}
return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

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;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  VI a(n);
  int idx = -1;
  REP(i, 0, n) {
    cin >> a[i];
    if (a[i] == 1) idx = i;
  }
  int r1 = idx % (k - 1);
  int r2 = (n - idx - 1) % (k - 1);
  int ans = idx / (k - 1) + (n - idx - 1) / (k - 1);
  if (r1 + r2 > 0) ans++;
  if (r1 + r2 >= k) ans++;
  cout << ans << endl;
}


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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

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

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

	int a=0,b=0,buf;

	REP(i,4) cin>>buf,a+=buf;
	REP(i,4) cin>>buf,b+=buf;

	cout<<max(a,b)<<en;
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
long long a[100010][3];

long long dp[100010][3];

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

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][j]);
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < 3; i++) chmax(res, dp[N][i]);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4992
import operator
n = int(input())
lisa = list(map(int,input().strip().split()))
lisb = []
suma = 0
for val in lisa:
	suma+=abs(val)
#print(suma)
m = 0
for i,val in enumerate(lisa):
	if val < 0:
		m+=1
		lisa[i] = abs(val)
		lisb.append((val,i))
#print(lisa)
#print(lisb)
if m%2==0:
	print(suma)
else:
	minb = min(lisb,key = operator.itemgetter(0))
	mina = min(lisa)
	print(suma-2*min(-minb[0],mina))

Measured memory_bytes: 66448
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    --n;
    constexpr ll A = 26;
    ll t = A;
    ll i = 1;

    while (true) {
        if(n < t){
            break;
        }
        n -= t;
        t = t * A;
        ++i;
    }

    string s(i, 'a');


    for0(j, i){
        s[j] = n % A + 'a';
        n /= A;
    }

    reverse(s.begin(), s.end());

    cout << s << "\n";


    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}



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

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<int> blocked(N+1,0);
  for(int i=0; i<M; i++)
  {
    int a;
    std::cin >> a;
    blocked[a]=1;
  }

  long long prevPatterns = 1LL;
  long long prev2Patterns = 0;
  
  for(int i=1; i<=N; i++)
  {
	if( blocked[i] )
    {
      prev2Patterns = prevPatterns;
      prevPatterns = 0;
    }
    else
    {
      auto temp = prevPatterns;
      prevPatterns = (prevPatterns + prev2Patterns) % 1000000007;
      prev2Patterns = temp;
    }
  }
  
  std::cout << prevPatterns;
}


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

using namespace std;

int main(){
  int a, b ,c;
  cin >> a >> b >>c;
  map<int, int> m;
  m[a]++;m[b]++,m[c]++;
  if(m[5]==2 && m[7]==1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

const int MAX = 1000;

class Stack {
private:
    int top;
    int S[MAX];
public:
    Stack() {
        top = 0;
    }
    int isEmpty();
    int isFull();
    void push(int x);
    int pop();
};

int Stack::isEmpty() {
    if (top == 0) {
        return (1);
    } else {
        return (0);
    }
}
int Stack::isFull() {
    if ( top >= (MAX - 1) ) {
        return (1);
    }
    else {
        return (0);
    }
}
void Stack::push(int x) {
    if (isFull()) {
        cout << "Error : Stack Over Flow!!\n";
        exit(1);
    }
    /* topを加算してから、その位置へ挿入 */
    S[++top] = x;
}

int Stack::pop() {
    if (isEmpty()) {
        cout << "Error : Stack Under Flow!!\n";
        exit(1);
    }
    top--;
    /* topが指していた要素を返す */
    return S[top + 1];
}

int main() {
    Stack S;
    int a, b;
    string s;

    while (cin >> s) {
        if ( s[0] == '+' ) {
            a = S.pop();
            b = S.pop();
            S.push(a + b);
        }
        else if ( s[0] == '-' ) {
            b = S.pop();
            a = S.pop();
            S.push(a - b);
        }
        else if ( s[0] == '*' ) {
            a = S.pop();
            b = S.pop();
            S.push(a * b);
        }
        else {
            S.push(atoi(s.c_str()));
        }
    }
    
    cout << S.pop() << endl;

    return (0);
}



Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    if(n<1200){
        cout<<"ABC";
    }else{
        cout<<"ARC";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define datatype int

//比較関数
int compare(datatype a, datatype b){
	return a - b;
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if((compare(tmp[j], tmp[k]) <= 0 && j < half) || k == right){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, i, j, ans = 0, nowA = 0, nowAnum = 0;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	sort(A, N);
	for(i = 0; i < N; i ++){
		if(A[i] == nowA){
			nowAnum++;
			if(nowAnum % 2 == 0){
				ans++;
			}
			else{
				ans--;
			}
		}
		else{
			nowA = A[i];
			ans++;
			nowAnum = 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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


int main() {

  int n;
  cin>>n;

  vector<pair<int, int> > pairs(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    pairs[i] = make_pair(b, a);
  }

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

  int64_t sum=0;
  bool flg=true;
  for(int i=0;i<n;i++){
      sum+=pairs[i].second;
      if(sum> pairs[i].first){
          flg=false;
          break;
    }
  }

  if(flg)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

    return 0;
}

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

int main(){
	int n,m,a[50],b[50],c[50],d[50];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<m;i++){
		cin>>c[i]>>d[i];
	}
	for(int i=0;i<n;i++){
		int ans;
		int cnt=2100000000;
		for(int j=m-1;j>=0;j--){
			if(cnt>=abs(a[i]-c[j])+abs(b[i]-d[j])){
				ans=j+1;
				cnt=abs(a[i]-c[j])+abs(b[i]-d[j]);
			}
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int a[1007];
int main(){
	int k=read(),t=read(),s=0;
	for(int i=0;i<t;++i)a[i]=read(),s+=a[i];
	for(int i=0;i<t;++i){
		int o=a[i]+a[i]-s-1;
		if(o>=0){printf("%d\n",o);return 0;}
	}
	puts("0");
	return 0;
} 

Measured memory_bytes: 256