akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class  Main{
    public static void main(String[] args){
        Scanner sr = new Scanner(System.in);
        String inputLine = sr.nextLine();
        int result = 0;
        if(inputLine.length() == 4){
            for (int i = 0; i < inputLine.length(); i++){
                String plusOrMinus =inputLine .substring(i,i+1);
                if(plusOrMinus.equals("+")){
                    result ++;
                }else{
                    result--;
                }
            }
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    int w,h,i,j,k,m,n;
    for(i=0; ; i++)
    {
        scanf("%d %d",&h,&w);
        if(h==0&&w==0)
            break;
        for(j=0; j<h; j++)
        {
            for(k=0; k<w; k++)
            {
                if(j%2==0)
                {
                    if(k%2==0)
                        printf("#");
                    else
                        printf(".");
                }
                else if(j!=0)
                {
                    if(k%2==0)
                        printf(".");
                    else
                        printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const double inf = 1e9;
const int mod = 1e5;
const int MAX = 5005;

struct status {int y, x, len;};

int main() {
    int h;
    while (cin >> h && h) {
        int ans = 0;
        vvint field(h,vint(5));
        rep(i,h)rep(j,5) cin >> field[i][j];
        while (true) {
            bool update = false;
            vector<status> del;
            rep(i,h) {
                int index = -1;
                rep(j,3) {
                    if (field[i][j] == field[i][j+1] && field[i][j+1] == field[i][j+2]) {
                        index = j;
                        break;
                    }
                }
                if (index == -1) continue;
                int ct = 0;
                for (int j = 0; j+index < 5; j++) {
                    if (field[i][index] == field[i][index+j]) ct++;
                    else break;
                }
                del.push_back(status{i,index,ct});
                if (field[i][index] != 0) update = true;
                ans += ct*field[i][index];
            }
            if (del.empty() || !update) break;
            for (auto d: del) {
                for (int j = d.x; j < (d.x+d.len); j++) {
                    field[d.y][j] = 0;
                }
            }
            rep(j,5) {
                deque<int> q;
                rep(k,h) {
                    if (field[k][j] != 0) q.push_back(field[k][j]);
                }
                while (q.size() < h) q.push_front(0);
                int a = h-1;
                while (!q.empty()) {
                    int x = q.back(); q.pop_back();
                    field[a--][j] = x;
                }
            }
        }
        cout << ans << endl;
    }
}


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


int main() {
  double d,n,s;
  cin >> d >> n >> s;
  double ans = d / s;

  if(n >= ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}   



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

int d[10];

int solve(double x){
  int i,sum=d[0];
  for(i=1; i<10; i++){
    if(x<=sum)break;
    sum+=d[i];
  }
  return i;
}

int main(){
  char t;
  int v1, v2;
  while(cin>>d[0]>>t){
    int len=d[0];
    for(int i=1; i<10; i++){cin>>d[i]>>t; len+=d[i];}
    cin>>v1>>t>>v2;
    double time=((double)len/(double)(v1+v2));
    cout<<solve(v1*time)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
H, W = map(int, input().split())
dp = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

cost = 0
for a in A:
    for i in a:
        if i > -1:
            cost += dp[i][1]
print(cost)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>




int main(void){
int n;
int x[105];
int sum=0;
int min=999999999;
scanf("%d",&n);

for(int i=0;i<n;i++){
    scanf("%d",&x[i]);
}

for(int count=0;count<100;count++){
    for(int count2=0;count2<n;count2++){
        sum=sum+(x[count2]-count)*(x[count2]-count);
    }
    if(min>sum){min=sum;}
    sum=0;
}
printf("%d",min);


}


Measured memory_bytes: 128
#include<stdio.h>

int main (void){
  
  int N,T,E,i,j,time=0,ans=-1;
  int x[10001]={0};
  scanf("%d %d %d",&N,&T,&E);
  for(i=1;i<=N;i++){
    scanf("%d",&x[i]);
  }
  for(i=1;i<=N;i++){
    //printf("i=%d\n",i);
    time=0;
    for(j=1;time<=T+E;j++){
      time = x[i]*j;
      //printf("x[%d]=%d time=%d\n",i,x[i],time);
      if(T-E <= time && time <= T+E){
        //printf("OK\n");
        ans=i;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


int main(){
    cin>>N;
    vec num(3,0);
    ll ans = 1;
    rep(i,N){
        cin>>A;
        ll temp = 0, id = -1;
        rep(j,3){
            if(num[j] == A){
                ++temp;
                id = (id == -1 ? j : id);
            }
        }
        if(id != -1) {
            (ans *= temp) %= MOD;
            ++num[id];
        }else{
            ans = 0;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    t=[parseInt(readline()) for i in 1:n]
    ans=1
    for i in t
        ans=lcm(ans,i)
    end
    println(ans)
end
main()

Measured memory_bytes: 165864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    int m0 = 0, m1 = 0;
    int i0 = 0, i1 = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a < m0) {
            i0 = i;
            m0 = a;
        }
        if (a > m1) {
            i1 = i;
            m1 = a;
        }
    }

    cout << 2 * n << '\n';
    if (m1 > -m0) {
        cout << i1 + 1 << ' ' << 1 << '\n';
        cout << i1 + 1 << ' ' << 1 << '\n';
        for (int i = 1; i < n; i++) {
            cout << i << ' ' << i + 1 << '\n';
            cout << i << ' ' << i + 1 << '\n';
        }
    } else {
        cout << i0 + 1 << ' ' << n << '\n';
        cout << i0 + 1 << ' ' << n << '\n';
        for (int i = n - 2; i >= 0; i--) {
            cout << i + 2 << ' ' << i + 1 << '\n';
            cout << i + 2 << ' ' << i + 1 << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 384
A, B, M = map(int, input().split())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

z = []
result = min(As) + min(Bs)

for _ in range(M):
    a, b, m = map(int, input().split())
    k = As[a - 1] + Bs[b - 1] - m
    if result > k:
        result = k

print(result)




Measured memory_bytes: 18684
N,K,*L=map(int,open(0).read().split())
S=sorted([(d,t)for t,d in zip(*[iter(L)]*2)],reverse=True)
In=set()
C=X=0
uni=[]
dub=[]
for d,t in S:
	if t not in In:
		In.add(t)
		uni.append(d)
		X+=1
		if X==K:
			break
	else:
		dub.append(d)
det=0
C=X
for d in dub:
	if C<K:
		det+=d
		C+=1
	elif uni[-1]+2*X-1<=d:
		uni.pop()
		X-=1
		det+=d
print(sum(uni)+det+X**2)



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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    sort(a.begin(),a.end());
    
    ll c1,c2,m1,m2;
    c1 = 1+(n%2==1);
    c2 = (n-2)/2;
    m1 = 1-(n%2==1);
    m2 = (n-2+1)/2;
    
    ll tmp = 0;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if(i<m2){
           tmp += -2*a[i]; 
        }else if(i<m2+m1){
            tmp += -1*a[i];
        }else if(i<m2+m1+c1){
            tmp += 1*a[i];
        }else{
            tmp += 2*a[i];
        }
    }
    res = tmp;
    tmp = 0;
    
    for (int i = 0; i < n; i++) {
        if(i<c2){
           tmp += -2*a[i]; 
        }else if(i<c2+c1){
            tmp += -1*a[i];
        }else if(i<c2+c1+m1){
            tmp += 1*a[i];
        }else{
            tmp += 2*a[i];
        }
    }
    
    std::cout << max(res,tmp) << std::endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e4+17;
const int MOD = 1e9+17;
int a[MAXN],b[MAXN];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    int dis = 9e8/(n+1);
    for (int i = 0; i < n; ++i)
    {
    	a[i] = (i+1)*dis;
    	b[i] = (n-i+1)*dis;
    }

    for (int i = 0; i < n; ++i)
    {
    	int tmp;
    	cin>>tmp;
    	b[tmp-1]+=i+1;
    }
    for (int i = 0; i < n; ++i)
    {
    	printf("%d%c",a[i],i==n-1?'\n':' ');
    }
    for (int i = 0; i < n; ++i)
    {
    	printf("%d%c",b[i],i==n-1?'\n':' ');
    }
    return 0;        
}

Measured memory_bytes: 768
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=LONG_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
string s;
ll ans,n,a[26],i;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s;
	n=s.size();
    for(i=0;i<n;i++)a[s[i]-'a']++;
    for(i=0;i<=25;i++)ans+=max(0LL,((a[i]-1)*a[i])/(2LL));
    ans=max(1LL,(n*(n-1))/(2LL)+1-ans);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';
    char c;
    cin >> c;
    cout << mp[c] << endl;
    return 0;
}



Measured memory_bytes: 3588
def solve():
    N, M = map(int, input().split())

    d = {}
    for _ in range(M):
        a, b = map(int, input().split())
        d.setdefault(a, 10)
        if d[a] !=10 and d[a] != b:
            return -1
        d[a] = min(d[a], b)
        
    if M == 0 and N == 1:
        return 0
    
    ans = 10 ** 5
    for i in range(1000):
        s = str(i)
        if len(s) != N:
            continue

        c = 0
        for a, b in d.items():
            if len(s) > a-1 and int(s[a-1]) == b:
                c += 1
        
        if c == len(d):
            ans = min(i, ans)
    
    if ans == 10 ** 5:
        ans = -1

    return ans

print(solve())

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int m;
	float k;
    cin >> m;
  	double ans = 0;
  	for(int i = 0; i < m; ++i)
    {
      	cin >> k;
        if(k != 0)
          ans += 1/k;
    }
  	cout << 1/ans;
}


Measured memory_bytes: 256
k,n = list(map(int, input().split()))
a = list(map(int, input().split()))

dist = k
for i in range(len(a)-1):
    d = k - (a[i+1]-a[i])
    if d < dist:
        dist = d
if max(a)-min(a) < dist:
    print(max(a)-min(a))
else:
    print(dist)


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

int main() {
  int X,A;
  cin >> X>>A;
  if(X<A) cout<<0<<endl;
  else cout<<10<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=3009;
ll pre[1LL<<17]; 
int ara[17][17]; 
ll dp[1<<17] ; 
int main()
{
	fast; 
	int  n;
	cin>>n; 
	for(int  i=0;i<n;i++)
	{
		for(int  j=0;j<n;j++) cin>>ara[i][j];
	}
	for(int mask=0;mask<(1<<n);mask++)
	{
		for(int  j=0;j<n;j++)
		{
			if(mask&(1<<j))
			{
				for(int  k=j+1;k<n;k++)
				{
					if(mask&(1<<k))
					{
						pre[mask]+=ara[j][k]; 
					}
				}
			}
		}
	}
	
	for(int mask=0;mask<(1<<n);mask++)
	{
		dp[mask]=pre[mask]; 
		for(int i=mask;i;i=(i-1)&mask)
		{
			dp[mask]=max(dp[mask],dp[mask^i]+pre[i]);
		}
	}
	cout<<dp[(1LL<<n)-1]<<endl;
}


Measured memory_bytes: 1280
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(allr(a));
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[2*i +1];
  }
  cout << ans << endl;
}


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

int main() {
  const int MOD = 1000000007;
  int H, W; cin >> H >> W;
  vector<string> G(H);
  for (int i = 0; i < H; i++) cin >> G.at(i);
  // dp[i][j] := (0, 0) -> (i, j) の経路の総数
  vector<vector<long long>> dp(H, vector<long long>(W, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (G.at(i).at(j) == '#') continue;
      // 下へ
      if (i != H-1 && G.at(i+1).at(j) != '#') {
        dp.at(i+1).at(j) = (dp.at(i+1).at(j) + dp.at(i).at(j)) % MOD;
      }
      // 右へ
      if (j != W-1 && G.at(i).at(j+1) != '#') {
        dp.at(i).at(j+1) = (dp.at(i).at(j+1) + dp.at(i).at(j)) % MOD;
      }
    }
  }
  cout << dp.at(H-1).at(W-1) << endl;
}

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

typedef double R;
typedef complex<R> D;
typedef pair<D, D> L;
#define fs first
#define sc second

inline R dot(const D &a, const D &b) {
    return real(a) * real(b) + imag(a) * imag(b);
}
inline R det(const D& a, const D& b) {
    return real(a) * imag(b) - imag(a) * real(b);
}
D projection(const L &l, const D &d) {
    R t = dot(d - l.fs, l.fs - l.sc) / norm(l.fs - l.sc);
    return l.fs + t * (l.fs - l.sc);
}
D inline refr(const L &l, const D &d) {
    return d + 2. * (projection(l, d) - d);
}
inline D vec(const L &l) { return l.sc - l.fs; }
D inline intersect(const L &l1, const L &l2) {
    R ratio = det(vec(l2), l2.fs - l1.fs) / det(vec(l2), vec(l1));
    return l1.fs + vec(l1) * ratio;
}

class Node {
    public:
        D a, b;
        Node(D a_ = {}, D b_ = {1e9, 1e9}):a(a_), b(b_){}
        inline bool is_point() {
            return b.real() > 1000.;
        }
};
Node refrection(Node x, Node y) {
    if (x.is_point()) swap(x, y);
    return Node(refr({x.a, x.b}, y.a));
}
Node intersection(Node x, Node y) {
    return Node(intersect({x.a, x.b}, {y.a, y.b}));
}

string s;
int idx;

Node pl();
Node plf();

int number() {
    bool is_neg = false;
    if (s[idx] == '-') {
        is_neg = true;
        idx++;
    }

    int ret = 0;
    while (isdigit(s[idx])) {
        ret = ret * 10 + (s[idx] - '0');
        idx++;
    }

    if (is_neg) ret *= -1;
    return ret;
}

Node pl() {
    Node left = plf();

    while (s[idx] == '@') {
        idx++;

        Node right = plf();
        if (left.is_point()) {
            if (right.is_point())
                left = Node(left.a, right.a);
            else
                left = refrection(left, right);
        } else {
            if (right.is_point())
                left = refrection(left, right);
            else
                left = intersection(left, right);
        }
    }

    return left;
}

Node plf() {
    Node ret;
    idx++; // skip '('
    if (s[idx] == '-' || isdigit(s[idx])) {
        double left = number();
        idx++;
        double right = number();
        ret = Node(D(left, right));
    } else {
        ret = pl();
    }
    idx++;
    return ret;
}


int main() {
    while (cin >> s, s != "#") {
        idx = 0;
        Node ret = pl();
        printf("%.8lf %.8lf\n", ret.a.real(), ret.a.imag());
    }
}



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

struct node{
    string s;
	int t;
	
}a[55];
string k;
bool z=false;
unsigned long long sum=0;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{ 
		cin>>a[i].s;
		cin>>a[i].t;
	} 
	cin>>k;
	for(int i=1;i<=n;i++)
	{
		if(z)
		{
			sum+=a[i].t;
			continue;
		}
		if(a[i].s==k) z=true;
	}
	cout<<sum;
	return 0;
 } 

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


int main(){
	int N, M;
	cin >> N >> M;
	vector<int> p(M), y(M), s(M);
	vector<vector<pair<int, int>>> v(N+1);
	for(int i = 0;i<M;i++){
		cin >> p[i] >> y[i];
		v[p[i]].push_back(pair<int, int>(y[i], i));
	}
	for(int i = 1;i<=N;i++){
		sort(v[i].begin(), v[i].end());
		for(int j=0;j<(int)v[i].size();j++){
			s[v[i][j].second] = j + 1;
		}
	}
	for(int i=0;i<M;i++){
		printf("%06d%06d\n", p[i], s[i]);
	}
}

Measured memory_bytes: 8192
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x

const int N = 3333;

typedef long long llint;

const llint INF = 0x3f3f3f3f3f3f3f3fLL;

int n;
vector<int> ns;
llint dp[N][N];

llint dfs(int l, int r) {
    if (l > r) {
        return 0;
    }
    if (dp[l][r] != INF) {
        return dp[l][r];
    }
    int m = r - l + 1;
    int delta = n - m;

    int flag = delta % 2 == 0? 1: -1;

    llint a = flag * ns[l] + dfs(l + 1, r);
    llint b = flag * ns[r] + dfs(l, r - 1);

    return dp[l][r] = delta % 2 == 0? max(a, b): min(a, b);
}

int main() {
    input(n);

    memset(dp, 0x3f, sizeof(dp));
    ns = vector<int>(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &ns[i]);
    }
    print(dfs(0, n - 1));
    return 0;
}


Measured memory_bytes: 87296
#include <iostream>
#include<cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	char a[h + 2][w + 2];
	for (int i = 0 ; i <= h + 1 ; i++) {
        for (int j = 0 ; j <= w + 1 ; j++) {
            if (i == 0 || j == 0 || i == h + 1 || j ==  w + 1) a[i][j] = '.';
            else cin >> a[i][j];
        }
        cout << endl;
    }
	 for (int i = 1 ; i <= h ; i++) {
        for (int j = 1 ; j <= w ; j++) {
            int c = 0;
            if( a[i][j] == '#' ) cout << '#';
            else {
                if (a[i - 1][j - 1] == '#') c++;
                if (a[i - 1][j] == '#') c++;
                if (a[i - 1][j + 1] == '#') c++;
                if (a[i][j - 1] == '#') c++;
                if (a[i][j + 1] == '#') c++;
                if (a[i + 1][j - 1] == '#') c++;
                if (a[i + 1][j] == '#') c++;
                if (a[i + 1][j + 1] == '#') c++;
                cout << c;
            }
        }
        cout << endl;
    }
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<bool> dead(n);
  for (int i = 0; i < k; ++i) {
    int c;
    cin >> c;
    for (int j = 0; j < c; ++j) {
      int f;
      cin >> f;
      dead[f - 1] = true;
    }
  }
  cout << count(dead.begin(), dead.end(), false) << "\n";
  return 0;
}


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

int main(){
    int N,K,ans=0;
    cin>>N>>K;
    vector<int>h(N);
    for(int i=0;i<N;i++){
        cin>>h.at(i);
        if(h.at(i)>=K){
            ++ans;
        }
    }

    cout<<ans<<endl;

}

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  int as[n - 1];
  int a;
  for (int i = 0; i < n - 1; i++) {
    std::cin >> as[i];
  }
  std::cin >> a;
  std::cout << a;
  for (int i = n - 3; i >= 0; i -= 2) {
    std::cout << " " << as[i];
  }
  for (int i = n % 2; i < n - 1; i += 2) {
    std::cout << " " << as[i];
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)(s1[0] - 'a' + 'A') << (char)(s2[0] - 'a' + 'A') << (char)(s3[0] - 'a' + 'A') << endl;
}


Measured memory_bytes: 256
NK= list(map(int,input().split()))
a = NK[1]
b = NK[1]+1
if NK[1] == 0:
    a = 1
    b = 1
temp = 0
while a <= NK[0]-1:
    temp += (NK[0]-a)
    a+=1
while b <= (NK[0]-NK[1]):
    step = int(NK[0]/b)
    cross = b-NK[1]
    temp += (step-1)*cross
    if (b*step + NK[1]) < NK[0]:
        temp += (NK[0]+1-(b*step + NK[1]))
    if (b*step + NK[1]) == NK[0]:
        temp += 1
    b+=1

print(temp)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>	
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x > 0; --x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)
char s[105], t[105];
int n, m;
string ans;

int main()
{
	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);
	if (n < m)
	{
		puts("UNRESTORABLE");
		return 0;
	}
	
	rep(i, n - m + 1)
	{
		//cout << i << endl;
		bool flag = 0;
		string tmp = "";
		rep(j, i - 1) if (s[j] == '?')
			tmp += "a";
		else tmp += s[j];
		FOR(j, i, i + m - 1)
		{
			if (s[j] != '?' && s[j] != t[j - i + 1])
			{
				flag = 1;
				break;
			}
			tmp += t[j - i + 1];
			//cout << tmp << endl;
		}
		FOR(j, i + m, n) if (s[j] == '?')
			tmp += "a";
		else tmp += s[j];
		if (flag) continue;
		if (ans == "" || tmp < ans)
			ans = tmp;
	}
	if (ans == "")
		puts("UNRESTORABLE");
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int n;
int x[100005];

int main(){
	scanf("%d",&n);
	fore(i,0,n)scanf("%d",x+i);
	int i=0,r=0;
	while(i<n){
		int j=i;
		while(j<n&&x[j]==x[i])j++;
		if(j==n){r++;break;}
		if(x[j]>x[i]){
			while(j<n&&x[j]>=x[j-1])j++;
		}
		else {
			while(j<n&&x[j]<=x[j-1])j++;
		}
		r++;
		i=j;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++)
	cin>>ar[i];
	int ans=0,find=1;
	for(int i=0;i<n;i++)
	{
		if(ar[i]!=find)
		ans++;
		else
		find++;
	}
	if(ans==n)
	ans=-1;
	cout<<ans;
}
	

Measured memory_bytes: 1024
from heapq import heappush, heappushpop
 
N = int(input())
a = list(map(int, input().split()))
 
a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)
 
sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1
 
for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2
 
max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score
 
print(max_score)

Measured memory_bytes: 38292
import sys

N = int(input())

if(N == 0):
    print(0)
    sys.exit()

ans = ""
while(N != 0):
    mod = N % (-2)
    if(mod != 0):
        ans = "1" + ans
    else:
        ans = "0" + ans
    N = (N + mod) // (-2)
print(ans)

Measured memory_bytes: 3060
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    int count = 0;
        rep(i, 0, a.size()) {
            while(true) {
                if (a[i] % 2 == 0) {
                    a[i] = a[i] / 2;
                    ++count;
                } else {
                    break;
                }
            }
        }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,c,i,j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			j++;
		}
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 2756
N=int(input())
h=list(map(int,input().split()))
dp=[0]
for i in range(1,N):
    if i>=2:
        dp.append(min(dp[i-1]+abs(h[i]-h[i-1])\
                     ,dp[i-2]+abs(h[i]-h[i-2])))
    else:
        dp.append(abs(h[0]-h[1]))
print(dp[N-1])

Measured memory_bytes: 55240
#include <algorithm>
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
ll arr[100005];
int dp[100005], pre[100005];
int main()
{
	// freopen("AGC009-C.in", "r", stdin);
	int n;
	ll a, b;
	scanf("%d%lld%lld", &n, &a, &b);
	if (a > b)
		std::swap(a, b);
	arr[0] = -1e18;
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", arr + i);
		if (i >= 3 && arr[i] - arr[i - 2] < a)
		{
			puts("0");
			return 0;
		}
	}
	dp[0] = pre[1] = 1;
	int l = 0, r = 0;
	for (int i = 1; i <= n; i++)
	{
		while (arr[i] - arr[r] >= b)
			r++;
		dp[i] = (pre[r] - pre[l] + MOD) % MOD;
		pre[i + 1] = (pre[i] + dp[i]) % MOD;
		if (arr[i] - arr[i - 1] < a)
			l = r = i - 1;
	}
	printf("%d\n", (pre[n + 1] - pre[l] + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void)          
{
	int middle_t = 0, final_t = 0, Re_t = 0;
	
	while (1 > 0)
	{
		scanf("%d %d %d", &middle_t, &final_t, &Re_t);
		if (middle_t == -1 && final_t == -1 && Re_t == -1)
		{
			break;
		}

		if (middle_t + final_t >= 80) printf("A\n");
		if (middle_t + final_t >= 65 && middle_t + final_t < 80) printf("B\n");
		if (middle_t + final_t >= 50 && middle_t + final_t < 65 || Re_t >= 50) printf("C\n");
		if (middle_t + final_t >= 30 && middle_t + final_t < 50 && Re_t < 50 && final_t != -1 && middle_t != -1) printf("D\n");
		if (middle_t + final_t < 30 || final_t == -1 || middle_t == -1) printf("F\n");
	}


	return 0;
}

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

const int INF = 1 << 29;
const long long int Mod = 1000000007;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)



int main() {
	ll x[4];
	rep(i, 4) cin >> x[i];

	ll ans = x[0] * x[2];
	ans = max(ans, x[0] * x[3]);
	ans = max(ans, x[1] * x[2]);
	ans = max(ans, x[1] * x[3]);
	
	cout << ans << endl;
}

Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n, m, s, g1, g2;
	while (cin >> n >> m >> s >> g1 >> g2, n)
	{
		const int INF = 1 << 25;
		int dis[128][128];
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				dis[i][j] = i == j ? 0 : INF;
		while (m--)
		{
			int a, b, c;
			cin >> a >> b >> c;
			dis[a][b] = c;
		}
		for (int k = 1; k <= n; ++k)
			for (int i = 1; i <= n; ++i)
				for (int j = 1; j <= n; ++j)
					min_swap(dis[i][j], dis[i][k] + dis[k][j]);

		int res = INF;
		for (int k = 1; k <= n; ++k)
			min_swap(res, dis[s][k] + dis[k][g1] + dis[k][g2]);
		cout << res << endl;
	}
}

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

int main(){
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S == U) cout << A - 1 << " " << B << endl;
	else cout << A << " " << B - 1 << endl;
}


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

int main(){
  int N,a;cin>>N;
  vector<int> A(N+2,0);
  A[0]=3;
  long long c=1;
  REP(i,N){
    scanf("%d",&a);
    c*=(A[a]-A[a+1]++);
    c%=1000000007;
  }
  cout<<c<<endl; 
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    SORT(a);
    lint ans = 0, tmp = 0;
    if(n % 4 == 1){
        tmp += abs(a[n-1] - a[0]) + abs(a[n-1] - a[1]);
        for(int i = n - 2, j = 0, k = 2 ; i > n/2 ; i--, j++, k++){
            tmp += abs(a[i] - a[j]) + abs(a[i] - a[k]);
        }
        ans = max(ans, tmp);
        reverse(a.begin(), a.end());
        tmp = 0;
        tmp += abs(a[n-1] - a[0]) + abs(a[n-1] - a[1]);
        for(int i = n - 2, j = 0, k = 2 ; i > n/2 ; i--, j++, k++){
            tmp += abs(a[i] - a[j]) + abs(a[i] - a[k]);
        }
        ans = max(ans, tmp);
    }else if(n % 4 == 3){
        tmp += abs(a[0] - a[n-1]) + abs(a[0] - a[n-2]);
        for(int i = 1, j = n-1, k = n-3 ; i < n/2 ; i++, j--, k--){
            tmp += abs(a[i] - a[j]) + abs(a[i] - a[k]);
        }
        ans = max(ans, tmp);
        reverse(a.begin(), a.end());
        tmp = 0;
        tmp += abs(a[0] - a[n-1]) + abs(a[0] - a[n-2]);
        for(int i = 1, j = n-1, k = n-3 ; i < n/2 ; i++, j--, k--){
            tmp += abs(a[i] - a[j]) + abs(a[i] - a[k]);
        }
        ans = max(ans, tmp);
    }else if(n == 2){
        ans = abs(a[1] - a[0]);
    }else{
        tmp += abs(a[0] - a[n-1]) + abs(a[0] - a[n-2]);
        for(int i = 1, j = n-1, k = n-3 ; i < n/2 - 1 ; i++, j--, k--){
            tmp += abs(a[i] - a[j]) + abs(a[i] - a[k]); 
        }
        tmp += abs(a[n/2-1] - a[n/2+1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << max({a, b, c}) * 10 + (a + b + c) - max({a, b, c});
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef long long ll;
typedef int64_t in;
using namespace std;


int main() {
    int p,q,r;
    cin >> p >> q >> r;
    int M;
    M = max(max(p,q),r);

    cout << p+q+r-M << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long a,b,c,k;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &k);
  long dif = a-b;
  if (k%2 != 0) {
    dif *= -1;
  }
  printf("%ld\n", dif);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		int[] ara = new int[5];
		
		for(int i = 0;i<ara.length;i++) {
			ara[i] = in.nextInt();
			
			if(ara[i] == 0) {
				System.out.println((i+1));
				break;
			}
		}

	}

}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
string k;
int d;
long long bio[10005][105][2];
int br = 0;
long long modz(long long x, long long y)
{
	if(x+y >= MOD)
	{
		return x+y-MOD;
	}
	return x+y;
}
long long r(int poz, int o, bool f)
{
	if(poz == k.size() && o == 0)
	{
		return 1;
	}
	if(poz == k.size())
	{
		return 0;
	}
	if(bio[poz][o][f] != -1)
	{
		return bio[poz][o][f];
	}
	bio[poz][o][f] = 0;
	int z;
	if(f == 0)
	{
		z = k[poz] - '0';
	}
	else
	{
		z = 9;
	}
	for(int i = 0; i <= z; i++)
	{
		int no = (o+i) % d;
		if(f == 1 || i < z)
		{
			bio[poz][o][f] = modz(bio[poz][o][f], r(poz+1, no, 1));
		}
		else
		{
			bio[poz][o][f] = modz(bio[poz][o][f], r(poz+1, no, 0));
		}
	}
	return bio[poz][o][f];
}
int main()
{
    cin >> k >> d;
    for(int i = 0; i < k.size(); i++)
    {
    	for(int j = 0; j < d; j++)
    	{
    		bio[i][j][0] = -1;
			bio[i][j][1] = -1; 
		}
	}
	cout << (r(0, 0, 0) - 1 + MOD) % MOD << endl;
}



Measured memory_bytes: 17408
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int n, m;
int p[1000];
int ans;
vector<int> v;

void solve(){
	ans = 0;
	v.clear();
	v.push_back(0);
	for(int i = 0; i < n; i++){
		scanf("%d", &p[i]);
		if(p[i] <= m) v.push_back(p[i]);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(p[i]+p[j] <= m) v.push_back(p[i]+p[j]);
		}
	}
	sort(v.begin(),v.end());
	int j = v.size()-1;
	for(int i = 0; i < v.size(); i++){
		while(true){
			if(v[i]+v[j] <= m){
				ans = max(ans,v[i]+v[j]);
				break;
			}
			j--;
		}
	}
	printf("%d\n", ans);
}

int main(){
	while(scanf("%d%d", &n, &m),n||m) solve();
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n;
    cin >> n;
    if(n < 1200)cout << "ABC" << endl;
    else if(n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    system("pause");
}

Measured memory_bytes: 504
N = int(input())
a = list(map(int,input().split()))

a_max = max(a)
max_idx = a.index(a_max)
a_mix = min(a)
min_idx = a.index(a_mix)

ans = ''

if abs(a_max) >= abs(a_mix):
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(max_idx + 1, i + 1)
	for i in range(1, N):
		ans += '{} {}\n'.format(i, i + 1)
else:
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(min_idx + 1, i + 1)
	for i in range(N, 1, -1):
		ans += '{} {}\n'.format(i, i - 1)

print(ans,end="")

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    long long x,y,z,N,tmp;

    // map<long long, long long> mp;


    cin>>N;

    vector<long long > mp(N+5,0);

    for(x=1;x<=N;x++){
        for(y=1;y<=N;y++){
            if(x*y > N)break;
            for(z=1;z<=N;z++){
                tmp=x*x+y*y+z*z+x*y+y*z+z*x;
                if(tmp > N)break;
                mp[tmp]++;
            }
        }
    }

    for(int i=1;i<=N;i++){
        cout<<mp[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 998244353
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}

int main()
{
    IOS;
    lli n;
    cin>>n;
    lli ans = 0;
	for(lli i = 1; i<n+1; i++)
	{
		for(lli j = 1; j<n+1; j++)
		{
			for(lli k = 1; k<n+1; k++)
			{
				lli temp = __gcd(i, j);
				temp = __gcd(temp, k);
				ans += temp;
			}
		}
	}
	cout<<ans<<endl;
 /*   string s;
    cin>>s;
    lli dp[3][n+1];
    memset(dp, 0, sizeof(dp));
    for(lli i = 1; i<n+1; i++)
    dp[0][i] = dp[0][i-1] + (s[i-1] == 'R'), dp[1][i] = dp[1][i-1] + (s[i-1] == 'G'), dp[2][i] = dp[2][i-1] + (s[i-1] == 'B');
	lli ans = 0;
    for(lli i = 0; i<n; i++)
    {
		for(lli k = i+3; k<n; k++)
		{
			if(s[i] != s[k])
			{
				if(s[i]!='R' and s[k]!='R')
				{
					ans += dp[0][k] - dp[0][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'R'))
					ans--;
				}
				else if(s[i]!='G' and s[k]!='G')
				{
					ans += dp[1][k] - dp[1][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'G'))
					ans--;
				}
				else
				{
					ans += dp[2][k] - dp[2][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'B'))
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;*/
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, K;
    cin >> N >> K;
    if(K & 1){
        vector<vector<int>> graph(N);
        vector<P> es;
        for(int i = 0; i < N - 1; ++i){
            int A, B;
            cin >> A >> B;
            --A, --B;
            graph[A].emplace_back(B);
            graph[B].emplace_back(A);
            es.emplace_back(A, B);
        }
        vector<int> dist(N);
        auto dfs = [&](auto&& self, int from, int ban, int d = 0, int par = -1) -> void {
            dist[from] = d;
            for(int to : graph[from]){
                if(to == ban || to == par)  continue;
                self(self, to, ban, d + 1, from);
            }
        };
        int ans = INF;
        --K;
        for(int i = 0; i < N - 1; ++i){
            int u = es[i].first, v = es[i].second;
            dfs(dfs, u, v);
            dfs(dfs, v, u);
            int cnt = 0;
            for(int w = 0; w < N; ++w){
                if(dist[w] > K / 2) ++cnt;
            }
            chmin(ans, cnt);
        }
        cout << ans << '\n';
    }
    else{
        vector<vector<int>> graph(N);
        for(int i = 0; i < N - 1; ++i){
            int A, B;
            cin >> A >> B;
            --A, --B;
            graph[A].emplace_back(B);
            graph[B].emplace_back(A);
        }
        vector<int> dist(N);
        auto dfs = [&](auto&& self, int from, int d = 0, int par = -1) -> void {
            dist[from] = d;
            for(int to : graph[from]){
                if(to == par)  continue;
                self(self, to, d + 1, from);
            }
        };
        int ans = INF;
        for(int v = 0; v < N; ++v){
            dfs(dfs, v);
            int cnt = 0;
            for(int u = 0; u < N; ++u){
                if(dist[u] > K / 2) ++cnt;
            }
            chmin(ans, cnt);
        }
        cout << ans << '\n';
    }
}

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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;

const int maxn = 400010;

int Begin[maxn], Next[maxn], To[maxn], e;
int n, size[maxn], q;

inline void add(int u, int v) { To[++ e] = v; Next[e] = Begin[u]; Begin[u] = e; }

inline void DFS(int u, int fa)
{
    for ( int i = Begin[u]; i; i = Next[i] ) 
    {
        int v = To[i]; if ( v == fa ) continue ;
        size[v] += size[u];
        DFS(v, u);
    }
}

int main()
{
    scanf("%d%d", &n, &q);
    REP(i, 1, n - 1) { int u, v; scanf("%d%d", &u, &v); add(u, v); add(v, u); }
    REP(i, 1, q) { int x, val; scanf("%d%d", &x, &val); size[x] += val; }
    DFS(1, 0);
    REP(i, 1, n) printf("%d ", size[i]);
    return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
int main() {
  double w, h, x, y, a;
  int z = 0;
  cin >> w >> h >> x >> y;
  if (x * 2 == w && y * 2 == h) {
    z++;
  }
  a = w * h / 2;
  cout << a << " " << z << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int n;
int c[10000];
int idx = 0;

vector<int> edge[10000];
int ans[10000];

void dfs(int u, int p = -1) {
	for (int v: edge[u]) {
		if (v == p)continue;

		dfs(v, u);
	}
	ans[u] = c[idx++];
}


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

	cin >> n;
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	rep(i, n)cin >> c[i];

	sort(c, c + n);



	dfs(0);
	int sum = 0;
	rep(i, n) {
		int u = i;
		for (int v : edge[u]) {
			if (u < v) {
				sum += min(ans[u], ans[v]);
			}
		}
	}

	cout << sum << endl;
	rep(i, n) {
		if (i)cout << ' ';
		cout << ans[i];
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 1408
/* ex3_2
   offNaria */
#include <stdio.h>
int main(void){
  int N; //整数Nを定義
  scanf("%d", &N); //入力を変数に代入
  
  N = N % 10; //Nの1の位のみを取得
  if(N == 3){
    printf("bon\n"); //3はbon
  } else if(N == 0 || N == 1 || N == 6 || N == 8){
    printf("pon\n"); //0,1,6,8はpon
  } else {
    printf("hon\n"); //それ以外はhon
  }
  return 0;
}


Measured memory_bytes: 1592