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

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
		a.at(i)--;
	}
}
void DFS(vector<vector<int> > & Ad,
		 vector<int> & D,
		 vector<int> & F,
		 int & time,
		 int idx)
{
	if (F[idx] < 0) {
		for(int i=0;i<(int)Ad[idx].size();++i) {
			int next = Ad[idx][i];
			if (D[next] < 0) {
				D[next] = time++;
				DFS(Ad,D,F,time,next);
			}
		}
		F[idx]= time++;
	}
}
int main(){
	int n;
	cin >> n;
	vector<vector<int> > Ad(n);
	vector<int> D(n,-1),F(n,-1);
	for(int k=0;k<n;++k) {
		int u;
		cin >> u;
		--u;
		InputSet(Ad[u]);
	}
	int time=1;
	for(int i=0;i<n;++i) {
		if (D[i] < 0) {
			D[i] = time++;
			DFS(Ad,D,F,time,i);
		}
	}

	for(int i=0;i<n;++i){
		cout << i + 1 << " " << D[i] << " " << F[i] << endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
	int n;
	double x1, x2, x3;
	double y1, y2, y3;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double px, py, r;
		double A = (x2 - x1)*(y3 - y2) - (y2 - y1)*(x3 - x2);
		px = 0.5*((y3 - y2)*(x2*x2 - x1*x1 + y2*y2 - y1*y1) - (y2 - y1)*(x3*x3 - x2*x2 + y3*y3 - y2*y2)) / A;
		py = 0.5*(-(x3 - x2)*(x2*x2 - x1*x1 + y2*y2 - y1*y1) + (x2 - x1)*(x3*x3 - x2*x2 + y3*y3 - y2*y2)) / A;
		double a = px - x1;
		double b = py - y1;
		double r0 = (a*a + b*b);
		double r1 = sqrt(r0);
		cout << fixed << setprecision(3) << px << " " << py << " " << r1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
program an_odd_problem
  implicit none
  integer :: n, a(100) = 0, i, x = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    x = x + mod(i * a(i), 2)
  end do
  write(*,'(i0)') x
end program an_odd_problem

Measured memory_bytes: 2860
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1,0);
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	long long cnt=0;
	for(int i=1;i<=n;i++){
		if(a[a[i]]==i)cnt++;
	}
	cout << cnt/2 << endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
 
using namespace std;
 
#define y1 hogwhoasjfd
 
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
 
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;
 
template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
 
constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;
 
int w, h;
int n;
int x1[1005], x2[1005];
int y1[1005], y2[1005];
 
bool fld[1005*6+2][1005*6+2];
 
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
 
int compress(int *x1, int *x2, int w)
{
    vi xs;
 
    rep(i, n) {
        for (int d = -1; d <= 1; ++d) {
            int tx1 = x1[i] + d, tx2 = x2[i] + d;
 
            if (0 <= tx1 && tx1 <= w) xs.PB(tx1);
            if (0 <= tx2 && tx2 <= w) xs.PB(tx2);
        }
    }
 
    sort(all(xs));
    xs.erase(unique(all(xs)), end(xs));
 
    rep(i, n) {
        x1[i] = lower_bound(all(xs), x1[i]) - begin(xs);
        x2[i] = lower_bound(all(xs), x2[i]) - begin(xs);
    }
 
    return xs.size();
}
 
int main()
{
    while (cin >> w >> h, w) {
        cin >> n;
 
        memset(fld, 0, sizeof fld);
 
        rep(i, n) {
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        }
 
        w = compress(x1, x2, w);
        h = compress(y1, y2, h);
 
        rep(i, n) {
            for (int y = y1[i]; y <= y2[i]-1; ++y) {
                for (int x = x1[i]; x <= x2[i]-1; ++x) {
                    fld[y][x] = true;
                }
            }
        }
 
        int ans = 0;
 
        rep(y, h-1) rep(x, w-1) {
            if (fld[y][x]) continue;
 
            ans++;
 
            queue<pii> q;
            q.push(pii(y, x));
 
            while (q.size()) {
                pii p = q.front(); q.pop();
                rep(i, 4) {
                    int ny = p.fst + dy[i], nx = p.scd + dx[i];
 
                    if (ny < 0 || ny >= h-1 || nx < 0 || nx >= w-1 || fld[ny][nx]) continue;
 
                    fld[ny][nx] = true;
                    q.push(pii(ny, nx));
                }
            }
        }
 
        cout << ans << endl;
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B; cin >> A >> B;
    cout << A * B << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,m;
char w[1<<18],a[1<<18],b[1<<18];
bool ok(bool jk,int poz)
{
    for(int i=1;i<=m;++i)
    {
        if(a[i]==w[poz])
        {
            if(b[i]=='L')
                poz--;
            else poz++;
        }
        if(jk)
        {
            if(poz==n+1) return 1;
        }
        else
            if(poz==0) return 1;
    }
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m>>(w+1);
    for(int i=1;i<=m;++i) cin>>a[i]>>b[i];
    int st=0;
    for(int step=1<<17;step;step>>=1)
        if(st+step<=n&&ok(0,st+step))
            st+=step;
    int dr=n+1;
    for(int step=1<<17;step;step>>=1)
        if(dr-step>0&&ok(1,dr-step))
            dr-=step;
    ///cout<<st<<' '<<dr<<'\n';
    if(dr>st) cout<<dr-st-1;
    else cout<<0;
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define show(x, y); cout << x << " " << y << endl;
using namespace std;

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

    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    bool dp[k + 1];
    memset(dp, false, sizeof dp);
    for(int i = 0; i < n; i++){
        dp[a[i]] = true;
    }
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(a[j] <= i && !dp[i - a[j]]){
                dp[i] = true;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 384
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, d_list = gets_n_and_i_list
M, t_list = gets_n_and_i_list

d_count_hash = d_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

t_list.each do |t|
  count = d_count_hash[t]
  if count.nil? || count.zero?
    puts "NO"
    exit
  else
    d_count_hash[t] = count - 1
  end
end

puts "YES"


Measured memory_bytes: 70496
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

int main(){fastio
    ll k,t;cin>>k>>t;
    ll a[t];rep(i,0,t-1)cin>>a[i];
    sort(a,a+t);
    ll ans=0;
    while(1){
        if(k<2*a[t-1]-1){
            k--;a[t-1]--;
            ans++;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fll fill_n
#define ll long long
#define pb push_back
const ll md=998244353;
ll fpb(ll a, ll b){
   if(b==0) return a;
   else return fpb(b,a%b);
}
ll pw(ll a, ll b){
   if(b==0) return 1;
   else{
		ll smp=pw(a,b/2)%md;
		if(b%2==0) return (smp*smp)%md;
		else return (((smp*smp)%md)*a)%md;
   }
}

int main(){
	ll n,x,mx;
	cin>>n;
	ll ar[100005];
	for(int i=0; i<100005; i++){
		ar[i]=0;
	}
	ll ans=1;
	for(int i=0; i<n; i++){
		cin>>x;
		ar[x]++;
		if(i==0) mx=x;
		else if(mx<x) mx=x;
		if(x==0 && i!=0) ans=0;
	}
	for(int i=0; i<=mx; i++){
		if(i==0){
			if(ar[i]!=1) ans=0;
		}
		else{
			ans=((ans%md)*(pw(ar[i-1],ar[i])%md))%md;
		}
	}
	cout<<ans<<endl;
}



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

using namespace std;
typedef long long int lld;

priority_queue<pair<lld,int> > q;
lld dp[2222][2222];
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=1;e<=n;e++){
		lld a;
		scanf("%lld",&a);
		q.push(make_pair(a,e));
	}
	int num = 0;
	while(!q.empty()){
		lld val = q.top().first;
		int wh = q.top().second;
		q.pop();
		for(int q=0;q<=num;q++){
			int ll = q;
			int rr = n+1-(num-q);
			dp[ll+1][rr] = max(dp[ll+1][rr],dp[ll][rr]+val*(lld)abs((wh-(ll+1))));
			dp[ll][rr-1] = max(dp[ll][rr-1],dp[ll][rr]+val*(lld)abs((wh-(rr-1))));
		}
		num++;
	}
	lld ans = 0;
	for(int e=0;e<=n;e++){
		ans = max(ans,dp[e][e+1]);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int>C{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << C.at(N - 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define par pair<pair<int,int>, int>
#define f first
#define s second

int x[20][20], n,d,dif,sum,sq,cnt;


int main() {
    scanf("%d%d",&n,&d);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<d ;j++) 
            scanf("%d",&x[i][j]);
    }
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            sum = 0;
            for(int k=0; k<d ;k++)
            {
                dif = x[i][k] - x[j][k];
                sum += dif * dif;
            }
            sq = int(sqrt(sum)+0.5);
            if(sq * sq == sum) cnt++;
        }
    }
    printf("%d",cnt);
	return 0;
}

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

ans = 1

for x in arr:
    if x == 0:
        ans = 0

if ans == 0:
    print(ans)
else:
    for x in arr:
        ans *= x
        if ans > 1000000000000000000:
            break
    if ans > 1000000000000000000:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21652
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest100
{
    class QC
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            ulong[] a = new ulong[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = ulong.Parse(s[i]);
            }

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                while(true)
                {
                    if (a[i] % 2 == 0)
                    {
                        a[i] /= 2;
                        count++;
                    }
                    else break;
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

int lol[1<<18] = {};
int oof[19] = {};
int uwu[19] = {};
int sum = 0, n, m;
vector<int> vec;

void update(int s){
    int i = n, j, t = s;
    while (t){
        j = uwu[i];
        if (j < t){
            t -= j;
            uwu[i] = 0;
            sum -= j;
            oof[i] = j;
        }
        else{
            uwu[i] -= t;
            sum -= t;
            oof[i] = t;
            t = 0;
        }
        i--;
    }
    t = s;
    for (int i = 0; i <= n; i++){
        t -= oof[i];
        oof[i] = 0;
        uwu[i] += t;
        sum += t;
    }
}


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

    cin >> n;
    m = 1<<n;
    for(int i = 0; i < m; i++) cin >> lol[i];
    sort(lol, lol + m);

    int i = m - 1, s = 1;
    while (i){
        if (lol[i] == lol[i-1]) s++;
        else{
            vec.push_back(s);
            s = 1;
        }
        i--;
    }
    vec.push_back(s);

    uwu[n] = 1;
    sum = 1;
    bool ans = 1;

    for (int i = 0; i < vec.size(); i++){
        s = vec[i];
        if (sum < s){
            ans = 0;
            break;
        }
        else{
            update(s);
        }
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

ll digsum(ll n, ll k) {
    ll res = 0;
    while(n > 0) {
        // 各桁の和 (k進数)
        res += n % k;
        // 桁数 (k進数)
        // res++;
        n /= k;
    }
    return res;
}

int main() {
    ll n, a, b, ans;
    ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++) {
        int sum = digsum(i, 10);
        if(sum >= a && sum <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<LLI> D(N); cin >> D;

    map<int,int> m1;
    REP(i,N){
      m1[D[i]] = i;
    }

    sort(RALL(D));

    vector<pair<int,int>> ans;
    vector<int> size_subtree(N,1);
    bool no = false;
    vector<LLI> d_sum(N);

    //dump(D);

    int root = m1[D.back()];

    REP(i,N-1){
      LLI d = D[i];
      int x = m1[d];

      LLI dd = d+size_subtree[x]-(N-size_subtree[x]);
      //dump(dd);

      if(not EXIST(m1,dd) or d == dd){
	no = true;
	break;
      }else{
	size_subtree[m1[dd]] += size_subtree[x];
	d_sum[m1[dd]] += d_sum[x] + size_subtree[x];
	ans.push_back({x,m1[dd]});
      }
    }
    //dump(d_sum);
    if(d_sum[root] != D.back()) no = true;

    if(no){
      cout << -1 << endl;
    }else{
      for(auto &p : ans){
	cout << p.fst+1 << " " << p.snd+1 << endl;
      }
    }
    cerr << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9080
a,b,c,x,y = map(int, input().split())

A = a * x + b * y
if min(x,y) == x:
    B = c * x * 2 + (y-x) * b
    C = c * y * 2
else:
    B = c * y * 2 + (x-y) * a
    C = c * x * 2

print(min(A,B,C))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int calc(int N, const vector<vector<int>> &D, const vector<vector<int>> &c, int i, int j, int x)
{
	int ans = 0;
	for (; i >= 0 && j < N; --i, ++j) {
		ans += D[c[i][j]][x];
	}
	return ans;
}

int main()
{
	int N, C;
	cin >> N >> C;
	vector<vector<int>> D(C, vector<int>(C));
	for (auto &v : D) {
		for (auto &x : v) {
			cin >> x;
		}
	}
	vector<vector<int>> c(N, vector<int>(N));
	for (auto &v : c) {
		for (auto &x : v) {
			cin >> x;
			--x;
		}
	}

	vector<vector<int>> s(2 * N - 1, vector<int>(C, 0));

	for (int i = 0; i < N; ++i) {
		for (int x = 0; x < C; ++x) {
			s[i][x] = calc(N, D, c, i, 0, x);
		}
	}
	for (int i = 1; i < N; ++i) {
		for (int x = 0; x < C; ++x) {
			s[N - 1 + i][x] = calc(N, D, c, N - 1, i, x);
		}
	}

	int ans = 1 << 29;

	for (int c1 = 0; c1 < C; ++c1) {
		for (int c2 = 0; c2 < C; c2++) if (c1 != c2) {
			for (int c3 = 0; c3 < C; c3++) if (c1 != c3 && c2 != c3) {
				int result = 0;

				for (int i = 0; i < 2 * N - 1; ++i) {
					switch (i % 3) {
					case 0: result += s[i][c1]; break;
					case 1: result += s[i][c2]; break;
					case 2: result += s[i][c3]; break;
					}
				}
				ans = min(ans, result);
			}
		}

	}

	cout << ans << endl;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		BufferedReader br = 
				new BufferedReader(new InputStreamReader(System.in));
		Scanner scan = new Scanner(System.in);
		String str = "";
		String check="";
		int[] alph = new int[26];
		while(scan.hasNext()){
			str = scan.next();
			for(int j=0;j<str.length();j++){
				check =String.valueOf(str.charAt(j));	
				if(check.matches("[a-z]+")){
					alph[str.charAt(j)-'a']++;
				}else if(check.matches("[A-Z]+")){
					alph[str.charAt(j)-'A']++;
				}
			}
			//System.out.println(str.length());
			//System.out.println(Character.isLetterOrDigit(str.charAt(0)));
		}
		for(int i=97;i<123;i++)
			System.out.println((char)i+" : "+alph[i-97]);
	}
}

Measured memory_bytes: 22964
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll j = 1;
    rep(i, n){
        if(a[i] == j) j++;
    }
    if(j > 1) cout << n - j + 1 << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 1792
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    # else :                                                                                         
    #     print("restaurant is ok.")           



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]   
    # num=8                                                                                          

    num=int(input())
    if 1<=num<=100:
        # [[] for i in range(5)]                                                                     
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        # print(restaurant)                                                                          
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()



Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	final static int N = 100;
	final static int INF = 100000;
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] m = new int[n + 1][n + 1];
		int[] p = new int[n + 1];
		int i = 0, j = 0, r = 0;
		
		
		for(i = 1; i <= n; i++){
			String[] str = br.readLine().split(" ");
			p[i - 1] = Integer.parseInt(str[0]);
			p[i] = Integer.parseInt(str[1]);
		}
		
		for(int l = 2; l <= n ; l++){
			for(i = 1; i <= n - l + 1; i++){
				j = i + l - 1;
				m[i][j] = INF;
				for(int k = i; k < j; k++){
					r = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
					//System.out.println(m[i][k] + "+" + m[k + 1][j] + "+" + p[i - 1] + "*" + p[k] + "*" + p[j]);
					if(m[i][j] > r) m[i][j] = r;
				}
			}
		}
		
		System.out.println(m[i - 1][j]);
	}
}

Measured memory_bytes: 24420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    priority_queue<long long> A;
    long long a;
    for(long long i = 0; i < N; i++){
        cin >> a;
        A.push(a);

    }

    for(long long i = 0; i < M; i++){
        a = A.top();
        if(a == 0){
            break;
        }else{
            a /= 2LL;
            A.pop();
            A.push(a);
        }
    }

    long long ans = 0;
    while(true){
        ans += A.top();
        A.pop();
        if(A.size() == 0 || A.top() == 0){
            break;
        }
    }
    cout << ans << endl;
    
    

    return 0;
}

Measured memory_bytes: 1400
def read():
    N = int(input().strip())
    A = input().strip()
    B = input().strip()
    C = input().strip()
    return N, A, B, C


def solve(N, A, B, C):
    n_change = 0
    for i in range(N):
        same = 0
        if A[i] == B[i]:
            same += 1
        if A[i] == C[i]:
            same += 1
        if B[i] == C[i]:
            same += 1
        if same == 0:
            n_change += 2
        elif same == 1:
            n_change += 1
    return n_change


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int N; cin >> N;
  int Q; cin >> Q;
  string S; cin >> S;

  vector<int> l(Q), r(Q);
  REP(i, Q) {
    cin >> l[i] >> r[i];
  }

  vector<int> ans(S.size());
  REP(i, S.size()) {
    ans[i] = 0;
  }

  REP(i, S.size()) {
    if(i == 0) continue;
    if(S[i - 1] == 'A' && S[i] == 'C') ans[i]++;
    ans[i] += ans[i - 1];
  }

  REP(i, Q) {
    cout << ans[r[i] - 1] - ans[l[i] - 1] << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> W[i];
    sum+=W[i];
  }
  int sumy;
  int sumz;
  for(int i=0;sumz<sum/2;i++){
    sumy=sumz;
    sumz+=W[i];
  }
  cout << min(abs(2*sumy-sum),abs(2*sumz-sum));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


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

int main(){

    int a=0,b=0;
    string S;
    cin >> S;
    size_t N = S.length();
    
    rep(i,(N-1)/2){
        if(S[i]!=S[N-1-i])a++;
    }
    
    if(a==0){
        rep(i,N/4){
            if(S[i]!=S[(N-1)/2-1-i])b++;
            if(S[(N-1)/2+1+i]!=S[N-1-i])b++;
        }
    }
    
    
    if(a==0&&b==0)cout << "Yes";
    else cout << "No";
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	}
}//??§???????°?????????????????°????????????????????????????

Measured memory_bytes: 24168
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int a;
    cin >> a ;
    
    if(a < 600){
        cout << 8 << endl;
    } else if (a < 800){
        cout << 7 << endl;
    } else if (a < 1000){
        cout << 6 << endl;
    } else if (a < 1200){
        cout << 5 << endl;
    } else if (a < 1400){
        cout << 4 << endl;
    } else if (a < 1600){
        cout << 3 << endl;
    } else if (a < 1800){
        cout << 2 << endl;
    } else if (a < 2000){
        cout << 1 << endl;
    }
    
}


Measured memory_bytes: 3668
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), r = 0, g = 0;
            char c[] = in.next().toCharArray();
            for (int i = 0; i < n; ++i) if (c[i] == 'R') r++;
            for (int i = 0; i < r; ++i) if (c[i] != 'R') g++;
            out.println(g);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 34708
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int[] tmp = ReadIntArray();
	long n = tmp[0], k = tmp[1];
	int[] a = ReadIntArray();

	const int M = 1000000007;
	
	long na = 0, nb = 0;
	for (int i = 0; i < n-1; i++)
	{
	    for (int j = i+1; j < n; j++)
	    {
		if (a[i] > a[j]) na++;
		if (a[i] < a[j]) nb++;
	    }
	}

	long ans = k*(k-1)/2 % M *(na+nb) %M  + k*na%M;
	WriteLine(ans%M);
    }
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int r = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') r++;
    else if (s[i] == 'B') b++;
  }

  if (r > b) {
    py();
  } else {
    pn();
  }
}

Measured memory_bytes: 256
#include <iostream> 
#include <set>
using namespace std;
int main()  {
    int n; cin>>n;
    set<string> s;
    for(int i=0;i<n;i++)    {
        string a; cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

class UnionFind
{
public:
  UnionFind(int N) : parent(N, -1)
  {
  }
  int Root(int i)
  {
    if (parent[i] < 0) return i;
    return parent[i] = Root(parent[i]);
  }
  int Size(int i)
  {
    return -parent[Root(i)];
  }
  bool Connect(int a, int b) {
    a = Root(a);
    b = Root(b);
    if (a == b) return false;
    if (Size(a) < Size(b)) swap(a, b);
    parent[a] = parent[a] + parent[b];
    parent[b] = a;
    return true;
  }
  vector<int> parent;
};

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<long long> ans(M, 0);
  ans[M-1] = (long long)N * (N-1) / 2;
  for (int i=0;i<M;i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  UnionFind uni(N);
  for (int i=M-1;i>=1;i--) {
    ans[i-1] = ans[i];
    if (uni.Root(A[i]) != uni.Root(B[i])) {
      ans[i-1] -= (long long)uni.Size(A[i]) * uni.Size(B[i]);
      uni.Connect(A[i], B[i]);
    }
  }
  for (int i=0;i<M;i++)
  {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll m,d; cin >> m >> d;
    ll m2,d2; cin >> m2 >> d2;
    cout << (m != m2 ? 1 : 0) << endl;
    
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
X = X/50
count = 0
sumA = 0
sumB = 0
sumC = 0
for i in range(A+1):
    sumA += 10*i
    for j in range(B+1):
        sumB =sumA + 2*j
        for k in range(C+1):
            sumC = sumB + k
            if sumC == X:
                count +=1
            sumC = 0
        sumB = 0
    sumA = 0
print(count)

Measured memory_bytes: 39664
def solve():
    MOD = 10**9 + 7

    N, K = map(int, input().split())
    As = list(map(int, input().split()))

    if K == N:
        ans = 1
        for A in As:
            ans *= A
            ans %= MOD
        print(ans)
        return

    As.sort(key=lambda x: abs(x))

    if max(As) < 0 and K%2 != 0:
        ans = 1
        for A in As[:K]:
            ans *= A
            ans %= MOD
        print(ans)
        return

    pos0As, negAs = [], []
    for A in As:
        if A >= 0:
            pos0As.append(A)
        elif A < 0:
            negAs.append(A)
    pos0As.sort()
    negAs.sort(reverse=True)

    ans = 1
    rest = K
    while rest > 0:
        if rest == 1:
            ans *= pos0As.pop()
            rest -= 1
        else:
            if len(pos0As) < 2:
                ans *= negAs.pop()
                ans *= negAs.pop()
                rest -= 2
            elif len(negAs) < 2:
                ans *= pos0As.pop()
                rest -= 1
            else:
                pPos0 = pos0As[-1] * pos0As[-2]
                pNeg = negAs[-1] * negAs[-2]
                if pPos0 >= pNeg:
                    ans *= pos0As.pop()
                    rest -= 1
                else:
                    ans *= negAs.pop()
                    ans *= negAs.pop()
                    rest -= 2
        ans %= MOD

    print(ans)


solve()


Measured memory_bytes: 31692
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main()
{
	string s;
	cin >> s;
	map<string, int> m;
	m["SUN"] = 7;
	m["MON"] = 6;
	m["TUE"] = 5;
	m["WED"] = 4;
	m["THU"] = 3;
	m["FRI"] = 2;
	m["SAT"] = 1;
	cout << m[s] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int key;
  int left,right,parent;
}node;

node t[500005];

int find(int key,int u){
  if(t[u].key==key)
    return 1;
  if(u==-1)
    return 0;
  
  int rec=0;
  if(key>t[u].key)
    rec+=find(key,t[u].right);
  if(key<t[u].key)
    rec+=find(key,t[u].left);
	      
  return rec;
}

void pre(int u){
  printf(" %d",t[u].key);

  if(t[u].left!=-1)pre(t[u].left);
  if(t[u].right!=-1)pre(t[u].right);
  
  return;
}

void in(int u){
  
  if(t[u].left!=-1)in(t[u].left);
  printf(" %d",t[u].key);
  if(t[u].right!=-1)in(t[u].right);

  return;
}

main()
{

  for(int i=0;i<500005;i++){
    t[i]=(node){-2000000001,-1,-1,-1};
  }

  int n;
  string q;
  int a;
  int next=0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> q;
    if(q=="insert"){
      cin >> a;
      int b=0;
      int num=0;
      if(next==0){
	t[next].key=a;
      }else{
	while(num!=-1){
	  b=num;
	  if(t[num].key<a){
	    num=t[num].right;
	  }else{
	    num=t[num].left;
	  }
	}
	if(t[b].key<a){
	  t[b].right=next;
	}else{
	  t[b].left=next;
	}
	t[next].key=a;
	t[next].parent=b;
      }
      next++;
    }

    if(q=="print"){
      in(0);
      printf("\n");
      pre(0);
      printf("\n");
    }

    if(q=="find"){
      cin >> a;
      if(find(a,0))
	cout << "yes" << endl;
      else
	cout << "no" << endl;
    }
  }

  return (0);
}

Measured memory_bytes: 11164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		// intN,intM,intLを入力
		int intN = scanner.nextInt();
		int intM = scanner.nextInt();
		int intL = scanner.nextInt();

		long[][] longA = new long[intN][intM];
		for (int intI = 0; intI < intN; intI++) {
			for (int intJ = 0; intJ < intM; intJ++) {
				// 配列longAに数値を入力する
				longA[intI][intJ] = scanner.nextInt();
			}
		}

		long[][] longB = new long[intM][intL];
		for (int intO = 0; intO < intM; intO++) {
			for (int intP = 0; intP < intL; intP++) {
				// 配列longBに数値を入力する
				longB[intO][intP] = scanner.nextInt();
			}
		}
		//long[][] longC = new long[intN][intL];
		long longC = 0;
		for (int intX = 0; intX < intN; intX++) {
			for (int intY = 0; intY < intL; intY++) {
				for (int intZ = 0; intZ < intM; intZ++) {
					longC += longA[intX][intZ] * longB[intZ][intY];
						if (intZ == intM -1) {
							if (!(intY == intL -1)) {
								System.out.print(longC + " ");
								longC = 0;
							} else if (intY == intL - 1) {
								System.out.println(longC);
								longC = 0;
							}
						}
				}
			}
		}

	}
}



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

int main()
{
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> a(N, vector<int>(N, 0));
  rep(i, M)
  {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    a.at(l).at(r)++;
  }
  vector<int> p(Q), q(Q);
  rep(i, Q)
  {
    cin >> p.at(i) >> q.at(i);
    p.at(i)--;
    q.at(i)--;
  }
  vector<vector<int>> s(N + 1, vector<int>(N + 1, 0));
  rep(i, N)
  {
    rep(j, N)
    {
      s.at(i + 1).at(j + 1) = s.at(i + 1).at(j) + s.at(i).at(j + 1) - s.at(i).at(j) + a.at(i).at(j);
    }
  }
  vector<int> ans(Q);
  rep(i, Q)
  {
    ans.at(i) = s.at(q.at(i) + 1).at(q.at(i) + 1) - s.at(q.at(i) + 1).at(p.at(i)) - s.at(p.at(i)).at(q.at(i) + 1) + s.at(p.at(i)).at(p.at(i));
  }
  rep(i, Q) cout << ans.at(i) << endl;
}

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

string S;


int solve(){
	if(S.length() == 2){
		cout << S << endl;
	}

	if(S.length() == 3){
		for(int i=S.length()-1;0<=i;i--){
			cout << S[i];
		}
		cout << endl;
	}
	return 0;
}

int main(){
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		
		//スキャナーで半径rを読み取る
	    Scanner sc = new Scanner(System.in);
	    String s1 = sc.next();
	    double r = Double.parseDouble(s1);
	    
	    //面積sと円周lを求める
	    double s = Math.PI * r * r;
	    double l = Math.PI * (r + r);
	    
	    //面積sと円周lを表示する
	    System.out.println(String.format("%1$3f",s) + " " + String.format("%1$3f",l));
	    
		
	}

}

Measured memory_bytes: 17144
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int a, b;

int main(){
	cin >> a >> b;
	if(a<=0 && b>=0){
		cout << "Zero" << endl;
	} else if(a>0){
		cout << "Positive" << endl;
	} else if((b-a)%2==1){
		cout << "Positive" << endl;
	} else{
		cout << "Negative" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    while (true) {
      int h = sc.nextInt();
      int w = sc.nextInt();

      if (h == 0 && w == 0) break;

      IntStream.range(0, h).forEach(i -> {
        IntStream.range(0, w).forEach(j -> {
          String c = i != 0 && i != (h-1) && j != 0 && j != (w-1) ? "." : "#";
          pw.append(c);
        });
        pw.println();
      });
      pw.println();
    }

    pw.flush();
  }
}


Measured memory_bytes: 32768
#include <stdio.h>
# define N 100000
# define node0 -1
int sibilings(int);
int degree(int);
int depth(int);
int hight(int);

typedef struct{
  int parent;
  int left;
  int right;
} tree_node;
tree_node tree[N];

int sibilings(int);
int degree(int);
int depth(int);
int hight(int);

int main(){
  int i,j,n;
  int par,Lef,Rig;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=node0;
    tree[i].left=node0;
    tree[i].right=node0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&par);
     scanf("%d",&Lef);
      scanf("%d",&Rig);
      tree[Lef].parent=par;
      tree[Rig].parent=par;
      tree[par].left=Lef;
      tree[par].right=Rig;
  }
  for(i=0;i<n;i++){
     printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,sibilings(i),degree(i),depth(i),hight(i));
    if(tree[i].parent==node0){
      printf("root\n");
    }
    else if(tree[i].left==node0 && tree[i].right==node0){
	printf("leaf\n");
      }
    else printf("internal node\n");
  }
  return 0;
}
int sibilings(int nodeNum){
  if(tree[nodeNum].parent==node0){
    return node0;
  }
  else if(tree[tree[nodeNum].parent].left==nodeNum){
    return tree[tree[nodeNum].parent].right;
		}
  else return tree[tree[nodeNum].parent].left;
}
int degree(int nodeNum){
  if(tree[nodeNum].left==node0 && tree[nodeNum].right==node0){
    return 0;
  }
  else if(tree[nodeNum].left!=node0 && tree[nodeNum].right!=node0){
    return 2;
  }
  else{
    return 1;
  }
}
  int depth(int nodeNum){
    int count=0;
    if(tree[nodeNum].parent==node0){
      return 0;
    }
    else{
      count=depth(tree[nodeNum].parent)+1;
      return count;
    }
  }

  int hight(int nodeNum){
    int leftHight=0,rightHight=0;
    if(tree[nodeNum].left!=node0){
      leftHight=hight(tree[nodeNum].left)+1;
    }
    
   if(tree[nodeNum].right!=node0){
      rightHight=hight(tree[nodeNum].right)+1;
     }
   if(leftHight>rightHight){
     return leftHight;
   }
   else return rightHight;
  }

Measured memory_bytes: 612