akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i, j, t1, t2;
vector<int> data;

int ask(int pos) {
    string s;

    cout << pos << endl;
    cin >> s;

    if (s == "Vacant") exit(0);
    if (s == "Male") return 1;
    return 0;
}

void solve(int l, int r, int t1, int t2) {
    if (l + 1 == r)
        ask((data[l] + 1) % n);

    int mid = (l + r) >> 1;
    int tt = ask(data[mid]);

    if (tt == t1)
        solve(mid, r, tt, t2);
    else
        solve(l, mid, t1, tt);
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n;
    for (i = 0; i != 1; i = (i + 2) % n) data.pb(i);
    data.pb(1);

    t1 = ask(0);
    t2 = ask(1);

    solve(0, data.size() - 1, t1, t2);



    return 0;
}


Measured memory_bytes: 1236
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
bool comp(const Pl &a, const Pl &b){
  return a.first > b.first;
}

int main(int argc, char const* argv[])
{
  int w, h;
  cin >> w >> h;
  vector<Pl> vec;
  rep(i, w){
    ll x;
    cin >> x;
    vec.pb(mk(x, 0));
  }
  rep(i, h){
    ll x;
    cin >> x;
    vec.pb(mk(x, 1));
  }
  sort(vec.begin(), vec.end(), comp);
  ll res = 0;
  int vnum = 0;
  int rnum = 0;
  rep(i, vec.size()){
    if(vec[i].second == 0){
      res += (vnum + 1) * vec[i].first;
      rnum++;
    }else{
      res += (rnum + 1) * vec[i].first;
      vnum++;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 6512
n=int(input())
w=list(map(int,input().split()))
s=sum(w)
s1=w[0]
s2=s-w[0]
x=[]
x.append(abs(s1-s2))
for i in range(n-2):
    s1+=w[i+1]
    s2-=w[i+1]
    x.append(abs(s1-s2))
print(min(x))

Measured memory_bytes: 3064
n, x, y = map(int, input().split())
a = [0 for i in range(n-1)]
for ii in range(n):
	for jj in range(ii+1,n):
		i = ii+1
		j = jj+1
		if i < x and j < x:
			b = j-i
		elif i < x and j >= x and j <= y:
			b = min(j-i, y-j+1+x-i)
		elif i < x and j > y:
			b = j-i-(y-x)+1
		elif i >= x and i <= y and j >= x and j <= y:
			b = min(j-i,i-x+y-j+1)
		elif i >= x and i <= y and j > y:
			b = min(j-i,i-x+1+j-y)
		else:
			b = j-i
		#print (i,j,b)
		a[b-1] += 1
for i in a:
	print (i)


Measured memory_bytes: 47452
#include <iostream>

#include <algorithm>

using namespace std;

int a[10005];
int b[105][105];
int main()
{
	int h, w, n, k = 1;
	cin >> h;
	cin >> w;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
	}
	for(int i = 1; i <= h; i ++)
	{
		for(int j = 1; j <= w; j ++)
		{
			a[k] --;
			b[i][j] = k;
			if(a[k] == 0)
			{
				k ++;
			}
		}
	}
	for(int i = 2; i <= h; i += 2)
	{
		reverse(b[i] + 1, b[i] + w + 1);
	}
	for(int i = 1; i <= h; i ++)
	{
		for(int j = 1; j <= w; j ++)
		{
			cout << b[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e14
#define N 500001
#define K 4
#define ALPHA 1.3
#define BETA 1.0



int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int d;
    cin >> d;
    vector<int> c(26);
    double average = 0.0;

    for(int i = 0;i < 26;i++)
        cin >> c[i];
    vector<vector<int>> v(d,vector<int>(26,0));
    for(int i = 0;i < d;i++)
    {
        for(int j = 0;j < 26;j++)
        {
            cin >> v[i][j];
            average += v[i][j];
        }
    }
    average /= (d * 26);
    vector<int> last(26,-1);
    for(int i = 0;i < d;i++)
    {
        double mxgain = -inf;
        int ind = -1;

        for(int j = 0;j < 26;j++)
        {
            double gain = pow(v[i][j],BETA) + pow((i - last[j]) * c[j],ALPHA);
            // cerr << j << " " << gain << endl;
            if(gain > mxgain)
            {
                mxgain = gain;
                ind = j;
            }
        }
        last[ind] = i;
        cout << ind + 1 << endl;
    }

    
    return 0;    
} 



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


void solve(std::string S){
    if(S == "SUN"){
        cout << 7 << endl;
    }else if(S == "MON"){
        cout << 6 << endl;
    }else if(S == "TUE"){
        cout << 5 << endl;
    }else if(S == "WED"){
        cout << 4 << endl;
    }else if(S == "THU"){
        cout << 3 << endl;
    }else if(S == "FRI"){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);

    if (n / 2 + n % 2 < k) {
        std::cout << "NO" << std::endl;
    } else {
        std::cout << "YES" << std::endl;
    }

    return 0;
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG
#define WHITE 0
#define BLACK 1

struct QItem{
    complex<int> p;
    ll step;
};

bool isIn(complex<int> p, vec2<int>& field){
    int r = p.real();
    int c = p.imag();
    int H = field.size();
    int W = field[0].size();

    if(!(0 <= r && r < H)){
        return false;
    }
    if(!(0 <= c && c < W)){
        return false;
    }
    return true;
}

ll getShortest(int H, int W, vec2<int>& field){
    complex<int> goal(H-1, W-1);
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    queue<QItem> que;
    que.push(QItem{complex<int>(0, 0), 0});
    ll res = -1;
    while(!que.empty()){
        auto popped = que.front();
        que.pop();
    
        // ここ来ちゃいけないならやめる
        if(!isIn(popped.p, field) || visited[popped.p.real()][popped.p.imag()] || field[popped.p.real()][popped.p.imag()] == BLACK){
            continue;
        }
    
        // visitedをつける
        visited[popped.p.real()][popped.p.imag()] = true;
    
        // もしゴールならゴール
        if(popped.p == goal){
            res = popped.step;
            break;
        }
    
        // 次にいく
        vector<complex<int>> ds{complex<int>(1, 0), complex<int>(-1, 0), complex<int>(0, 1), complex<int>(0, -1)};
        for(auto d: ds){
            que.push(QItem{popped.p + d, popped.step + 1});
        }
    }
    return res;
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int H, W;
    cin >> H >> W;
    vec2<int> field(H, vec<int>(W));
    ll whites = 0;
    for(int i=0; i < H; i++){
        for(int j=0; j < W; j++){
            while(true){
                char temp;
                cin >> temp;
                if(temp == '#'){
                    field.at(i).at(j) = BLACK;
                }else if(temp == '.'){
                    field.at(i).at(j) = WHITE;
                    whites++;
                }else{
                    assert(0);
                }
                break;
            }
        }
    }

    ll shortest = getShortest(H, W, field);

    if(shortest == -1){
        cout << -1 << endl;
    }else{
        cout << whites - shortest - 1<< endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool check(int n, int *p1, int *p2) {
    REP(i, n) if (p1[i] != p2[i]) return false;
    return true;
}

int main() {
    int N, p[50], p_sorted[50];
    cin >> N;
    REP(i, N) {
        cin >> p[i];
        p_sorted[i] = p[i];
    }
    sort(p_sorted, p_sorted + N);

    REP(i, N - 1) FOR(j, i, N) {
        swap(p[i], p[j]);
        if (check(N, p, p_sorted)) {
            cout << "YES" << endl;
            return 0;
        }
        swap(p[i], p[j]);
    }
    cout << "NO" << endl;
    return 0;
}

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

const int MaxN = 100000;
uint_fast32_t S[ MaxN + 10 ];

int main()
{
uint_fast32_t i;
uint_fast32_t N;
uint_fast32_t M;
uint_fast32_t A;
uint_fast32_t x;
uint_fast32_t iCnt;
uint_fast32_t iSum;

	scanf( "%llu %llu", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		scanf( "%llu", &A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%llu\n", iCnt );

	return 0;
}






Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,s[1000];

void push(int x){
	s[++top]=x;
}

int pop(void){
	top--;
	return s[top+1];
}

main(){
	top=0;
	int a,b;
	char s[100];
	while(scanf("%s",s) != EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push (atoi(s));
		}
		
	}
	printf("%d\n",pop());
}


Measured memory_bytes: 2076
#include <stdio.h>
 
int main()
{
    int n,b,f,r,v;
    int i,j,k;
    int x[4][3][10] = {0};
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        x[b-1][f-1][r-1] += v;
    }
     
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",x[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3)
        printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 612
import sys
from collections import defaultdict
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

# BEGIN CUT HERE
class RollingHash():
    BASE1 = 1007
    BASE2 = 2009
    MOD1 = 1000000007
    MOD2 = 1000000009

    def __init__(self, s):
        self.n = len(s)
        self.hash1 = [0] * (self.n + 1)
        self.hash2 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        self.power2 = [1] * (self.n + 1)
        for i, e in enumerate(s):
            self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
            self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
            self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
            self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2

    def get(self, l: int, r: int):
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
        if(res1 < 0):
            res1 += self.__class__.MOD1
        res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
        if(res2 < 0):
            res2 += self.__class__.MOD2
        return (res1, res2)
# END CUT HERE

def ABC131E():
    N = ii()
    S = li()
    rh = RollingHash(S)
    def check(n: int):
        d = dict()
        for i in range(N - n + 1):
            p = rh.get(i, i + n)
            if p in d:
                if(i - d[p] >= n):
                    return True
            else:
                d[p] = i
        return False
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)



if __name__ == '__main__':
    ABC131E()


Measured memory_bytes: 44656
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 3e5 + 10;
int n;
struct node{
    ll x, y, h;
};
node arr[105];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> arr[i].x >> arr[i].y >> arr[i].h;
    }
    for(ll i = 0; i <= 100; i ++){
        for(ll j = 0; j <= 100; j ++){
            ll H = 0;
            bool ok = true;
            ll tmp = (-llabs(arr[0].x - i) -llabs(arr[0].y - j));
            H = tmp - arr[0].h;
            H *= (-1LL);
            for(int it = 0; it < n; it ++){
               
                    if(max(H - llabs(arr[it].x - i) - llabs(arr[it].y - j), 0LL) == arr[it].h  ){
                        
                    }
                    else{
                        ok = false;
                        break;
                    }
                }
            if(ok){
                if(H <= 1)continue;
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
    for(ll i = 0; i <= 100; i ++){
        for(ll j = 0; j <= 100; j ++){
            for(ll H = 1; H <= 1000; H ++){
                bool ok = true;
                for(int it = 0; it < n; it ++){
    
                    if(max(H - llabs(arr[it].x - i) - llabs(arr[it].y - j), 0LL) == arr[it].h  ){
                        
                    }
                    else{
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    cout << i << " " << j << " " << H << endl;
                    return 0;
                }
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
        int a, b;
        cin >> a >> b;

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


Measured memory_bytes: 256
N, A, B = map(int, input().split())
h = []

for i in range(N):
    h.append(int(input()))

def bool(n, h):
    h.sort()
    damage = n * B
    hx = list(map(lambda x: x - damage, h))
    count = 0
    for i in range(len(hx)):
        count += max(0, 1 + (hx[i]-1) // (A - B))
    if count > n:
        return False
    else:
        return True
start = 0
end = 10000000000
while end - start > 1:
    mean = (start + end)//2
    if bool(mean, h):
        end = mean
    else:
        start = mean

print(end)


Measured memory_bytes: 12948
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long H, long W, long N) = Slice3<long>();
            var blacks = new HashSet<(long h, long w)>((int)N);
            for (var i = 0; i < N; ++i)
            {
                (long a, long b) = Slice2<long>();
                blacks.Add((a - 1, b - 1));
            }
            var used = new HashSet<(long h, long w)>((int)(N * 9));
            var dh = new long[] { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
            var dw = new long[] { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
            var ans = Enumerable.Repeat(0L, 10).ToArray();
            foreach(var b in blacks)
            {
                for (var i = 0; i < 9; ++i)
                {
                    var ch = b.h + dh[i];
                    var cw = b.w + dw[i];
                    if (ch <= 0 || H - 1 <= ch || cw <= 0 || W - 1 <= cw)
                        continue;
                    if (used.Contains((ch, cw)))
                        continue;
                    var cnt = 0L;
                    for (var j = 0; j < 9; ++j)
                    {
                        var sh = ch + dh[j];
                        var sw = cw + dw[j];
                        if (blacks.Contains((sh, sw)))
                            ++cnt;
                    }
                    used.Add((ch, cw));
                    ++ans[cnt];
                }
            }
            ans[0] = 0;
            ans[0] = (H - 2) * (W - 2) - ans.Sum();
            foreach (var a in ans)
                WriteLine(a);
        }
    }
}

Measured memory_bytes: 74720
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int b,f,r,v;
    int first[3][10];
    int second[3][10];
    int third[3][10];
    int forth[3][10];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            first[i][j] = 0;
            second[i][j] = 0;
            third[i][j] = 0;
            forth[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        if(b == 1){
            first[f - 1][r - 1] += v;
        }
        else if(b == 2){
            second[f - 1][r - 1] += v;
        }
        else if(b == 3){
            third[f - 1][r - 1] += v;
        }
        else if(b == 4){
            forth[f - 1][r - 1] += v;
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",first[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",second[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",third[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",forth[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2752
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	auto A = new long[][](H, W);
	auto B = new long[][](H, W);
	foreach (y; 0..H)
	{
		A[y] = RDA;
	}
	foreach (y; 0..H)
	{
		B[y] = RDA;
	}

	auto dp = new bool[][][](H, W, 160*(H+W));
	dp[0][0][A[0][0] - B[0][0] + 80*(H+W)] = true;
	dp[0][0][B[0][0] - A[0][0] + 80*(H+W)] = true;
	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			long d1, d2;
			if (y != H-1)
				d1 = A[y+1][x] - B[y+1][x];
			if (x != W-1)
				d2 = A[y][x+1] - B[y][x+1];
			foreach (key; 0..dp[y][x].length)
			{
				if (dp[y][x][key] == false) continue;
				debug writeln(y, ":", x, " ", cast(long)key - 80*(H+W));
				if (y != H-1)
				{
					dp[y+1][x][key+d1] = true;
					dp[y+1][x][key-d1] = true;
				}
				if (x != W-1)
				{
					dp[y][x+1][key+d2] = true;
					dp[y][x+1][key-d2] = true;
				}
			}
		}
	}

	long ans = long.max;
	foreach (key; 0..dp[H-1][W-1].length)
	{
		if (dp[H-1][W-1][key] == false) continue;
		ans.chmin(abs(cast(long)key - 80*(H+W)));
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

using namespace std;

int N, sol = (1 << 30), M, r, t[10];
long long D[205][205], x, y, z;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> r;
    for (int i = 1; i <= r; ++i) {
        cin >> t[i];
    }
    
    for (int i = 1; i <= M; ++i) {
        cin >> x >> y >> z;
        D[x][y] = D[y][x] = z;
    }
    
    sort(t + 1, t + r + 1);
    
    for (int k=1; k<=N; ++k)
        for (int i=1; i<=N; ++i)
            for (int j=1; j<=N; ++j)
                if (i!=j && D[i][k] > 0 && D[k][j] > 0 && (!D[i][j] || D[i][k]+D[k][j]<D[i][j]))
                    D[i][j]=D[i][k]+D[k][j];
    
    do {
        int cost = 0;
        
        for (int i = 2; i <= r; ++i) {
            cost += D[t[i - 1]][t[i]];
        }
        
        sol = min(sol, cost);
    } while (next_permutation(t + 1, t + r + 1));
    
    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  int n;
  vector<string> v;
  cin>>n;
  string prev,tmp;
  cin>>tmp;
  v.push_back(tmp);
  prev = tmp;
  for(int i = 1;i<n;i++){
    cin>>tmp;
    if (prev[prev.size()-1] != tmp[0]){
      cout<<"No"<<endl;
      return 0;
    }
    for(int j = 0;j<v.size();j++){
      if(tmp == v[j]){
	cout<<"No"<<endl;
	return 0;
      }
    }
    v.push_back(tmp);
    prev = tmp;
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll p[100100],q[100100],r[100100];

vector<ll> v;

int main(void){
	int x,y,z,a,b,c,i;
	ll ans = 0ll;
	cin >> x >> y >> a >> b >> c;
	for(i=0; i<a; ++i){
		cin >> p[i];
	}
	for(i=0; i<b; ++i){
		cin >> q[i];
	}
	for(i=0; i<c; ++i){
		cin >> r[i];
	}
	sort(p,p+a,greater<ll>());
	sort(q,q+b,greater<ll>());
	sort(r,r+c,greater<ll>());
	for(i=0; i<x; ++i){
		v.push_back(p[i]);
		ans += p[i];
	}
	for(i=0; i<y; ++i){
		v.push_back(q[i]);
		ans += q[i];
	}
	sort(v.begin(),v.end());
	z = min(x+y,c);
	for(i=0; i<z; ++i){
		if(v[i]<r[i]){
			ans -= v[i];
			ans += r[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  long double a,b;
  cin>>a>>b;
  long long ans=a*b;
  cout<<ans<<endl;
}


Measured memory_bytes: 3732
#include <iostream>

#include <vector>

using namespace std;

long long GCD(long long a, long long b) {

    if (b == 0) return a;

    else return GCD(b, a % b);

}

int main() {

    int N; long long X;

    cin >> N >> X;

    vector<long long> x(N); for (int i = 0; i < N; ++i) cin >> x[i], x[i] -= X;

    long long g = abs(x[0]);

    for (int i = 0; i < N; ++i) g = GCD(g, abs(x[i]));

    cout << g << endl;

}

Measured memory_bytes: 3996
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double distance = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));

	printf("%.5f\n", distance);
	return 0;
}

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

const int MAXN = 5.5E5;
long long f[MAXN];
long long value[MAXN];
int D[MAXN];
vector <int> adj[MAXN];
int n, root;

void getAns(int u, int fa)
{
	long long maxLine = 0;
	long long allLine = 0;
	for (int v : adj[u])
	{
		if (v == fa)
			continue;
		getAns(v, u);
		
		maxLine = max(maxLine, f[v]),
		allLine += f[v];
	}
	
	if (!allLine)
	{
//		assert(adj[u].size() == 1);
		f[u] = value[u];
		return ;
	}
	
	f[u] = 2ll * value[u] - allLine;
	long long restLine = allLine - maxLine;
	
	if (f[u] < 0 || f[u] > value[u] || maxLine - f[u] > restLine)
		puts("NO"), exit(0);
}

int main(void)
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	for (int i = 1;i <= n; ++i)
		cin >> value[i];
	
	if (n == 2)
	{
		puts((value[1] == value[2]) ? "YES" : "NO");
		return 0;
	}
	
	for (int i = 1;i < n; ++i)
	{
		int u = 0, v = 0;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		D[u]++, D[v] ++;
		
		if (D[u] > 1)
			root = u;
		if (D[v] > 1)
			root = v;
	}
	
	getAns(root, 0);
	if (f[root])
		puts("NO");
	else
		puts("YES");
	
	return 0;
}

/*
up + 2 * down = all
up + down = value
down = all - value
up + 2 * (all - value) = all
up = 2 * value - all
*/

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

int main() {
    long n, m;
    cin >> n >> m;
    vector<vector<long>> vvl(n+1);
    for (long i=0; i<m; i++) {
        long a, b;
        cin >> a >> b;
        vvl[a].push_back(b);
    }
    long len = vvl[1].size();
    for (long i=0; i<len; i++) {
        long x = vvl[1][i];
        auto y = vvl[x];
        if (find(y.begin(), y.end(), n) != y.end()) {
            puts("POSSIBLE");
            return 0;
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 8832
#include <cstdio>
#include <cstring>
#include <set>
#define MAXN 100010
#define LL long long
using namespace std;

int n1,n2,n3,n;
int a[MAXN][4],b[MAXN];
multiset< pair<int,int> > S[4][4];
LL ans=0;

int query(int x,int y){
	if(S[x][y].empty() || S[y][x].empty()) return 0;
	return S[x][y].rbegin()->first+S[y][x].rbegin()->first;
}

int query(int x,int y,int z){
	if(S[x][y].empty() || S[y][z].empty() || S[z][x].empty()) return 0;
	return S[x][y].rbegin()->first+S[y][z].rbegin()->first+S[z][x].rbegin()->first;
}

void gao(int v0,int v1){
	int x=S[v0][v1].rbegin()->second;
	for(int j=1;j<=3;j++)
		if(j^b[x])
			S[b[x]][j].erase(S[b[x]][j].find(make_pair(a[x][j]-a[x][b[x]],x)));
	b[x]=v1;
	for(int j=1;j<=3;j++)
		if(j^b[x])
			S[b[x]][j].insert(make_pair(a[x][j]-a[x][b[x]],x));
}

bool gao(){
	int res=0;
	int s12=query(1,2); res=max(res,s12);
	int s13=query(1,3); res=max(res,s13);
	int s23=query(2,3); res=max(res,s23);
	int s123=query(1,2,3); res=max(res,s123);
	int s132=query(1,3,2); res=max(res,s132);
	if(!res) return 0;
	if(s12==res) gao(1,2),gao(2,1);
	else if(s13==res) gao(1,3),gao(3,1);
	else if(s23==res) gao(2,3),gao(3,2);
	else if(s123==res) gao(1,2),gao(2,3),gao(3,1);
	else if(s132==res) gao(1,3),gao(3,2),gao(2,1);
	ans+=res;
	return 1;
}

int main(){
#ifdef DEBUG
	freopen("C.in","r",stdin);
#endif
	scanf("%d%d%d",&n1,&n2,&n3);
	n=n1+n2+n3;
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]);
	for(int i=1;i<=n1;i++){
		int x=i;
		b[x]=1;
		ans+=a[x][b[x]];
		for(int j=1;j<=3;j++)
			if(j^b[x])
				S[b[x]][j].insert(make_pair(a[x][j]-a[x][b[x]],x));
	}
	for(int i=1;i<=n2;i++){
		int x=i+n1;
		b[x]=2;
		ans+=a[x][b[x]];
		for(int j=1;j<=3;j++)
			if(j^b[x])
				S[b[x]][j].insert(make_pair(a[x][j]-a[x][b[x]],x));
	}
	for(int i=1;i<=n3;i++){
		int x=i+n1+n2;
		b[x]=3;
		ans+=a[x][b[x]];
		for(int j=1;j<=3;j++)
			if(j^b[x])
				S[b[x]][j].insert(make_pair(a[x][j]-a[x][b[x]],x));
	}
	while(gao());
	printf("%lld\n",ans);
}


Measured memory_bytes: 13568
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

uint64_t f(uint64_t A, uint64_t B, uint64_t x)
{
  return ((A * x) / B) - A * (x / B);
}

int main()
{
  uint64_t A, B, N;
  cin >> A >> B >> N;

  cout << f(A, B, min(B - 1, N)) << endl;

  return 0;
}

Measured memory_bytes: 3624
unittest
{
	assert( [ "3", "1 2 300", "3 3 600", "1 4 800" ].solve == "2900\n900\n0\n0" );
	assert( [ "5", "3 5 400", "5 3 700", "5 5 1000", "5 7 700", "7 5 400" ].solve == "13800\n1600\n0\n0\n0\n0" );
	assert( [ "6", "2 5 1000", "5 2 1100", "5 5 1700", "-2 -5 900", "-5 -2 600", "-5 -5 2200" ].solve == "26700\n13900\n3200\n1200\n0\n0\n0" );
	assert( [ "8", "2 2 286017", "3 1 262355", "2 -2 213815", "1 -3 224435", "-2 -2 136860", "-3 -1 239338", "-2 2 217647", "-1 3 141903" ].solve == "2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0" );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyps = new long[ 3 ][ n ];
	foreach( ref xyp; xyps )
	{
		input.popFront;
		xyp = input.front.split.to!( long[] );
	}
	
	// 縦の鉄道を引くパターンごとに、各集落が横方向に移動する場合の歩行距離を計算
	auto vss = new long[][]( 1L << n, n );
	{
		auto ds = new long[ n ];
		foreach( ref d, xyp; lockstep( ds, xyps ) )
		{
			d = abs( xyp[ 0 ] ) * xyp[ 2 ];
		}
		foreach( b, ref vs; vss )
		{
			vs = ds.dup;
			foreach( i, xyp_a; xyps )
			{
				if( ( b & ( 1L << i ) ) == 0 ) continue;
				foreach( ref d, xyp_b; lockstep( vs, xyps ) )
				{
					d = min( d, abs( xyp_a[ 0 ] - xyp_b[ 0 ] ) * xyp_b[ 2 ] );
				}
			}
		}
	}
	
	// 横の鉄道を引くパターンごとに、各集落が縦方向に移動する場合の歩行距離を計算
	auto hss = new long[][]( 1L << n, n );
	{
		auto ds = new long[ n ];
		foreach( ref d, xyp; lockstep( ds, xyps ) )
		{
			d = abs( xyp[ 1 ] ) * xyp[ 2 ];
		}
		foreach( b, ref hs; hss )
		{
			hs = ds.dup;
			foreach( i, xyp_a; xyps )
			{
				if( ( b & ( 1L << i ) ) == 0 ) continue;
				foreach( ref d, xyp_b; lockstep( hs, xyps ) )
				{
					d = min( d, abs( xyp_a[ 1 ] - xyp_b[ 1 ] ) * xyp_b[ 2 ] );
				}
			}
		}
	}
	
	// 全住民の歩行距離合計の最小を計算
	auto anss = new long[ n + 1 ];
	anss[] = long.max;
	solve2( anss, vss, hss, 0, 0, 0, 0 );
	return anss.to!( string[] ).join( "\n" );
}

void solve2( ref long[] anss, long[][] vss, long[][] hss, long vb, long hb, long c, long i )
{
	if( i + 1 < anss.length )
	{
		// i番目の集落に縦の鉄道を引くとき
		solve2( anss, vss, hss, vb | ( 1L << i ), hb, c + 1, i + 1 );
		
		// i番目の集落に横の鉄道を引くとき
		solve2( anss, vss, hss, vb, hb | ( 1L << i ), c + 1, i + 1 );
		
		// i番目の集落に鉄道を引かないとき
		solve2( anss, vss, hss, vb, hb, c, i + 1 );
	}
	else
	{
		// c本の鉄道を引いた場合の全住民の歩行距離合計を計算
		auto s = 0L;
		foreach( v, h; lockstep( vss[ vb ], hss[ hb ] ) )
		{
			s += min( v, h );
		}
		anss[ c ] = min( anss[ c ], s );
	}
}


Measured memory_bytes: 16664
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main() {
	ll N;
	cin >> N;
	vector<long double> p(N + 1);
	repn(i, N) cin >> p[i];

	vector<vector<long double>> dp(N + 1, vector<long double>(N + 1, 0));
	dp[0][0] = 1;

	rep(i, N + 1)rep(j, i + 1) {
		ll k = i - j;
		if (j > 0)dp[i][j] += dp[i - 1][j - 1] * p[i];
		if (k > 0)dp[i][j] += dp[i - 1][j] * (1 - p[i]);
	}

	long double ans = 0;

	rep(j, N + 1) {
		ll k = N - j;
		if (j > k) { ans += dp[N][j]; }
	}

	cout << fixed << setprecision(13);
	cout << ans << endl;
}



Measured memory_bytes: 144272
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

void updmax(int &x, int y) {
	x = max(x, y);
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int q;
	cin >> q;
	vector<int> vv(q), dd(q), c(q);
	vector<vector<int>> dp(n, vector<int>(11, -1));
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d", &vv[i], &dd[i], &c[i]);
		vv[i]--;
		updmax(dp[vv[i]][dd[i]], i);
	}
	for (int i = 10; i >= 1; i--) {
		for (int u = 0; u < n; u++) {
			updmax(dp[u][i - 1], dp[u][i]);
			for (int v : g[u]) {
				updmax(dp[v][i - 1], dp[u][i]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (dp[i][0] == -1) {
			puts("0");
		} else {
			printf("%d\n", c[dp[i][0]]);
		}
	}
}

Measured memory_bytes: 16248
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

n_multi4 = 0
n_multi2 = 0
for i in range(N):
  if A[i] % 4 == 0:
    n_multi4 += 1
  elif A[i] % 2 == 0:
    n_multi2 += 1

n_odd = N - (n_multi4 + n_multi2)

if n_multi4 >= n_odd:
  print('Yes')
elif n_multi4 +1 == n_odd and n_multi2 == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int m = Integer.parseInt(lines[1]);
      int l = Integer.parseInt(lines[2]);
      long[][] mA = new long[n][m];
      long[][] mB = new long[m][l];
      long[][] mC = new long[n][l];

      for(int i = 0; i < n; i++ ) {
        lines = br.readLine().split(" ");
        mA[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }
      for( int i = 0; i < m; i++ ) {
        lines = br.readLine().split(" ");
        mB[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }

      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < l; j++ ){
          for( int k = 0; k < m; k++ )
          mC[i][j] += mA[i][k] * mB[k][j];
        }
      }

      System.out.println(
        Stream.of(mC)
              .map( a -> ArrayToString(a) )
              .collect(Collectors.joining("\n"))
      );
    }
  }
  public static String ArrayToString(long[] a) {
      if (a == null)
          return "null";
      int iMax = a.length - 1;
      if (iMax == -1)
          return "[]";

      StringBuilder b = new StringBuilder();
      for (int i = 0; ; i++) {
          b.append(a[i]);
          if (i == iMax)
              return b.toString();
          b.append(" ");
      }
  }
}


Measured memory_bytes: 38564
#include <cstdio>
using namespace std;
int main()
{
	int a;
	while(scanf("%d",&a)==1)
	{
		if(a<=599&&a>=400)
			printf("8\n");
		else if(a<=799&&a>=600)
			printf("7\n");
		else if(a<=999&&a>=800)
			printf("6\n");
		else if(a<=1199&&a>=1000)
			printf("5\n");
		else if(a<=1399&&a>=1200)
			printf("4\n");
		else if(a<=1599&&a>=1400)
			printf("3\n");
		else if(a<=1799&&a>=1600)
			printf("2\n");
		else if(a<=1999&&a>=1800)
			printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    int n;
    cin >> n;

    vector<int> a(n), ra(n+1);
    rep(i, n) {
        cin >> a[i];
        ra[a[i]] = i;
    }

    set<int> st;
    st.insert(-1);  st.insert(n);

    ll ans = 0;
    for(int d = 1; d <= n; d++) {
        int i = ra[d];
        auto it = st.lower_bound(i);
        int r = *it;
        it--;
        int l = *it;
        ans += (ll)d*(i-l)*(r-i);
        st.insert(i);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {  
	ll kazu=1;
	while(1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁


/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	string s;cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

namespace MP2019C
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);

            long N = s[0];

            N = N - (s[1] - 1);

            long ans = s[1];
            if (s[2] - s[1] <= 2)
            {
                ans = s[1] + N;
            }
            else
            {
                ans += (s[2] - s[1]) * (N / 2);
                ans += N % 2;
            }

            Console.WriteLine(ans);
            return;


        }
    }
}


Measured memory_bytes: 13268
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a =input()

    if a =="A":
        print("T")
    if a == "C":
        print("G")
    if a == "T":
        print("A")
    if a == "G":
        print("C")


Measured memory_bytes: 3828
import copy
def main():
    N = int(input())
    A = [0] + [int(a) for a in input().split()]

    total = 0
    for i in range(1, N + 1):
        if i != N:
            total += abs(A[i] - A[i - 1])
        else:
            total += abs(A[i] - A[i - 1])
            total += abs(A[i] - A[0])

    for i in range(1, N + 1):
        S = copy.deepcopy(total)

        if i != N:
            S -= (abs(A[i] - A[i-1]) + abs(A[i] - A[i + 1]))
            S += abs(A[i - 1] - A[i + 1])

        else:
            S -= (abs(A[i] - A[i - 1]) + abs(A[i] - 0))
            S += abs(A[i - 1] - 0)

        print(S)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14560
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if(N % 2 == 0)
      System.out.println(N / 2);
    else
      System.out.println(N / 2 + 1);
  }
}

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

using namespace std;

typedef long long ll;

string RGB = "RGB";

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

    vector <int> Cnt(RGB.size());
    for(int i = 0; i < n; i++)  Cnt[RGB.find(s[i])]++;

    ll Ans = (ll) Cnt[0] * (ll) Cnt[1] * Cnt[2];

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'R')
        {
            for(int j = 0; j < n; j++)
            {
                if(s[j] == 'G')
                {
                    int I = i, J = j;

                    if(I > J)   swap(I, J);

                    int d = J - I;

                    if(J + d < n && s[J + d] == 'B')    Ans--;
                    if(I - d >= 0 && s[I - d] == 'B')   Ans--;
                    if(d % 2 == 0 && s[I + d / 2] == 'B')   Ans--;
                }
            }
        }
    }

    cout << Ans << endl;
}


Measured memory_bytes: 3640