akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,m,l,k,i,j;
  int A[101][101],B[101][101];
  long long sum[101][101]={};
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&B[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
	sum[i][j]+=A[i][k]*B[k][j];
      }
      printf("%lld",sum[i][j]);
      if(j!=l-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}



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

int N, T;

int A[3005];
int B[3005];

long long memo[3005][3005][2];

// j is time remaining
long long dp(int i, int j, int k){
    if(i == 0 || j == 0){
        return 0;
    }else if(memo[i][j][k] != -1){
        return memo[i][j][k];
    }else{
        long long ans = dp(i-1, j, k); // ignore
        if(k == 1){
            ans = max(ans, dp(i-1, j, 0) + B[i-1]); // take
        }
        if(A[i-1] <= j){
            ans = max(ans, dp(i-1, j-A[i-1], k) + B[i-1]); // take
        }
        return memo[i][j][k] = ans;
    }
}

int main(){
    scanf("%d%d", &N, &T);

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

    memset(memo, -1, sizeof(memo));
    printf("%lld", dp(N, T-1, 1));
    return 0;
}


Measured memory_bytes: 141568
import heapq
N = int( input())
A = list( map( int, input().split()))
fsum = [0]*(N+1)
bsum = [0]*(N+1)
forward = A[:N]
back = A[2*N:]
back = list(map( lambda x:-x, back))
heapq.heapify(forward)
heapq.heapify(back)
fsum[0] = sum(forward)
fsumnow = fsum[0]
bsum[N] = -sum(back)
bsumnow = bsum[N]
for i in range(1,N+1):
    heapq.heappush(forward, A[N+i-1])
    fsumnow += A[N+i-1]
    fsumnow -= heapq.heappop(forward)
    fsum[i] = fsumnow
    heapq.heappush(back, -A[2*N-i])
    bsumnow += A[2*N-i]
    bsumnow += heapq.heappop(back)
    bsum[N-i] = bsumnow
ans = fsum[0] - bsum[0]
for i in range(1,N+1):
    ans = max(ans, fsum[i] - bsum[i])
print(ans)

Measured memory_bytes: 37212
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		if(s[i]=='x')cnt++;
	}
	if(cnt > 7)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int k, t;
int a[103];

int main()
{
	cin >> k >> t;

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

	int mx = a[0];

	for (int i = 0; i < t; i++) {
		mx = std::max(mx, a[i]);
	}

	int ans = 0;
	int ot = k - mx;

	if (mx < ot) {
		ans = 0;
	}
	else {
		ans = mx - (k - mx) - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
a['~~'],j;main(i){for(;++i<98;)for(j=i;j<1e4;a[j+=i]=a[1]=1);for(;~scanf("%d",a);printf("%d\n",j))for(i=j=*a;i;--i)j-=a[i]|a[*a-i+1];}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define first    ff
#define second   ss
#define pi       acos(-1.0)
#define test     int t;cin>>t;while(t--)
typedef long long ll;
using namespace std;
int a[28],b[28];

int main()
{      
     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
  
      string s;
      cin>>s;
     if(s[s.size()-1]=='s')
      cout<<s<<"es"<<endl;
    else
      cout<<s<<"s"<<endl;
      return 0;
      
 }       

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

vector<vector<int>> dist;
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};

int main(){
  int height,width; cin >> height >> width;
  vector<string> field(height);
  for(int h=0;h<height;h++) cin >> field[h];
  
  vector<vector<int>> dist(height,vector<int>(width,-1));
  dist[0][0]=0;

  vector<vector<int>> prev_x(height,vector<int>(width,-1));
  vector<vector<int>> prev_y(height,vector<int>(width,-1));

  queue<pair<int,int>> que;
  que.push(make_pair(0,0));

  while(!que.empty()){
    const auto current=que.front();
    const int x=current.first;
    const int y=current.second;
    que.pop();

    for(int direction=0;direction<4;direction++){
      int next_x=x+dx[direction];
      int next_y=y+dy[direction];
      if(next_x<0||next_x>=height||next_y<0||next_y>=width) continue;
      if(field[next_x][next_y]=='#') continue;

      if(dist[next_x][next_y]==-1){
        que.push(make_pair(next_x,next_y));
        dist[next_x][next_y]=dist[x][y]+1;
        prev_x[next_x][next_y]=x;
        prev_y[next_x][next_y]=y;
      }
    }
  }
  int x=height-1,y=width-1;
  int ans=-1;
  if(dist[x][y]!=-1){
    ans=0;
    while(x!=-1&&y!=-1){
      field[x][y]='o';
      int px=prev_x[x][y];
      int py=prev_y[x][y];
      x=px,y=py;
    }
    for(int h=0;h<height;h++){
      for(int w=0;w<width;w++){
        if(field[h][w]!='o'&&field[h][w]=='.'){
          ans++;
        }
      }
    }
  }
  cout << ans <<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){

  ios_base::sync_with_stdio (false);
  cin.tie(NULL);

  string S, T;
  cin >> S >> T;
  ll sol = T.size();

  FOR(i, 0, S.size()-T.size()+1){
    ll sim = 0;
    FOR(j, 0, T.size()){
      if(S[i+j]==T[j]) sim++;
    }
    sol = min(((ll)T.size())-sim, sol);
  }

  cout << sol << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

class DisjointSet {
public:
  V<ll> rank, p;
  DisjointSet() {};
  DisjointSet(ll size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    REP(i, size) makeSet(i);
  }

  void makeSet(ll x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(ll x, ll y) {
    return findSet(x) == findSet(y);
  }

  void unite(ll x, ll y) {
    link(findSet(x), findSet(y));
  }

  void link(ll x, ll y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  ll findSet(ll x) {
    if (x != p[x]) p[x] = findSet(p[x]);
    return p[x];
  }
};

int main() {
  ll n, k, l; cin >> n >> k >> l;
  DisjointSet road=DisjointSet(n);
  DisjointSet rail=DisjointSet(n);
  REP(i, k) {
    ll p, q; cin >> p >> q;
    road.unite(p-1, q-1);
  }
  REP(i, l) {
    ll r, s; cin >> r >> s;
    rail.unite(r-1, s-1);
  }
  map<P<ll, ll>, ll> rnum;
  REP(i, n) rnum[make_pair(road.findSet(i), rail.findSet(i))]++;
  REP(i, n) {
    cout << rnum[make_pair(road.findSet(i), rail.findSet(i))];
    if (i != n-1) cout << ' ';
  }
  cout << endl;
  return 0;
}


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

int main() {
  int N, K;
  int sum=1;
  cin >> N >> K;
  
  rep(i, N) {
  	if (2*sum < sum+K) {
      sum *= 2;
    }
    else {
      sum += K;
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3548
n = int(input())
preorder = list(map(int,input().split()))
inorder = list(map(int,input().split()))
postorder = []

def rec(l):
    if len(l) == 0:
        return
    # preorderから次の値を取り出す
    x = preorder.pop(0)
    for i in range(len(l)):
        if l[i] == x:
            # preorderの値と一致したら、そこから左右に分割
            rec(l[:i])
            rec(l[i+1:])
    postorder.append(x)
    return

rec(inorder)
print(*postorder)



Measured memory_bytes: 5600
from sys import stdin
readline = stdin.readline


GOAL = [i for i in range(1, 16)] + [0]
MAX_DEPTH = 45  # 80
count = 0

# ??£??\?????????
adjacent = (
    (1, 4),          # 0
    (0, 2, 5),       # 1
    (1, 6, 3),       # 2
    (2, 7),          # 3
    (0, 5, 8),       # 4
    (1, 4, 6, 9),    # 5
    (2, 5, 7, 10),   # 6
    (3, 6, 11),      # 7
    (4, 9, 12),      # 8
    (5, 8, 10, 13),  # 9
    (6, 9, 11, 14),  # 10
    (7, 10, 15),     # 11
    (8, 13),         # 12
    (9, 12, 14),     # 13
    (10, 13, 15),    # 14
    (11, 14)         # 15
)

# ???????????????????????¢
distance = (
    (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
    (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
    (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
    (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
    (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
    (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
    (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
    (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
    (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
    (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
    (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
    (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
    (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
    (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
    (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1)
)


def manhattan_distance(board):
    return sum(distance[bi][i] for i, bi in enumerate(board))


def answer_is_odd(board):
    return sum(divmod(board.index(0), 4)) % 2


def search(board):
    lower = manhattan_distance(board)
    start_depth = lower
    if (lower % 2) ^ answer_is_odd(board):
        start_depth += 1
    for limit in range(start_depth, MAX_DEPTH + 1, 2):
        id_lower_search(board, limit, 0, board.index(0), None, lower)
        if count > 0:
            return limit


def nxt_board(board, space, prev):
    for nxt in adjacent[space]:
        if nxt == prev:
            continue
        b = board[:]
        b[space], b[nxt] = b[nxt], 0
        yield b, nxt


def id_lower_search(board, limit, move, space, prev, lower):
    if move == limit:
        if board == GOAL:
            global count
            count += 1
    else:
        for b, nxt in nxt_board(board, space, prev):
            p = board[nxt]
            new_lower = lower - distance[p][nxt] + distance[p][space]
            if new_lower + move <= limit:
                id_lower_search(b, limit, move + 1, nxt, space, new_lower)


def main():
    start = (map(int, readline().split()) for _ in range(4))
    start = [y for x in start for y in x]
    print(search(start))
main()

Measured memory_bytes: 6964
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    h, w, m = map(int, input().split())
    rows = defaultdict(int)
    cols = defaultdict(int)
    d1 = lambda :defaultdict(int)
    d2 = defaultdict(d1)
    m = map(int, read().split())
    ab = zip(m, m)
    for a, b in ab:
        rows[a-1] += 1
        cols[b-1] += 1
        d2[a-1][b-1] = 1
    rm = max(rows.values())
    cm = max(cols.values())
    rs = [i for i, v in rows.items() if v == rm]
    cs = [i for i, v in cols.items() if v == cm]
    r = rm + cm
    #p = set()
    for rse in rs:
        for cse in cs:
            if d2[rse][cse] == 0:
                print(r)
                sys.exit()
    print(r-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 280916
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define Zero(dp) memset(dp,0,sizeof(dp))
#define pb emplace_back
using namespace std;
int32_t main(){
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
*/
ios
int t=1;
//cin>>t;
while(t--)
{
	int n;cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	int dp[n][3];
	dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
}

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

int main() {
  int X,Y;
  cin >> X >> Y ;
  if ( 2*X <= Y && Y <= 4*X && Y%2==0){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> students(N);
	vector<pair<int, int>> checkpoints(M);

	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		students[i] = make_pair(a, b);
	}

	for (int i = 0; i < M; i++) {
		int c, d;
		cin >> c >> d;
		checkpoints[i] = make_pair(c, d);
	}

	for (int i = 0; i < N; i++) {
		auto &s = students[i];
		int d = 1000000000;
		int index = -1;

		for (int j = 0; j < M; j++) {
			auto &c = checkpoints[j];
			int di = abs(s.first - c.first) + abs(s.second - c.second);
			if (d > di) {
				d = di;
				index = j;
			}
		}

		cout << index + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 13 - 08 - 20  |
// Atcoder BC 175|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll x,k,d;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> x >> k >> d;
  ll pst = x/d;
  //if(((abs(pst))&1) == (k&1));
  //else pst++;
  if(abs(pst) >= k){
	if(x > 0)
	cout << abs(x - k*d) << "\n";
	else
	cout << abs(x + k*d) << "\n"; 
  }
  else{
	  x -= pst*d;
	  k -= abs(pst);
	  ll ans = abs(x);
	  if(k&1) ans = min(abs(x - d),abs(x + d));
	  cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int tmp = -1;
    if (n % 2 == 1) {
      tmp = a[n - 1];
      n--;
    }
    int[] a2 = new int[n];
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        a2[(i + n) / 2] = a[i];
      } else {
        a2[(n - i) / 2] = a[i];
      }
    }
    if (tmp == -1) {
      for (int i = 0; i < a2.length; i++) {
        System.out.print(a2[i]);
        if (i != a2.length - 1) {
          System.out.print(" ");
        }
      }
    } else {
      System.out.print(tmp);
      for (int i = a2.length - 1; i >= 0; i--) {
        System.out.print(" " + a2[i]);
      }
    }
  }
}

Measured memory_bytes: 93716
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> x(n,0);
  REP(i, n){
    cin >> x[i];
  }

  int ans = 1e9;
  int tmp = 0;
  REP(i, n -k + 1){
    tmp = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1]));
    ans = min(ans, tmp);
    // cout << x[i]<< " -> " << x[i + k - 1] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	char ch;
	cin >> ch;
	printf("%c\n", ch+1);
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = 102;
char s[maxn][maxn];
int n, m;

int xe, ye;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == 'E') {
        xe = i, ye = j;
      }
    }
  }
  return 1;
}

int prec[2][maxn][maxn];

inline int get(int type, int x, int l, int r) {
  auto &cur = prec[type][x];
  return cur[r] - cur[l];
}

short dp[maxn][maxn][maxn][maxn];
short res;

inline void update(int x1, int x2, int y1, int y2, short nval) {
  auto &cur = dp[x1][x2][y1][y2];
  if (cur < nval) {
    cur = nval;
    if (res < nval) {
      res = nval;
    }
  }
}

void solve() {
  for (int i = 0; i < n; ++i) {
    prec[0][i][0] = 0;
    for (int j = 0; j < m; ++j) {
      prec[0][i][j + 1] = prec[0][i][j] + (s[i][j] == 'o');
    }
  }

  for (int i = 0; i < m; ++i) {
    prec[1][i][0] = 0;
    for (int j = 0; j < n; ++j) {
      prec[1][i][j + 1] = prec[1][i][j] + (s[j][i] == 'o');
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][0] = 0;
  int xl = xe + 1, xr = n - xe;
  int yl = ye + 1, yr = m - ye;

  res = 0;

  for (int cxl = 0; cxl < xl; ++cxl) {
  for (int cxr = 0; cxr < xr; ++cxr) {
  for (int cyl = 0; cyl < yl; ++cyl) {
  for (int cyr = 0; cyr < yr; ++cyr) {
    auto cur = dp[cxl][cxr][cyl][cyr];
    if (cur < 0) {
      continue;
    }
    int x1 = max(xe - cxl, cxr);
    int x2 = min(xe + cxr, n - 1 - cxl) + 1;

    int y1 = max(ye - cyl, cyr);
    int y2 = min(ye + cyr, m - 1 - cyl) + 1;

    if (cxr + cxl + 1 < xl) {
      update(cxl + 1, cxr, cyl, cyr, cur + get(0, x1 - 1, y1, y2));
    }
    if (cxr + cxl + 1 < xr) {
      update(cxl, cxr + 1, cyl, cyr, cur + get(0, x2, y1, y2));
    }
    if (cyr + cyl + 1 < yl) {
      update(cxl, cxr, cyl + 1, cyr, cur + get(1, y1 - 1, x1, x2));
    }
    if (cyr + cyl + 1 < yr) {
      update(cxl, cxr, cyl, cyr + 1, cur + get(1, y2, x1, x2));
    }
  }
  }
  }
  }
  printf("%d\n", (int) res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 211712
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 6001
#define INF 1e9
 
struct State{
  int dist,v,cap;
  State(int dist,int v,int cap)
    : dist(dist),v(v),cap(cap) {}
 
  bool operator > (const State &s)const{
    return dist > s.dist;
  }
};
 
struct Edge{
  int to,dist;
  Edge(int to,int dist) : to(to),dist(dist) {}
};
 
int N,M,cap,src,dst,idx;
set<int> LPG;
vector<Edge> G[MAX];
 
void init(){
  idx = 1;
  LPG.clear();
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }
}
 
int dijkstra(){
  vector<int> dist[idx];
  cap *= 10;
  
  for(int i = 0 ; i < idx ; i++){
    dist[i].resize(cap+1);
    for(int j = 0 ; j <= cap ; j++){
      dist[i][j] = INF;
    }
  }
 
  dist[src][cap] = 0;
 
  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(0,src,cap));
 
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v,c = s.cap;
     
    if(dist[v][c] < s.dist) continue;
     
    if(v == dst){
      return dist[v][c];
    }
 
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      Edge e = G[v][i];
      int nc = (LPG.find(v) != LPG.end()) ? cap : c;
      if(e.dist <= nc){
        nc -= e.dist;
        if(dist[v][c] + e.dist < dist[e.to][nc]){
          dist[e.to][nc] = dist[v][c] + e.dist;
          Q.push(State(dist[e.to][nc],e.to,nc));
        }                          
      }
    }
  }
  return -1;
}
 
int main(){
  int d;
  string a,b;
   
  while(cin >> N >> M >> cap, N){
    init();
    map<string,int> mp;
    cin >> a; mp[a] = src = idx++;
    cin >> a; mp[a] = dst = idx++;
    for(int i = 0 ; i < N ; i++){
      cin >> a >> b >> d;
      if(mp.find(a) == mp.end()){
        mp[a] = idx++;
      }
      if(mp.find(b) == mp.end()){
        mp[b] = idx++;
      }
      G[mp[a]].push_back(Edge(mp[b],d));
      G[mp[b]].push_back(Edge(mp[a],d));
    }
    for(int i = 0 ; i < M ; i++){
      cin >> a;
      LPG.insert(mp[a]);
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 51384
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,M,R; cin >> N >> M >> R;
    int r[R]; REP(i,R){cin >> r[i]; r[i]--;}
    ll dist[N][N]; REP(i,N)REP(j,N) dist[i][j] = INF;
    REP(i,M){
        ll a,b,c; cin >> a >> b >> c;
        dist[a-1][b-1] = c; dist[b-1][a-1] = c;
    }
    REP(i,N) dist[i][i] = 0;

    for(int k=0; k<N; k++)
        for(int i=0; i<N; i++)
            for(int j=0; j<N; j++)
                chmin(dist[i][j], dist[i][k]+dist[k][j]);
    
    VI v(R); REP(i,R) v[i] = r[i];
    SORT(v);
    ll ans = INF;
    do {
        ll tmp=0;
        REP(i,R-1){
            tmp += dist[v[i]][v[i+1]];
        }
        chmin(ans, tmp);
    } while (next_permutation(v.begin(), v.end()));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
odatas1 = []
odatas2 = []
# sum = 0
while True:
    datas = list(map(int, input()))
    if len(datas) == 1 and 0 in datas:
        break
    else:
        odatas1.append(datas)

# print(odatas1)
for i in range(len(odatas1)):
    print(sum(odatas1[i]))

# 今回、TypeError: 'int' object is not callableというエラーを吐いた
# 理由は3行目に sum = 0 を定義していたために発生した
# ビルトイン関数(組み込み関数)と同じ名前の変数を定義するとこのエラーがでる。
# ex) sum, max, min, str



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

using namespace std;

void merge(vector<int> &a, const int left, const int mid, const int right, int &cnt)
{
    int n1 = mid - left, n2 = right - mid;
    vector<int> l(n1 + 1), r(n2 + 1);
    for (int i = 0; i < n1; i++)
        l[i] = a[left + i];
    l[n1] = INT_MAX;

    for (int i = 0; i < n2; i++)
        r[i] = a[mid + i];
    r[n2] = INT_MAX;

    int i = 0, j = 0;

    for (int k = left; k < right; k++)
    {
        if (l[i] <= r[j])
            a[k] = l[i++];
        else
            a[k] = r[j++];
        cnt++;
    }
}

int mergeSort(vector<int> &a, const int left, const int right, int &cnt)
{
    int mid;
    if (left + 1 < right)
    {
        mid = (left + right) / 2;
        mergeSort(a, left, mid, cnt);
        mergeSort(a, mid, right, cnt);
        merge(a, left, mid, right, cnt);
    }
    return cnt;
}

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

    int cnt = 0;
    cnt = mergeSort(a, 0, n, cnt);
    for (int i = 0; i < n; i++)
    {
        printf("%d", a[i]);
        if (i != n - 1)
            printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int D[57];
    cin >> N;
    REP(i,N){
        cin >> D[i];
    }
    sort(D,D+N);
    int Ans=INF;
    vector<int> V;
    V.push_back(0);
    REP(i,N){
        if(i%2==0){
            V.push_back(D[i]);
        }else{
            V.push_back(24-D[i]);
        }
    }
    REP(i,V.size()){
        REP(j,V.size()){
            if(i==j)continue;
            Ans=min(Ans,abs(V[i]-V[j]));
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        要素xが属するグループの根を返す
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        要素xが属するグループと要素yが属するグループを併合
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """
        要素xが属するグループのサイズを返す
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        要素x, yが同じグループかどうか
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """
        要素xが属するグループの要素をリストで返す
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """
        すべての根の要素をリストで返す
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """
        グループの数を返す
        """
        return len(self.roots())

    def all_group_members(self):
        """
        {ルート要素: [そのグループの要素, ...], ...}を返す
        """
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """
        print()での表示用
        """
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
N, M = map(int, input().split())
uf = UnionFind(N)
P = list(map(int, input().split()))
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    uf.union(P[a] - 1, P[b] - 1)

res = 0
for i, p in enumerate(P):
    if uf.same(p - 1, i):
        res += 1

print(res)


Measured memory_bytes: 84348
#include<bits/stdc++.h>
using namespace std;
#define MAX 7777777
bool u[MAX];
int main(){
  int m,n;
  while(cin>>m>>n,m||n){
    memset(u,0,sizeof(u));
    int i,j,k=m;
    for(i=0;i<n;i++){
      while(u[k]) k++;
      for(j=k;j<MAX;j+=k) u[j]=1;
    }
    for(i=m;u[i];i++);
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<int,int> P;

int main() {
  int n; cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) a[i]--;
  int b[n]; for(int i=0;i<n;i++) b[a[i]]=i;

  // 1つ以上連続する値
  int an=n-1;
  for(int i=1,sm=n-1,nw=b[0];i<n;i++) {
    if (nw < b[i]) sm--, nw=b[i], an=min(an,sm);
    else sm=n-1, nw=b[i];
  }
  cout<<an<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  long cost = 0;
  if(N <= K){
    cost = X * N;
  }else{
    cost = X * K + Y * (N-K);
  }
  cout << cost << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a , b;
  	cin >> a >> b;
  	if(a >= 13)
      cout << b << endl;
  	else if( a >= 6)
      cout << b/2 << endl;
  	else
      cout << 0 << endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }

  vector<set<int>> g(n);
  rep(i, m) {
    g[a[i]].insert(b[i]);
    g[b[i]].insert(a[i]);
  }

  bool possible = false;
  rep(i, n) {
    if (g[i].find(0) != g[i].end() && g[i].find(n-1) != g[i].end()) possible = true;
  }
  if (possible) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 33064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int a[2];

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int n, p; cin >> n >> p;
    for(int i = 0 ; i < n ; i++){
        int tmp; cin >> tmp;
        a[tmp%2]++;
    }
    ll tot = 1;
    for(int i = 0; i < n ; i++) tot *= 2;
    if(a[1]) tot /= 2;
    if(a[1]==0&&p==1) tot = 0;
    cout << tot;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[4000][4000];
string go(string a,string b){
	for(int i=0;i<a.length()+1;i++){
		for(int j=0;j<b.length()+1;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}
			else if(a[i-1]==b[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i=a.length();
	int j=b.length();
	string ans="";
	while(i>0&&j>0){
		if(a[i-1]==b[j-1]){
			ans+=a[i-1];
			i--,j--;
		}
		else if(dp[i-1][j]<=dp[i][j-1]){
			j--;
		}
		else{
			i--;
		}
	}
	
	reverse(ans.begin(),ans.end());
	return ans;
}
int main(){
	string a;
	string b;
	cin>>a>>b;
	cout<<go(a,b);
}

Measured memory_bytes: 50536
def resolve():
    import itertools
    n = int(input())
    p = tuple([int(i) for i in input().split()])
    q = tuple([int(i) for i in input().split()])

    all_list = list(itertools.permutations(range(1, n + 1)))

    print(abs(all_list.index(p) - all_list.index(q)))


resolve()

Measured memory_bytes: 8052
def main():
    N = int(input())
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=lambda x:x[1], reverse=True)
    # x 昇順
    cd.sort()
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()


Measured memory_bytes: 3064
from itertools import accumulate
N, M = map(int, input().split())
T = [0]*(N+1)

for _ in range(M):
    L, R = map(int, input().split())
    T[L-1] += 1
    T[R] -= 1

T = list(accumulate(T))
print(T.count(M))

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

using namespace std;

int mcxitoi(string s) {
	int res = 0;
	int t = 1;
	for (char c : s) {
		if (isdigit(c)) {
			t = c - '0';
		} else {
			if (c == 'm') t *= 1000;
			else if (c == 'c') t *= 100;
			else if (c == 'x') t *= 10;
			res += t;
			t = 1;
		}
	}
	return res;
}

string sign(int x) {
	string res;
	if (x == 1) return res;
	res += '0' + x;
	return res;
}

string itomcxi(int x) {
	string res;
	if (x / 1000) res += sign(x / 1000) + "m";
	x %= 1000;
	if (x / 100) res += sign(x / 100) + "c";
	x %= 100;
	if (x / 10) res += sign(x / 10) + "x";
	x %= 10;
	if (x) res += sign(x) + "i";
	return res;
}

int main() {
	int n; cin >> n;
	while (n--) {
		string s1, s2; cin >> s1 >> s2;
		cout << itomcxi(mcxitoi(s1) + mcxitoi(s2)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll a, b, c;
  cin>>a>>b>>c;
  if(a+b<=c) cout << 0 << " " << 0;
  else {
    if(a<=c) cout << 0 << " " << a+b-c;
    else cout << a-c << " " << b;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a[n],b[n],c[m],d[m];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,m){
        cin >> c[i] >> d[i];
    }
    rep(i,n){
        intl min = INF;
        intl idx = -1;
        rep(j,m){
            intl mi = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(min > mi){
                min = mi;
                idx = j + 1;
            }
        }
        cout << idx << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
$array = array();

while(true){
	$input = trim(fgets(STDIN));

	if($input == 0) break;

	$array[] = $input;
}

$count = count($array);

for($i = 0; $i < $count; $i++){
	$case = $i + 1;

	if($i == $count - 1) echo 'Case'," ","$case".':'.' '."$array[$i]";
	else echo 'Case'," ","$case".':'.' '."$array[$i]"."\n";
}

?>

Measured memory_bytes: 10956
# 参考：jj1guj，https://atcoder.jp/contests/abc152/submissions/9630014

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

N=int(input())
A=list(map(int,input().split()))
a_lcm=A[0]

for i in range(1,N):
    a_lcm=lcm(a_lcm,A[i])

a_lcm%=1000000007

result=0
for i in range(N):
    result+=(a_lcm*pow(A[i],1000000007-2, 1000000007))%1000000007
print(result%1000000007)


Measured memory_bytes: 4084
def gcd(x0, y0):
    if x0<y0:
        tmp0 = x0
        x0 = y0
        y0 = tmp0
    if y0 == 0:
        return x0
    else:
        return gcd(y0, x0 % y0)

a,b = map(int,input().split())

g = gcd(a,b)

print(a*b//g)

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

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();
		//sc.nextLine();
		
		int l = s.length();
		char[] str = new char[l];
		for(int i = 0; i < l; i++){
			int a = s.charAt(i) + n;
			if(a > 90){
				str[i] = (char)(s.charAt(i) + n - 26);
			}else{
			str[i] = (char)(s.charAt(i) + n);
			}
		}
		for(int i = 0; i < l; i++){
			System.out.print(str[i]);
		}
	}
		
		
}

Measured memory_bytes: 25776
N=int(input())
h_array=input().split()
dp=[0]*N


dp[0]=0
dp[1]=abs(int(h_array[0])-int(h_array[1]))
for  n in range(2,N):
    dp[n] =min(abs(int(h_array[n])-int(h_array[n-1]))+dp[n-1],abs(int(h_array[n])-int(h_array[n-2]))+dp[n-2])
print(dp[-1])

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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}




ll A[10005] = { 0 };

ll doit(ll a, ll b, ll c) {
    ll s = (a * a) + (b * b) + (c * c) + (a * b) + (a * c) + (b * c);
    return s;
}

void solve() {
    
     ll N;
     cin >> N;
     
    for(ll i = 1; i <= sqrt(N); i++) {
        for(ll j = 1; j <= sqrt(N); j++) {
            for(ll k = 1; k <= sqrt(N); k++) {
                  ll g = doit(i, j, k);
                  if(g <= N) {
                      A[g]++;
                  } 
            }
        }
    }
    
    for(ll i = 1; i <= N; i++) {
        cout << A[i] << endl;
    }

}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
	if (ch == 'A')return 1;
	if (ch == 'C')return 2;
	if (ch == 'G')return 3;
	if (ch == 'T')return 4;
	return 0;
}
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;;i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}
int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}
int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)H[i][0] = '\0';
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;
int c[1000];

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

	for (int i = 1;i < 1000;i++) c[i] = i + c[i - 1];
	cout << c[b - a - 1] - a << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mape[505][505];
int ans[505][505];
int ans2[505][505];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie();
	int n,m,q;
	cin>>n>>m>>q;
	memset(mape,0,sizeof(mape));
	memset(ans,0,sizeof(ans));
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		mape[l][r]++;
	}
	for(int i=1;i<=500;i++){
		for(int j=1;j<=500;j++){
			ans[i][j]=ans[i][j-1]+mape[i][j]; 
		}
	}
	for(int i=500;i>=1;i--){
		for(int j=1;j<=500;j++){
			ans[i][j]+=ans[i+1][j]; 
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		cout<<ans[l][r]<<endl;
	}
} 

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int A, B, C;
string s[200];

int main() {
	scanf("%d %d %d", &A, &B, &C);
	rep(i, A) cin >> s[i];
	int ans = 0;
	rep(i, A) rep(j, B - C + 1) {
		int cnt = 0;
		rep(k, C) {
			if(s[i][j + k] == '.') ++cnt;
			else break;
		}
		if(cnt == C) ++ans;
	}
	rep(i, A - C + 1) rep(j, B) {
		int cnt = 0;
		rep(k, C) {
			if(s[i + k][j] == '.') ++cnt;
			else break;
		}
		if(cnt == C) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC138A();
        }

        static void AC138A()
        {
            //https://atcoder.jp/contests/abc138/tasks

            var n = double.Parse(Console.ReadLine());
            var listA = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double gyaku1 = 0;

            foreach(var a in listA)
            {
                gyaku1 += 1 / a;
            }


            Console.WriteLine(1 / gyaku1);

        }

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>
 
 
signed main(){
	
	string s;cin>>s;
	
	int ans = 0;
	rep(i,4) ans += (s[i]=='+'?1:-1);
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	rep(i,n) std::cin >> vec[i];
	int count = 0;
	rep(i,n-2) if((vec[i]<vec[i+1]&&vec[i+1]<vec[i+2])||(vec[i]>vec[i+1]&&vec[i+1]>vec[i+2])) count++;
	print(count);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long INF = 1e18;

struct Edge{
    int from;
    int to;
    int cost;
};

int main(){
    int v,e,r;
    cin>>v>>e>>r;

    Edge g[e+100];
    long long d[v+100];

    for(int i=0; i<e; i++){
        cin>>g[i].from>>g[i].to>>g[i].cost;
    }
    for(int i=0; i<v; i++){
        d[i]=INF;
    }

    d[r] = 0;
    bool update = true;
    long long cnt = 0;

     while(update){
         
        update = false;

        for(int i = 0; i < e; i++){

            Edge e = g[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){

                d[e.to] = d[e.from] + e.cost;

                update = true;

            }

        }

        if(!update) break;
         cnt++;
         if(cnt==v){
             cout<<"NEGATIVE CYCLE"<<endl;
             return 0;
         }

    }

    for(int i=0; i<v ;i++){
        if(d[i]==INF){
            cout<<"INF"<<endl;
        }else{
            cout<<d[i]<<endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
typedef long long ll;
typedef double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX=3000;
ld coins[MAX];
ld mem[MAX][MAX/2];
int n;

ld dp(int i,int sellos){
	if(sellos<0)return 0.0;
	if(i==n)return 1.0;
	ld &ans=mem[i][sellos];
	if(ans > -0.5) return ans;
	ans = 0;
	ans += coins[i]*dp(i+1,sellos)+(1.0-coins[i])*dp(i+1,sellos-1);
	return ans;
}
int main() {

  ios::sync_with_stdio(0), cin.tie(0);
  cin>>n;
  for(int i=0;i<=n;i++){
  	for(int j=0;j<=n;j++){
  		mem[i][j]=-1.0;
  	}
  }
  forn(i,n){
  	cin>>coins[i];
  }
  int m = (n+1)/2-1;
  ld ans = dp(0, m);
  cout<<fixed<<setprecision(10)<< ans << endl;
  return 0;
}

Measured memory_bytes: 35584