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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){out << q.F << " " << q.S; return out;}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F-p2.F, p1.S-p2.S};}

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < si(s); i++){
        if(s[i] == '?')s[i] ='D';
    }
    cout << s << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 3748
def resolve():
    import math
    K = int(input())
    
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            gcd1 = math.gcd(a,b)
            for c in range(1, K+1):
                gcd2 = math.gcd(gcd1,c)
                ans += gcd2
    print(ans)
resolve()

Measured memory_bytes: 67816
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
template <class typ> struct BIT{
	vector<typ> x;
	BIT(int n):x(n,0){}
	typ sum(int a,int b){
		if(a==0){
			typ s=0;
			for(int i=b;i>=0;i=(i&(i+1))-1) s+=x[i];
			return s;
		}
		else return sum(0,b)-sum(0,a-1);
	}
	void add(int ind,typ f){
		for(int i=ind;i<x.size();i|=i+1) x[i]+=f;
	}
};
lint a[200100],s[200100];
int pos[200100];
vector<pint> v;
int main()
{
	int n;lint k,out=0;
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	//sort(a,a+n);
	s[0]=0;
	rep(i,n){
		s[i+1]=s[i]+a[i];s[i+1]-=k;
		v.pb(mp(s[i+1],i+1));
	}
	//rep(i,n+1) cout<<s[i]<<endl;
	sort(All(v));
	rep(i,n) pos[v[i].se]=i;//cout<<pos[2]<<endl;
	BIT<int> bit(n+10);
	for(int i=n-1;i>=0;i--){
		bit.add(pos[i+1],1);
		int t=lower_bound(All(v),mp(s[i],0))-v.begin();
		//cout<<t<<' '<<bit.sum(t,n+5)<<endl;
		out+=bit.sum(t,n+5);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 9072
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong(), y = s.nextLong();
        long mx = -1;
        long a10000 = -1, a5000 = -1, a1000 = -1;
        boolean ok = true;
        for(long i = 0; i <= y / 10000 && ok; ++i) {
            for(long j = 0; j <= (y - i * 10000)/ 5000; ++j) {
                long total = i * 10000 + j * 5000;
                long k = (y - total) / 1000;
                if (i * 10000 + j * 5000 + k * 1000 == y && i + j + k == n) {
                    a10000 = i;
                    a5000 = j;
                    a1000 = k;
                    ok = false;
                    break;
                }
            }
        }
        System.out.println(a10000 + " " + a5000 + " " + a1000);
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
const int N=1e5;
int ind,cnt,temp;
int main(){
int n;
cin>>n;
int ar[N];
for(int i=1;i<=n;++i)
cin>>ar[i];
ind=1,cnt=1,temp=0;
for(int j=ind;j<=n;){
if(ar[j]==2){
cout<<cnt<<"\n";
break;
}
else if(cnt>=n){
cout<<"-1\n"; break;
}
++cnt;
j=ar[j];

}
return 0;
}

Measured memory_bytes: 640
from collections import Counter

N,K,L = map(int, input().split())

road = [tuple(map(int,input().split())) for i in range(K)]
train = [tuple(map(int,input().split())) for i in range(L)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1


uf_road = UnionFind(N)
for p,q in road:
    p,q = p-1, q-1
    if not uf_road.is_same(p,q):
        uf_road.unite(p,q)

uf_train = UnionFind(N)
for r,s in train:
    r,s = r-1, s-1
    if not uf_train.is_same(r,s):
        uf_train.unite(r,s)

total_union_num = Counter()
for i in range(N):
    r = uf_road.root(i)
    t = uf_train.root(i)
    total_union_num[(r,t)] += 1

ans = []
for i in range(N):
    r = uf_road.root(i)
    t = uf_train.root(i)
    ans.append(total_union_num[(r,t)])

print(*ans)


Measured memory_bytes: 80396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] t = new int[n];
        int count = 0;
        for (int i = 0; i < n; i++) {
            t[i] = scanner.nextInt();
            count += t[i];
        }

        int m = scanner.nextInt();

        for (int i = 0; i < m; i++) {
            int p = scanner.nextInt();
            int x = scanner.nextInt();

            System.out.println(count-t[p-1]+x);
        }
    }
}

Measured memory_bytes: 10452
#include<bits/stdc++.h>
using namespace std;
int component[100001],c=0;
vector<int> gr[100001];
void dfs(int node)
{
  if(component[node]>0)
    return;
  component[node]=c;
  for(auto neighbour:gr[node])
    dfs(neighbour);
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
    int x,y,z;
    cin>>x>>y>>z;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  memset(component,0,sizeof(component));
  for(int i=1;i<=n;i++)
  {
    if(component[i]>0)
      continue;
    ++c;
    dfs(i);
  }
  cout<<c;
}

Measured memory_bytes: 9216
var
  i,j,h,w:longint;
  s:string[5];
  c:char;
begin
  read(h);
  readln(w);
  for i:=1 to h do
  begin
    for j:=1 to w do
    begin
      read(s);
      if s='snuke' then
      begin
        write(chr(64+j));
        writeln(i);
      end;
      read(c);
    end;
  end;
end.

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (2 * m + 1 >= n) {
    puts("1");
  } else {
    printf("%d\n", (n + 2 * m) / (2 * m + 1));
  }
}


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

bool can_reach(pair<int, int> p1, pair<int, int> p2, int dt) {
    int l1_dist = abs(p1.first - p2.first) + abs(p1.second - p2.second);
    //cout << "l1_dist: " << l1_dist << " dt: " << dt <<  endl;
    if (dt < l1_dist) return false;
    else if ((dt - l1_dist) % 2 == 0) return true;
    else return false;
}

int main() {
    int N;
    cin >> N;
    bool flag = true;
    int t, x, y;
    int old_t = 0;
    int old_x = 0;
    int old_y = 0;

    for (int i = 0; i < N; i++) {
        if (i > 0) {
            old_t = t;
            old_x = x;
            old_y = y;
        }
        cin >> t >> x >> y;
        //cout << t << " " << old_t << endl;
        flag = flag && can_reach(make_pair(old_x, old_y), make_pair(x, y), t-old_t);
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

int timeLimit = 1990;
/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    //d = 365
    int D; cin >> D;
    int N = 26;
    D++; N++;
    
    //しばらく特定のタイプのコンテストが開催されないと、満足度が下がってしまいます
    int c[N]; rep(i,1,N) cin >> c[i]; 
    
    //d日目にiタイプのコンテスト開催　＝＞　満足度 += s[d][i]
    int s[D][N];
    rep(d,1,D) rep(i,1,N) cin >> s[d][i];

    // タイプ i のコンテストを開催した最後の日
    int last[N] = {};

    int ans[D];

    //満足度の合計
    ll satisfaction = 0;
    rep(d,1,D){
        ll tmpSatisfaction = -1e9;
        int tmpAns = 1;

        rep(i,1,N){
            if(satisfaction + s[d][i] - c[i]*(d-last[i]) > tmpSatisfaction){
                tmpAns = i;
                tmpSatisfaction = satisfaction + s[d][i] - c[i]*(d-last[i]);
            }
        }
        satisfaction = tmpSatisfaction;
        last[tmpAns] = d;
        ans[d] = tmpAns;
    }
    
    //満足度が　sum 1.to 26 ci * (d-last[i]) 低下する
    // つまり、個々のタイプに対しての和、満足度の下がりやすさ×空いた日数
    // 満足度の下がりやすさのほうが重みが大きい

    /*
    while(1){
        end = chrono::system_clock::now();
        int time = static_cast<int>(chrono::duration_cast<chrono::microseconds>(end - start).count()/1000);
        if(time > timeLimit){
            break;
        }

        int tmpD = rand()%(D-1)+1;
        int tmpI = rand()%(N-1)+1;



    }
    */

    rep(d,1,D){
        cout << ans[d] << "\n";
    }
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

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

	int n;
	string s;
	cin >> n >> s;

	int Wsum[300000] = {0}, Esum[300000] = {0}, w = 0, e = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] == 'W') w++;
		else if(s[i] == 'E') e++;
		Wsum[i] = w;
		Esum[i] = e;
	}

	int min = 100000000;
	for(int i = 0;i < s.size();i++){
		int left = Wsum[i-1], right = Esum[n-1] - Esum[i];
		if(left+right < min) min = left+right;
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 2964
#include <stdio.h>

int main (){
	
	int N,j, i = 0, dif, o = 0;
	int s[1000];
	int sum1 = 0, sum2 = 0, min, T = 0 ;
	scanf("%d", &N);
	
	for (int y = 0; y < N; y++){
		scanf("%d", &s[y]);
	}
	
	for (int u = 0; u < N; u++){
		min = min + s[u];
	}
	
	
	
	for (int i = 1; i < N; i++){
		for (int j = 0; j < i; j++){
			sum1 = sum1 + s[j];
		}
		for (int k = i; k < N; k++){
			sum2 = sum2 + s[k];
		}
		
		dif = sum1 - sum2;
		if(dif < 0){
			dif = -dif;
		}
		
		if(dif < min){
			min = dif;
			T = i;
		}
		
		sum1 = 0;
		sum2 = 0;
	}
	
	
	printf("%d", min);
	
	
	
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

cb = S.count("#")
cw = S.count(".")

if cb == 0:
	ans = 0
else:
	x = 0
	y = cw
	ans = float("inf")
	for i in range(N):
		if S[i] == "#":
			v = x + y
			if ans > v:
				ans = v
			x += 1
		else:
			y -= 1
			v = x + y
			if ans > v:
				ans = v


print(ans)

Measured memory_bytes: 3884
n,k = [int(x) for x in input().split()]
mod = 1000000007
if n == 1:
    print(1)
    quit()
f = [0,n]
i = 1
while f[i] >= i:
    i += 1
    f.append(n//i)
s = [0]*len(f)
for i in range(1,len(f)):
    s[i] = 1
for i in range(2,len(f))[::-1]:
    if f[i] <= i:
        s[-1] = f[i-1]-f[i]
    else:
        s.append(f[i-1]-f[i])
MA = len(s)
dp = [[0]*MA for i in range(k)]
dp[0] = [s[i] for i in range(MA)]
for i in range(MA-1):
    dp[0][i+1] += dp[0][i]
    dp[0][i+1] %= mod
for l in range(k-1):
    for i in range(1,MA):
        j = MA-i
        dp[l+1][i] += dp[l][j]*s[i]
        dp[l+1][i] %= mod
        dp[l+1][i] += dp[l+1][i-1]
        dp[l+1][i] %= mod
print(dp[-1][-1])


Measured memory_bytes: 94128
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <cstdint>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    int N,M,R;
    cin >> N >> M >> R;
    
    vector<int> rs(R);
    for( int& r : rs )
    {
        cin >> r;
        --r;
    }
    
    vector<vector<int>> graph(N, vector<int>(N, INT_MAX/2));

    for( int i : irange(0, N) )
    {
        graph[i][i] = 0;
    }

    for( int i : irange(0, M) )
    {
        int a,b,c;
        cin >> a >> b >> c;
        --a; --b;
        graph[a][b] = graph[b][a] = c;
    }

    for( int i : irange(0, N) )
    {
        for( int j : irange(0, N) )
        {
            for( int k : irange(0, N) )
            {
                graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
            }
        }
    }
    
    int shortest_path = INT_MAX/2;
    
    sort(rs.begin(), rs.end());
    
    do{
        int path = 0;
        for( int i : irange(1, R) )
        {
            path += graph[rs[i-1]][rs[i]];
        }
        
        shortest_path = min(shortest_path, path);
        
    }while( next_permutation(rs.begin(), rs.end()) );
    
    cout << shortest_path << '\n';

    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if(a > 0){
		cout << "Positive" << endl;
	}
	else if(a == 0){
		cout << "Zero" << endl;
	}
	else if(a < 0 && b >= 0){
		cout << "Zero" << endl;
	}
	else if( (abs(a) - abs(b)) % 2 == 0){
		cout << "Negative" << endl;
	}
	else{
		cout << "Positive" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
struct Node {
    int left;
    int right;
    int w;
    Node() {}
    Node(int left, int right, int w)
        : left(left)
        , right(right)
        , w(w)
    {
    }
    friend bool operator<(const Node& a, const Node& b)
    {
        if (a.left == b.left)
            return a.right < b.right;
        return a.left < b.left;
    }
} node[maxn];
namespace Segment {
const LL inf = 0X3f3f3f3f3f3f3f3f;
LL tree[maxn << 2], lazy[maxn << 2];
void build()
{
    memset(tree, 0X3f, sizeof(tree));
    memset(lazy, 0X3f, sizeof(lazy));
}
void pushdown(int root, int left, int right)
{
    if (lazy[root] == inf)
        return;
    tree[root << 1] = min(tree[root << 1], lazy[root]);
    tree[root << 1 | 1] = min(tree[root << 1 | 1], lazy[root]);
    lazy[root << 1] = min(lazy[root << 1], lazy[root]);
    lazy[root << 1 | 1] = min(lazy[root << 1 | 1], lazy[root]);
    lazy[root] = inf;
}
void update(int root, int left, int right, int stdl, int stdr, LL x)
{
    if (left >= stdl && right <= stdr) {
        tree[root] = min(tree[root], x);
        lazy[root] = min(lazy[root], x);
        return;
    }
    pushdown(root, left, right);
    int mid = (left + right) >> 1;
    if (stdl <= mid)
        update(root << 1, left, mid, stdl, stdr, x);
    if (stdr > mid)
        update(root << 1 | 1, mid + 1, right, stdl, stdr, x);
    tree[root] = min(tree[root << 1], tree[root << 1 | 1]);
}
LL query(int root, int left, int right, int stdl, int stdr)
{
    if (left >= stdl && right <= stdr) {
        return tree[root];
    }
    pushdown(root, left, right);
    LL res = inf;
    int mid = (left + right) >> 1;
    if (stdl <= mid)
        res = min(res, query(root << 1, left, mid, stdl, stdr));
    if (stdr > mid)
        res = min(res, query(root << 1 | 1, mid + 1, right, stdl, stdr));
    return res;
}
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int u, v, w;
    for (int i = 1; i <= m; i++) {
        scanf("%d%d%d", &u, &v, &w);
        node[i] = Node(u, v, w);
    }
    sort(node + 1, node + 1 + m);
    // for (int i = 1; i <= m; i++) {
    //     cout << node[i].left << ' ' << node[i].right << ' ' << node[i].w << '\n';
    // }
    Segment::build();
    Segment::update(1, 1, n, 1, 1, 0);
    //cout << Segment::query(1, 1, n, 1, 1) << '\n';
    for (int i = 1; i <= m; i++) {
        Segment::update(1, 1, n, node[i].left, node[i].right,
            (Segment::query(1, 1, n, node[i].left, node[i].right) + node[i].w));
        // for (int j = 1; j <= n; j++)
        //     cout << Segment::query(1, 1, n, j, j) << ' ';
        // cout << '\n';
    }
    LL ans = Segment::query(1, 1, n, n, n);
    if (ans == Segment::inf)
        printf("-1\n");
    else
        printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7680
// AOJ 2198 "ムーンライト牧場" (ICPC模擬国内予選 2010 Problem B)
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            Crop[] crops = new Crop[n];
            for (int i = 0; i < crops.length; i++) {
                String l = sc.next();
                int p = sc.nextInt();
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                int d = sc.nextInt();
                int e = sc.nextInt();
                int f = sc.nextInt();
                int s = sc.nextInt();
                int m = sc.nextInt();
                
                int time = a + b + c + (d + e) * m;
                int income = s * f * m - p;
                crops[i] = new Crop(l, (double)income / time);
            }
            Arrays.sort(crops);
            for (int i = 0; i < crops.length; i++) {
                System.out.println(crops[i].name);
            }
            System.out.println("#");
        }
    }
}

class Crop implements Comparable<Crop> {
    String name;
    double efficiency;
    
    Crop(String name, double eff) {
        this.name = name;
        this.efficiency = eff;
    }
    
    public int compareTo(Crop o) {
        if (Math.abs(this.efficiency - o.efficiency) > 1e-8) {
            return Double.compare(o.efficiency, this.efficiency);
        } else {
            return this.name.compareTo(o.name);
        }
    }
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int c[10001];
	for(int i=0;i<=10000;i++)
		c[i]=0;
	int n=1000,n1;
	cin>>n1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				int cal=i*i+j*j+k*k+i*j+j*k+k*i;
				if(cal<=10000){
					c[cal]++;
				}
			}
		}
	}
	for(int i=1;i<=n1;i++)
		cout<<c[i]<<endl;
	return 0;
}

Measured memory_bytes: 3696
package main

import "fmt"

var dir [][]int = [][]int{
	{-1, -1}, {0, -1}, {1, -1},
	{-1,  0},          {1,  0},
	{-1,  1}, {0,  1}, {1,  1}}

func main() {

	h, w := 0, 0
	fmt.Scan(&h, &w)
	mass := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&mass[i])
	}

	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if mass[y][x] == 46 { // "."
				count := 0
				for _, d := range dir {
					cx := x + d[0]
					cy := y + d[1]
					if cx >= 0 && cx < w && cy >= 0 && cy < h {
						if mass[cy][cx] == 35 { // "#"
							count++
						}
					}
				}
				fmt.Print(count)
			} else {
				fmt.Print("#")
			}
		}
		fmt.Println("")
	}
}


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

int N;

double calcDist(double x1, double y1, double x2, double y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

bool checkRad(double rad, vector<int> x, vector<int> y){
  
  bool ok = false;
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      double interCenterDist = 
        sqrt((double)((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])));
      if(interCenterDist > 2 * rad) continue;
      
      //interCenterDist += 0.00001;
      
      double interCommonpDistHalf = 
        sqrt(rad*rad - (interCenterDist*interCenterDist * 0.25));
      double interX = double(x[i] + x[j]) * 0.5;
      double interY = double(y[i] + y[j]) * 0.5;
      double commonp1X, commonp1Y, commonp2X, commonp2Y;
      if(x[i] == x[j]){
        commonp1X = interX + interCommonpDistHalf;
        commonp2X = interX - interCommonpDistHalf;
        commonp1Y = commonp2Y = interY;
      }else if(y[i] == y[j]){
        commonp1X = commonp2X = interX;
        commonp1Y = interY + interCommonpDistHalf;
        commonp2Y = interY - interCommonpDistHalf;
      }else{
        double slope = - ((double)(x[i] - x[j]) / (double)(y[i] - y[j]));
        double angle = atan(slope);
        commonp1X = interX + interCommonpDistHalf * cos(angle);
        commonp1Y = interY + interCommonpDistHalf * sin(angle);
        commonp2X = interX - interCommonpDistHalf * cos(angle);
        commonp2Y = interY - interCommonpDistHalf * sin(angle);
      }
      
      /*confirm
      cout << "points: (" << x[i] << ", " << y[i] << ") and (" << x[j] << ", " << y[j] << ")" << endl;
      cout << "1X = "<< commonp1X << endl;
      cout << "1Y = "<< commonp1Y << endl;
      cout << "2X = "<< commonp2X << endl;
      cout << "2Y = "<< commonp2Y << endl;
      */
      
      bool allContain1 = true;
      bool allContain2 = true;
      for(int k = 0; k < N; k++){
        if(k == i || k == j) continue;
        if(calcDist(commonp1X, commonp1Y, (double)x[k], (double)y[k]) > rad + 0.00000001)
          allContain1 = false;
        if(calcDist(commonp2X, commonp2Y, (double)x[k], (double)y[k]) > rad + 0.00000001)
          allContain2 = false;
      }
      if(allContain1 || allContain2)
        ok = true;
      if(ok) break;
    }
    if(ok) break;
  }
  
  return ok;
}


int main(){
  cin >> N;
  vector< int > x(N);
  vector< int > y(N);
  
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  
  double leftRad = 0.0, rightRad = 10000.0;
  while(rightRad - leftRad > 0.00000001){
    double midRad = (rightRad + leftRad) * 0.5;
    if(checkRad(midRad, x, y)) rightRad = midRad;
    else leftRad = midRad;
  }
  
  cout << fixed << setprecision(10) << leftRad << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,b,e,q;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    for(long long i=0;i<q;i++){
        cin>>b>>m>>e;
        rotate(a+b,a+m,a+e);
    }
    for(long long i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll h[200001] , a[200001];
ll mod = 1e9+7;
ll seg[800001];
ll dp[200001];

void Update(ll s , ll e , ll index , ll pos , ll val)
{
    if(index > e || index < s)
    return ;
    if(s == index && e == index)
    {
        seg[pos] = val;
        return;
    }

    ll mid=(s+e)/2;
    Update(s , mid , index , 2*pos , val);
    Update(mid+1 , e , index , 2*pos+1 , val);
    seg[pos] = max(seg[2*pos] , seg[2*pos+1]);
}


ll query(ll qs , ll qe , ll s , ll e , ll pos){
    if(s > qe || e < qs)
    return 0;
    if(s >= qs && e <= qe)
    return seg[pos];

    ll mid= (s+e)/2;
    return max(query(qs , qe , s , mid , 2*pos) , query(qs , qe , mid+1 , e , 2*pos+1));
}



int main() { 
    ll n;
    cin >> n;
    for(ll i = 1 ; i <= n  ;i++)
    cin >> h[i];
    for(ll i = 1 ; i <= n ; i++)
    cin >> a[i];
    
    memset(dp , 0 , sizeof(dp));
    ll ans = 0;
    for(ll i = 1 ; i<= n ; i++)
    {   
        ll max_val = query(1 , h[i]-1 , 1 , n , 1);
        dp[h[i]] = a[i] + max_val;
        ans= max(ans , dp[h[i]]);
        Update(1 , n , h[i] , 1 , dp[h[i]]);
    }

    cout << ans ;
    
}


Measured memory_bytes: 12396
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, L;
int T[500011], V[500011];
double H[500011];

pair<double, int> qu[500011], *head = qu, *tail = qu;

void MAIN() {
    scanf("%d%d", &N, &L);
    REP (i, N) scanf("%d%d", T+i, V+i);

    H[0] = T[0];
    double sum = (double)T[0]*L;

    *head = make_pair(T[0], L);
    for (int i=1; i<N; i++) {
	int rest = V[i];
	while (rest) {
	    if (rest >= head->second) {
		rest -= head->second;
		sum -= head->first * head->second;
		head++;
	    } else {
		sum -= head->first * rest;
		head->second -= rest;
		rest = 0;
	    }
	}

	sum += (double)T[i] * V[i];
	H[i] = sum / L;
	tail++;
	*tail = make_pair(T[i], V[i]);
	while (head < tail && (tail-1)->first >= tail->first) {
	    tail--;
	    double nu = tail->first * tail->second + (tail+1)->first * (tail+1)->second;
	    double de = tail->second + (tail+1)->second;
	    *tail = make_pair(nu/de, de);
	}
    }

    REP (i, N) printf("%.12f\n", H[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 27136
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int x[100010], a[100010], b[100010];
int r[30][100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> x[i];
  int l, q;
  cin >> l >> q;
  REP(i, q) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    if(a[i] > b[i]) swap(a[i], b[i]);
  }

  // r[0][i]を求める
  REP(i, n) {
    // x[i]+L 以下でもっとも右のホテル
    int low = 0, high = n;
    while(high-low>1) {
      int mid = (low+high)/2;
      if(x[mid] <= x[i]+l) {
        low = mid;
      } else {
        high = mid;
      }
    }
    r[0][i] = low;
  }
  r[0][n-1] = r[0][n] = n;

  FOR(i, 1, 30) REP(j, n+1) r[i][j] = r[i-1][r[i-1][j]];

  // REP(i, 5) {
  //   REP(j, n+1) {
  //     cout << r[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  REP(i, q) {
    // cout << "i:" << i << endl;
    int ret = 0, idx = a[i];
    bool update = true;
    while(update) {
      // cout << "idx:" << idx << endl;
      if(r[0][idx] > b[i]) {ret++; break;}
      int low = -1, high = 30;
      while(high-low>1) {
        int mid = (low+high)/2;
        // cout << low << " " << mid << " " << high << endl;
        if(r[mid][idx] < b[i]) {
          low = mid;
        } else if(r[mid][idx] > b[i]) {
          high = mid;
        } else {
          ret += 1LL<<mid;
          update = false;
          break;
        }
      }
      if(!update) break;
      ret += 1LL<<low;
      idx = r[low][idx];
    }
    cout << ret << endl;
  }

  return 0;
}


Measured memory_bytes: 13696
z=int(input())
for _ in range(z):
    gx,gy = map(int,input().split())
    p=int(input())
    mat=[tuple(map(int,input().split())) for _ in range(p)]
    dp=[[0]*(gy+1) for _ in range(gx+1)]
     
    x0=gx
    y0=gy
    for x1,y1,x2,y2 in mat:
        if x1+x2==0: y0=min(y0,min(y1,y2))
        if y1+y2==0: x0=min(x0,min(x1,x2))
    for i in range(x0+1):
        dp[i][0]=1
    for i in range(y0+1):
        dp[0][i]=1
     
    for y in range(1,gy+1):
        for x in range(1,gx+1):
            a=0
            if (x-1,y,x,y) not in mat and (x,y,x-1,y) not in mat:
                a+=dp[x-1][y]
            if (x,y-1,x,y) not in mat and (x,y,x,y-1) not in mat:
                a+=dp[x][y-1]
            dp[x][y]=a
    print(dp[-1][-1] or "Miserable Hokusai!")


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
 
    fastio
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";
    
    }



Measured memory_bytes: 3644
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    let mut ok = false;
    for x in 1..10001 {
        if x * 8 / 100 == a && x * 10 / 100 == b {
            println!("{}", x);
            ok = true;
            break;
        }
    }
    if !ok {
        println!("-1");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, m;
  Solver() {
    S002 r;
    r >= n >= m;
  }
  void solve() {
    long res = 0;
    long t = std::min(n, m / 2);
    res += t;
    n -= t;
    m -= 2 * t;
    res += m / 4;
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

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

  if(b > a+W){
		cout << b-a-W << endl;
	}else if(a > b+W){
		cout << a-b-W << endl;
	}else{
		cout << "0" << endl;
	}
return 0;
}


Measured memory_bytes: 256
S = input()

def func(S):
    mid = 0
    if len(S)%2 == 0:
        mid = len(S)//2-1
        #2
        for i in range(mid+1):
            if S[i] != S[-i-1]:
                return False
        for i in range(mid//2+1):
            if S[i] != S[mid-i]:
                return False
        for i in range(len(S)//4+1): 
            if S[mid+1+i] != S[-i-1]:
                return False
        return False
    else:
        mid = len(S)//2
        #3
        for i in range(mid+1):
            if S[i] != S[-i-1]:
                return False
        for i in range(mid//2+1):
            if S[i] != S[mid-i-1]:
                return False
        for i in range(len(S)//4+1): 
            if S[mid+1+i] != S[-i-1]:
                return False
        return True

if func(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
object Main extends App {
  for(line <- io.Source.stdin.getLines()) {
    val numAry = line.split(' ').map { _.toInt }
    val _money = numAry(0).toInt
    val money = if ((0 <= _money) && (_money <= 1000000000)) _money else 0

    val coinNum500: Int = money/500
    val coinNum5: Int = (money - coinNum500*500)/5
    val hpns500: Int = coinNum500*1000
    val hpns5: Int = coinNum5*5
    val hapiness = hpns500 + hpns5
    println(hapiness)
  }
}


Measured memory_bytes: 25512
#include <stdio.h>
#include <math.h>

int main (){

	int count=0;
	int input;
	int max=0;

	int result=0;
	int prime[1000000]= {};
	int sq_num=0;
	int deli=0;
	int i=0;

	//??\???
	while(1){
		scanf("%d",&input);
		if(input == 0 ){
			break;
		}
		count = 0;

		prime[2]=1;
		i=3;
		while(1){
			prime[i]=1;
			i++;
			prime[i]=0;
			i++;
			if( i > 1000000){
				break;
			}
		}

		i=input;
		sq_num = (int)sqrt(2*i);
		i=2;	
		while(1){
			
			if(prime[i]==1){
				deli=i;
				
				while( input*2 > deli ){
					deli += i;
					//printf("deli:%d\n",deli );
					prime[deli] = 0;

				}

			}
			i++;

			if(sq_num < i){
				break;
			}

		}

		i=input;
		i++;
		while(1){
			if(prime[i] == 1){
				result++;
			}
			i++;
			
			if (2*input < i){
				break;
			}
		}
		
		
		if(input == 0 ){
		//printf("input finish\n");
			break;
		}
		printf("%d\n",result);

		result = 0;




	}
	

	return 0;
}

Measured memory_bytes: 4516
N,Y=map(int,input().split())
ans="-1 -1 -1"
for i in range(N+1):
    for j in range(N+1-i):
        if i*10000+j*5000+(N-i-j)*1000==Y:
            ans=str(i)+" "+str(j)+" "+str(N-i-j)
print(ans)

Measured memory_bytes: 3060
program main
      implicit none
      integer(4) :: n, k, i, j, d
      integer(4), allocatable :: cnt(:), a(:)

      read *, n, k

      allocate( cnt(n) )
      cnt = 0

      do i = 1, k
        read *, d
        allocate( a(d) )
        read *, a

        do j = 1, d
          cnt(a(j)) = cnt(a(j)) + 1
        end do

        deallocate( a )
      end do
     
      j = 0
      do i = 1, n
        if( cnt(i) == 0 ) then
          j = j + 1
        end if
      end do 
      print *, j

end program main


Measured memory_bytes: 2804
#include <iostream>

using namespace std;

int main() {
  long long int n;
  cin >> n;
  long long int a, b;
  long long int c, d;
  c = d = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a > c) {
      c = a;
      d = b;
    }
  }
  cout << c+d << endl;
  return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;




int main(void) {
	string S;
	int i,j, cnt[2] = {0, 0}, tc = 1;

	char c[2] = { 0,0};
	
	cin >> S;
	for (i = 0; i < 4; i++) {
		S[i];
	}

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 2; j++) {
			if (c[j] == S[i]) {
				cnt[j]++;
				break;
			}
			else if(c[j] == 0){
				c[j] = S[i];
				cnt[j]++;
				break;
			}
			else {//既にある場合
				//何もしない
			}
		}
	}
	if (cnt[0] == 2 && cnt[1] == 2) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	


	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  int n;
  cin >> n;
  string t;
  cin >> t;
  int q;
  cin >> q;
  vector<vi> s(26,vi(n+1,0));
  rep(i,n){
    int a = t[i]-'a';
    rep(j,26){
      s[j][i+1] = s[j][i]+(j==a);
    }
    //s[a][i+1]+=s[a][i]+1;
  }

  map<int,char> mp;
  vi ans;
  rep(_,q){
    int T;
    cin >> T;
    if(T == 1){
      int k;
      char c;
      cin >> k >> c;
      k--;
      mp[k]=c;
    }
    else{
      int l,r;
      cin >> l >> r;
      l--;r--;
      int sum=0;
      vi e(26,0);
      for(auto v:mp){
        if(v.fi>=l && v.fi<=r){
          int a = v.se-'a';
          e[a]++;
          int b = t[v.fi]-'a';
          e[b]--;
        }
      }
      // rep(i,26)cout<<e[i]<<" ";
      // cout<<endl;
      rep(i,26){
        sum+=min(1,s[i][r+1]-s[i][l] + e[i]);
      }
      ans.push_back(sum);
    }
  }
  for(auto e:ans)cout<<e<<endl;
  return 0;
}

Measured memory_bytes: 53636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll a, b, m;cin >> a >> b >> m;
	vector<ll> rei(a);REP(i, a)cin >> rei[i];
	vector<ll> den(b);REP(i, b)cin >> den[i];
	vector<pair<P, ll>> v(m);
	REP(i, m){
		ll x, y, c;cin >> x >> y >> c;
		x--;y--;
		v[i] = MP(MP(x, y), c);
	}

	ll min_rei = LLINF;
	REP(i, a)min_rei = min(min_rei, rei[i]);
	ll min_den = LLINF;
	REP(i, b)min_den = min(min_den, den[i]);
	ll ans = min_rei + min_den;

	REP(i, m){
		ans = min(ans, rei[v[i].FI.FI] + den[v[i].FI.SE] - v[i].SE);
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
 
using namespace std;
 
string A, B;
int lIdx, rIdx;
 
int get(string& s, int& idx)
{
  int num = 0;
  while(isdigit(s[idx])) num = num * 10 + s[idx++] - '0';
  return (num);
}
 
void dfs()
{
  bool left = A[lIdx] == '(';
  bool right = B[rIdx] == '(';
  bool mid = left & right;
  if(!left & !right) return;
  lIdx += left;
  rIdx += right;
  if(mid) cout << "(";
  dfs();
  if(mid) cout << ")";
  lIdx += left * 2;
  rIdx += right * 2;
  int value = get(A, lIdx) + get(B, rIdx);
  if(mid) cout << "[" << value << "]";
  lIdx += left * 2;
  rIdx += right * 2;
  if(mid) cout << "(";
  dfs();
  if(mid) cout << ")";
  lIdx += left;
  rIdx += right;
  if(lIdx == A.size() && rIdx == B.size()) cout << endl;
}
 
int main()
{
  cin >> A;
  cin >> B;
  dfs();
}

Measured memory_bytes: 3200
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	cin>>k;
	string s,w;
	cin>>s;
	if(s.length()>k)
	{
		w=s.substr(0,k);
		cout<<w+"...";
	}
	else
		cout<<s;
}



	



Measured memory_bytes: 3648
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion
    
int main() {
    int N;
    string s1, s2; input(N);
    cin >> s1 >> s2;
    ll ans = 1;
    int i = 0;
    bool two;
    if (s1[0] == s2[0]) {
        ans *= 3;
        i++;
        two = false;
    }
    else {
        ans *= 6;
        i += 2;
        two = true;
    }
    for (; i < N; i++) {
        if (s1[i] == s2[i]) {
            if (two) {
                ans *= 1;
            }
            else {
                ans *= 2;
            }
            ans %= MOD;
            two = false;
        }
        else {
            if (two) {
                ans *= 3;
            }
            else {
                ans *= 2;
            }
            i++;
            ans %= MOD;
            two = true;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int score = 0;
		int cnt_2 = 0;
		for(int i=0;i<N;i++){
			long tmp = sc.nextLong();
			if(tmp%4==0)
				score += 2;
			else if(tmp%2==0){
				cnt_2++;
				if(cnt_2 >= 2){
					score += 1;
				}
			}
		}
		if(score>=N-1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


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

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    int sections_begin[N];
    for(int i = 0; i < N; i++){
        cin >> sections_begin[i];
    }
    sort(sections_begin, sections_begin + N);
    int first_begin = sections_begin[0], now_member = 1, ans = 0;
    for(int i = 1; i < N; i++){
        if(sections_begin[i] > first_begin + K || now_member == C){
            ans++;
            first_begin = sections_begin[i];
            now_member = 1;
        }else{
            now_member++;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define inf 999999999999999999
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
long long n,a,b; 
int main()
{
	cin>>n>>a>>b;
	if(a%2==b%2) cout<<abs(a-b)/2<<endl;
	else
	{
		long long ans=inf;
		ans=min(max(a-1,b-1),max(n-a,n-b));
		ans=min(ans,(a+b-1)/2);
		ans=min(ans,(2*n-a-b+1)/2);
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
from statistics import median

# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))
l_ = [num - i - 1 for i, num in enumerate(l)]
l_ = sorted(l_)

b = median(l_)

print(int(sum([abs(i-b) for i in l_])))

Measured memory_bytes: 28856
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int num = sc.nextInt();
      if (map.containsKey(num)) {
        map.put(num, map.get(num) + 1);
      } else {
        map.put(num, 1);
      }
    }
    int ans = 0;
    for (Integer key : map.keySet()) {
      int value = map.get(key);
      if (value < key) {
        ans += value;
      } else if (key < value) {
        ans += value - key;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  bool ans=false;
  rep(i,30) {
    rep(j,20) {
      if(4*i+7*j==n) ans=true;
      if(ans) break;
    }
  }
  puts(ans?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256