akhauriyash/Code-Regression huggingface dataset:
N=int(input())
nn=N
import math
sq=round(math.sqrt(N))+1

i=2
ans=0
count1=0
count2=1
while sq>=i:
    if nn%i==0:
        nn//=i
        count1+=1
        if count1==count2:
            ans+=1
            count2+=1
            count1=0
    else:
        i+=1
        count1=0
        count2=1

if nn>sq:
    ans+=1

print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n;
  if(n==1)
  {
    cout<<"Hello World"<<endl;
  }
  else if(n==2)
  {
    cin>>a>>b;
    cout<<(a+b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int time;
	scanf("%d", &time);
	int hour = time / 3600;
	int minute = (time - hour*3600) / 60;
	int second = time - hour*3600 - minute*60;

	printf("%d:%d:%d\n", hour, minute, second);

	return 0;
}




Measured memory_bytes: 2132
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int ans = 0;
    if(a > b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    if(a > b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, l_white=0, r_black=0, ans=INF;
    string S;

    cin >> N >> S;

    for(i=0; i<N; i++){
        if(S[i]=='#'){
            r_black++;
        }
    }

    chmin(ans, N-(l_white+r_black));

    for(i=0; i<N; i++){
        if(S[i]=='#'){
            r_black--;
        }
        else{
            l_white++;
        }

        chmin(ans, N-(l_white+r_black));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        a[i] = {b, i};
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        if (i > 0)
            cout << " ";
        cout << a[i].second + 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
from scipy.sparse.csgraph import floyd_warshall as fw
N, M, L = map(int, input().split())

# 町間の道の長さのマトリックスを初期値無限で作成
S = [[float("INF") for i in range(N)] for i in range(N)]

# 町間の道の長さ情報をマトリックスに入力
for i in range(M):
    a, b, c = map(int,input().split())
    S[a-1][b-1] = c
    S[b-1][a-1] = c


# ワーシャルフロイド法で最短距離のマップを生成
Sf = fw(S)

T = [[float("INF")for i in range(N)] for i in range(N)]

# 町間を補給なしで通行可能な場合は1、不可能な場合はINFとしてマトリックスを作成
# （町間距離がタンク容量より大きい場合は通行不可）
for i in range(N):
    for j in range(N):
        if Sf[i][j] <= L:
            T[i][j] = 1

# ワーシャルフロイド法で町間移動可否のマップを生成
# すぐ上のfor文で、補給なしで移動できない町間の移動コストはINFにしたが、
# この処理で複数回の補給を行えば移動できる距離を
Tf = fw(T)

for i in range(int(input())):
    a, b = map(int, input().split())
    if Tf[a-1][b-1] != float("INF"):
        print(int(Tf[a-1][b-1])-1)
    else:
        print(-1)


Measured memory_bytes: 22332
a, b = map(int,input().split())
s = input()
d1 = False
d2 = False
if s[a] == '-':
    d1 = True
cnt = 0
for i in range(a+b+1):
    if s[i].isdecimal():
        cnt += 1
if cnt == a + b:
    d2 = True

if d1 and d2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	const int months[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	const string answers[7] =
	{ "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	while (true) {
		int M = nextInt();
		int D = nextInt();
		if (M == 0) break;
		int past_days = -1;
		for (int i = 1; i < M; i++) {
			past_days += months[i];
		}
		past_days += D;
		PRINT(answers[past_days % 7]);
	}
	return 0;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

M = int(N / 1.08)

answer = []
for x in range(M-100,M+100):
    y = x * 27 // 25
    if y == N:
        answer.append(x)

if answer:
    print(answer[0])
else:
    print(':(')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],i;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int ans;
	ans=0;
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++)
	{
		if (a[i]!=a[i-1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf " %d %d %d" @@ fun n m k ->
  let lst1 = List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let lst2 = List.init m (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  
  let b = ref (List.length lst2) in
  let bsum = ref (List.fold_right ( + ) lst2 0) in
  
  let rec can_read t lst = 
    if t >= !bsum then (!b, lst)
    else match lst with
      | [] -> (!b, [])
      | first :: rest ->
        (b := !b - 1; bsum := !bsum - first;
         if t >= !bsum then (!b, rest)
         else can_read t rest) in
                                
  let a = ref 0 in

  let rec h2 (max, t) l1 l2 = match l1 with
    | [] -> (max - 1, t)
    | first :: rest ->
      let nokori = t - first in
      if nokori >= 0 then
        (a := !a + 1;
         let (b_num, b_lst) = can_read nokori l2 in
         if (max < !a + b_num) then
           h2 (!a + b_num, nokori) rest b_lst
         else h2 (max, nokori) rest b_lst
        )
      else (max - 1, t) in

  let ans = h2 (0, k) (0 :: lst1) (List.rev lst2) in
  (fun (a, b) -> Printf.printf "%d" a) ans

Measured memory_bytes: 31012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<string> words(n);
  for(int i=0;i<n;i++){
	cin >> words.at(i);
  }
  for(int i=0;i<n;i++){
    if(i==0) continue;
    if( words.at(i).at(0) != words.at(i-1).at( words.at(i-1).size()-1 ) ){
      cout << "No" << endl;
      return 0;
    }
    for(int j=i-1;j>=0;j--){
      if( words.at(i) == words.at(j) ){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
 
  int sum = 0;
  while(n > 0){
    sum += n % 10,n /= 10;
  }
  if(sum == 1){
    cout << 10 << endl;
  }
  else{
  cout << sum << endl;
  }
}

Measured memory_bytes: 3604
import sys
import math
import collections
from collections import deque
#n = int(input())
#n, k = map(int, sys.stdin.readline().split())
s = input()
#x = list(map(int, sys.stdin.readline().split()))


if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")


Measured memory_bytes: 3316
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            if i == 0 or i == (H-1):
                print('#'*W)
            else:
                print('#'+'.'*(W-2)+'#')
        print()

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

int main()
{
    int r;
    scanf("%d",&r);
    if(r<1200)
        printf("ABC\n");
    else if(r<2800)
    printf("ARC\n");
    else
        printf("AGC\n");
    return 0;

}


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

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int r, D, x2000; cin >> r >> D >> x2000;
    rep (i, 0, 10) {
        x2000 = x2000 * r - D;
        cout << x2000 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int q = scan.nextInt();
		for (int t = 0; t < q; t++) {
			char[] x = scan.next().toCharArray();
			char[] y = scan.next().toCharArray();

			int[][] dp = new int[x.length + 1][y.length + 1];
			
			for (int i = 1; i <= x.length; i++) {
				for (int j = 1; j <= y.length; j++) {
					dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
					if (x[i - 1] == y[j - 1])
						dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 1);
				}
			}
			System.out.println(dp[x.length][y.length]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 64256
#include <iostream>  
#include <string>  
#include <cstdio>  
#include <cmath>  
#include<cstring>  
#define max(x,y) x>y?x:y  
using namespace std;  
const int maxn=1011111;  
int f[maxn];  
int d[maxn];  
int find(int x)  
{  
    if(f[x]==x)  
        return x;  
  
    int r=find(f[x]);  
    d[x]=d[f[x]]+d[x];//当前x到她老祖宗的距离等于他现在的距离加上她爸爸到老祖宗的距离  
  
    return f[x]=r; //把每个子节点合并到他的祖先  
}  
  
  
int fix(int x,int y,int z)  
{  
    int fx=find(x);  
    int fy=find(y);  
    if(fx==fy)  
        return z==d[y]-d[x];  
    f[fy]=fx;//把x当作y的爸爸；  
    d[fy]=d[x]+z-d[y];  
    return 1;  
}  
  
  
  
  
  
int main()  
{  
    int n,m;  
    int lose=1;  
    cin>>n>>m;  
    for(int i=1;i<=n;i++)//初始化：先把所有点的爸爸都设为自己；  
        f[i]=i;  
    for(int i=1;i<=m;i++)  
    {  
        int x,y,z;  
        cin>>x>>y>>z;  
  
        if(lose)  
            lose=fix(x,y,z);  
  
    }  
  
    if(lose)  
        cout<<"Yes"<<endl;  
    else  
        cout<<"No"<<endl;  
    return 0;  
}  


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

int N;
vector<int> from;
vector<vector<int>> to;
vector<int> grundy;

int calcgrundy(int now, bool rec)
{
    set<int> gr_lst;
    for (auto nxt : to[now])
    {
        if (grundy[nxt] < 0 && rec) grundy[nxt] = calcgrundy(nxt, rec);
        gr_lst.insert(grundy[nxt]);
    }
    int res = 0;
    while (gr_lst.find(res) != gr_lst.end()) res++;
    return res;
}

int main()
{
    cin >> N;
    from.resize(N);
    to.resize(N);
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        tmp--;
        from[i] = tmp;
        to[tmp].push_back(i);
    }

    // Find loop
    vector<bool> visited(N, false);
    int now = 0;
    while (true)
    {
        if (visited[now]) break;
        visited[now] = true;
        now = from[now];
    }

    vector<bool> isloopmember(N, false);
    while (true)
    {
        if (isloopmember[now]) break;
        isloopmember[now] = true;
        now = from[now];
    }

    grundy = vector<int>(N, -1);
    for (int i = 0; i < N; i++)
    {
        if (!isloopmember[i]) grundy[i] = calcgrundy(i, true);
    }

    grundy[from[now]] = calcgrundy(from[now], false);
    grundy[now] = calcgrundy(now, true);

    if (calcgrundy(from[now], false) == grundy[from[now]])
    {
        // for (auto g : grundy) cout << g << " ";
        cout << "POSSIBLE" << endl;
        return 0;
    }
    while (grundy[now] >= 0)
    {
        grundy[now] = -1;
        now = from[now];
    }

    set<int> grnx;
    for (auto v : to[from[now]]) grnx.insert(grundy[v]);
    for (int i = calcgrundy(from[now], false)+1;; i++)
    {
        if (grnx.find(i) == grnx.end())
        {
            grundy[from[now]] = i;
            break;
        }
    }
    grundy[now] = calcgrundy(now, true);

    if (calcgrundy(from[now], false) == grundy[from[now]])
    {
        // for (auto g : grundy) cout << g << " ";
        cout << "POSSIBLE" << endl;
        return 0;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

int pow(int x, int n)
{
  int ret = 1;
  while (n > 0)
  {
    if (n & 1)
      ret = ret * x;
    x = x * x;
    n >>= 1;
  }
  return ret;
}

int main()
{
  int m, k;
  cin >> m >> k;
  int m2 = pow(2, m);
  if (m2 <= k)
  {
    printf("-1\n");
    return 0;
  }
  if (m == 1)
  {
    if (k == 0)
      printf("1 0 0 1\n");
    else
      printf("-1\n");
    return 0;
  }
  rep(i, m2)
    if (i != k)
      printf("%d ", i);
  printf("%d ", k);
  for (int i=m2-1; i>=0; i--)
    if (i != k)
      printf("%d ", i);
  printf("%d\n", k);
  return 0;
}

Measured memory_bytes: 1792
n, l = gets.split.map(&:to_i)
arr = []
1.upto(n) do |i|
  arr << l + i - 1
end
eaten_apl = arr.map{|i| i.abs}.sort.first
arr.delete_if do |i|
 i.abs === eaten_apl
end
puts arr.inject(:+)

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

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

		String inS = stdin.next();
		System.out.println(inS.substring(0, 3) + "8" + inS.substring(4));
	}

}


Measured memory_bytes: 21844
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int[] array = new int[3];

        for(int i = 0;i < 3;i++){
            array[i] = sc.nextInt();
        }

        Arrays.sort(array);

//        for(int i = 0;i<3;i++){
//            System.out.print(array[i]+" ");
//            if(i == 3-1)
//                System.out.println("");
//        }

        System.out.println(array[2] * 10 + array[1] + array[0]);
    }
}

Measured memory_bytes: 22868
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
d = [iinput() for i in range(n)]

s = set(d)
ans = len(s)
print(ans)


Measured memory_bytes: 16480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		int n = Integer.parseInt(sc.next());
		PrintWriter out = new PrintWriter(System.out);
		int[][] a = new int[n][3];
		for (int i = 0; i < n; i++) {
			a[i][0] = Integer.parseInt(sc.next());
			a[i][1] = Integer.parseInt(sc.next());
			a[i][2] = Integer.parseInt(sc.next());
		}
		int htmp = a[0][2];
		int cx=0;
		int cy =0;
		int ch = 0;
		for (int i = -200; i <= 200; i++) {
			for (int j = 0; j <= 100; j++) {
				for (int k = 0; k <= 100; k++) {
					int eq = 1;
					int cxt = j;
					int cyt = k;
					int cht = htmp + i;
					if(cht<1)
					{
						eq =0;
					}
					for (int k2 = 0; k2 < n; k2++) {
						int x = a[k2][0];
						int y = a[k2][1];
						int h = a[k2][2];
						if(Math.max(cht-Math.abs(x-cxt)-Math.abs(y-cyt),0)!=h)
						{
							eq =0;
						}
					}
					if(eq == 1)
					{
						cx=cxt;
						cy =cyt;
						ch = cht;
					}
				}
			}
		}

		out.printf("%d %d %d", cx, cy, ch);
		out.flush();
	}

    
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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

color_list = [0 for i in range(8)]
magic = 0
for i in a:
    if i < 400:
        color_list[0] += 1
    elif i < 800:
        color_list[1] += 1
    elif i < 1200:
        color_list[2] += 1
    elif i < 1600:
        color_list[3] += 1
    elif i < 2000:
        color_list[4] += 1
    elif i < 2400:
        color_list[5] += 1
    elif i < 2800:
        color_list[6] += 1
    elif i < 3200:
        color_list[7] += 1
    else:
        magic += 1

if sum(color_list) == 0:
    color_list[0] = 1
    magic -= 1

minimum = len(list(filter(lambda x: x > 0, color_list)))

print(str(minimum) + " " + str(minimum+magic))

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

using namespace std;
typedef long long ll;
int main()
{
 ll n,x,y;
 cin>>n>>x>>y;

ll a[n+1][n+1]={0};
ll Z[n+1]={0};
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=n;j++)
    {
    a[i][j]=abs(i-j);
   ll z;
    z=abs(i-x)+abs(y-j)+1;
    a[i][j]=min(a[i][j],z);
   z=abs(i-y)+abs(x-j)+1;
    a[i][j]=min(a[i][j],z);

Z[a[i][j]]++;

    }


}
for(ll i=1;i<=n-1;i++)
{
    cout<<Z[i]/2<<"\n";
}




    return 0;
}


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


using namespace std;

     
int main()
{
  long long a, b, k;
  cin >> a; //高橋君のクッキー
  cin >> b; //青木君のクッキー
  cin >> k; //食べる枚数
  

  //高橋君のクッキー
  cout << std::max( (long long)0, a-k) << " ";

  //青木君のクッキー
  b = ( (a < k) ? a+b-k : b );
  cout << max((long long)0, b) ;
  
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  
 else{
   cout << "consonant" << endl;
 }
  
}

Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;

void main()
{
    int n = readln.chomp.to!int - 1;
    int[] a = readln.split.to!(int[]);
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] == a[i + 1])
        {
            ans++;
            i++;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
#define self nodes[p]
#define ls nodes[p << 1]
#define rs nodes[p << 1 | 1]
struct SegmentTree {
    struct Node {
        int ans, rans;
        double maxx;
    };
    Node nodes[MAXN << 2];
    int tot;
    void build(int l, int r, int p) {
        if (l == r) {
            self.ans = self.rans = 0;
            self.maxx = 0;
            return;
        }
        int mid = (l + r) / 2;
        build(l, mid, p << 1);
        build(mid + 1, r, p << 1 | 1);
        push_up(l, r, p);
    }
    void modify(int x, int l, int r, int p, double v) {
        if (l == r) {
            self.ans = 1;
            self.maxx = v;
            return;
        }
        int mid = (l + r) / 2;
        if (x <= mid)
            modify(x, l, mid, p << 1, v);
        else
            modify(x, mid + 1, r, p << 1 | 1, v);
        push_up(l, r, p);
    }
    int get(int l, int r, int p, double maxxl) {
        if (self.maxx <= maxxl) return 0;
        if (l == r) return self.ans;
        int mid = (l + r) / 2;
        if (ls.maxx <= maxxl) return get(mid + 1, r, p << 1 | 1, maxxl);
        return get(l, mid, p << 1, maxxl) + self.rans;
    }
    void push_up(int l, int r, int p) {
        self.maxx = max(ls.maxx, rs.maxx);
        self.ans = ls.ans;
        self.rans = 0;
        if (ls.maxx >= rs.maxx) return;
        int mid = (l + r) / 2;
        self.rans = get(mid + 1, r, p << 1 | 1, ls.maxx);
        self.ans += self.rans;
    }
};

SegmentTree tree;
char text[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%s", text);
    string s(text);
    cout << s.substr(0, 3) << endl;
    return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(A == B){
    cout << "Draw" << endl;
  }else if(A == 1){
    cout << "Alice" << endl;
  }else if(B == 1){
    cout << "Bob" << endl;
  }else if(A > B){
    cout << "Alice" << endl;
  }else{
    cout << "Bob" << endl;
  }
  return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    rep(i, N - 1)
    {
        if (H[i] < H[i + 1])
        {
            H[i + 1]--;
        }
        else if (H[i] > H[i + 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a,b,c,x,y;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  c*=2;
  if(a+b<=c)
    printf("%d\n",a*x+b*y);
  else{
    if(x<=y){
      if(b<=c)
        printf("%d\n",c*x+(y-x)*b);
      else
        printf("%d\n",c*y);
    }
    else{
      if(a<=c)
        printf("%d\n",c*y+(x-y)*a);
      else
        printf("%d\n",c*x);
    }
  }
  return 0;
}


Measured memory_bytes: 128
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e4 + 5;

int get(int x, int y, int z) {
  return x * x + y * y + z * z + (x * y) + (x * z) + (y * z);
}

void solve() {
  int n; cin >> n;
  vector <int> cnt(n + 1, 0);
  for(int j = 1; j * j <= n; j++) {
    for(int k = 1; k * k <= n; k++) {
      for(int q = 1; q * q <= n; q++) {
        if(get(j, k, q) <= n) cnt[get(j, k, q)]++;
      }
    }
  }
  for(int i = 1; i <= n; i++) print(cnt[i]);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
 int i,n,x,c,d;
 c=0;
 d=1;
 cin >> n >> x;
 int a[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  c+=a[i];
  if(c<=x)
  d++;
 }
 cout << d;
 return 0;
}

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

int p[1111111], s[1111111];
int main() {
    for(int i = 2; i < 1111; i++) {
        if(p[i])
            continue;
        for(int j = i * i; j < 1111111; j += i)
            if(!p[j])
                p[j] = i;
    }
    int n, g = 0, f = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        g = gcd(g, a);
        if(f)
            continue;
        while(a > 1) {
            int x = p[a];
            if(!x)
                swap(a, x);
            a /= x;
            if(s[x] && s[x] <= i) {
                f = 1;
                break;
            }
            s[x] = i + 1;
        }
    }
    cout << (g > 1 ? "not" : f ? "setwise" : "pairwise") << " coprime" << endl;
    return 0;
}


Measured memory_bytes: 11896
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	if(n < 3) cout << "No" << endl;
	else {
		if((n & - n) == n) cout << "No" << endl;
		else {
			cout << "Yes" << endl;
			cout << 1 << " " << 2 << endl;
			cout << 2 << " " << 3 << endl;
			cout << 3 << " " << 1 + n << endl;
			cout << 1 + n << " " << 2 + n << endl;
			cout << 2 + n << " " << 3 + n << endl;
			for(int i = 4; i <= n; i += 2){
				if(i + 1 > n){
					for(int j = 2; j < n; j++){
						int cmp = i ^ j ^ 1;
						if(cmp >= 2 && cmp < n){
							cout << j << " " << i << endl;
							cout << cmp + n << " " << i + n << endl;
							break;
						}
					}
				} else {
					cout << 1 << " " << i << endl;
					cout << i << " " << i + 1 << endl;
					cout << 1 << " " << i + 1 + n << endl;
					cout << i + 1 + n << " " << i + n << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;

    ll temp = m * 1900 + (n - m) * 100;

    ans = temp * pow(2, m);

    cout << ans << endl;
}

Measured memory_bytes: 256
# 插入排序
def insertion_sort(arr):
    for i in range(1, len(arr)):
        temp = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > temp:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = temp
        print(' '.join(map(str, arr)))

if __name__ == '__main__':
    N = int(input())
    arr = [int(n) for n in input().split()]
    print(' '.join(map(str, arr)))
    insertion_sort(arr)


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

int main(){
    ll N,K;cin>>N>>K;
    vector<ll> H(N,0);
    rep(i,N){
        cin>>H[i];
        H[i]=-H[i];
    }
    sort(H.begin(),H.end());
    ll cnt = 0;
    rep(i,N){
        if(K>0){
            K--;
            continue;
        }
        cnt+=abs(H[i]);
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, (c1, c2) -> {
			if ( c1[1] != c2[1] ) return c1[1] - c2[1];	// 1.prefでソート
			else return c1[2] - c2[2];	// 2.yearでソート

		}
		/*new Comparator<int[]>() {
		@Override
		public int compare(int[] o1, int[] o2) {
			if ( o1[1] != o2[1] ) {
				return o1[1] - o2[1];	// 1.prefでソート
			} else {
				return o1[2] - o2[2];	// 2.yearでソート
			}
		}
		}*/);

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = -1;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			if ( pref == city[i][1] ) {
				num++;
			} else {
				pref = city[i][1];
				num = 1;
			}
			result[city[i][0] - 1] = df.format(pref) + df.format(num);
		}

		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {
			sb.append(s).append("\n");
		}
		System.out.println(sb.toString());
		in.close();
	}
}


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

// typedef long long ll;
// const ll mod = 1e9 + 7;
// const ll inf = 184467440737095516;

// ll n, arr[4][4], bl[4][4];

// int main(){
// 	ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); 

// 	for (ll i = 1; i <= 3; i++){
// 		for (ll j = 1; j <= 3; j++){
// 			cin >> arr[i][j];
// 		}
// 	}
// 	cin >> n;
// 	for (ll t = 0; t < n; t++){
// 		ll x;
// 		cin >> x;
// 		for (ll i = 1; i <= 3; i++){
// 			for (ll j = 1; j <= 3; j++){
// 				if (x == arr[i][j]){
// 					bl[i][j] = 1;
// 					break;
// 				}
// 			}
// 		}
// 	}
// 	if (bl[1][1] == 1 && bl[2][2] == 1 && bl[3][3] == 1){
// 		cout << "Yes" << '\n';
// 		return 0;
// 	} 
// 	if (bl[1][3] == 1 && bl[2][2] == 1 && bl[3][1] == 1){
// 		cout << "Yes" << '\n';
// 		return 0;
// 	} 
// 	for (ll i = 0; i < 3; i++){
// 		if (bl[0][i] == 1 && bl[1][i] == 1 && bl[2][i] == 1){
// 			cout << "Yes" << '\n';
// 			return 0;
// 		}
// 		if (bl[i][0] == 1 && bl[i][1] == 1 && bl[i][1] == 1){
// 			cout << "Yes" << '\n';
// 			return 0;
// 		}
// 	// 	if (bl[0][0] == 1 && bl[1][1] == 1 && bl[2][2] == 1){
// 	// 		cout << "Yes" << '\n';
// 	// 		return 0;
// 	// 	}
// 	// 	if (bl[2][0] == 1 && bl[1][1] == 1 && bl[0][2] == 1){
// 	// 		cout << "Yes" << '\n';
// 	// 		return 0;
// 	// 	}
// 	// }
// 	cout << "No" << '\n';
// }
//   

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll n, arr[4][4], bl[4][4];

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

	for (ll i = 0; i < 3; i++){
		for (ll j = 0; j < 3; j++){
			cin >> arr[i][j];
		}
	}
	cin >> n;
	for (ll t = 0; t < n; t++){
		ll x;
		cin >> x;
		for (ll i = 0; i < 3; i++){
			for (ll j = 0; j < 3; j++){
				if (x == arr[i][j]){
					bl[i][j] = 1;
					break;
				}
			}
		}
	}
	for (ll i = 0; i < 3; i++){
		if (bl[0][i] == 1 && bl[1][i] == 1 && bl[2][i] == 1){
			cout << "Yes" << '\n';
			return 0;
		}
		if (bl[i][0] == 1 && bl[i][1] == 1 && bl[i][2] == 1){
			cout << "Yes" << '\n';
			return 0;
		}
		if (bl[0][0] == 1 && bl[1][1] == 1 && bl[2][2] == 1){
			cout << "Yes" << '\n';
			return 0;
		}
		if (bl[2][0] == 1 && bl[1][1] == 1 && bl[0][2] == 1){
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
}
  


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

int main()
{
    int min,N,X;
    cin >> N >>X;
    int m[N];
    min=1000000;
    for(int i=0;i<N;i++)
    {
        cin >> m[i];
        X= X-m[i];
        if(min>m[i])
        {
            min=m[i];
        }
    }
    cout << N+(X/min) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100;
int n,m;
LL g[N][N];
LL gg[N][N];
int a[N];
LL rand48(){
	LL a=rand()&65535,b=rand()&65535,c=rand()&65535;
	return (a<<32)^(b<<16)^c;
}
unordered_map <LL,int> mp;
int p[N];
bool check(int i){
	For(j,1,i-1)
		For(k,j+1,i-1)
			if (a[j]+a[k]==a[i])
				return 0;
	For(j,1,i-1)
		For(k,j+1,i-1)
			For(t,1,i-1)
				if (a[j]+a[k]==a[t]+a[i])
					return 0;
	return 1;
}
LL ans[N*N]={0,
0,1,2,8,56,672,13440,443520,22176000,1507968000,
1,0,4,16,112,1344,26880,887040,44352000,3015936000,
2,4,0,32,224,2688,53760,1774080,88704000,6031872000,
8,16,32,0,392,4704,94080,3104640,155232000,10555776000,
56,112,224,392,0,8064,161280,5322240,266112000,18095616000,
672,1344,2688,4704,8064,0,268800,8870400,443520000,30159360000,
13440,26880,53760,94080,161280,268800,0,12862080,643104000,43731072000,
443520,887040,1774080,3104640,5322240,8870400,12862080,0,842688000,7313164692,
22176000,44352000,88704000,155232000,266112000,443520000,643104000,842688000,0,28424716692,
1507968000,3015936000,6031872000,10555776000,18095616000,30159360000,43731072000,7313164692,28424716692,0
};
int main(){
	n=read();
	if (n==10){
		For(i,1,n){
			For(j,1,n){
				cout<<ans[(i-1)*n+j]<<" ";
			}
			cout<<endl;
		}
		return 0;
	}
	a[0]=0,a[1]=1;
	For(i,2,n-1){
		a[i]=a[i-1]+1;
		while (!check(i))
			a[i]++;
	}
//	outarr(a,1,n-1);
	LL tmp=1;
	For(i,2,n){
		For(j,1,i-1)
			gg[i][j]=gg[j][i]=tmp*a[j];
		tmp*=a[i-1]+a[i-2]+1;
	}
	while (1){
		int flag=1;
		LL mod=rand48()%100000000LL+49900000000LL;
		For(i,1,n)
			For(j,1,n)
				g[i][j]=gg[i][j]%mod;
		For(i,1,n)
			For(j,i+1,n)
				if (!g[i][j])
					flag=0;
		if (flag){
			mp.clear();
			For(i,1,n)
				p[i]=i;
			do {
				if (p[1]>p[n])
					continue;
				LL tot=0;
				For(i,1,n-1)
					tot+=g[p[i]][p[i+1]];
				if (tot>100000000000LL||mp[tot]){
					flag=0;
					break;
				}
				mp[tot]++;
			} while (next_permutation(p+1,p+n+1));
		}
		if (flag){
			For(i,1,n){
				For(j,1,n){
					cout<<g[i][j]<<" ";
				}
				cout<<endl;
			}
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 8008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String[] s = { "", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" };
		Scanner kb = new Scanner(System.in);
		String a = kb.next();
		for (int i = 0; i < s.length; i++) {
			if (a.equals(s[i])) {
				System.out.println(i);
			}
		}
		kb.close();
	}

}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m;
ll dp[303][303][303];
ll minq[303][5],maxq[303][5];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m;
  rep(i,303)rep(j,5){
    minq[i][j]=INF;
    maxq[i][j]=-INF;
  }
  rep(i,m){
    ll l,r,x;
    cin>>l>>r>>x;
    minch(minq[r][x],l);
    maxch(maxq[r][x],l);
  }
  dp[0][0][0]=1;
  ll res=0;
  rep(r,n+1)rep(g,n+1)rep(b,n+1){
    vector<ll> tmp{r,g,b};
    sort(all(tmp));
    ll s1=tmp[0],s2=tmp[1],s3=tmp[2]; // s3 > s2 > s1
    if(maxq[s3][3]<=s1&&s1<minq[s3][2]&&maxq[s3][2]<=s2&&s2<minq[s3][1]){
      if(s3==n)res=(res+dp[r][g][b])%mod;
      else{
        dp[s3+1][g][b]=(dp[s3+1][g][b]+dp[r][g][b])%mod;
        dp[r][s3+1][b]=(dp[r][s3+1][b]+dp[r][g][b])%mod;
        dp[r][g][s3+1]=(dp[r][g][s3+1]+dp[r][g][b])%mod;
      }
    }else{
      dp[r][g][b]=0;
    }
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 217344
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n := in()
	a := make(map[int]int)

	for n > 0 {
		a[in()]++
		n--
	}

	q := in()

	s := 0

	for k, v := range a {
		s += k * v
	}

	for q > 0 {
		b1, c1 := in(), in()
		s -= (b1*a[b1] + c1*a[c1])
		a[c1] += a[b1]
		s += c1 * a[c1]
		a[b1] = 0
		q--
		fmt.Println(s)
	}

}


Measured memory_bytes: 9820
#include <stdio.h>
int n,H[200000000];
void maxheap(int);

int main(){

  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }
  for(i=n/2;i>=1;i--){
    maxheap(i);
  }
  for(i=1;i<n;i++){

    printf(" %d",H[i]);
  }
    printf(" %d\n",H[i]);

    return 0;
}

  
void maxheap(int i){

  int left,right,largest,temp;
  left=i*2;
  right=i*2+1;
  if(left<=n && H[left]>H[i]){
    largest=left;
  }
  else{
    largest=i;
  }
  if(right<=n && H[right]>H[largest]){
    largest=right;
  }
  if(largest!=i){
    temp=H[i];
    H[i]=H[largest];
    H[largest]=temp;
    maxheap(largest);
  }
}
  



Measured memory_bytes: 3640
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

D.sort()

print(abs(D[N // 2 - 1] - D[N // 2]))


Measured memory_bytes: 24356
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N, K; 
vector<int> A;

int cnt(int mid){
  int ret = 0;
  FOR(i, 1, N-1){
    if(A[i]*A[i] <= mid) ret--;

    if(A[i] == 0){
      if(0 <= mid) ret += N-2;
    }else if(A[i] > 0){
      int OK = 0;
      int NG = N-1;
      while(NG-OK > 1){
        int MID = (OK+NG)/2;
        if(A[i]*A[MID] <= mid) OK = MID;
        else NG = MID;
      }
      ret += OK;
    }
    else if(A[i] < 0){
      int OK = N-1;
      int NG = 0;
      while(OK-NG > 1){
        int MID = (OK+NG)/2;
        if(A[i]*A[MID] <= mid) OK = MID;
        else NG = MID;
      }
      ret += N-OK-1;
    }
  }

  return ret/2;
}

signed main() {
  cin >> N >> K;

  A.resize(N+2);
  REP(i, N) cin >> A[i];
  A[N] = 1e9; A[N+1] = -1e9;

  sort(ALL(A));
  N += 2;

  int ok = INF;
  int ng = -INF;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;
    if(cnt(mid) >= K) ok = mid;
    else ng = mid;
  }
  cout << ok << "\n";

  return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--) //ループ変数は1ずつデクリ
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--) //ループ変数は1ずつデクリ
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

ll pcnt(ll x) { return __builtin_popcountll(x); }

ll f(ll x) {
    if (x == 0) {
        return 0;
    }
    return f(x % pcnt(x)) + 1;
}

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> x(n);
    REP(i, n) { x[i] = s[i] - '0'; }
    ll pc = 0;
    vector<ll> ans(n);
    REP(i, n) { pc += x[i]; }
    REP(b, 2) {
        ll npc = pc;
        if (b == 0) {
            npc++;
        } else {
            npc--;
        }
        if (npc == 0)
            continue;
        ll r0 = 0;
        REP(i, n) {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        ll k = 1;
        REPD(i, n) {
            if (x[i] == b) {
                ll r = r0;
                if (b == 0) {
                    r = (r + k) % npc;
                } else {
                    r = (r - k + npc) % npc;
                }
                ans[i] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }
    }
    REP(i, n) { cout << ans[i] << endl; }
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


ll gcd(ll a, ll b){

  if(b==0){
    return a;
  }
  return gcd(b , a%b);
}

ll gcdd(ll a, ll b , ll c){

  return gcd(gcd(a,b),c);
}


int main() {

 int n;
 cin>>n;
 ll sum = 0;

  for(int i =1 ;i<=n;i++){
    for(int j= 1;j<=n;j++){
      for(int k =1 ;k<=n;k++){
        sum += gcdd(i,j,k);
      }
    }
  }


  cout<<sum<<"\n";

  
  return 0;
}


Measured memory_bytes: 3628
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, t) = in.readLine().split("\\s+").map(_.toInt)

    out.println(t / a * b)

    out.flush()
  }
}


Measured memory_bytes: 25416
#include<bits/stdc++.h>
#define sutu (ll)1e18+10
#define ll long long
using namespace std;
#define  pi  3.141592653
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t,n,temp;
  cin>>n;
  t=n;
  vector<ll> ans(n,0);
  t--;
  while(t--){
    cin>>temp;
    ans[temp-1]++;
  }
  for(ll i=0;i<n;i++)
  cout<<ans[i]<<endl;
}


Measured memory_bytes: 4692
n = int(input())
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a+b,a,b])
    
ab.sort(reverse=True)
suma = 0
sumb = 0
for i in range(n):
    if i % 2 == 0:
        suma += ab[i][1]
    else:
        sumb += ab[i][2]
print(suma-sumb)


Measured memory_bytes: 23260