akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

/**
 * B - TAKOYAKI FESTIVAL 2019
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        int n = sc.nextInt();   // たこ焼きの数
        int[] d = new int[n];   // 美味しさ


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

        int sum = 0;
        for( int j = 0; j < n; j++ ) {
            for( int k = j; k < ( n - 1 ); k++ ) {
                sum += d[j] * d[k + 1];
            }
        }

        System.out.println( sum );

        sc.close();
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int X;
    cin >> X;
    X -= 400;
    X = X / 200;
    cout << 8 - X << endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Measured memory_bytes: 8436
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int main(){
  int N, M, C[16], x[20000];
  int dp[2][256];
  
  while(scanf("%d %d", &N, &M), N){
    for(int i = 0; i < M; i++){
      scanf("%d", &C[i]);
    }
    for(int i = 0; i < N; i++){
      scanf("%d", &x[i]);
    }
    fill_n( *dp, 2 * 256, INF);
    dp[0][128] = 0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 256; j++){
        if(dp[i & 1][j] == INF) continue;
        for(int k = 0; k < M; k++){
          int value = min( 255, max( 0, j + C[k]));
          dp[(i + 1) & 1][value] = min( dp[(i + 1) & 1][value], dp[i & 1][j] + (x[i] - value) * (x[i] - value));
        }
      }
      for(int j = 0; j < 256; j++) dp[i & 1][j] = INF;
    }
    int ret = INF;
    for(int i = 0; i < 256; i++){
      ret = min( ret, dp[N & 1][i]);
    }
    printf("%d\n", ret);
  }
}

Measured memory_bytes: 1268
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BS

countBCs :: BS.ByteString -> (Int, BS.ByteString)
countBCs s = loop 0 s
  where
    loop !i s | "BC" `BS.isPrefixOf` s = loop (i+1) (BS.drop 2 s)
              | otherwise = (i, s)

parse :: BS.ByteString -> [[(Int, Int)]]
parse s = doParse [] s
  where
    doParse acc s = case BS.uncons s of
      Nothing -> [reverse acc]
      Just ('A', xs) -> let (as, xs') = BS.span (== 'A') xs
                            (bcs, xs'') = countBCs xs'
                        in if bcs == 0
                           then reverse acc : doParse [] xs''
                           else doParse ((BS.length as + 1, bcs) : acc) xs''
      Just (_, xs) -> reverse acc : doParse [] xs

calc :: [(Int, Int)] -> Int
calc xs = loop 0 0 xs
  where
    loop :: Int -> Int -> [(Int,Int)] -> Int
    loop !s !sa [] = s
    loop !s !sa ((a,b):xs) = loop (s + (sa + a) * b) (sa + a) xs

main = do
  s <- BS.getLine
  print $ sum $ map calc $ parse s


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

int main()
{
    int n;
    cin>>n;
    double h,k;
    if(n%2==1)
    {
       k=n;
       h=((k+1)/2)/k;
       cout<<h;
    }

    else
      {
         k=n;
         h=(k/2)/k;cout<<h;}
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int P = 998244353;
int n, m, a[3005], f[3005][3005], ans;
int main(){
	scanf("%d%d", &n, &m);
	for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (register int i = 1; i <= n; ++i)
		for (register int j = 1; j <= m; ++j){
			if (j == a[i]) f[i][j] = (f[i][j] + i) % P;
			if (j >= a[i]) f[i][j] = (f[i][j] + f[i - 1][j - a[i]]) % P;
			if (j == m) ans = (ans + 1ll * f[i][j] * (n - i + 1)) % P;
			f[i][j] = (f[i][j] + f[i - 1][j]) % P;
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 35456
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26), t(D+1);
    std::vector<std::set<int>> days(26);
    for(int i(0); i < 26; ++i){
        days[i].emplace(0);
        days[i].emplace(D+1);
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26));
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    for(int i(1); i <= D; ++i){
        long long mx(-LINF); int id(-1);
        for(int j(0); j < 26; ++j){
            std::cin >> s[i][j];
            auto itr(std::lower_bound(std::begin(days[j]), std::end(days[j]), i));
            long long d1(*(--itr));
            if(chmax(mx, s[i][j] + c[j]*((d1-i)*(i-D) + i - d1))) id = j;
        }
        t[i] = id;
        days[t[i]].emplace(i);
    }

    long long v(0);
    for(int i(1); i <= D; ++i){
        long long dcr(0);
        for(int j(0); j < 26; ++j){
            auto itr(std::upper_bound(std::begin(days[j]), std::end(days[j]), i));
            dcr += c[j] * (i - *(--itr));
        }
        v += s[i][t[i]] - dcr;
    }
    int M(1000000);
    srand((unsigned int)time(NULL));
    {
        int d, q;
        for(int qq(0); qq < M; ++qq){
            d = rand() % D + 1;
            q = rand() % 25;
			if(q >= t[d]) ++q;
            long long oldv(v);

            auto itr(days[t[d]].find(d));
            long long d1(*(--itr));
            itr = std::upper_bound(std::begin(days[t[d]]), std::end(days[t[d]]), d);
            long long d2((*itr)-1);
            v -= c[t[d]] * ((d1-d)*(d-d2) + d - d1);

            itr = std::lower_bound(std::begin(days[q]), std::end(days[q]), d);
            d1 = *(--itr);
            itr = std::upper_bound(std::begin(days[q]), std::end(days[q]), d);
            d2 = (*itr)-1;
            v += c[q] * ((d1-d)*(d-d2) + d - d1);

            v += s[d][q] - s[d][t[d]];
            if(oldv <= v){
                days[t[d]].erase(d);
                days[q].emplace(d);
                t[d] = q;
            }else{
                v = oldv;
            }
        }
    }
    for(int i(1); i <= D; ++i){
        std::cout << t[i] + 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f,g;
    cin>>a>>b>>c>>d;
    e=c-a;
    if(e<0)
        e=-e;
    f=b-a;
    if(f<0)
        f=-f;
    g=c-b;
    if(g<0)
        g=-g;
    if(e<=d)
        cout<<"Yes";
    else if(f<=d&&g<=d)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, w, c4, c2, c int
	fmt.Scan(&N)
	a := make([]int, int(N))
	for i := 0; i < int(N); i++ {
		fmt.Scan(&w)
		a[i] = w
		if w%4 == 0 {
			c4++
		} else if w%2 == 0 {
			c2++
		} else {
			c++
		}
	}
	if c4+1 == c && N == c4+c {
		fmt.Println("Yes")
		return
	}
	if c4 < c {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

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

int main(){
  int N,L;
  cin>>N>>L;
  int A[N];
  for(int i=0;i<N;i++){
    A[i]=L+i;
  }
  int sum=0;
  if(L>=0){
    for(int i=1;i<N;i++){
      sum+=A[i];
    }
  }else if(L<=-N){
    for(int i=0;i<N-1;i++){
      sum+=A[i];
    }
    }else{
      for(int i=0;i<N;i++){
        sum+=A[i];
      }
  }
  cout<<sum<<endl;
}
    

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInt();
            if (s < 1000) WriteLine("ABC");
            else WriteLine("ABD");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e15);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    int n,x,y;
    cin>>n>>x>>y;
    vi ans(n,0);--x;--y;
    f(i,0,n){
        f(j,i+1,n){
            int d=abs(x-i)+abs(y-j)+1;
            ans[min(d,j-i)]++;
        }
    }
    f(i,1,n)cout<<ans[i]<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BExchange {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int a = in.ints(), b = in.ints(), k = in.ints();
            for (int i = 0; i < k; i++) {
                if (i % 2 == 0) {
                    a /= 2;
                    b += a;
                } else {
                    b /= 2;
                    a += b;
                }
            }
            out.print(a);
            out.print(' ');
            out.println(b);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

int main(){
  string s; 
  cin >> s;
  string S = s;
  reverse(S.begin(), S.end());
  int N = (s.size()-1)/2;
  int n = (s.size()+3)/2;
  string a = s.substr(0,N);
  string A = a;
  reverse(A.begin(), A.end());
  string b = s.substr(n-1,N);
  string B = b;
  reverse(B.begin(), B.end());
  if(S == s & A == a & B == b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		int[] end = new int[n+1];
		end[1]++;
		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);

		while(!q.isEmpty()) {

			int v1 = q.poll();

			int tdist = dist[v1] + 1;

			Iterator<Integer> adjit = adj[v1].iterator();
			while(adjit.hasNext()) {
				int v2 = adjit.next();
				if(end[v2]<1) {
					q.add(v2);
					end[v2]++;

					dist[v2] = tdist;
					ans[v2] = v1;
				}
			}
		}

		System.out.println("Yes");
		for(int i = 2; i < n+1; i++) {
			System.out.println(ans[i]);
		}
	}

}


Measured memory_bytes: 97904
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);
        System.out.println(s.equals("ARC") ? "ABC" : "ARC");

    }

}


Measured memory_bytes: 32428
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (int i = 0; i < n; i++)
	{
		if (s.at(i) == 'R')
		{
			a++;
		}
		else
		{
			b++;
		}
	}
	if (a > b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 4/21
// Problem:/ / / a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s);
  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if (s[2] == 'o') ans += 100;

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	int maxn;
	maxn=max(a,b);
	maxn=max(maxn,c);
	if((3*maxn-a-b-c)%2==0)printf("%d\n",(3*maxn-a-b-c)/2);
	else printf("%d\n",(3*maxn-a-b-c)/2+2);
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());

            Set<Integer> s = new HashSet<>();

            s.add(a);
            s.add(b);
            s.add(c);

            if (s.size() == 2) out.println("Yes");
            else out.println("No");

        }

    }
}



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

using namespace std;

int main() {
	int num = 0;
	int cnt = 0;
	vector<int> forbiddenLs;

	cin >> num >> cnt;
	for(int i = 0; i < cnt; i++) {
		int p = 0;
		cin >> p;
		forbiddenLs.push_back(num - p);
	}

	if (cnt == 0) {
		cout << num << endl;
	} else {
		for(int i = 0; i <= 100; i++) {
			vector<int>::iterator itr;
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), i);
			if (itr == forbiddenLs.end()) {
				cout << num - i << endl;
				break;
			}
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), -i);
			if (itr == forbiddenLs.end()) {
				cout << num + i << endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3192
n = int(input())
num = n

fct = []
cur = 2
while cur * cur <= n:
    while n % cur == 0:
        n //= cur
        fct.append(cur)
    cur += 1
if n > 1:
    fct.append(n)

print(str(num) + ": " + ' '.join(str(f) for f in fct))



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  string s; cin >> s;
  if(s[2]==s[3] && s[4]== s[5]) cout << "Yes";
  else cout << "No";
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

typedef long long int ll;

ll n, a[114514], b[114514];

int main(void){
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	vector<pair<ll, ll> > v;
	for(int i=0;i<n;i++){
		v.pb(mp(b[i] + a[i], i));
	}
	sort(v.begin(), v.end());
	// for(int i=0;i<n;i++) cerr << v[i].first << " " << v[i].second << endl;
	vector<ll> sum(2);
	for(int i=0;i<n;i++){
		int idx = v[n-1-i].second;
		if (i%2){
			sum[1] += b[idx];
		}else{
			sum[0] += a[idx];
		}
	}
	cout << sum[0] - sum[1] << endl;

	


    return 0;
}


Measured memory_bytes: 3956
def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 9)
    
    H, W = list(map(int, input().split()))
    G = [list(input()) for i in range(H)]
    
    Visited = [[0] * W for i in range(H)]
    direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    
    
    def dfs(ny, nx, color):
        for dy, dx in direction:
            if not ((0 <= ny + dy < H) and (0 <= nx + dx < W)):
                continue
    
            if G[ny + dy][nx + dx] == G[ny][nx]:
                continue
    
            if Visited[ny + dy][nx + dx] != 0:
                continue
    
            if G[ny + dy][nx + dx] == '#':
                Visited[ny + dy][nx + dx] = color
            else:
                Visited[ny + dy][nx + dx] = -color
    
            dfs(ny + dy, nx + dx, color)
    
    
    Color = 1
    for y in range(H):
        for x in range(W):
            if Visited[y][x] == 0:
                if G[y][x] == '#':
                    Visited[y][x] = Color
                else:
                    Visited[y][x] = -Color
                dfs(y, x, Color)
                Color += 1
    
    D = defaultdict(int)
    for i in range(1, Color + 1):
        D[i] = 0
        D[-i] = 0
    
    for row in Visited:
        for data in row:
            D[data] += 1
    
    ans = 0
    for key in D.keys():
        ans += D[key] * D[-key]
    
    print(ans // 2)
    
main()


Measured memory_bytes: 186020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1,M1,H2,M2,K,time;
  cin>>H1>>M1>>H2>>M2>>K;
  time=H2*60+M2-H1*60-M1-K;
  cout<<time<<endl;
  
}

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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007

#define Yn(a) ((a)?"Yes":"No")
#define YN(a) ((a)?"YES":"NO")
#define yn(a) ((a)?"yes":"no")

/*
確認ポイント
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
YesNo大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main() { 
  int h,w,a,b;cin>>h>>w>>b>>a;
  int mp[h][w];
    for(int i = 0; h > i; i++){
      for(int j = 0; w > j; j++){
        if(a > i){
          mp[i][j] = 1;
        }else{
          mp[i][j] = 0;
        }
      }
    }
    for(int i = 0; w > i; i++){
      for(int j = 0; h > j; j++){
        if(b > i){
          mp[j][i] = (mp[j][i]+1)%2;
        }
      }
    }

  //output
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cout << mp[i][j];
    }
    cout << endl;
  }
}

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

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

int main()
{
    ll MOD = 2019;
    string s;
    cin >> s;
    ll cnt = 0;
    reverse(ALL(s));


    vector<int> mod_list(MOD);
    vector<int> memo(s.size()+2);
    memo[0] = 0;
    rep(i,s.size()){
        ll mod_i = ((s[i]-'0') * modpow(10, i, MOD) + memo[i] + MOD) % MOD;
        mod_list[mod_i]++;
        memo[i+1] = mod_i;
    }

    cnt += mod_list[0];
    rep(i,mod_list.size()){
        if(mod_list[i] >= 2) cnt += (mod_list[i]*(mod_list[i]-1))/2;
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

vector<long long int> DP;
vector<int> h;
long long int DP_function(int i){
	if(DP[i] == -1)
		DP[i] = min(abs(h[i + 2] - h[i]) + DP_function(i + 2), abs(h[i + 1] - h[i]) + DP_function(i + 1)); 
	
	return DP[i];
}

int main(){
	int N;
	cin >> N;

	h.resize(N);
	for(int index = 0; index < N; index++)
		cin >> h[index];

	DP.resize(N, -1);
	DP[N - 1] = 0;
	DP[N - 2] = abs(h[N - 1] - h[N - 2]);
	cout << DP_function(0);

	return 0;
}


Measured memory_bytes: 7680
//	C++ (Clang3.8.0)
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int a[3][3];
	int n;
	int *b;
	bool aF[3][3] = {false};
	
	for(int i=0; i<3; ++i){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	cin >> n;
	b = new int[n];
	for(int i=0; i<n; ++i){
		cin >> b[i];
	}
	
	for(int i=0; i<n; ++i){
		for(int j=0; j<3; ++j){
			for(int k=0; k<3; ++k){
				if(a[j][k] == b[i]){
					aF[j][k] = true;
					break;
				}
			}
		}
	}
	
	if(aF[0][0] && aF[1][1] && aF[2][2]){
		cout << "Yes";
	}else if(aF[0][2] && aF[1][1] && aF[2][0]){
		cout << "Yes";
	}else{
		for(int i=0; i<3; ++i){
			if((aF[i][0] && aF[i][1] && aF[i][2]) || (aF[0][i] && aF[1][i] && aF[2][i])){
				cout << "Yes";
				break;
			}else if(i == 2){
				cout << "No";
			}
		}
	}
	
	delete[] b;
	
	return 0;
}

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

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

    if(n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }else{
        rep(i, n/2) {
            if(s[i] != s[i+n/2]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
i = 1
ans = ''
while n != 0:
    if n % i == 0 and n % (i * -2) != 0:
        n -= i
        ans += '1'
    else:
        ans += '0'
    i *= -2
if ans == '':
  print(0)
else:
  print(ans[::-1])

Measured memory_bytes: 3060
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int n, a, b;
int h[100000];

bool can(int m){
	long k=0;
	for(int i=0; i<n; i++){
		if(h[i]>(long)m*b){
			k+=(h[i]-(long)m*b+a-1)/a;
		}
	}
	return k<=m;
}

int main(void){
	n=nextint();
	a=nextint();
	b=nextint();
	a=a-b;
	int m=0;
	for(int i=0; i<n; i++){
		h[i]=nextint();
		if(h[i]>m) m=h[i];
	}
	int l=0, r=m/b+1;
	while(l<=r){
		int m=(l+r)/2;
		if(can(m)) r=m-1; else l=m+1;
	}
	printf("%d\n", l);
}


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

float solve(vector<int> &vec, int x) {
  if(x == 0) {
    float t = (float)vec.at(vec.size() - 1);
    vec.pop_back();
    return t;
  }
  return (vec.at(vec.size() - x) + solve(vec, x - 1)) / 2.00;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  cout << solve(vec, n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

#define all(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)

using namespace std;
typedef long long ll;

/*class SAClass{
  public: string first;
  int second;
  bool operator <(const SAClass& SA2){
    if(SA2.first != first)return SA2.first < first;
    return SA2.second < second;
  }
  bool operator =(SAClass& SA2){
   SA2.first = first;
    SA2.second = second;
  }
  bool operator ==(const SAClass& SA2){
    return (SA2.first == first) && (SA2.second == second);
  }
};*/

int main() {
  int N;
  cin>>N;
  //SAClass *SA = new SAClass[N];
  //SAClass *SACopy = new SAClass[N];
  vector<pair<string,int> > SA(N);
  vector<pair<string,int> > SACopy(N);
  for(int i = 0;i < N;i++){
    cin>>SA[i].first>>SA[i].second;
    SA[i].second = -SA[i].second;
    SACopy[i] = SA[i];

  }
  
  sort(all(SA));
  
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      if(SA[i] == SACopy[j]){

        cout<<j+1<<endl;
        break;
      }
      
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int T;
	cin >> T;
	while (T>0) {
		if (T%10 == 7)
		{
			cout << "Yes" << endl;
			return 0;
		}
		T = T/10;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define all(v) (v).begin(),(v).end()
#define clr(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
template<class T>void chmin(T&a, const T&b)
{
   if(a > b)
      a = b;
}
template<class T>void chmax(T&a, const T&b)
{
   if(a < b)
      a = b;
}

int nxint()
{
   int x;
   scanf("%d", &x);
   return x;
}

int a[200005], b[200005];
int main()
{
   int m, n;
   while(cin >> n) {
      rep(i, n){
      cin >> a[i];
      b[i] = a[i];
      }
      sort(a, a + n);
      rep(i, n){
         if(b[i] < a[n / 2])
            cout << a[n / 2] << endl;
         else
            cout << a[n / 2 - 1] << endl;

      }


   }

   return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main() {
	int n, b, i, maxi=0, sum=0;
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> b;
		if (b > maxi) {
			maxi = b;
		}
		sum += b;
	}
	if (maxi < sum - maxi) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# 2019/09/06

n,m=map(int,input().split())
box=[[1,1,0]]+[[1,0,1] for _ in range(n-1)]

for i in range(m):
    x,y=map(int,input().split())
    x-=1;y-=1
    box[y][1]|=box[x][1]
    box[y][2]|=box[x][2]
    box[y][0]+=1
    box[x][0]-=1
    if box[x][0]==0:
        box[x]=[0,0,0]        

cnt=0
for c,r,w in box:
    if  not c:continue
    if r:
        cnt+=1
print(cnt)
    

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

using namespace std;

int main() {
	string s;
	int k;

	cin >> s >> k;

	int l = s.size();

	vector <string> subs;
	
	for (int i = 0; i < l; i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j <= l) {
				subs.push_back(s.substr(i, j));
			}
		}
	}

	sort(subs.begin(), subs.end());
	unique(subs.begin(), subs.end());

	cout << subs[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 1660
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39144
#include <stdio.h>

int main(void)
{
    int n, x;
    int a, b, c;
    int result = 0;
    int i;
    
    for(i = 0; ; i++) {
        scanf("%d %d", &n, &x);
        
        if(!(n | x)) {
            break;
        } 
        
        for(a = 1; a <= n - 2; a++) {
            for(b = a + 1; b <= n - 1; b++) {
                for(c = b + 1; c <= n; c++) {
                    if(a + b + c == x) {
                        result++;
                    }
                }
            }
        }
        
        printf("%d\n", result);
        result = 0;
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
int main(void)
{
	int a, b, c, min, max, total;

	scanf("%d %d %d", &a, &b, &c);
	total = a + b + c;
	if(a >= b && a >= c)
	{
		max = a;
	}
	else if(b >= c && b >= a)
	{
		max = b;
	}
	else
	{
		max = c;
	}
	if(a <= b && a <= c)
	{
		min = a;
	}
	else if(b <= c && b <= a)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, total - min - max, max);
	return 0; 
}


Measured memory_bytes: 2616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;

using namespace std;

const int MAXN = 1000500;
// const int MAXN = 1050;
// const long long int mod = 1000003;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

i64 mod = 1000000009;

i64 n, m, r;

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

	cout.precision(16);

	cin >> r;
	cout << 2 * r*PI << endl;


	//a.resize(n + 1);
	//dp.assign(n + 1, -1);	

	return 0;
}

Measured memory_bytes: 3256
n=int(input())
s=input()
from itertools import product

cnt=0
for i,j in product("0123456789",repeat=2):
    try:
        ind_i=s.index(i)
    except:
        continue
    try:
        ind_j=s.rindex(j)
    except:
        continue
    if ind_i>ind_j:
        continue
    for k in "0123456789":
        cnt+=(k in s[ind_i+1:ind_j])
        
print(cnt)

Measured memory_bytes: 66872
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	string s; cin >> s;
	if (s == "ABC") dunk("ARC");
	else if (s == "ARC") dunk("ABC");
	return 0;
}


Measured memory_bytes: 3592
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll dp[107][107];
int solve() 
{
	//happy coding

		
	int n,m;
	cin>>n>>m;
	ll a[n+1],b[n+1];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll dp[n+1][m+1];
	memset(dp,0,sizeof dp);

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j<a[i-1]) dp[i][j] = dp[i-1][j];
			else {
				//cout<<dp[i-1][j-a[i-1]]+b[i-1]<<endl;
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
			}
		}
	}
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	cout<<dp[n][m]<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 79104
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    k--;
    vector<int> a(n);
    int p = -1;
    rep(i,n){
        cin >> a[i];
        if(a[i] == 1) p = i;
    }
    int ans = 0;
    for(int i = 0; i < n; i+=k){
        if(i >= p){
            p = i;
            break;
        }
        ans++;
    }
    for(int i = p; i < n-1; i+=k){
        ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

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

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	auto A=vecin(N);

	REP(i,N){
		if(A[i]==0){
			out(0);
			return 0;
		}
	}

	ll S=1;
	REP(i,N){
		if(S<=(1000000000000000000ll/A[i])){
			S *= A[i];
		}
		else{
			out(-1);
			return 0;
		}
	}
	out(S);
	return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    ll x;
    cin >> x;
    ll ans;
    if(x<=6) ans = 1;
    else if(x<=11) ans = 2;
    else{
        ans = (x/11)*2;
        x%11 <= 6 ? ans++ : ans+=2;
        if(x%11 == 0) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>

int main(void)
{
	int n,m;
	int i,j,flag;
	int taro[100],hanako[100];
	int set,set1,set2;
	int sum=0,sum_taro,sum_hanako;
	
	
	for(;;)
	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0) break;
		
		set=200,flag=0,sum=0,sum_taro=0,sum_hanako=0;
		for(i=0; i<100; i++)
		{
			taro[i]=0;
			hanako[i]=0;
		}
		
		for(i=0; i<n; i++)
		{
			scanf("%d", &taro[i]); //太郎の点数取り込み
			sum_taro+=taro[i];
		}
		for(i=0; i<m; i++)
		{
			scanf("%d",&hanako[i]); //花子の点数取り込み
			sum_hanako+=hanako[i];
		}
		
		for(i=0; i<n; i++)
		{
			for(j=0; j<m; j++)
			{
				if(sum_taro-taro[i]+hanako[j]==sum_hanako-hanako[j]+taro[i])
				{
					if(taro[i]+hanako[j]<=set)
					{
						set=taro[i]+hanako[j];
						set1=i,set2=j;
					}
					flag=1;
				}
			}
			if(flag==1)
			{
				break;
			}
		}
		if(flag==1) printf("%d %d\n",taro[set1],hanako[set2]);
		if(i==n && j==m) printf("-1\n");
	}
	
	return 0;
}

Measured memory_bytes: 1040
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 5e3 + 7;
const ll HA = 1e9 + 7;

int n, size[MAXN];
std::vector<int> E[MAXN];
ll f[MAXN][MAXN], g[MAXN], tmp[MAXN];

void dfs(int u, int pre) {
	size[u] = f[u][1] = 1;
	for (auto v: E[u]) {
		if (v == pre) continue;
		dfs(v, u);
		rep(i, 0, size[u] + size[v]) tmp[i] = 0;
		rep(i, 0, size[u]) rep(j, 0, size[v]) tmp[i + j] = (tmp[i + j] + f[u][i] * f[v][j] % HA) % HA;
		rep(i, 0, size[u] + size[v]) f[u][i] = tmp[i];
		size[u] += size[v];
	}
	for (int i = 2; i <= size[u]; i += 2) f[u][0] = (f[u][0] + HA - f[u][i] * g[i] % HA) % HA;
}

int main() {
	scanf("%d", &n);
	int u, v;
	rep(i, 1, n - 1) scanf("%d %d", &u, &v), E[u].pb(v), E[v].pb(u);
	g[0] = 1;
	for (int i = 2; i <= n; i += 2) g[i] = (g[i - 2] * (i - 1)) % HA;
	dfs(1, 0);
	printf("%lld\n", HA - f[1][0]);
	return 0;
}

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

const int p = 1e9 + 7;

int qpow(int x, int n)
{
    int ret = 1;
    while (n)
    {
        if (n & 1)
        {
            ret = 1ll * ret * x % p;
        }
        x = 1ll * x * x % p;
        n /= 2;
    }
    return ret;
}

int main()
{
    int n;
    std::cin >> n;
    if (n == 1)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << ((qpow(10, n) + qpow(8, n)) % p + p - 2ll * qpow(9, n) % p) % p << std::endl;
    return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#define waru 1000000000+7

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int now = 1;
    if((b-1)%(a-1) == 0)    { cout << (b-1)/(a-1);}
    else{
        cout << ((b-1)/(a-1))+1;
    }
}

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

using namespace std;

using ll = long long;

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

    int h, w;
    cin >> h >> w;
    vector<string> a(h + 2, string(w + 2, '#'));
    for (int i = 0; i < h; ++i) {
        string s; cin >> s;
        a[i + 1].replace(1, w, s);
    }

    for (const auto &r : a) cout << r << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b, m;
    cin >> a >> b >> m;
    vi aa(a);
    vi bb(b);
    int ma = INF;
    int mb = INF;
    REP(i, a) {
        cin >> aa[i];
        chmin(ma, aa[i]);
    }
    REP(i, b) {
        cin >> bb[i];
        chmin(mb, bb[i]);
    }
    int ans = ma + mb;
    int x;
    int y;
    int c;
    REP(i, m) {
        cin >> x >> y >> c;
        x--; y--;
        chmin(ans, aa[x] + bb[y] - c);
    }
    cout << ans << endl;
}


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

int main(void){
    // Your code here!
    int n;
    int output = 0;
    
    cin >> n;
    for(int i = 1; i <= n; i+=2){
        int count = 0;
        for(int j = 1; j <= i; j++)
            if(i % j == 0)
                count++;
        if(count == 8)
            output++;
    }
    
    cout << output << endl;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]

r0 = int(N/K) # 余りが0のケースの数

r2 = 0
if K%2==0: # 偶数のときのみ可能性あり
    K2 = int(K/2) # このあまりにならなくてはいけない
    r2 = int(N/K2)
    r2 -= r0

result = r0*r0*r0 + r2*r2*r2
print(result)

Measured memory_bytes: 2940