akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
using namespace std;

#define MAX_V 10000

typedef int int32_t;

// ?????????topological sort???????????????

int main(void) {
    int v, e;
    vector<int> g[MAX_V];
    int n_in[MAX_V] = {};

    scanf("%d %d", &v, &e);
    for (int i = 0; i < e; i++) {
        int t, u;
        scanf("%d %d", &t, &u);
        g[t].push_back(u);
        n_in[u]++;
    }

    // topological sort
    vector<int> s;
    for (int i = 0; i < v; i++) {
        if (n_in[i] == 0) {
            s.push_back(i);
        }
    }

    vector<int> done;
    while (!s.empty()) {
        int t = s.back();
        s.pop_back();
        done.push_back(t);
        while (!g[t].empty()) {
            int u = g[t].back();
            g[t].pop_back();
            if (--n_in[u] == 0) {
                s.push_back(u);
            }
        }
    }

    for (int i = 0; i < v; i++) {
        printf("%d\n", done[i]);
    }
    return 0;
}

Measured memory_bytes: 1832
package main

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

func stoi(a []string) []int {
	r := []int{}
	for _, v := range a {
		val, _ := strconv.Atoi(v)
		r = append(r, val)
	}

	return r
}

type card struct {
	mark string
	val  int
}

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var A []card
	for {
		sc.Scan()
		instr := sc.Text()
		if instr == "" {
			break
		}
		in2 := strings.Split(instr, " ")
		mark := in2[0]
		val, _ := strconv.Atoi(in2[1])
		A = append(A, card{mark, val})

	}

	qA := append([]card{}, A...)
	mA := append([]card{}, A...)

	quickSort(qA, 0, n-1)

	if reflect.DeepEqual(mergeSort(mA), qA) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	for _, m := range qA {
		fmt.Printf("%v %v", m.mark, m.val)
		fmt.Println()
	}

}

func quickSort(A []card, p int, r int) { // infinite loop for #5 http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3964211#3
	if p < r {
		q := partition(A, p, r)
		quickSort(A, p, q-1)
		quickSort(A, q+1, r)
	}

	return
}

func partition(A []card, p int, r int) int {
	x := A[r].val
	i := p
	for j := p; j < r; j++ {
		if A[j].val <= x {
			A[i], A[j] = A[j], A[i]
			i++
		}
	}
	A[i], A[r] = A[r], A[i]
	return i
}

func mergeSort(val []card) []card {
	length := len(val)
	if length == 1 {
		return val
	}

	var mid int
	if len(val)%2 == 0 {
		mid = length / 2
	} else {
		mid = length/2 + 1
	}
	left := val[:mid]
	right := val[mid:len(val)]

	lr := mergeSort(left)
	rr := mergeSort(right)

	return merge(lr, rr)
}

var count int

func merge(a1 []card, a2 []card) []card {
	var result []card
	a1Idx := 0
	a2Idx := 0
	for {
		a1done := len(a1) <= a1Idx
		a2done := len(a2) <= a2Idx
		if a1done && a2done {
			return result
		} else if a1done {
			result = append(result, a2[a2Idx])
			a2Idx++
			continue
		} else if a2done {
			result = append(result, a1[a1Idx])
			a1Idx++
			continue
		}
		count++
		if a1[a1Idx].val <= a2[a2Idx].val {
			result = append(result, a1[a1Idx])
			a1Idx++
		} else {
			result = append(result, a2[a2Idx])
			a2Idx++
		}
	}
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	 int a,p;cin>>a>>p;
	 
	 writeln((a*3+p)/2);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        String s;
        s=scan.next();
        String[] arr = {"Sunny","Cloudy","Rainy"};
        if(s.equals("Sunny")) System.out.println(arr[1]);
        if(s.equals("Cloudy")) System.out.println(arr[2]);
        if(s.equals("Rainy")) System.out.println(arr[0]);
    }
}

Measured memory_bytes: 21844
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N = xs[0];
   let num = Math.floor(N/15)*200;
   console.log(N*800-num);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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


int main() {
    int N;
    cin >> N;
    string Ans = "No";
    if(N%10 == 7)Ans = "Yes";
    N /= 10;
        if(N%10 == 7)Ans = "Yes";
    N /= 10;
        if(N%10 == 7)Ans = "Yes";

        cout << Ans << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
    int i,count=0;
    char W[10],S[1000];

    scanf("%s",W);

    while(1){
        scanf("%s",S);
        if(!strcmp(S,"END_OF_TEXT")) break;
        
        for(i=0;S[i]!='\0';i++){
            S[i]=tolower(S[i]);
        }

        if(!strcmp(S,W)) count++;
    }
    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 2044
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int[][] array = new int[3][3];
    
    for(int i=0 ; i<3 ; i++){
      for(int h=0 ; h<3 ; h++){
        array[i][h] = sc.nextInt();
      }
    }
    
    int n = sc.nextInt();
    int[] arrayans = new int[n];
    
    for(int i=0 ; i<n ; i++){
      arrayans[i] = sc.nextInt();
    }
    
    for(int i=0 ; i<3 ; i++){
      for(int h=0 ; h<3 ; h++){
        for(int g=0 ; g<n ; g++){
    if(arrayans[g]==array[i][h]){
      array[i][h] = 0;
    }
        }
      }
    }
    
    if((array[0][0]==0)&&(array[1][0]==0)&&(array[2][0]==0)){
      System.out.println("Yes");
      return;
    }else if((array[0][1]==0)&&(array[1][1]==0)&&(array[2][1]==0)){
      System.out.println("Yes");
      return;
    }else if((array[0][2]==0)&&(array[1][2]==0)&&(array[2][2]==0)){
      System.out.println("Yes");
      return;
  	}else if((array[0][0]==0)&&(array[0][1]==0)&&(array[0][2]==0)){
      System.out.println("Yes");
      return;
	}else if((array[1][0]==0)&&(array[1][1]==0)&&(array[1][2]==0)){
      System.out.println("Yes");
      return;
	}else if((array[1][0]==0)&&(array[1][1]==0)&&(array[1][2]==0)){
      System.out.println("Yes");
      return;
	}else if((array[2][0]==0)&&(array[2][1]==0)&&(array[2][2]==0)){
      System.out.println("Yes");
      return;
	}else if((array[0][0]==0)&&(array[1][1]==0)&&(array[2][2]==0)){
      System.out.println("Yes");
      return;
	}else if((array[0][2]==0)&&(array[1][1]==0)&&(array[2][0]==0)){
      System.out.println("Yes");
      return;
	}else{
      System.out.println("No");
      }
    }
}

Measured memory_bytes: 22608
//ÃˆÃ“Ã£ Ã‡Ã¡Ã¡Ã¥ Ã¦Ã¡Ã‡ ÃÃ¦Ã¡ Ã¦Ã¡Ã‡ ÃžÃ¦Ã‰ Ã…Ã¡Ã‡ ÃˆÃ‡Ã¡Ã¡Ã¥
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define pb push_back
#define ins insert
#define be begin
#define en end
#define fast ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int INF=1e9;
//ll a,b;
ll a[202020],b[202020];
vector<int>adj[200005];
pair<ll,ll>p;
map<string,int>mp;
//map<string,int>::iterator it;
set<ll>st;
set<ll>::iterator it;
string s,t;
ll q,n,m,k,z,x,y,d,sum,ans;
bool vis[2020202];
int mx=1,cnt;
void dfs(int node){
	vis[node]=1;
	for(int i=0;i<(int)adj[node].size();i++){		
		if(!vis[adj[node][i]])
			++cnt,dfs(adj[node][i]);
	}
}
int main(){
	fast;
	int n,p;
	cin>>p>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			cnt=1;
			dfs(i);
			mx=max(mx,cnt);
		}
	cout<<mx;
}

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

typedef long long ll;
typedef vector<ll> v1;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

ll n,m;
graph g;
queue<v1> q;
ll s,t;
typedef vector<v1> v2;
v2 visit;

int main(){
  cin >> n >> m;
  for(ll i = 0;i < m;i++){
    ll u,v;
    cin >> u >> v;
    g[u][v] = 1;
  }
  cin >> s >> t;
  visit = v2(3,v1(n+1));
  q.push(v1({s, 0, 0}));
  visit[0][s] = 1;
  while(!q.empty()){
    ll x = q.front()[0];
    ll c = q.front()[1];
    ll d = q.front()[2];
    q.pop();
    if(x == t && c == 0){
      cout << d/3 << endl;
      return 0;
    }
    for(auto y : g[x]){
      if(visit[(c+1)%3][y.first]) continue;
      visit[(c+1)%3][y.first] = 1;
      q.push(v1({y.first, (c+1)%3, d+1}));
    }
  }
  cout << -1 << endl;
  return 0;


}


Measured memory_bytes: 18468
#include<cstdio>
inline int in();
inline void wr(int);
char s[4];
int main(int argc,char**argv){
	scanf("%s",s+1);
	s[2]='B'+'R'-s[2];
	printf("%s\n",s+1);
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 1664
import heapq
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    ABdct = {}
    for _ in range(N):
        A, B = [int(x) for x in stdin.readline().rstrip().split()]
        if A in ABdct:
            ABdct[A].append(B)
        else:
            ABdct[A] = [B]
    ans = 0
    candidate = []
    for i in range(1, M + 1):
        if i in ABdct:
            for b in ABdct[i]:
                heapq.heappush(candidate, -b)
        if not candidate:
            continue
        b = heapq.heappop(candidate)
        b = -b
        ans += b
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25996
#include<stdio.h>
#include<stdlib.h>

void maxheapify(int*,int,int);
void buildMaxHeap(int*,int);

int main(){
  int i,H,*z;

  scanf("%d",&H);
  z = malloc(H*sizeof(int)+1);
  for(i=1;i <= H;i++){
    scanf("%d",&z[i]);
  }
  buildMaxHeap(z,H);
  for(i=1;i <= H;i++){
    printf(" %d",z[i]);
  }
  printf("\n");
  return 0;
}

void maxheapify(int *z,int i,int H){
  int j,largest;
  if(2*i <= H && z[2*i] > z[i]) largest = 2*i;
  else largest = i;
  if(2*i+1 <= H && z[2*i+1] > z[largest]) largest = 2*i+1;

  if(largest != i){
    j = z[i];
    z[i] = z[largest];
    z[largest] = j;
    maxheapify(z,largest,H);
  }
}

void buildMaxHeap(int *z,int H){
  int i;
  for(i = H/2;i >=1;i--){
    maxheapify(z,i,H);
  }
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

  
  int sum2=0;
  for(int i=1; i<n+1; i++){
    int sum1=0;
    for(int j=1; j<i+1; j++){
    if(i%2==1 && i%j==0){
      sum1++;
    }
    }
      if(sum1==8){
        sum2++;
      }
  }

      cout << sum2 << endl;
}


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

s = str(input())

flag = 1
if s[0] != "A":
    flag = 0


num_C = 0
for i in s[2:-1]:
    if i == "C":
        num_C += 1

for i in s[1:]:
    if i != "C" and i.isupper():
        flag = 0

if num_C != 1:
    flag = 0


if flag == 0:
    print("WA")
else:
    print("AC")


Measured memory_bytes: 9120
class FordFulkerson:
    """Ford-Fulkerson Algorithm: find max-flow
       complexity: O(FE) (F: max flow)
    """
    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append([to, cap, len(self.E[to])])
                self.E[to].append([fr, 0, len(self.E[fr])-1])
        self.maxflow = self.ford_fulkerson(source, sink)

    def ford_fulkerson(self, source, sink, INF=10**9):
        """find max-flow"""
        def dfs(vertex, sink, flow):
            """find augmenting path"""
            if vertex == sink:
                return flow
            used[vertex] = True
            for i, (to, cap, rev) in enumerate(self.E[vertex]):
                if not used[to] and cap > 0:
                    d = dfs(to, sink, min(flow, cap))
                    if d > 0:
                        self.E[vertex][i][1] -= d
                        self.E[to][rev][1] += d
                        return d
            return 0

        maxflow = 0
        while True:
            used = [False] * self.V
            flow = dfs(source, sink, INF)
            if flow == 0:
                return maxflow
            else:
                maxflow += flow

V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    u, v, cap = map(int, input().split())
    edge[u].append((v, cap))
print(FordFulkerson(V, edge, 0, V-1).maxflow)

Measured memory_bytes: 6996
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<double> P;

#define EQ(x,y) (abs((x)-(y))<EPS)

double cross(P a, P b) {
	return (a.real()*b.imag() - a.imag()*b.real());
}

int is_parallel(P a1, P a2, P b1, P b2) {
	return EQ(cross(a1-a2, b1-b2), 0.0);
}

P intersection_ls(P a1, P a2, P b1, P b2) {
	P b = b2-b1;
	double d1 = abs(cross(b, a1-b1));
	double d2 = abs(cross(b, a2-b2));
	double t = d1 / (d1+d2);

	return a1 + (a2-a1) * t;
}

int main() {
	int N, X, Y;
	cin >> N;
	vector<P> points(N);
	REP(i, N) {
		cin >> X >> Y;
		points[i] = P(X, Y);
	}

	REP(i, N) {
		if(!is_parallel(points[i], points[(i+1)%N], points[(i+N/2)%N], points[(i+N/2+1)%N])) {
			cout << "NA" << endl;
			return 0;
		}
		if(!EQ(abs(points[i]-points[(i+1)%N]), abs(points[(i+N/2)%N]-points[(i+N/2+1)%N]))) {
			cout << "NA" << endl;
			return 0;
		}
	}

	P ans = intersection_ls(points[0], points[N/2], points[1], points[N/2+1]);
	printf("%.6f %.6f\n", ans.real(), ans.imag());

	return 0;
}

Measured memory_bytes: 1244
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bit(i) (1<<(i))
#define set(mask,i) (mask |= (1<<(i)))
#define get(mask,i) (mask & (1<<(i)))
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
const int64_t INF64 = (int64_t)1e18;
const int INF32 = (int)1e9 + (int)1e8;
const int64_t md = (int64_t)((int64_t)1e9 + 7);
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
 	int r, c;
 	cin >> r >> c;
 	string arr[r];
 	for(int i = 0; i < r; i++) {
 		cin >> arr[i];
 	}
 	// dp[i][j] is number of path to cell [r][c] starting from cell [i][j];
 	int64_t dp[r+1][c+1];
 	for(int i = 0; i <= r; i++) {
 		for(int j = 0; j <= c; j++) {
 			dp[i][j] = 0;
 		}
 	}
 	dp[r-1][c-1] = 1;
 	for(int i = r-1; i >= 0; i--) {
 		for(int j = c-1; j >= 0; j--) {
 			if(i == r-1 && j == c-1) continue;
 			if(arr[i][j] == '#') {dp[i][j] = 0; continue;}
 			dp[i][j] += (dp[i][j+1]%md);
 			dp[i][j] += (dp[i+1][j]%md);
 		}
 	}
 	cout << dp[0][0]%md;
 
	return 0;
}

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n],mx=0,ans=0;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	ans+=max(0ll,mx-a[i]);
    	mx=max(mx,a[i]);
    }
    cout << ans;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int n,m,k;
  cin >> n >> m >> k;
  REP(i,n+1) REP(j,m+1) if(k==i*j+(n-i)*(m-j)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def z_algo(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i, j = 1, 0
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        A[i] = j
        if not j:
            i += 1
            continue
        k = 1
        while i+k < N and k+A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

n = int(input())
s = input()
ans = 0
for i in range(n):
  A = z_algo(s[i:])
  for j in range(1, n-i):
    m = min(j, A[j])
    ans = max(m, ans)
print(ans)

Measured memory_bytes: 51140
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a+4),t(b+4);
  for(int i=2;i<=a+1;i++)
  {
    cin>>s[i];
  }
  for(int i=2;i<=b+1;i++)
  {
    cin>>t[i];
  }
  s[0]=SE;t[0]=SE;
  s[1]=SE;t[1]=SE;

  s[a+2]=EE;t[b+2]=EE;
  s[a+3]=EE*2;t[b+3]=EE*2;

  long x;
  for(int i=0;i<q;i++)
  {
    cin>>x;
    long res=EE;
    auto si=lower_bound(s.begin(), s.end(), x);
    auto tr1=lower_bound(t.begin(), t.end(), *si);
    res=min(res,abs(*si-x)+abs(*tr1-*si));
    res=min(res,abs(*si-x)+abs(*(tr1-1)-*si));

    auto tr=lower_bound(t.begin(), t.end(), *(si-1));
    res=min(res,abs(x-*(si-1))+abs(*tr-*(si-1)));
    res=min(res,abs(x-*(si-1))+abs(*(tr-1)-*(si-1)));


    auto ti=lower_bound(t.begin(),t.end(),x);
    auto sr2=lower_bound(s.begin(),s.end(),*ti);
    res=min(res,abs(*ti-x)+abs(*sr2-*ti));
    res=min(res,abs(*ti-x)+abs(*(sr2-1)-*ti));

    auto sr=lower_bound(s.begin(),s.end(),*(ti-1));
    res=min(res,abs(x-*(ti-1))+abs(*sr-*(ti-1)));
    res=min(res,abs(x-*(ti-1))+abs(*(sr-1)-*(ti-1)));

    cout<<res<<"\n";

  }

  return 0;

}


Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    ans = 0
    i = 0
    A = [0] * (len(S) + 1)
    B = [0] * (len(S) + 1)
    i = len(S) - 1
    while i >= 0:
        if S[i] == ">":
            A[i] = 0
            while i >= 0 and S[i] == ">":
                A[i] = A[i+1] + 1
                i -= 1
        i -= 1
    i = 0
    while i < len(S):
        if S[i] == "<":
            B[i] = 0
            while i < len(S) and S[i] == "<":
                i += 1
                B[i] = B[i-1] + 1
        i += 1
    ans = 0
    for i in range(len(S) + 1):
        ans += max(A[i], B[i])
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 52716
n,l=map(int,input().split())
t=[]
for i in range(n):
    t.append(l+i)
#print(t)
T=sum(t)
S=[]
for i in range(n):
    k=t[:i]+t[i+1:]
#    print(k)
    S.append([abs(T-sum(k)),sum(k)])
S.sort(key=lambda x:x[0])
#print(S)
print(S[0][1])

    


Measured memory_bytes: 3060
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b) <= d && abs(b-c)  <= d)) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
from collections import deque


def main():
    ss = list(input())
    ans = deque([])
    for s in ss:
        if s == '0':
            ans.append(s)
        elif s == '1':
            ans.append(s)
        else:
            if len(ans) == 0:
                pass
            else:
                ans.pop()
    print(*list(ans), sep='')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9228
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        var ans = MathExt.Lcm(2, N);

        WriteLine(ans);
    }
}

static partial class MathExt
{
    public static int GcdAll(this IEnumerable<int> a) => (int)GcdAll(a.Select(x => (long)x));
    public static long GcdAll(this IEnumerable<long> a) => a.Aggregate((s, e) => Gcd(s, e));
    public static int Gcd(int a, int b) => (int)Gcd((long)a, b);
    public static long Gcd(long a, long b) => (b != 0) ? Gcd(b, a % b) : a;
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 27432
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }

        boolean flag = true;
        int count = 0;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 != 0) {
                    flag = false;
                }
            }
            if (flag) {
                count++;
                for (int i = 0; i < n; i++) {
                    a[i] = a[i] / 2;
                }
            } else {
                break;
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k; cin >> n >> k;
    vector<int> h(n);
    ll sum = 0;
    rep(i,n) {
        cin >> h[i];
        sum += h[i];
    }
    sort(h.begin(), h.end());
    rep(i,min(k,n)) {
        sum -= h[n-i-1];
    }
    if (sum < 0) sum = 0;
    cout << sum << endl;
    return 0;
}

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

int main() {
  string S;
  cin >>S;
 if ((S.at(0)==S.at(1)) || (S.at(1) == S.at(2)) || (S.at(2) ==S.at(3))){
cout <<"Bad" << endl;
 }
  else{
   cout << "Good" <<endl; 
  }
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll a, b, x;
    cin >> a >> b >> x;

    if(a == 0){
        cout << b/x + 1 << endl;
    }
    else{
        cout << b/x - (a-1)/x << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> like_cnt(m);
    for(auto& lc:like_cnt) lc = 0;

    rep(i,n)
    {
        int k; cin >> k;
        rep(j,k)
        {
            int a; cin >> a;
            like_cnt[a-1]++;
        }
    }

    int all_like_cnt = 0;
    rep(i,m)
        if(like_cnt[i] == n) ++all_like_cnt;
    
    cout << all_like_cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    string s1;
    set<string>s;
    for(int i=0;i<n;i++)
    {
        cin>>s1;
        s.insert(s1);
    }
    cout<<s.size()<<endl;
}



Measured memory_bytes: 19204
#selection sort


def printout(array,n):
    output = ""
    for i in range(n-1):
        output += str(array[i]) + " "
    output += str(array[N-1])
    print(output)


def linearsearch(subarray):
    # return index of minimum array element
    min = subarray[0]
    min_index = 0;
    for i in range(1,len(subarray)):
        if min > subarray[i]:
            min = subarray[i]
            min_index = i
    return min_index


N = int(input())
array = [int(i) for i in input().split()]

count,index,tmp = 0,0,0

for i in range(N):
    index = linearsearch(array[i:]) + i

    if index != i:
        #swap
        tmp = array[index]
        array[index] = array[i]
        array[i] = tmp
        count += 1

printout(array,N)
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> e[110000];
  int ans[110000];
  rep(i, m){
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  while(!q.empty()){
    int c = q.front();
    q.pop();
    for(int d : e[c]){
      if(d == c) continue;
      if(ans[d] != 0) continue;
      ans[d] = c;
      q.push(d);
    }
  }
  cout << "Yes" <<endl;
  for(int i = 2; i <= n; i++){
    cout << ans[i] <<endl;
  }
}
  

Measured memory_bytes: 10648
s=list(map(int,list(input())))
if s[0]+s[1]+s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]+s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")

Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
	int N,ans=0;
	scanf("%d",&N);
	int l[N],r[N];
	for(int i=0; i<N; i++){
		scanf("%d%d",&l[i],&r[i]);
		ans += r[i]-l[i]+1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int a,b,c,d,n,f;
	for(;;){
		if(scanf("%d",&n)==EOF){break;}
		f=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(n==a+b+c+d){f++;}
					}
				}
			}
		}
		printf("%d\n",f);
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String s = br.readLine();

        br.close();

        bw.write((s.equals("ABC")) ? "ARC" : "ABC");

        bw.flush();

    }
}

Measured memory_bytes: 32460
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    vector<int> l;
    cin >> n;
    n *= 2;

    REP(i, n){
        int x;
        cin >> x;
        l.pb(x);
    }

    VSORT(l);
    int sum = 0;
    REP(i, n){
        if(i % 2 == 0) sum += l[i];
    }

    cout << sum << endl;

    
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

class Bit {
    int n;
    vector<long long> b;

public:
    Bit(int n)
        : n(n), b(n + 1) {}

    // sum[1,i]
    long long sum(int i) {
        long long s = 0;
        while (i > 0) {
            s += b[i];
            i -= i & -i;
        }
        return s;
    }

    // sum[i,j]
    long long sum(int i, int j) {
        if (j < i) return 0;
        return sum(j) - sum(i - 1);
    }

    // i <- [1..n]
    void add(int i, int x) {
        while (i <= n) {
            b[i] += x;
            i += i & -i;
        }
    }
};

const int MAX_N = 500000;

int n, q;
int col[MAX_N + 1];
int l[MAX_N], r[MAX_N];
int qr[MAX_N];

int main() {
    fastio();

    cin >> n >> q;
    forn1(i, n) {
        cin >> col[i];
    }

    forn(i, q) {
        cin >> l[i] >> r[i];
        qr[i] = i;
    }

    sort(qr, qr + q, [&](int i, int j) {
        return r[i] < r[j];
    });

    Bit bit(n);

    vi ans(q);

    vi prev(n + 1);
    int ci = 1;

    forn(idx, q) {
        int i = qr[idx];
        while (ci <= n and ci <= r[i]) {
            int c = col[ci];

            if (prev[c]) {
                bit.add(prev[c], -1);
            }

            prev[c] = ci;

            bit.add(ci, 1);

            ci++;
        }

        ans[i] = bit.sum(l[i], r[i]);
    }

    for (auto x : ans) {
        cout << x << "\n";
    }

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a1(n), a2(n), a3(n);
  rep(i, n) cin >> a1[i];
  rep(i, n) cin >> a2[i];
  rep(i, n) cin >> a3[i];

  vector<ll> lmax(n + 1, 0);
  priority_queue<int, vector<int>, greater<int>> pq1;
  rep(i, n) {
    lmax[0] += a1[i];
    pq1.push(a1[i]);
  }
  rep(i, n) {
    lmax[i + 1] = lmax[i];
    pq1.push(a2[i]);
    lmax[i + 1] += a2[i];
    int m = pq1.top();
    pq1.pop();
    lmax[i + 1] -= m;
  }

  vector<ll> rmin(n + 1, 0);
  priority_queue<int> pq3;
  rep(i, n) {
    rmin[0] += a3[i];
    pq3.push(a3[i]);
  }
  rep(i, n) {
    rmin[i + 1] = rmin[i];
    pq3.push(a2[n - 1 - i]);
    rmin[i + 1] += a2[n - 1 - i];
    int m = pq3.top();
    pq3.pop();
    rmin[i + 1] -= m;
  }

  ll ans = lmax[0] - rmin[0];
  rep(i, n + 1) ans = max(ans, lmax[i] - rmin[n - i]);

  cout << ans << endl;
}


Measured memory_bytes: 4088
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

ll modpow(ll x, ll n) {
    ll ret = 1;
    while(n > 0) {
        if((n & 1) == 1) {
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

ll combine(ll n, ll k) {
    ll ret;
    ll p = 1;
    ll q = 1;
    for(ll i = 0; i < k; i++) {
        p *= n - i;
        p %= MOD;
        q *= k - i;
        q %= MOD;
    }
    ret = p * modpow(q, MOD - 2);
    ret %= MOD;
    return ret;
}

int main() {
    double r;
    cin >> r;
    cout << 2 * r * 3.14 << endl;
}


Measured memory_bytes: 3772
use std::io::stdin;

fn main() {
    let n: i32 = get_line().parse().expect("cant parse it");
    println!("{}", n/3);
}

fn get_line() -> String{
    let mut inp = String::new();
    stdin().read_line(&mut inp).expect("input err");
    inp.trim().to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
    int main(){
    int N,M;cin>>N>>M;
    vector<int> v(N);
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>v[i];
        sum+=v[i];
    }
 
    double j=1.0*sum/(4*M);
    int ans=0;
    for(int i=0;i<N;i++){
        if(v[i]>=j)ans++;
 
    }
    if(ans>=M)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int N;
Vi A, B;
int dp[(1 << 18) + 1][20];

int bit_dp(int bit, int v) {
    // メモ済みならメモの値を返す
    if (dp[bit][v] != -1) {
        return dp[bit][v];
    }

    // 初期値
    if (bit == (1 << v)) {
        return dp[bit][v] = 0;
    }

    int res = I_INF;

    int prev_bit = bit & ~(1 << v);
    int v_pos = __builtin_popcount(bit) - 1;  // v番目のカードがおかれる位置
    int v_val;
    // v番目のカードの表の値を求める
    if (abs(v_pos - v) & 1) {
        v_val = B[v];
    }
    else {
        v_val = A[v];
    }

    for (int u = 0; u < N; u++) {
        // prev_bit に u が無かったら飛ばす
        if (!(prev_bit & (1 << u))) continue;

        // u番目とカードの表の値を求める
        int u_pos = v_pos - 1;
        int u_val;
        if (abs(u_pos - u) & 1) {
            u_val = B[u];
        }
        else {
            u_val = A[u];
        }
        if (u_val > v_val) continue;  // 広義単調増加出なければ飛ばす

        // v番目のカードを追加することによる転倒数の増分を求める
        int dtento = 0;
        for (int k = 0; k < N; k++) {
            if (!(prev_bit & (1 << k))) continue;
            if (k > v) ++dtento;
        }

        int val = bit_dp(prev_bit, u);
        if (val != I_INF)
            res = min(res, val + dtento);
    }

    return dp[bit][v] = res;
}

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

    cin >> N;
    A.resize(N), B.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < (1 << N); i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = -1;
        }
    }

    int ans = I_INF;
    for (int i = 0; i < N; i++) {
        ans = min(ans, bit_dp((1 << N) - 1, i));
    }

    if (ans == I_INF) {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20736
package main

import "fmt"

type Pair struct {
	First  int64
	Second int
}

func prime_factor(n int64) []Pair {
	ret := make([]Pair, 0, 0)
	var num int

	for i := int64(2); i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		num = 0
		for n%i == 0 {
			num++
			n /= i
		}
		ret = append(ret, Pair{First: i, Second: num})
	}
	if n != 1 {
		ret = append(ret, Pair{First: n, Second: 1})
	}
	return ret
}

func gcd(x, y int64) int64 {
	if y == 0 {
		return x
	} else {
		return gcd(y, x%y)
	}
}

func main() {
	var a, b int64
	fmt.Scan(&a, &b)

	g := gcd(a, b)
	fmt.Println(len(prime_factor(g)) + 1)
}

Measured memory_bytes: 512
n=int(input())
b=list(map(int, input().split()))
result=[]
flag_2=1


for i in range(n):
    flag_1=1
    for j in range(n-i-1, -1, -1):
        if b[j]==j+1:
            result.append(b.pop(j))
            flag_1=0
            break

    if flag_1:
        print(-1)
        flag_2=0
        break

if flag_2:
    for i in range(n-1, -1, -1):
        print(result[i])


Measured memory_bytes: 38768
#include<stdio.h>

int main(void)
{
	int t[4][3][10] = { 0 };
	int b, f, r, v, i, j, k, n;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d%d%d%d", &b, &f, &r, &v);
		t[b - 1][f - 1][r - 1] = t[b - 1][f - 1][r - 1] + v;



	}
	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){
				printf(" %d", t[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3){
			printf("####################\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2048
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int a[MAXN];
int main()
{
	int n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,greater<int>());
	for (int i=0;i<=n;i++)
		if (i+1>a[i+1])
		{
			int r=i;
			while (a[r+1]==i) r++;
			puts((((a[i]-i)&1)||((r-i)&1))?"First":"Second");
			break;
		}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int a, b, c, d;
    io >> a >> b >> c >> d;
    ll p = (ll)a * c;
    ll q = (ll)a * d;
    ll r = (ll)b * c;
    ll s = (ll)b * d;
    ll ans = max({p, q, r, s});
    io << ans << BR;
}

Measured memory_bytes: 3796
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdio>
using namespace std;
#define N 1000000
#define INF 0x3f3f3f3f
#define MOD 998244353 
#define LL long long
int rd()
{
	LL x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f*x;
}
int n,m;
LL fac[N+5],inv[N+5];
LL ksm(LL a,LL b)
{
	LL res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
void Init()
{
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[N]=ksm(fac[N],MOD-2);
	for(int i=N-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%MOD;
}
LL c(int a,int b)
{
	return fac[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int main()
{
	Init();
	n=rd(),m=rd();
	if(n<m) swap(n,m);
	LL ans=0;
	for(int i=1;i<=m;i++)
		ans=(ans+c(n-i+m-i,m-i)*c(2*i,i)%MOD*ksm(2ll/*1/2的贡献*/*c(n+m,m)%MOD,MOD-2)%MOD)%MOD;
	ans=(ans+n)%MOD;
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 18852
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
class Main{
  public static void main(String args[]){
    BigDecimal a = new BigDecimal(readLong());
    BigDecimal b = new BigDecimal(readL());
    a = a.multiply(b);
    long l = a.longValue();
    pl(l+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return Long.parseLong(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 100005;

ll a[maxn], b[maxn], c[maxn];
ll dp[maxn][3];

int main(){
	ll n;
	scanf ("%lld", &n);
	for (ll i = 1; i <= n; i++){
		scanf ("%lld %lld %lld", &a[i], &b[i], &c[i]);
	}
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];

	for (ll i = 2; i <= maxn; i++){
		dp[i][0] = a[i] + max (dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max (dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max (dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max (max (dp[n][0], dp[n][1]), dp[n][2]) << '\n';
	return 0;
}

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

using namespace std;

bool ok(vector<int> &K, int now) {
    if (now != 0) return false;
    int cnt = 0;
    for(int i = 0; i < K.size(); i++) {
        if (K[i] != 0) cnt++;
    }
    return cnt == 1;
}

void solve(int N, int P) {
    vector<int> K(N);
    int now = P;
    int now_i = 0;
    while(!ok(K, now)) {
        if (now == 0) {
            now = K[now_i];
            K[now_i] = 0;
        } else {
            K[now_i]++;
            now--;
        }
        now_i = (now_i + 1) % N;
    }
    cout << (now_i + N - 1) % N << endl;
}

int main() {
    int N, P;
    while(cin >> N >> P, N) {
        solve(N, P);
    }
    return 0;
}


Measured memory_bytes: 3056