akhauriyash/Code-Regression huggingface dataset:
/*
It's really an interesting idea to 
transform "Count a rectangle to another rectangle" 
into "Count 4 points to another 4 points".
*/
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=2000010;
const int mod=1000000007;
int fac[maxn],ifac[maxn];
int f(int x1,int y1,int x2,int y2) {return (x1<=x2&&y1<=y2)?(ll)fac[x2-x1+y2-y1]*ifac[x2-x1]%mod*ifac[y2-y1]%mod:0;}
void init(int n) {
	fac[0]=ifac[0]=ifac[1]=1;
	rep(i,2,n) ifac[i]=(ll)(mod-mod/i)*ifac[mod%i]%mod;
	rep(i,1,n) fac[i]=(ll)fac[i-1]*i%mod,ifac[i]=(ll)ifac[i-1]*ifac[i]%mod;
}
int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6;
int calc(int sx,int sy,int tx,int ty) {
	int ans=0;
	rep(x,x3,x4) {
		(ans-=(ll)f(sx,sy,x,y3-1)*f(x,y3,tx,ty)%mod*(x+y3)%mod)%=mod;
		(ans+=(ll)f(sx,sy,x,y4)*f(x,y4+1,tx,ty)%mod*(x+y4+1)%mod)%=mod;
	}
	rep(y,y3,y4) {
		(ans-=(ll)f(sx,sy,x3-1,y)*f(x3,y,tx,ty)%mod*(x3+y)%mod)%=mod;
		(ans+=(ll)f(sx,sy,x4,y)*f(x4+1,y,tx,ty)%mod*(x4+y+1)%mod)%=mod;
	}
	return (ans+mod)%mod;
}
int work(int x,int y) {
	int ans=0;
	(ans+=calc(x,y,x5,y5))%=mod;
	(ans-=calc(x,y,x6+1,y5))%=mod;
	(ans-=calc(x,y,x5,y6+1))%=mod;
	(ans+=calc(x,y,x6+1,y6+1))%=mod;
	return (ans+mod)%mod;
}
int main() {
	init(2000000);
	x1=read();x2=read();x3=read();x4=read();x5=read();x6=read();
	y1=read();y2=read();y3=read();y4=read();y5=read();y6=read();
	int ans=0;
	(ans+=work(x1-1,y1-1))%=mod;
	(ans-=work(x2,y1-1))%=mod;
	(ans-=work(x1-1,y2))%=mod;
	(ans+=work(x2,y2))%=mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n;
	cin>>n;
	priority_queue<mp,vector<mp>,greater<mp> > q;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		q.push(mp(b,a));
	}
	ll sum = 0;
	bool f = false;
	while(!q.empty()){
		mp now = q.top();
		q.pop();
		sum+=now.second;
		if(sum > now.first){
		    	f = true;
		}
	}
	if(!f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}


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


int main(){
ll x , y ;
cin>>x>>y;
if( x%y == 0 )printf("-1\n");
else{

    ll d=x+x;
    while( d%y==0 && d<= 1000000000000000000ll )d+=x;
    if( d%y!=0 )printf("%lld\n",d);
    else printf("-1\n");

}


return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

def solve():
    s = input()
    n = len(s)

    if s[0] != '1' or s[-1] != '0':
        print(-1)
        return
    for i in range(n // 2):
        if s[i] != s[-(i + 2)]:
            print(-1)
            return

    v = [i + 1 if c == '1' else 0 for (i, c) in enumerate(s)]
    v[-1] = n

    last = n
    for i, x in reversed(list(enumerate(v))):
        if x != 0:
            v[i] = last
            last = x
        else:
            v[i] = last

    for i, x in enumerate(v[:-1]):
        print(i + 1, x)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 17404
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

S = collect(chomp(readline()))


if S[end] == 's'
    push!(S, 'e', 's')
else
    push!(S, 's')
end


for s in S
    print(s)
end

println()

Measured memory_bytes: 165924
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);

	ll n;
	unordered_set<string> mySet;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		mySet.insert(s);
	}

	cout << mySet.size() << endl;

	return 0;
}

Measured memory_bytes: 17724
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
ct1,ct2,ct3=0,0,0
for i in range(n):
  ct1+=(B[i]-A[i])
  ct2+=max(A[i]-B[i],0)
  if B[i]>A[i]:
    ct3+=(B[i]-A[i]-1)//2+1
print("Yes" if max(ct2,ct3)<=ct1 else "No")

Measured memory_bytes: 4600
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);

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

    int ans = 0;
    int before = -1;
    REP(i, N) {
        ans += B[A[i]];
        if (before + 1 == A[i]) {
            ans += C[before];
        }
        before = A[i];
    }
    print(ans);
}

int main() {

    solve();
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  LL all=1,exA=2,exB=1;
  
  rep(i,n){
    all *= 10;
    exA *= 9;
    exB *= 8;
    all %= 1000000007;
    exA %= 1000000007;
    exB %= 1000000007;
  }
  all = all - exA + exB;
  while(all<0){all += 1000000007;}
  all %= 1000000007;
  
  cout << all << endl;
  
  return 0;
}

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

namespace rolling_hash {

using hash_t = long long;
using hash_tuple = std::tuple<hash_t, hash_t>;
const hash_t base1 = 114514;
const hash_t base2 = 810893;
const hash_t mod1 = 1000000007;
const hash_t mod2 = 1000000009;
hash_t hash1[300010];
hash_t hash2[300010];
hash_t pow1[300010];
hash_t pow2[300010];

void init(const std::string &s){
	int n = s.size();
	hash1[0] = 0;
	hash2[0] = 0;
	pow1[0] = 1;
	pow2[0] = 1;
	for (int i = 1; i <= n; i++){
		hash1[i] = (hash1[i - 1] * base1 + s[i - 1]) % mod1;
		hash2[i] = (hash2[i - 1] * base2 + s[i - 1]) % mod2;
		pow1[i] = pow1[i - 1] * base1 % mod1;
		pow2[i] = pow2[i - 1] * base2 % mod2;
	}
}

hash_tuple get(int l, int r){
	hash_t h1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
	hash_t h2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
	return make_tuple(h1, h2);
}

}

int main()
{
	int n, m;
	string s;
	cin >> n >> m >> s;
	rolling_hash::init(s);
	set<rolling_hash::hash_tuple> st;
	int l = 0, r = 1;
	for (int i = 0; i < m; i++){
		cin >> s;
		if (s == "L++") l++;
		else if (s == "L--") l--;
		else if (s == "R++") r++;
		else r--;
		st.insert(rolling_hash::get(l, r));
	}
	cout << st.size() << endl;
}

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


int main(){

  int h,prev;
  int min,max;
  int t,n;

  cin >> t;

  for(int i=0; i<t; i++){
    
    max = 0; min = 0;
    cin >> n;
    cin >> prev;
    for(int j=1; j<n; j++){
      cin >> h;
      if(h>prev && max < h-prev)max = h-prev;
      if(h<prev && min > h-prev)min = h-prev;

      prev = h;

    }

    cout << max << ' ' << abs(min) << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ans = 0;
            while (N > 2)
            {
                ans++;
                N -= 3;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;

typedef long long int int64;

int main(int argc, char **argv)
{
    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] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int total2=0;
    REP(i,n){
        int tmp;
        cin >> tmp;
        while(tmp%2==0){
            tmp/=2;
            total2++;
        }
    }
    cout << total2 << endl;
    return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> s(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> s[i][j];
        }
    }

    vector<vector<int>> ans(h, vector<int>(w));
    for(int x=0; x<h; x++){
        for(int y=0; y<w; y++){
            int count = 0;
            if(s[x][y] == '#') continue;

            for(int dx=-1; dx<=1; dx++){
                for(int dy=-1; dy<=1; dy++){
                    if(0 <= x+dx && x+dx < h
                    && 0 <= y+dy && y+dy < w
                    && s[x+dx][y+dy] == '#') count += 1;
                }
            }
            ans[x][y] = count;// don't know why but (char) cast doesn't work...
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '#') cout << '#';
            if(s[i][j] != '#') cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Life is like a tube of toothpaste. When you've used all the toothpaste down the last squeeze, that's when you've really lived. Live with all your might. And struggle as long as you have life.
#include<bits/stdc++.h>
using namespace std;

#define s second
#define f first

const long long maxn = 1e6 + 10;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

long long ans;
long long n, m;
long long s, t;
long long weight[maxn];
long long dis[2][maxn];
long long num[2][maxn];
pair<long long, long long> sarotah[maxn];
vector<pair<long long, long long>> adj[maxn];

void in();
void solve();
void echeck(long long e);
void vcheck(long long u);
void dfs(long long id, long long u);
void dijk(long long id, long long u);
void out();

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    in();
    solve();
    out();
}

void in(){
    cin >> n >> m;
    cin >> s >> t;
    s--;
    t--;
    for(long long i = 0; i < m; i++){
        long long u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        weight[i] = w;
        sarotah[i] = {u, v};
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
}

void solve(){
    dijk(0, s);
    dijk(1, t);
    dfs(0, t);
    dfs(1, s);
    for(long long i = 0; i < n; i++)
        vcheck(i);
    for(long long i = 0; i < m; i++)
        echeck(i);
}

void echeck(long long e){
    long long u = sarotah[e].f;
    long long v = sarotah[e].s;
    if(dis[0][u] < dis[0][v])
        swap(u, v);
    if(dis[0][v] + dis[1][u] + weight[e] == dis[0][t] && dis[0][v] < (dis[0][t] + 1) / 2 && dis[1][u] < (dis[0][t] + 1) / 2){
        ans += num[0][v] * num[1][u] % mod * (((num[0][t] - num[0][v] * num[1][u] % mod) + mod) % mod) % mod;
        ans %= mod;
    }
}

void vcheck(long long u){
    if(dis[0][t] % 2 == 0 && dis[0][u] == dis[1][u] && dis[0][u] == dis[0][t] / 2){
        ans += num[0][u] * num[1][u] % mod * (((num[0][t] - num[0][u] * num[1][u] % mod) + mod) % mod) % mod;
        ans %= mod;
    }
}

void dfs(long long id, long long u){
    if(num[id][u] != 0)
        return;
    if(dis[id][u] == 0){
        num[id][u] = 1;
        return;
    }
    for(auto v: adj[u]){
        if(dis[id][u] - v.s == dis[id][v.f]){
            dfs(id, v.f);
            num[id][u] += num[id][v.f];
            num[id][u] %= mod;
        }
    }
}

void dijk(long long id, long long u){
    set<pair<long long, long long>> dijkstra;
    for(long long i = 0; i < n; i++){
        if(i != u)
            dis[id][i] = inf;
        dijkstra.insert({dis[id][u], u});
    }
    while(dijkstra.size()){
        auto x = (*dijkstra.begin()).s;
        dijkstra.erase({dis[id][x], x});
        for(auto v: adj[x]){
            if(dis[id][x] + v.s < dis[id][v.f]){
                dijkstra.erase({dis[id][v.f], v.f});
                dis[id][v.f] = dis[id][x] + v.s;
                dijkstra.insert({dis[id][v.f], v.f});
            }
        }
    }
}

void out(){
    cout << ans;
}


Measured memory_bytes: 53200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int T[] = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = scan.nextInt();
		}
		int M = scan.nextInt();
		int P[] = new int[M];
		int X[] = new int[M];
		for (int i = 0; i < M; i++) {
			P[i] = scan.nextInt();
			X[i] = scan.nextInt();
		}

		for (int i = 0; i < M; i++) {
			int total = 0;
			for (int j = 0; j < N; j++) {
				if (P[i] == j + 1) {
					total += X[i];
				} else {
					total += T[j];
				}
			}
			System.out.println(total);
		}
	}

}


Measured memory_bytes: 21588
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define il inline
#define rg register
#define gi read<int>
using namespace std;
const int O = 1010;
template<class TT>
il TT read() {
	TT o = 0,fl = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-') ch = getchar();
	if (ch == '-') fl = -1, ch = getchar();
	while (isdigit(ch)) o = o * 10 + ch - '0', ch = getchar();
	return fl * o;
}
int n, m;
int main() {
    n = gi();
    for (int i = 1; i < 10; ++i)
        if (n % i == 0 && n / i < 10)
            return 0 & puts("Yes");
    puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << "\n";
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int n , r ;
int main()
{
    cin >> n >> r ;
    if (n >= 10)
    {
        cout << r <<"\n";
    }else
    {
        int rem = 100 * (10 - n);
        cout << r + rem <<"\n";

    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n, m, k;
char s[10][10], t[10][10];
bool check(int r, int c) {
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < m; j++) t[i][j] = s[i][j];
    for (int i = 0; i < n; i++) {
        if (r & (1 << i)) 
            for (int j = 0; j < m; j++) t[i][j] = 'x';
    }
    for (int j = 0; j < m; j++) {
        if (c & (1 << j)) 
            for (int i = 0; i < n; i++) t[i][j] = 'x';
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < m; j++) 
            if (t[i][j] == '#') cnt++;
    return cnt == k;
}

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    int res = 0;
    for (int i = 0; i < (1 << n); i++) 
        for (int j = 0; j < (1 << m); j++) 
            if (check(i, j)) res++;
    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807


int main()
{
ll n;
cin >> n;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
}

deque<ll> v; 
v.push_front(t[0]);
rep(i,n-1){
    if(lower_bound(v.begin(),v.end(), t[i+1])==v.begin()){
        v.push_front(t[i+1]);
    }
    else {
        auto itr=lower_bound(v.begin(),v.end(), t[i+1]);
        itr--;
        *itr=t[i+1];
    }
}
cout << v.size() << endl;
return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int input_num;
	scanf("%d", &input_num);
	while(0 < input_num--)
	{
		int sides[3];
		scanf("%d %d %d", &sides[0], &sides[1], &sides[2]);

		for(int i = 0; i < 2; i++)
		{
			if(sides[i] > sides[i+1])
			{
				int swap = sides[i];
				sides[i] = sides[i+1];
				sides[i+1] = swap;
 			}
		}
		printf("%s\n", (sides[0]*sides[0]+sides[1]*sides[1]==sides[2]*sides[2]) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#include<queue>
#define ll long long
using namespace std;
int n,m;
ll a,ans;
priority_queue<ll> q;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&a),q.push(a);
	while(m){
		m--;
		ll x=q.top(); q.pop();
		ll y=x/2;
		q.push(y);
	}
	while(!q.empty()){
		ans+=q.top();
		q.pop();
	}
	printf("%lld",ans);
	return 0;
}

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

int main()
{
	string card;
	while(cin >> card && card != "-")
	{
		int N, H;
		cin >> N;
		for(int i = 0; i < N; ++i)
		{
			cin >> H;
			card = card.substr(H) + card.substr(0, H);
		}
		
		cout << card << endl;
	}

    return 0;
}



Measured memory_bytes: 3140
#include <stdio.h>
int main(){
    long int n,k;
    scanf("%ld%ld",&n,&k);
    if(n==k){
        printf("0");
        return 0;
    } else {
        long int zzz=n%k;
        long int xxx=-(zzz-k);
        if(zzz>=xxx){
            printf("%ld",xxx);
            return 0;
        } else{
            printf("%ld",zzz);
            return 0;
        }
    }
}


Measured memory_bytes: 128
/*
^-^ THINK SIMPLE ^-^
^-^ THINK FAST ^-^
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007
#define siz 100001

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n;
	cin >> n;
	if(n >= 30) cout << "Yes" << "\n";
	else cout << "No" << "\n"; 
}























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

inline void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main() {
	init();
	int sum = 0;
	string str;
	cin >> str;
	for(int i = 0; i < (int)str.size(); ++i)
		sum += (str[i] - '0');
	if((sum % 9) == 0)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

int N;
int A, B, mini=99999999;
char a[10];
char b[10];
int sumA, sumB;

int main()
{
  cin >> N;
  if(N % 2 == 0)
  {
    A = N / 2;
    B = N / 2;
  }
  else
  {
    A = N / 2;
    B = (N / 2) + 1;
  }
  while(A>0)
  {
    sprintf(a, "%d", A);
    sprintf(b, "%d", B);
    for(int i=0; i<strlen(a); i++)
      sumA += a[i] - 48;
    for(int i=0; i<strlen(b); i++)
      sumB += b[i] - 48;
    if(sumA + sumB < mini)
      mini = sumA + sumB;
    sumA = 0;
    sumB = 0;
    A--;
    B++;
  }
  cout << mini << "\n";
  return 0;
}


Measured memory_bytes: 256
import re
def main():
    n = int(input())
    ans = []
    while n // 26 > 0:
        ans.append(chr(97 + (n-1)%26))
        n = (n - 1) // 26
    if n > 0:
        ans.append(chr(97 + (n-1)%26))

    ans.reverse()
    print("".join(ans))
    return 

if __name__ == "__main__":
    main()

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int lg(int n , int k)
{
	ld x = log(n);
	ld y = log(k);
	
	x = x/y;
	int ans = x+1;
	return ans;
}
int32_t main(){
	fast;
	int n;
	cin >> n;
	
	int a[n];
	f(i,0,n)    cin >> a[i];
	
	int ans = inf64;
	f(i,0,101)
	{
		int t = 0;
		f(j,0,n)
			t += pow(a[j]-i,2);
		ans = min(ans , t);
	}
	cout << ans;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	b := SingleStr()
	bs := strings.Split(b, "")
	var max int

	for idx, _ := range bs {
		t := bs[idx:]
		var c int
		for _, v := range t {
			var end bool
			switch v {
			case "A", "C", "G", "T":
				c++
			default:
				end = true
			}
			if end {
				break
			}
		}
		if max < c {
			max = c
		}
	}
	fmt.Println(max)
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

string S;
ll K;
int main(){

cin.tie(0);
ios::sync_with_stdio(false);
cin>>S>>K;
if(S.size()==1){
    cout<<S[0]<<endl;
    return 0;
}
if(S[0]!='1'){
    cout<<S[0]<<endl;
}else{
    ll x=1; char y='1';
    rep(i,S.size()){
        if(S[i]!='1'){
            x=i+1; 
            y=S[i];
            break;
        }
    }
    if(K<=x-1){
        cout<<1<<endl;
    }else{
        cout<<y<<endl;
    }
}

}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, K; cin >> N >> K;
    vector<int> x(N), cost;
    rep (i, 0, N) cin >> x[i];

    int ans = INF;
    rep (i, 0, N-K+1) {
        ans = min(ans, min(x[i+K-1] - x[i] + abs(x[i+K-1]), x[i+K-1] - x[i] + abs(x[i])));
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll p,q=0,r=0,s=0;
    cin>>p;
    q=p/500;
    r=p%500;
    s=s+q*1000;
    s=s+(r/5)*5;
    cout<<s<<endl;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll x) {
  if (x == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll x;
  scanf("%lld", &x);
  solve(x);
  return 0;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	int a[250];
	rep(i, n) cin >> a[i];

	m = 0;
	f = 0;
	while(1){
		rep(i, n){
			if(a[i]%2 != 0){
				f = 1;
				break;
			}
			a[i] /= 2;
		}
		if(f == 1) break;
		++m;
	}

	cout << m << endl;
}

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

using namespace std;

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

    uint64_t num_finger = 0;
    if(n!=0)
    {
        num_finger = uint64_t(log2l(n)) + 1;
    }
    cout << num_finger << endl;

    return 0;

}

Measured memory_bytes: 3272
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ll c = 0;
    ll x,m=100;
    cin >> x;
    while(x > m)
    {
        m += m/100;
        c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll l = 0, r = inf; //(l, r]
    while(r-l > 1){
        ll m = (l+r)/2;
        ll sum = 0;
        rep(i, N){
            sum += (A[i]-1)/m;
        }
        if(sum <= K) r = m;
        else l = m;
    }
    cout << r << endl;
}

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

int main()
{
	int len[10];
	int v1,v2;
	while( scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &len[0],&len[1],&len[2],&len[3],&len[4],&len[5],&len[6],&len[7],&len[8],&len[9],&v1,&v2) != EOF ){
		int accum[10] = {0};
		accum[0] = len[0];
		for(int i=1;i<10;i++){
			accum[i] += accum[i-1] + len[i];
		}
		
		// accum[9] は合計の距離
		double t = (double)accum[9]/(v1 + v2);
		double dist = (double) v1*t;
		for(int i=0;i<10;i++){
			if( dist <= accum[i] ){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
# coding: utf-8

def main():
    N = int(input())
    btc_to_jpy = 380000.0
    ans = 0
    for i in range(N):
        temp_value,unit = input().split()
        value = float(temp_value)
        if unit == "BTC":
            value *= btc_to_jpy
        ans += value
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
x1,y1,x2,y2 = map(int,input().split())
x = x2 - x1
y = y2 - y1
x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 =y1 + x
print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];

    ll ans = 0;
    rep(i,N-1)srep(j,i+1,N) {
        ans += (d[i]*d[j]);
    }
    cout << ans << endl;
    return 0;
}


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

const int MAXN = 200020;
int NODOS = 0;
typedef int Costo;
const Costo INF = 1 << 30;

typedef pair<Costo, int> CostoNodo;
vector<CostoNodo> grafoCosto[MAXN];
const bool bi = false;
// Grafos con ponderacion.
// Nodos indexados de 0 a n - 1.
// bi = true -> Bidireccional.
// bi = false -> Dirigido.

struct Ponderada{
  int x, y;
  Costo c;
  Ponderada(){}
  Ponderada(int x_, int y_, int c_) : x(x_), y(y_), c(c_) {}
  bool operator<(const Ponderada& q) const {
    return c < q.c ? true : false;
  }
};

void AgregarArista(int u, int v, Costo c) {
  if (bi) grafoCosto[v].push_back(CostoNodo(c, u));
  grafoCosto[u].push_back(CostoNodo(c, v));
}

void limpia(){
  for( int i = 0; i < NODOS; i++ )
    grafoCosto[i].clear();
}

// Algoritmo de Bellman-Ford optimizado, desde
// el nodo s. Devuelve un booleano indicando si
// existe un ciclo negativo en un digrafo.
// Obtiene el vector de distancias a todos.
Costo dst[MAXN]; // <- Resultado
bool BellmanFerrari(int s) {
  queue<int> q;
  vector<bool> en_cola(NODOS);
  vector<int> procesado(NODOS);
  for( int i = 0; i < NODOS; i++ ) dst[i] = INF;
  q.push(s), dst[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop(), en_cola[u] = false;
    if (++procesado[u] == NODOS) return true;
    for (CostoNodo arista : grafoCosto[u]) {
      int v = arista.second;
      Costo p = arista.first;
      if (dst[u] + p < dst[v]) {
        if (!en_cola[v]) q.push(v);
        dst[v] = dst[u] + p;
        en_cola[v] = true;
      }
    }
  }
  return false;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int casos, N, M, S, T, x, y, c;

	cin >> N >> M >> S;
	NODOS = N;

	limpia();
	for( int i = 0; i < M; i++ ){
		cin >> x >> y >> c;
		AgregarArista( x, y, c );
	}
	BellmanFerrari( S );

	for( int i = 0; i < NODOS; i++ ){
		if( dst[i] == INF ){
			cout << "INF\n";
		}
		else
			cout << dst[i] << '\n';
	}
	
	return 0;
}

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

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M/* your task */; }
int h2(int key){ return 1 + (key % (M -1))/* your task */; }

int find(char str[]){

    /* your task */
  long long key,i,h;

  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
}

int insert(char str[]){

  /* your task */
  long long key,i,h;

  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14916
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, h, n;
    cin >> w >> h >> n;
    bool tile[100][100] = {};
    REP(i, n){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
        case 1:
            FOR(i, 0, x - 1)FOR(j, 0, h - 1)
                tile[i][j] = true;
            break;
        case 2:
            FOR(i, x, w - 1)FOR(j, 0, h - 1)
                tile[i][j] = true;
            break;
        case 3:
            FOR(i, 0, w - 1)FOR(j, 0, y - 1)
                tile[i][j] = true;
            break;
        case 4:
            FOR(i, 0, w - 1)FOR(j, y, h - 1)
                tile[i][j] = true;
            break;
        }
    }

    int ans = 0;
    REP(i, w)REP(j, h)if(!tile[i][j])ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    string ans = "";
    std::cin >> s;
    int n = s.length();
    for (int i = 0; i < n-8; i++) {
        ans.push_back(s[i]);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
    int l, r;
};
const int N = 1e6 + 7;
string s[N];
int n;

vector<node>a;
vector<node>b;

bool cmp(node x, node y){
    return x.r < y.r;
}

bool cmp1(node x, node y){
    return x.l < y.l;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout .tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        int len = s[i].length();
        int l =0, r = 0;
        for(int j = 0; j < len; j++){
            if(s[i][j] == '(') l++;
            else if(l) l--;
            else r++;
        }
        if(l >= r) a.push_back({l, r});
        else b.push_back({l, r});
    }
    sort(a.begin(), a.end(), cmp);
    sort(b.begin(), b.end(), cmp1);
    int sum = 0, ok = 0;
    for(int i = 0; i < a.size(); i++){
        sum -= a[i].r;
        if(sum < 0){
            ok = 1;
            break;
        }
        sum += a[i].l;
    }
    int sum1 = 0;
    for(int i = 0; i < b.size(); i++){
        sum1 -= b[i].l;
        if(sum1 < 0){
            ok = 1;
            break;
        }
        sum1 += b[i].r;
    }
    if(ok){
       //cout << "No\n";
       //puts("No");
       puts("No");
    }else{
        if(sum == sum1){
            //cout << "Yes\n";
            //puts("Yes");
            puts("Yes");
        }else{
            //cout << "No\n";
            puts("No");
           //printf("No\n");
        }
    }

}

Measured memory_bytes: 42520
def main():
    N, T = list(map(int, input().split(' ')))
    t = list(map(int, input().split(' ')))
    ans = 0
    for i in range(N):
        if i < N - 1:
            ans += min([T, t[i+1] - t[i]])
        else:
            ans += T
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26708
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def parity():
    res=sum(xy[0])%2
    for x,y in xy:
        if (x+y)%2!=res:return -1
    return res

n=II()
xy=LLI(n)

p=parity()
if p==-1:
    print(-1)
    exit()

dd=[1]
if p==0:dd.append(1)
lim=10**12
while len(dd)<40 and dd[-1]*2<=lim:
    dd.append(dd[-1]*2)
print(40)
print(*dd)

for x,y in xy:
    ans=""
    for d in dd[::-1]:
        if abs(x)>abs(y):
            if x>0:
                x-=d
                ans+="R"
            else:
                x+=d
                ans+="L"
        else:
            if y>0:
                y-=d
                ans+="U"
            else:
                y+=d
                ans+="D"
    print(ans[::-1])


Measured memory_bytes: 9292
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = map(int, input().split())
    u = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        u.union(A-1, B-1)
    m = 0
    for i in range(N):
        if m < u.size(i):
            m = u.size(i)
    return m
print(main())


Measured memory_bytes: 80940
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	Scanner in=new Scanner(System.in);
	int W=in.nextInt();
	int H=in.nextInt();
	int x=in.nextInt();
	int y=in.nextInt();
	int r=in.nextInt();
	if(x-r<0 || x+r>W || y-r<0 || y+r>H)
		System.out.println("No");
	else
		System.out.println("Yes");
	}
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e4+1;
int n, c[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(x, 1, 100)FOR(y, 1, 100)FOR(z, 1, 100){
    int s = x*x+y*y+z*z+x*y+y*z+z*x;
    if(s<N) c[s]++;
  }
  cin >> n;
  FOR(i, 1, n+1) cout << c[i] << endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int main(void){

   ll n;
   cin >> n;
   vector<ll> a(3*n);
   for (int i = 0; i < 3*n;i++)
      cin >> a.at(i);
   sort(a.begin(), a.end());

   ll i = 3 * n - 2;
   ll ans = 0;
   while (n--){
      ans += a.at(i);
      i -= 2;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 2560
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut count = [0; 5];
    for _ in 0..n {
        let s = sc.chars();
        match s[0] {
            'M' => count[0] += 1,
            'A' => count[1] += 1,
            'R' => count[2] += 1,
            'C' => count[3] += 1,
            'H' => count[4] += 1,
            _ => {}
        }
    }

    let mut sum: i64 = 0;
    for mask in 0usize..(1 << 5) {
        if mask.count_ones() != 3 {
            continue;
        }
        let mut ans = 1;
        for i in 0..5 {
            if mask & (1 << i) != 0 {
                ans *= count[i];
            }
        }
        sum += ans;
    }
    println!("{}", sum);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

public class ABC164D {
	private static void Main(string[] args) {
		var s = ReadIntDigitsAsArray();
		Array.Reverse(s);

		var divisor = 2019;
		var counters = new int[divisor];
		var dmod = 0;
		var tmod = 1;

		counters[0]++;
		foreach (var digit in s) {
			dmod = (tmod * digit + dmod) % divisor;
			tmod = (tmod * 10) % divisor;

			counters[dmod]++;
		}

		var answer = counters.Where(n => n >= 2).Select(n => CalcCombination(n, 2)).Sum();
		Console.WriteLine(answer);
	}

	private static int[] ReadIntDigitsAsArray() => Console.ReadLine().Trim().Select(c => c - '0').ToArray();

	private static int CalcCombination(int n, int k) {
		var temp = 1;
		for (var i = 1; i <= k; i++) {
			temp = temp * (n - i + 1) / i;
		}
		return temp;
	}
}

Measured memory_bytes: 29228
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=1e5+5;
const int mod=1e9+7;
int f[maxm];
int ppow(int a,int b,int mod){
    int ans=1%mod;a%=mod;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
signed main(){
    int n,k;cin>>n>>k;
    int ans=0;
    for(int i=k;i>=1;i--){//枚举gcd
        f[i]=ppow(k/i,n,mod);
        for(int j=i+i;j<=k;j+=i){
            f[i]=(f[i]-f[j]+mod)%mod;
        }
        ans=(ans+f[i]*i%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
	if(s[i]==t[i])
	{
		continue;
	}
	if(s[i]!=t[i])
	{
		t[i]=s[i];
		ans++;
	}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3892
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;




int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    int ans = 0;
    Rep(i,a,b+1){
        if(c%i == 0) ans++;
    }
    cout << ans << endl;
}









Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    ll n,m;
    std::cin >> n>>m;
    if(m%2==1){
        ll l=n/m;
        std::cout <<ll(pow(l,3)) << std::endl;
    }
    else{
        ll l=n/m,lll=n/(m/2)-l;
        std::cout<<l*l*l+lll*lll*lll << std::endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<set>

using namespace std;

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

  if(a+b>=c) cout<<b+c<<endl;
  else  cout << (a+b)+b+1<<endl;
  }


Measured memory_bytes: 256
#!/usr/bin/env python3
#D
import numpy as np
import math
import re

n = int(input())
a = input()
a = re.split(" ",a)
a = list(map(int,a))
count = 0
sum = 0
for i in range(n):
    if(a[i] < 0):
        count += 1
if(count %2 == 0):
    for j in a:
        sum += abs(j)
    print(sum)
else:
    min = 10**9
    t = 0
    for i in range(n):
        if(min > abs(a[i])):
            min = abs(a[i])
            t = i
    for j in range(n):
        if j != t:
            sum += abs(a[j])
        else:
            sum -= abs(a[j])
    
    print(sum)

Measured memory_bytes: 23264