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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < n; ++i) {

        if (v[i] % 2 == 0) {
            if (v[i] % 3 != 0 and v[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return;
            }
        }
    }
    cout << "APPROVED";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    while (t--)
        solve();
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);

	ll x; cin >> x;
  if (x % 2 == 1)
    cout << 0;
  else
  {
    ll ans = 0;
    x /= 2;
    while (x)
    {
	ans += x / 5;
      x /= 5;
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(x,y);
  Vi group(12);
  group = {0,2,0,1,0,1,0,0,1,0,1,0};
  Yes(group.at(x-1) == group.at(y-1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};


const int mod = 1000003;
using modint = ModInt< mod >;

int main(){
    modint f[2010101];
    f[0] = 1;
    rep(i, 2010000){
        f[i+1] = f[i]*(i+1);
    }

    int q;
    cin >> q;
    rep(i, q){
        int x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            cout << modint(x).pow(n) << endl;
            continue;
        }
        modint s = x;
        s /= d;
        modint l = x;
        l /= d;
        l += n-1;
        if(s.x + n - 1 >= mod || s.x == 0){
            cout << 0 << endl;
            continue;
        }
        modint ans = f[l.x] / f[s.x-1];
        ans *= modint(d).pow(n);
        cout << ans << endl;
    }
}

Measured memory_bytes: 8704
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int h, n, ai, s;
    s = 0;
    cin >> h >> n;
    for (int i=0; i<n; i++){
        cin >> ai;
        s += ai;
    }
    // if (s < h) {
    //     cout << "No";
    // } else {
    //     cout << "Yes";
    // }

    puts(s<h?"No":"Yes");
}

Measured memory_bytes: 3596
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`



		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	n := nextInt()
	d := nextInts(n)

	sort.Ints(d)

	ans := d[n/2] - d[n/2-1]

	//fmt.Fprintln(out, "[DEBUG]", d)
	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, L = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
list = []

for i in range(N):
    s = input()
    list.append(s)

list = sorted(list)

ans = "".join(list)


print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	string S;
	cin >> S;
	int N = sz(S);
	int res = 15 - N;
	debug(res);
	rep(i, 0, N) {
		res += (S[i] == 'o');
	}
	if(res >= 8) cout << "YES\n";
	else cout << "NO\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

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

using namespace std;

int main(void)
{
	ll n;
	cin >> n;
	ll mini;
	bool bf = true;
	vector<ll> a(n);
	rep(i, n){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	while(bf){
		bf = false;
		for(int i=1; i<n; i++){
			if (a[i] % a[0] != 0){
				ll temp = a[i] % a[0];
				bf = true;
				a.erase(a.begin()+i);
				a.insert(a.begin(), temp);
			}
		}
	}
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
SP = defaultdict(list)

for i in range(N):
    S, P = input().split()
    SP[S].append([int(P),i+1])

SP = sorted(SP.items(), key=lambda x:x[0])

for key,item in SP:
    item_sort = sorted(item, reverse=True)
    for _,i in item_sort:
        print(i)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)


int main(){
	
	int N;
	cin>>N;
	vector<int> d(N);
	
	for(int i=0;i<N;i++){
		cin>>d[i];
	}
	
	sort(d.begin(),d.end());
	int a = d[N/2]-d[N/2-1];
	cout<<a<<endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 640
from math import factorial
n=int(input())
s=[]
k=1
ans=0
for i in range(n):
  s.append(sorted(input()))
s=sorted(s)
for j in range(n-1):
  if s[j]==s[j+1]:
    k+=1
  elif s[j]!=s[j+1] and k>2:
    ans+=factorial(k)/(factorial(2)*factorial(k-2))
    k=1
  elif s[j]!=s[j+1] and k==2:
    ans+=1
    k=1
  else:
    k=1
if k>2:
  ans+=factorial(k)/(factorial(2)*factorial(k-2))
elif k==2:
  ans+=1
print(int(ans))

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, cnt = 0, inp;
    cin >> n;
    ll *a = new ll [n + 1];
    for (int i = 0; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++){
        cin >> inp;
        if(a[i] > inp)
            cnt += inp;
        else{
            inp -= a[i];
            cnt += a[i];
            if(a[i + 1] > inp){
                a[i + 1] -= inp;
                cnt += inp;
            }
            else{
                cnt += a[i + 1];
                a[i + 1] = 0;

            }
        }
    }
    cout << cnt << endl;

    return 0;
}


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

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

    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0; i < M; i++) {
        int a = que.top();
        que.pop();
        que.push(a / 2);
    }
    int64_t sum = 0;
    while (!que.empty()) {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 892
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, i) = listOfInt()
    println(n-i+1)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ch = (char) Console.Read();
            Console.WriteLine('A' <= ch && ch <= 'Z' ? "A" : "a");
        }
    }
}

Measured memory_bytes: 25772
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

class BIT{
private:
    vector<int> bit;
    int size_;
public:
    BIT() {
        size_ = 0;
        bit = vector<int>(0);
    }
    BIT(int size__) {
        size_ = size__;
        bit.resize(size_ + 1);
    }
    ll sum(int i) {
        ll ret = 0;
        while(i > 0) {
            ret += bit[i];
            i -= i & (-i);
        }
        return ret;
    }
 
    void add(int i, int x) {
        while(i <= size_) {
            bit[i] += x;
            i += i & (-i);
            //cout << i << " " << size_ << endl;
        }
    }
};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    BIT B[26];
    rep(i, 26) {
        B[i] = BIT(N);
    }
    rep(i, N) {
        B[S[i] - 'a'].add(i + 1, 1);
    }
    while(Q--) {
        int q, a, b;
        cin >> q;
        if (q == 1) {
            int i; char c;
            cin >> i >> c;
            B[c - 'a'].add(i, 1);
            B[S[i - 1] - 'a'].add(i, -1);
            S[i - 1] = c;
        }
        int cnt = 0;
        if (q == 2) {
            int l, r;
            cin >> l >> r;
            //l--; r--;
            rep(i, 26) {
                if (B[i].sum(r) - B[i].sum(l - 1) > 0) cnt++;
            }
            cout << cnt << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 53788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
  int h, a;
  cin >> h >> a;
  int sum=0;
  while(h>0){
    sum+=1;
    h-=a;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

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

    ll n, m;
    cin>>n>>m;
    int diff = INT_MAX, index = 0;
    int l[m], r[m];
    int start = 1, finish=n;
    bool flag = true;
    for (int i=0;i<m;i++)
    {
        cin>>l[i]>>r[i];
        if ((l[i]>=start && l[i]<=finish)||(r[i]>=start && r[i]<=finish)||(l[i]<=start&&r[i]>=finish))
        {
            int b = 0, e = 0;
            if (l[i]<start)
                b=start;
            else
                b = l[i];
            if (r[i]<finish)
                e = r[i];
            else
                e = finish;
            start=b; finish=e;
        }
        else
            flag=false;
    }
    if (flag)
        cout<<finish-start+1;
    else
        cout<<0;
}


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

int main(){
    int N,K;
    string s;
    scanf("%d%d",&N,&K);
    cin>>s;
    int l=0,r=0;
    queue<int>que;
    int ans=0;
    while(r<N) {
        if(s[r]=='0') {
            while(s[r]=='0') r++;
            r=r-1;
            que.push(r);
        }
        if(que.size()>K) {
            l = que.front(); que.pop();
            l = l+1;
            ans = max(ans,r-l+1);
        }
        ans = max(ans,r-l+1);
//        cout<<ans<<endl;
        r++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
def main():
    l = list(map(int,input().split()))
    l = sorted(l,reverse=True)
    ans = ''

    for i in range(0,len(l)-1):
        ans = ans + str(l[i])
    ans_int = int(ans) + int(l[-1])

    print(ans_int)




if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  if(S[S.length()-1]=='s'){
    cout << S <<"es" << endl;
    return 0;
  }else{
    cout << S <<"s" << endl;
    return 0;
  }
}


Measured memory_bytes: 3036
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i <= 25; i++ {
		for j := 0; j <= 14; j++ {
			sum := i*4 + j*7
			if sum == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


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

int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 4; i++) {
		if (s.at(i) == '+') {
			count++;
		}
		else {
			count--;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var p2 = Enumerable.Range(0, n + 1).Select(i => (int)Math.Pow(2, i)).ToArray();
		var ks = new int[h[1]].Select(_ => new { a = read()[0], c = read().Select(x => p2[x - 1]).Aggregate((x, y) => x | y) }).ToArray();

		var dp = Enumerable.Repeat(int.MaxValue, p2[n]).ToArray();
		dp[0] = 0;
		for (int i = 0, j; i < p2[n]; i++)
		{
			if (dp[i] == int.MaxValue) continue;
			foreach (var k in ks) if ((j = i | k.c) != i) dp[j] = Math.Min(dp[j], dp[i] + k.a);
		}
		var m = dp[p2[n] - 1];
		Console.WriteLine(m == int.MaxValue ? -1 : m);
	}
}


Measured memory_bytes: 13524
import sys
input = lambda: sys.stdin.readline().rstrip()
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(tuple(sorted(s)))
d=Counter(a)
ans=0
for i in d:
    ans+=d[i]*(d[i]-1)//2
print(ans)
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        bool color[8] = {false};
        int n;
        int a;
        int cnt = 0;
        cin >> n;
        REP(i,n){
                cin >> a;
                if(a < 400) color[0] = true;
                else if(a < 800) color[1] = true;
                else if(a < 1200) color[2] = true;
                else if(a < 1600) color[3] = true;
                else if(a < 2000) color[4] = true;
                else if(a < 2400) color[5] = true;
                else if(a < 2800) color[6] = true;
                else if(a < 3200) color[7] = true;
                else cnt++;
        }
        int num = 0;
        REP(i,8) if(color[i]) num++;
        if(num == 0) cout << 1 << ' ' << cnt << endl;
        else cout << num << ' ' << num + cnt << endl;
        return 0;
}

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

int main() {

int K, A, B;
int judge=0;
cin >> K >> A >> B;
for (int i = 0; i < B-A+1; i++) {
 
    if ((A+i)%K==0) {
      judge=1;
      break; // i == 3 の時点でループから抜ける
    }
 
  }


if(judge==1)
 cout << "OK" << endl;
else{
  cout << "NG" << endl;
}
}

Measured memory_bytes: 3624
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])

if a==b+c or a+b==c or a+c==b:
    
    print("Yes")
    
else:
    
    print("No")
    


Measured memory_bytes: 3064
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long



int main(){
    int a[4],b[4];
    int count[4];
    rep(i,4)count[i]=0;
    rep(i,3){
        scanf("%d %d",&a[i],&b[i]);
        a[i]--;b[i]--;
        count[a[i]]++;
        count[b[i]]++;
    }
    int kisuu=0;
    rep(i,4){
        if(count[i]%2==1)kisuu++;
    }
    //全て偶数ほん
    if(kisuu==0||kisuu==2){
        printf("YES\n");
        return 0;
    }
    
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
A=list(map(int,input().split()))
dp=[False] * (k+1)
for i in range(k):
    for j in range(n):
        if dp[i]==False and i+A[j]<=k:
            dp[i+A[j]]=True
print('First' if dp[k] else 'Second')

Measured memory_bytes: 3956
def cmb(n, r, mod, g1, g2):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def main():
    N = int(input())
    if N == 1:
        return 0
    if N == 2:
        return 2
    
    mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ans = (10 ** N - 2) % (10**9+7)
    comb = 1
    tmp = 2
    total = 0
    for k in range(1, N):
        tmp = (tmp * 8) % (10**9+7)
        total += ((tmp * cmb(N, N - k, mod, g1, g2) % (10**9+7)))
    total += ((tmp * 8 // 2) % (10**9+7))
    return ((ans - total) % (10**9+7))

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 167564
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d;
        if (a > b) {
            d = a;
            a = b;
            b = d;
        } 
        if (b > c) {
            d = b;
            b = c;
            c = d;
        }
        if (a > b) {
            d = a;
            a = b;
            b = d;
        }
        {
            System.out.println( a+ " " + b + " " + c);
        }

    }
}

Measured memory_bytes: 26004
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int n;
        cin>>n;if(!n)return 0;
        bool map[21][21]={{false}};
        for(int i=0;i<n;++i){
            int x,y;
            cin>>x>>y;
            map[x][y]=true;
        }
        cin>>n;
        int xp=10,yp=10;
        for(int i=0;i<n;++i){
            char d;
            int v;
            cin>>d>>v;
            if(d=='N'){
                for(int j=0;j<v;++j){
                    yp++;
                    if(map[xp][yp])map[xp][yp]=false;
                }
            }
            if(d=='W'){
                for(int j=0;j<v;++j){
                    xp--;
                    if(map[xp][yp])map[xp][yp]=false;
                }
            }
            if(d=='E'){
                for(int j=0;j<v;++j){
                    xp++;
                    if(map[xp][yp])map[xp][yp]=false;
                }
            }
            if(d=='S'){
                for(int j=0;j<v;++j){
                    yp--;
                    if(map[xp][yp])map[xp][yp]=false;
                }
            }
        }
        bool flag=false;
        for(int i=0;i<21;++i){
            for(int j=0;j<21;++j){
                if(map[i][j])flag=true;
            }
        }
        if(flag)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

ll n, k;

int main() {
    cin >> n >> k;
    vector<ll> A(n, 0);
    for(int i = 0; i < n; ++i) cin >> A.at(i);
    vector<ll> F(n, 0);
    for(int i = 0; i < n; ++i) cin >> F.at(i);
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    ll ng = -1, ok = 1e12;
    while(abs(ok-ng) > 1) {
        ll mid = (ok+ng) / 2;
        ll sum = 0;
        for(int i = 0; i < n; ++i) {
            sum += max(0ll, A.at(i) - mid/F.at(i));
        }
        if(sum <= k) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 3328
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
asize = a.size
i = 0
hash = Hash.new(0)
while 
    hash[a[i]] += 1
    i += 1
    if i == asize
        break
    end
end
if hash.size == asize
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 39364
#include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
long long n, s[200000], ans,a[200000],t=0;
int main() {
	cin >> n;
	for (long long i = 0; i < n; i++)
	{
		cin >> s[i];
		t += s[i];
		a[i] = t;
	}
	ans = abs(a[n - 1] - 2 * a[0]);
	for (long long  i = 0; i < n-1; i++)
	{
		ans=min(abs(a[n - 1] - 2 * a[i]), ans);
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
long long BIG_NUM = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> T(N+2, 0);
    vector<int> A(N+2, 0);
    
    for (int i=1; i<=N; ++i) {
        cin >> T[i];
    }
    
    for (int i=1; i<=N; ++i) {
        cin >> A[i];
    }
    
    if (N == 1) {
        if (T[1] == A[1])
            cout << 1 << endl;
        else
            cout << 0 << endl;
        return 0;
    }
    

    vector<bool> due1(N+2, false);
    vector<bool> due2(N+2, false);
    vector<int> Hmax1(N+2, 1);
    vector<int> Hmax2(N+2, 1);
    
    for (int i=2; i<=N; ++i) {
        Hmax1[i] = T[i];
        if (T[i-1] < T[i]) {
            due1[i] = true;
        }
    }
    
    bool wrong = false;
    for (int i=1; i<N; ++i) {
        if (due1[i] && Hmax1[i] > A[i]) {
            wrong = true;
            break;
        }
        if (A[i] > A[i+1]) {
            if (due1[i] && Hmax1[i] != A[i]) {
                wrong = true;
                break;
            }
            due2[i] = true;
        }
        Hmax2[i] = A[i];
    }
    
    if (wrong) {
        // cout << "first wrong" << endl;
        cout << 0 << endl;
        return 0;
    }
    
    for (int i=1; i<=N; ++i) {
        if (due2[i] && Hmax2[i] > T[i]) {
            wrong = true;
            break;
        }
    }
    
    if (wrong) {
        // cout << "second wrong" << endl;
        cout << 0 << endl;
        return 0;
    }
    
    ll res = 1;
    for (int i=1; i<=N; ++i) {
        if (!(due1[i] || due2[i])) {
            res = (res * min(Hmax1[i], Hmax2[i]) % BIG_NUM);
        }
    }
    
    cout << res << endl;
    
    return 0;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
int AA[201010];
int check(int d) {
    int msk = 1 << d;
    rep(i, 0, N) AA[i] = A[i] % (msk * 2);

    vector<int> BB[2];

    rep(i, 0, N) {
        int b = B[i] % (msk * 2);

        if (b & msk) BB[1].push_back(b - msk);
        else BB[0].push_back(b);
    }

    rep(i, 0, 2) sort(all(BB[i]));

    ll cnt = 0;
    rep(i, 0, N) {
        if (AA[i] & msk) {
            int a = AA[i] - msk;

            // 繰り上がりダメ
            int c = lower_bound(all(BB[0]), msk - a) - BB[0].begin();
            cnt += c;

            // 繰り上がりする
            c = lower_bound(all(BB[1]), msk - a) - BB[1].begin();
            cnt += BB[1].size() - c;
        } else {
            int a = AA[i];

            int c = lower_bound(all(BB[0]), msk - a) - BB[0].begin();
            cnt += BB[0].size() - c;

            c = lower_bound(all(BB[1]), msk - a) - BB[1].begin();
            cnt += c;
        }
    }

    if (cnt % 2 == 1) return 1;
    else return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];

    int ans = 0;
    rep(d, 0, 29) if (check(d)) ans += 1 << d;
    cout << ans << endl;
}

Measured memory_bytes: 4412
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memo = [[None]*2000 for i in range(2000)]


def exhaustivesearch(i, target):
    if memo[i][target] is not None:
        return memo[i][target]
    if target == 0:
        memo[i][target] = True
        return True
    if i >= n:
        memo[i][target] = False
        return False
    else:
        memo[i][target] = exhaustivesearch(i + 1, target) or exhaustivesearch(i + 1, target-A[i])
        return memo[i][target]


for j in m:
    if exhaustivesearch(0, j):
        print("yes")
    else:
        print("no")

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
#define y1 y_1
#define x1 y_2
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 20;
const int M = 1e6;
const int mod = 1e9 + 7;
const int inf = 2e9 + 3;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

int n, was[N];
vi p[N];

int main() {
	data();
	for (int i = 2; i <= M; ++i)
	 	if (p[i].empty())
	 		for (int j = i; j <= M; j += i)
	 			p[j].pb(i);
	cin >> n;
	int now = 0;
	for (int i = 1, x; i <= n; ++i) {
		cin >> x;
		now = __gcd(now, x);
		for (auto it : p[x])
			was[it]++;
	}
	bool f = 1;
	for (int i = 2; i <= M; ++i)
		if (was[i] > 1)
			f = 0;
	if (f)
		cout << "pairwise coprime\n";
	else if (now == 1)
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";		
}

Measured memory_bytes: 62868
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "No";
		for(int i = 1; i <= 9; i++){
		    if(n%i == 0 && 1 <= n/i && n/i <= 9){
		        result = "Yes";
		    }
		}
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    vector<ll> z(d);
    for (int i = 0; i < d; i++) {
        cin >> z[i];
    }
    vector<vector<ll>> x(d, vector<ll>(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> x[i][j];
        }
    }
    vector<ll> ans(d,1);
    for (int i = 0; i < 14; i++) {
        vector<bool> flag(26, false);
        for (int j = 0; j < 26; j++) {
            ll mx = 0;
            ll atai = 0;
            for (int k = 0; k < 26; k++) {
                if (flag[k] == false) {
                    mx = max(x[i * 26 + j][k], mx);
                    if (mx == x[i * 26 + j][k])atai = k;
                }
            }
            flag[atai] = true;
            ans[i * 26 + j] = atai + 1;
        }
    }
    ll mix = 0;
    ll ataii = 0;
    for (int k = 0; k < 26; k++) {
        mix = max(x[364][k], mix);
        if (mix == x[364][k])ataii = k;
    }
    ans[364] = ataii+1;
    for (int i = 0; i < d; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))

int N;
int W[110];

int main()
{
	int sum = 0;
	cin >> N;
	REP(i, N) {
		cin >> W[i];
		sum += W[i];
	}

	int ans = sum;

	REP(i, N) {
		sum -= W[i] * 2;
		ans = min(ans, abs(sum));
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next())-1;
        int b = Integer.parseInt(sc.next())-1;
        
        Dijkstra dij = new Dijkstra(n);
        
        for(int i=0; i<n-1; i++){
            int u = Integer.parseInt(sc.next())-1;
            int v = Integer.parseInt(sc.next())-1;
            dij.addEdge(u,v,1);
        }
        
        long[] adist = dij.dijkstra(a);
        long[] bdist = dij.dijkstra(b);
        
        long firstDist = adist[b];
        
        long max = 0;
        for(int i=0; i<n; i++){
            if(adist[i] < bdist[i]){
                max = Math.max(max, bdist[i]);
            }
            //System.out.println("a " + adist[i] + " ; b " + bdist[i]);
        }
        
        System.out.println(Math.max(max-1, firstDist/2));
        //System.out.println(firstDist/2);
        //System.out.println(max-1);
    }
}

class Dijkstra{
    
    public final long INF = (long)1e18;
    private int n;
    private List<Edge>[] edge;
    
    public Dijkstra(int n){
        this.n = n;
        edge = new List[n];
        for(int i=0; i<n; i++){
            edge[i] = new ArrayList<>();
        }
    }
    
    public void addEdge(int from, int to, int cost){
        edge[from].add(new Edge(from, to, cost));
        edge[to].add(new Edge(to, from, cost));
    }
    
    public long[] dijkstra(int from){
        long[] dist = new long[n];
        Arrays.fill(dist, INF);
        dist[from] = 0;
        
        PriorityQueue<Vertex> q = new PriorityQueue<>();
        q.add(new Vertex(from, 0));
        while(q.size() != 0){
            int u = q.poll().ver;
            
            for(Edge ne : edge[u]){
                int v = ne.to;
                long weight = ne.cost;
                if(dist[v] > dist[u]+weight){
                    dist[v] = dist[u]+weight;
                    q.add(new Vertex(v, dist[v]));
                }
            }
        }
        
        return dist;
    }
}

class Edge implements Comparable<Edge>{
    public int from = 0;
    public int to = 0;
    public int cost = 0;
    
    public Edge(int from, int to, int cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }
    
    @Override
    public int compareTo(Edge o) {
        return this.cost - o.cost;
    }
}

class Vertex implements Comparable<Vertex>{
    public int ver = 0;
    public long cost = 0;
    
    public Vertex(int ver, long cost) {
        this.ver = ver;
        this.cost = cost;
    }
    
    @Override
    public int compareTo(Vertex o) {
        long tmp = this.cost - o.cost;
        if(tmp == 0) return 0;
        return (int)(tmp/Math.abs(tmp));
    }
}

Measured memory_bytes: 77652
import math
st=input().split()
H=int(st[0]);W=int(st[1])
c=[[0 for i in range(10)] for i in range(10)]
A=[[0 for i in range(W)]for i in range(H)]
for i in range(10):
    st=input().split()
    for j in range(10):
        c[i][j]=int(st[j])
for i in range(H):
    st=input().split()
    for j in range(W):
        A[i][j]=int(st[j])
def Dijkstra(s):
    d=[10000]*10
    d[s]=0
    Q=set(range(10))
    V=set(range(10))
    while(len(Q)>0):
        u=list(Q)[0]
        for i in Q:
            if d[i]<d[u]:
                u=i
        Q-={u}
        for v in V-{u}:
            if (d[v]>d[u]+c[u][v]):
                d[v]=d[u]+c[u][v]
    return d[1]
result=0
DD=[0]*10
for i in range(10):
    DD[i]=Dijkstra(i)
for i in range(H):
    for j in range(W):
        if A[i][j]!=-1:
            result+=DD[A[i][j]]
print(result)


Measured memory_bytes: 3444
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())

for loop in range(n):
    b,f,r,v = map(int,input().split())
    count[b-1][f-1][r-1] += v

for l in range(4):
    for a in range(3):
        print(" "+" ".join(map(str,count[l][a])))

    if l != 3:
        print("#"*20)


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    For(i, 1, 10010) {
        int eight = (int)(i * 1.08) - i;
        int ten = (int)(i * 1.1) - i;
        if (eight == a and ten == b) {
            print(i);
            return 0;
        }
    }
    print(-1);

    return 0;
}


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

int p[100010];
vector<int> ans;

int main(){
  int N, L; scanf("%d%d", &N, &L);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  int st = -1;
  for(int i = 1; i <= N - 1; i++){
    if(p[i] + p[i + 1] >= L){ st = i; break; }
  }

  if(st == -1) puts("Impossible");
  else{
    puts("Possible");

    // last : (st, st + 1)
    for(int i = 1; i < st; i++) printf("%d\n", i);
    for(int i = N - 1; i > st; i--) printf("%d\n", i);
    printf("%d\n", st);
  }

  return 0;
}

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

int main() {
  
  int length, num; cin >> length >> num;
  string S; cin >> S;
  num--;
  
  for (int i=0; i<S.size(); i++) {
  	if (i==num) {
      S[i] = tolower(S[i]);
    }else{
      S[i] = S[i];
    }
  }
  cout << S << endl;
}
  

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

res = ''
if tx - sx < 0:
    res += abs(tx - sx) * 'L'
else:
    res += abs(tx - sx) * 'R'

if ty - sy < 0:
    res += abs(ty - sy) * 'D'
else:
    res += abs(ty - sy) * 'U'
    
N = len(res)
tmp1 = res
tmp2 = ''
for i in range(N):
    if res[i] == 'U':
        tmp2 += 'D'
    if res[i] == 'D':
        tmp2 += 'U'
    if res[i] == 'R':
        tmp2 += 'L'
    if res[i] == 'L':
        tmp2 += 'R'
  
res = tmp1 + tmp2
tmp3 = ''
for i in range(N-1):
    if tmp1[i] != tmp1[i+1]:
        tmp3 = tmp1[:i] +tmp1[i] + tmp1[i:]
    
tmp3 = tmp2[-1] + tmp3 + tmp3[-1] + tmp2[0]     
res = res + tmp3 

N = len(tmp3)
tmp4 = ''
for i in range(N):
    if tmp3[i] == 'U':
        tmp4 += 'D'
    if tmp3[i] == 'D':
        tmp4 += 'U'
    if tmp3[i] == 'R':
        tmp4 += 'L'
    if tmp3[i] == 'L':
        tmp4 += 'R'    
        
res = res + tmp4

print(res)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1e9 + 7;

int ma=0;

int main(){
	int n;
    cin>>n;
    int a[111];
    P x[111][111]={};
    vector<P> v[111];
    bool ans[111]={};
    int an[111][2]={};
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            int c,b;
            cin>>b>>c;
            v[i].push_back(P(b-1,c));
        }
    }
    rep(i,1<<n){
        bool f=0;
        int f2[111]={};
        int k=0;
        rep(j,n)if(i&(1<<j)){
            k++;
            f2[j]=1;
        }
        rep(j,n){
            bool as=i&(1<<j);
            if(!as)continue;
            for(auto au:v[j]){
                if(f2[au.F]!=au.S){
                    f=1;
                    break;
                }
            }
        }
        if(f)continue;
        
        MAX(ma,k);
    }
    cout<<ma<<endl;

}

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

int main(){
  int H, W;
  while(true){
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    for(int i = 0; i < W; i++){
      cout << "#";
    }
    cout << endl;
    for(int i = 1; i < H - 1; i++){
      for(int j = 0; j < W; j++){
        if(j == 0 || j == W - 1){
          cout << '#';
        }
        else{
          cout << ".";
        }
      }
      cout << endl;
    }
    for(int i = 0; i < W; i++){
      cout << "#";
    }
    cout << endl;
    cout << endl;
  }
}


Measured memory_bytes: 3100