akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'
#define print(vec,l,r) for(int i = (l); i < (r); i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (b)-1; i >= (a); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	string s, t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	int minn = INT_MAX;
	for(int i=0; i<=n-m; i++)
	{
		int temp = 0;
		for(int j=0; j<m; j++)
		{
			if(t[j] != s[i+j]) temp++;
		}
		minn = min(temp, minn);
	}
	cout<<minn<<nl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3644
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(input())

    year = 0
    money = 100

    while money < x:
        money *= 1.01
        money = int(money)
        year += 1

    print(year)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63476
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

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

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

int main()
{
	int n;
	cin >> n;
	ll ans = 1LL;
	REP(i, n) {
		ll t;
		cin >> t;
		ans = lcm(ans, t); //一つずつ取っていく
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
F = True

if 0 in A:
  print(0)
else:
  prod = 1
  for i in A:
    prod *= i
    if prod>10**18:
      print(-1)
      F = False
      break
  if F:
  	print(prod)

Measured memory_bytes: 21544
import Data.List
main = interact $ unlines . map (card_game . map read . words) . lines
card_game [c1,c2,c3]
 | (length $ takeWhile (<= 20-(c1+c2)) ([1..10]\\[c1,c2,c3])) >= 4 = "YES"
 | otherwise = "NO"

Measured memory_bytes: 3972
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

map<string,string> A, B;
map<string,string> rA, rB;

void init() {
  A["00000"] = "A";
  A["00001"] = "B";
  A["00010"] = "C";
  A["00011"] = "D";
  A["00100"] = "E";
  A["00101"] = "F";
  A["00110"] = "G";
  A["00111"] = "H";
  A["01000"] = "I";
  A["01001"] = "J";
  A["01010"] = "K";
  A["01011"] = "L";
  A["01100"] = "M";
  A["01101"] = "N";
  A["01110"] = "O";
  A["01111"] = "P";
  A["10000"] = "Q";
  A["10001"] = "R";
  A["10010"] = "S";
  A["10011"] = "T";
  A["10100"] = "U";
  A["10101"] = "V";
  A["10110"] = "W";
  A["10111"] = "X";
  A["11000"] = "Y";
  A["11001"] = "Z";
  A["11010"] = " ";
  A["11011"] = ".";
  A["11100"] = ",";
  A["11101"] = "-";
  A["11110"] = "'";
  A["11111"] = "?";
  for(map<string,string>::iterator it = A.begin();
      it != A.end(); ++it) {
    rA[it->second] = it->first;
  }

  B[" "] = "101";
  B["'"] = "000000";
  B[","] = "000011";
  B["-"] = "10010001";
  B["."] = "010001";
  B["?"] = "000001";
  B["A"] = "100101";
  B["B"] = "10011010";
  B["C"] = "0101";
  B["D"] = "0001";
  B["E"] = "110";
  B["F"] = "01001";
  B["G"] = "10011011";
  B["H"] = "010000";
  B["I"] = "0111";
  B["J"] = "10011000";
  B["K"] = "0110";
  B["L"] = "00100";
  B["M"] = "10011001";
  B["N"] = "10011110";
  B["O"] = "00101";
  B["P"] = "111";
  B["Q"] = "10011111";
  B["R"] = "1000";
  B["S"] = "00110";
  B["T"] = "00111";
  B["U"] = "10011100";
  B["V"] = "10011101";
  B["W"] = "000010";
  B["X"] = "10010010";
  B["Y"] = "10010011";
  B["Z"] = "10010000";
  for(map<string,string>::iterator it = B.begin();
      it != B.end(); ++it) {
    rB[it->second] = it->first;
  }
}

int main() {
  init();
  string s;
  while(getline(cin, s)) {
    string t, u;
    for(int i = 0; i < s.size(); ++i) {
      t += rA[string(1,s[i])];
    }
    int i = 0;
    for(; i < t.size(); ) {
      bool update = false;
      for(int j = 1; i+j <= t.size(); ++j) {
        string m = t.substr(i, j);
        if(rB.count(m)) {
          u += rB[m];
          i += j;
          update = true;
          break;
        }
      }
      if(!update) break;
    }
    cout << u << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

int main(void){
	int a,b,c,cmp;
	
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		cmp=a;
		a=b;
		b=cmp;
	}if(a>c){
		cmp=c;
		c=a;
		a=cmp;
	}if(b>c){
		cmp=b;
		b=c;
		c=cmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2140
/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/


#include <bits/stdc++.h>
using namespace std;


int main()
{
    long k, n;
    cin >> k >> n;
    vector<long> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    long maxd = 0;
    for (int i = 0; i < n-1; i++)
        maxd = max(maxd, v[i+1] - v[i]);
    maxd = max(maxd, (k + v[0]) - v[n-1]);
    cout << k - maxd;

    return 0;
}


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

int n;
long long fp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		if(i % 5 && i % 3) fp += i;
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    h: usize,
    w: usize,
    fld: [chars; h]
  }
  let modulo = 1_000_000_007;
  let mut dp = vec![vec![0i64; w]; 2];
  dp[0][0] = 1;
  for i in 0..h {
    for j in 0..w {
      dp[i % 2][j] = if (i, j) == (0, 0) { 1 } else { 0 };
      if fld[i][j] == '.' {
        if i >= 1 {
          dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j]) % modulo;
        }
        if j >= 1 {
          dp[i % 2][j] = (dp[i % 2][j] + dp[i % 2][j - 1]) % modulo;
        }
      }
    }
  }
  println!("{}", dp[(h - 1) % 2][w - 1]);
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;
void count(vector<int>& table, string str){
    for(int i = 0; i < str.size(); ++i){
        int lower = tolower((int)str[i]);
        if(islower(lower)){
            table[lower] += 1;
        }
    }
}
int main()
{
    vector<int> table(256, 0);
    string s;
    while(getline(cin, s)){
        count(table, s);
    }
    for(int i = 'a'; i <= 'z'; ++i){
        char c = i;
        int n = table[i];
        cout << c << " : " << n << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
int d[200050], t[200050];
int main()
{
	int n, m;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", d + i);
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
		scanf("%d", t + i);
	sort(d, d + n);
	sort(t, t + m);
	bool flag = true;
	int j = 0;
	for (int i = 0; i < m; i++)
	{
		if (j >= n) { flag = false; break; }
		if (t[i] == d[j])
			j++;
		else
		{
			if (t[i] < d[j]) { flag = false; break; }
			j++; i--;
		}
	}
	if (flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	//system("pause");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const int MOD=1e9+7;
int power(int x, int y, int p=MOD)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res%p;  
}  

int phi(int n) 
{ 
    float result = n; // Initialize result as n 
  
    // Consider all prime factors of n and for every prime 
    // factor p, multiply result with (1 - 1/p) 
    for (int p = 2; p * p <= n; ++p) { 
          
        // Check if p is a prime factor. 
        if (n % p == 0) { 
              
            // If yes, then update n and result 
            while (n % p == 0) 
                n /= p; 
            result *= (1.0 - (1.0 / (float)p)); 
        } 
    } 
  
    // If n has a prime factor greater than sqrt(n) 
    // (There can be at-most one such prime factor) 
    if (n > 1) 
        result *= (1.0 - (1.0 / (float)n)); 
  
    return (int)result; 
}

signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    int sum1=0,count1=0;
    
    cin>>n>>k;
    //MOD = 1e9+7;
   
    //cout<<ans<<endl;
    for(i=1;i<=k;i++)
    {
        temp = k/i;
        count = power(temp,n);
        temp = phi(i);
        count1 = temp*count;
        count1=count1%MOD;
        ans+=count1;
        ans=ans%MOD;
        
        
    }
    
    
    cout<<ans<<endl;
        
    
}

Measured memory_bytes: 3652
#include <iostream>
#include <set>

struct medianset {
	std::multiset<long long> left;
	std::multiset<long long> right;
	long long left_sum;
	long long right_sum;

	medianset() {left_sum = right_sum = 0;}

	void balance() {
		if (left.size() == right.size() + 2) {
			right.insert(*left.rbegin());
			left.erase(--left.end());
			right_sum += *right.begin();
			left_sum -= *right.begin();
		}
		if (left.size() + 1 == right.size()) {
			left.insert(*right.begin());
			right.erase(right.begin());
			left_sum += *left.rbegin();
			right_sum -= *left.rbegin();;
		}
	}

	void insert(long long x) {
		if (left.empty()) {
			left.insert(x);
			left_sum += x;
			return;
		}
		if (x <= *left.rbegin()) {
			left.insert(x);
			left_sum += x;
		} else {
			right.insert(x);
			right_sum += x;
		}
		balance();
	}

	// return false : erasure failed
	bool erase(long long x) {
		auto itr1 = left.end();
		auto itr2 = right.end();
		if (x <= *left.rbegin()) itr1 = left.find(x);
		if (*right.begin() <= x) itr2 = right.find(x);
		if (itr2 != right.end()) {
			right.erase(itr2);
			right_sum -= x;
		} else if (itr1 != left.end()) {
			left.erase(itr1);
			left_sum -= x;
		}
		else return false;
		balance();
		return true;
	}

	std::pair<long long, long long> get_median() {
		if (right.empty()) return {*left.rbegin(), *left.rbegin()};
		else return {*left.rbegin(), *right.begin()};
	}
};

int main() {
	long long q;
	std::cin >> q;
	medianset st;
	long long sum = 0;
	while (q--) {
		long long x;
		std::cin >> x;
		if (x == 1) {
			long long a, b;
			std::cin >> a >> b;
			st.insert(a);
			sum += b;
		} else {
			x = st.get_median().first;
			std::cout << x << ' ';
			std::cout << x * (long long)st.left.size() - st.left_sum + st.right_sum - x * (long long)st.right.size() + sum << '\n';
		}
	}
}

Measured memory_bytes: 12968
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
ll n;

ll cur[13];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	n = s.size();
	cur[0] = 1;
	for (ll i = 0; i < n; i++) {
		ll kek[13];
		fill_n(kek, 13, 0);
		if (s[i] != '?') {
			ll t = s[i] - '0';
			for (ll j = 0; j < 13; j++) {
				kek[(10 * j + t) % 13] = cur[j];
			}
		}
		else {
			for (ll j = 0; j < 13; j++) {
				for (ll t = 0; t < 10; t++) {
					kek[(j*10 + t)%13] += cur[j]; kek[(j*10+t)%13] %= mod;
				}
			}
		}
		for (ll j = 0; j < 13; j++) cur[j] = kek[j];
	}
	cout << cur[5] << endl;
	return 0;
}
/*

*/

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
ll ai, bi, ci;
string a, b, c;
ll v[LIM];
char solve(char ch) {
  char nch;
  if (ch == 'a') {
    if (ai == a.size()) {
      return 'A';
    }
    nch = a[ai];
    ai++;
  } else if (ch == 'b') {
    if (bi == b.size()) {
      return 'B';
    }
    nch = b[bi];
    bi++;
 } else if (ch == 'c') {
    if (ci == c.size()) {
      return 'C';
    }
    nch = c[ci];
    ci++;
  }
  return solve(nch);
}
int main() {
  cin >> a >> b >> c;
  cout << solve('a') << endl;
  return 0;
}


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

int main(){
  long H,atk=1,cnt=1,i,p;
  cin >> H;
  while(H!=1){
    H = H/2;
    cnt++;
  }
  for(i=1;i<cnt;i++){
      p = pow(2,i);
      atk += p;
    }
  cout << atk;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}



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

int main() {
    string N;
    cin >> N;
    if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#pragma warning(disable:4996)

using namespace std;



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

	long long n, m, i, j, k, s, x;
	cin >> n >> m;
	s = 0;
	while (m--) {
		cin >> x;
		s += x;
	}

	if (s > n) cout << "-1\n";
	else cout << n - s << "\n";

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    printf("%.12f %d",double(w) * double(h) / 2,x * 2 == w && y * 2 == h);
}


Measured memory_bytes: 3744
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, w;
		int[] prime, weigh;
		String[] sp;
		int[][] dp;
		int[][] dpW;
		int cnt = 0;
		while((w = sc.nextInt()) != 0){
			cnt++;
			n = sc.nextInt();
			prime = new int[n + 1];
			weigh = new int[n + 1];
			for(int i = 1; i <= n; i++){
				sp = sc.next().split(",");
				prime[i] = Integer.parseInt(sp[0]);
				weigh[i] = Integer.parseInt(sp[1]);
			}

			dp = new int[w + 1][n + 1];
			dpW = new int[w + 1][n + 1];
			for(int i = 1; i <= w; i++){
				for(int j = 1; j <= n; j++){
					if(i < weigh[j]){
						dp[i][j] = dp[i][j - 1];
						dpW[i][j] = dpW[i][j - 1];

					//ツつ「ツづェツづ按つ「ツ陛サツつェツ可ソツ値ツつェツ債つつ「ツづつォ
					}else if(prime[j] + dp[i - weigh[j]][j - 1] < dp[i][j - 1]){
						dp[i][j] = dp[i][j - 1];
						dpW[i][j] = dpW[i][j - 1];

					//ツ禿シツづェツつスツ陛サツつェツ可ソツ値ツつェツつスツつゥツつュツづ按づゥツづつォ
					}else{
						dp[i][j] = prime[j] + dp[i - weigh[j]][j - 1];
						dpW[i][j] = weigh[j] + dpW[i - weigh[j]][j - 1];
					}
				}
			}

			System.out.println("Case " + cnt + ":");
			System.out.println(dp[w][n]);
			System.out.println(dpW[w][n]);

		}
	}
}

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

int main()
{
  long long ans=1e15;
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int &i:v) cin>>i;
  for(int i=0;i+k-1<n;i++)
  {
  	//cout<<i<<"\n";
    long long a1,a2;
    //indirect way to cal the direct
    a1 = abs(v[i])+abs(v[i+k-1]-v[i]);
    a2 = abs(v[i+k-1])+abs(v[i+k-1]-v[i]);
    ans = min(ans,min(a1,a2));
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    int copy = n;
    vector<int> prime;
    int cnt = 2;
    map<int, int> mp;
    while (cnt * cnt <= copy)
    {
        if(copy%cnt==0){
            copy /= cnt;
            prime.push_back(cnt);
            mp[cnt]++;
        }
        else{
            cnt++;
        }
    }
    if(copy!=1){
        prime.push_back(copy);
        mp[copy]++;
    }
    //show(prime);
    int ans = 0;
    for (auto &u : mp)
    {
        int x = 2 * u.second;
        int l = 0;
        int r = 1e9;
        while(l+1<r){
            int c = (l + r) / 2;
            if (c * (c+1) <= x){
                l = c;
            }
            else{
                r = c;
            }
        }
        //cerr << l << " "<<x<<endl;
        ans += l;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  char dif='A'-'a';
  A.at(0)+=dif;
  B.at(0)+=dif;
  C.at(0)+=dif;
  cout << A.at(0) << B.at(0) << C.at(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int H, W; cin>>H>>W;
  int h, w; cin>>h>>w;

  int white=H*W;
  cout<<white-W*h-H*w+h*w<<endl; 

  return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >>c;
    vector<ll> r(c);
    vector<ll> p(a);
    vector<ll> q(b);
    rep(i,0,a) cin >> p[i];
    rep(i,0,b) cin >> q[i];
    rep(i,0,c) cin >> r[i];
    sort(all(p),greater<ll>());
    sort(all(q),greater<ll>());
    rep(i,0,x) r.push_back(p[i]);
    rep(i,0,y) r.push_back(q[i]);
    ll ans = 0;
    sort(all(r),greater<ll>());
    rep(i,0,x+y) ans += r[i];
    cout << ans << endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, k; std::cin >> n >> k;
  std::vector< lint > a(n); std::cin >> a;
  lint ans = 0;
  rep(i,0,n-1) {
    lint& x = a.at(i);
    lint& y = a.at(i+1);
    if (x+y <= k) continue;
    lint now = x+y-k;
    y -= std::min(y, now);
    ans += now;
  }
  // debug(a);
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  
  int maxcount=0;
  for(auto x:mp){
    maxcount=max(maxcount,x.second);
  }
  
  vector<string> ans;
  for(auto x:mp){
    if(x.second==maxcount){
      ans.push_back(x.first);
    }
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 27180
import java.util.*;
public class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	long a,b;
	while(stdIn.hasNextInt()){
	    a = stdIn.nextInt();
	    b = stdIn.nextInt();
	    System.out.printf("%d %d\n",GCD(a , b),LCM(a , b));
	}
    }
    public static long GCD(long a,long b){
	if(b == 0) return a;
	else return GCD(b , a % b);
    }
    public static long LCM(long a,long b){
	return a*b / GCD(a , b);
    }
}

Measured memory_bytes: 18140
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int sum = 0;
    int squareSum = 0;
    for(int i = 0; i < N; i++){
      a[i] = sc.nextInt();
      sum += a[i];
      squareSum += a[i] * a[i];
    }
    long x = Math.round(sum / (double)N);
    
    System.out.println(N*x*x-2*x*sum+squareSum);
  }
}

Measured memory_bytes: 23764
n = list(input())
if len(n) % 2 != 0:
         print("No")
         exit()
for i in range(len(n)):
         if i % 2 == 0:
                  if n[i] != "h":
                           print("No")
                           exit()
         elif i % 2 == 1:
                  if n[i] != "i":
                           print("No")
                           exit()
print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 4e5 + 10;
const int M = (int) 1e6 + 10;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

ll n, a, b, c, d;

void gg(int x) {
    puts(x ? "NO" : "YES");
    exit(0);
}

int main() {
    #define fn "euler"
    #ifdef witch                                                            
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(fn".in", "r", stdin);
        //freopen(fn".out", "w", stdout);
    #endif      
    cin >> n >> a >> b >> c >> d;
    ll lo = a, hi = a;
    for (int i = 1; i < n; i++) {
        lo -= d;
    }
    for (int i = 1; i < n; i++) {
        hi += d;
    }
    if (!(lo <= b && b <= hi)) gg(1);
    //cout<<"h\n";
    ll step = (n - 1) * (d - c);
    ll TMP = 2 * c - (n - 2) * (d - c);
    if (TMP < 0) {
        gg(0);
    }
    TMP += step;
    ll which = (b - lo) / TMP;
    for (ll i = max(0ll, which - 1); i <= which + 1; i++) {
        ll cur_lo = lo + i * TMP;
        if (cur_lo <= b && b <= cur_lo + step) {
            gg(0);
        }
    }
    gg(1);
    cout << step << " " << TMP << endl;
    vector<ll> pos = {a};
    for (int i = 2; i <= n; i++) {
        vector<ll> go;
        for (auto it : pos) {
            for (int diff = c; diff <= d; diff++) {
                go.pb(it - diff);
                go.pb(it + diff);
            }
        }
        sort(all(go));
        go.resize(unique(all(go)) - go.begin());
        pos = go;
    }
    cout << "\n";
    for (int i=0;i<sz(pos);){
        int j=i;
        cout<<"[";
        while(j<sz(pos)&&pos[j]==pos[i]+(j-i)) {
            cout<<pos[j]<<",";
            j++;
        }
        cout<<"] = ";
        cout<<pos[j-1]-pos[i]<<" and ";
        if(j==sz(pos))break;
        cout<<pos[j]-pos[i]-(pos[j-1]-pos[i])<<"\n";
        i=j;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();

    let mut white_count: usize = 0;
    let mut map: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let line: Vec<char> = iterator.next().unwrap().chars().collect();
        white_count += line.iter().filter(|c| **c == '.').count();
        map.push(line);
    }

    const INF: usize = 100000;
    let di: Vec<isize> = vec![-1, 1, 0, 0];
    let dj: Vec<isize> = vec![0, 0, -1, 1];

    let mut d: Vec<Vec<usize>> = vec![vec![INF; w]; h];
    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    q.push_back((0, 0));
    d[0][0] = 1;
    while !q.is_empty() {
        let current = q.pop_front().unwrap();
        let ci = current.0;
        let cj = current.1;

        for direction in 0..4 {
            let ni = ci as isize + di[direction];
            let nj = cj as isize + dj[direction];
            if ni < 0 || nj < 0 || ni as usize >= h || nj as usize >= w {
                continue;
            }
            if map[ni as usize][nj as usize] == '#' || d[ni as usize][nj as usize] != INF {
                continue;
            }
            q.push_back((ni as usize, nj as usize));
            d[ni as usize][nj as usize] = d[ci][cj] + 1;
        }
    }

    if d[h - 1][w - 1] == INF {
        return "-1".to_string();
    }
    let ans = white_count - d[h - 1][w - 1];
    return ans.to_string();
}


Measured memory_bytes: 4352
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
char C[3][3];
int main() {

	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>C[i][j];
			if(i==j)cout<<C[i][j];
		}
	}




	cout<<endl;
	return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			bool[] p = Enumerable.Repeat(true, 1000000).ToArray();
			p[0] = p[1] = false;
			for (int i = 2; i < Math.Sqrt(p.Length); i++)
				if (p[i])
					for (int j = i * 2; j < p.Length; j++)
						if (j % i == 0)
							p[j] = false;
			var str = "";
			while ((str = Console.ReadLine()) != null)
			{
				var n = int.Parse(str) + 1;
				int count = 0;
				while (n-- != 0)
					if (p[n])
						count++;
				Console.WriteLine(count);
			}
		}
	}
}

Measured memory_bytes: 8320
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

typedef long long ll;

using namespace std;

int a[100005];
int c[100005];

int main(){
    int n;

    cin >> n;
    
    a[0] = a[n+1] = 0;

    ll sum = 0;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i-1]);
    }
    sum += abs(a[n]);
    
    for(int i = 1; i <= n; i++){
        cout << sum + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i] - a[i+1]) << endl;
    }

    return 0;
}

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] NK = Read(Console.ReadLine());
            int N = NK[0];
            int K = NK[1];

            //if(M == 0)
            //{
            //    Console.WriteLine(Stair(N));
            //    return;
            //}
            int ans = 0;

            if (K != 1) ans = N - K;
                Console.WriteLine(ans);
        }

        private static long Stair(int N)
        {
            if (N < 0) return 0;
            int twoM = N / 2;
            long ans = 0;
            for (int two = 0; two < twoM+1; two++)
            {
                int one = N - 2 * two;
                ans += Combination(one + two,two);
            }
            return ans;
        }

        private static long Combination(int N,int M)
        {
            
            long ans = Product(N) / (Product(M) * Product(N - M));
            return ans;

        }

        private static long Product(int N)
        {
            if (N == 0||N ==1) return 1;
            long ans = N;
            for (int i = 1; i < N; i++)
            {
                ans *= i;
            }
            return ans;
        }





        private static string ReplaceOneChar(string S ,int index,string newS)
        {
            string s1 = S.Substring(0, index-1);
            string s2 = S.Substring(index);
            return s1 + newS + s2;
        }

        private static int[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            int num = inputs.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(inputs[i]);
            }
            
            return ints;
        }


    }


}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    typedef pair<int,int> P;
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    int h,w;
    REP(i,H){
        cin>>S[i];
        REP(j,W) if(S[i][j]=='.'){
            h=i;w=j;
        }
    }
    int ans=0;
    int dx[4]={-1,1,0,0},dy[4]={0,0,1,-1};
    vector<vector<bool>> used(H,vector<bool>(W,false));
    REP(hoge,20){
        vector<vector<int>> d(H,vector<int> (W,-1));
        queue<P> que;
        que.push(P(h,w));
        d[h][w]=0;
        used[h][w]=true;
        while(!que.empty()){
            P p=que.front();que.pop();
            int x=p.first,y=p.second;
            REP(j,4){
                int nx=x+dx[j],ny=y+dy[j];
                if(0<=nx&&nx<H&&0<=ny&&ny<W&&S[nx][ny]=='.'&&d[nx][ny]==-1){
                    que.push(P(nx,ny)); d[nx][ny]=d[x][y]+1;
                    ans=max(ans,d[nx][ny]);
                    if(!used[nx][ny]){
                        h=nx;w=ny;
                    }
                }
            }
            
        }
    }
    std::cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
map<char, int> word;
string eng = " \',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string to_b(int a) {
	string ret;
	for(int i = 0; i < 5; i++) {
		ret += (bool)(a & 1 << (4 - i)) + '0';
	}
	return ret;
}
int main() {
	for(int i = 'A'; i <= 'Z'; i++) {
		word[i] = i - 'A';
	}
	word[' '] = 26;
	word['.'] = 27;
	word[','] = 28;
	word['-'] = 29;
	word['\''] = 30;
	word['?'] = 31;
	string f[32] = {
		"101", "000000", "000011", "10010001", "010001", "000001","100101",
		"10011010", "0101", "0001", "110", "01001", "10011011", "010000",
		"0111", "10011000", "0110", "00100", "10011001", "10011110", "00101",
		"111", "10011111", "1000", "00110", "00111", "10011100", "10011101",
		"000010", "10010010", "10010011", "10010000"
	};
	string str;
	while(getline(cin,str)) {
		string ret,ans;
		for(int i = 0; i < str.size(); i++) {
			ret += to_b(word[str[i]]);
		}
		for(int j = 3; j < 9; j++) {
			for(int i = 0; i < 32; i++) {
				if(f[i].size() != j) continue;
				if(ret.substr(0, j) != f[i]) continue;
				ret = ret.substr(j);
				ans += eng[i];
				j = 2;
				i = -1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)

A = -1
for i in range(N):
    if S[i] == "A":
        A = i
        break
Z = -1
for i in reversed(range(N)):
    if S[i] == "Z":
        Z = i
        break
print(Z-A+1)


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


int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> ab(n),cd(n);
  for(int i=0;i<n;++i){
    int a,b;
    cin >> a >> b;
    ab[i]=make_pair(b,a);
  }
  for(int i=0;i<n;++i){
    int c,d;
    cin >> c >> d;
    cd[i]=make_pair(c,d);
  }
  sort(ab.begin(),ab.end(),greater<pair<int,int>>());
  sort(cd.begin(),cd.end());

  vector<bool> f(n,false);
  int cnt=0;

  for(int i=0;i<n;++i){
    int c=cd[i].first;
    int d=cd[i].second;
    for(int j=0;j<n;++j){
      int b=ab[j].first;
      int a=ab[j].second;
      if(f[j])continue;
      if(a<c && b<d){
        f[j]=true;
        cnt++;
        break;
      }
    }
  }
  //int cnt=0;
  //for(int i=0;i<n;++i)if(f[i])cnt++;

  cout << cnt << endl;
  return 0;

}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[1010],b[1010],c[1010];
int main(){
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++)cin>>a[i];
	for(int i=0;i<y;i++)cin>>b[i];
	for(int i=0;i<z;i++)cin>>c[i];
	vector<ll>v,w;
	for(int i=0;i<x;i++)for(int j=0;j<y;j++)v.push_back(-(a[i]+b[j]));
	sort(v.begin(),v.end());
	for(int i=0;i<min(x*y,k);i++)for(int j=0;j<z;j++)w.push_back(-(-v[i]+c[j]));
	sort(w.begin(),w.end());
	for(int i=0;i<k;i++)cout<<-w[i]<<endl;
	return 0;
}


Measured memory_bytes: 44104
N,M = map(int, raw_input().split())
MOD = 10**9+7

F = [0]*100100
F[0] = 1
for i in range(1,100100):
  F[i] = i*F[i-1]%MOD

ans = 1
d = 2
while M>1:
  c = 0
  while M%d==0:
    M /= d
    c += 1
  if c>0:
    ans *= F[N+c-1]
    ans %= MOD
    ans *= pow(F[N-1], MOD-2, MOD)
    ans %= MOD
    ans *= pow(F[c], MOD-2, MOD)
    ans %= MOD
  d += 1
  if d*d>M:
    d = M

print ans


Measured memory_bytes: 9092
#include<stdio.h>

int main()
{
	int N;
	char S[13],H[13],C[13],D[13];
	char e;
	int i,num;
	for(i=0;i<13;i++)
	{
		S[i]=0;H[i]=0;C[i]=0;D[i]=0;
	}
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf(" %c %d",&e,&num);
		if(e=='S')S[num-1]=1;
		else if(e=='H')H[num-1]=1;
		else if(e=='C')C[num-1]=1;
		else if(e=='D')D[num-1]=1;
	}
	for(i=0;i<13;i++)
	{
		if(S[i]==0)printf("S %d\n",i+1);
	}
	for(i=0;i<13;i++)
	{
		if(H[i]==0)printf("H %d\n",i+1);
	}
	for(i=0;i<13;i++)
	{
		if(C[i]==0)printf("C %d\n",i+1);
	}
	for(i=0;i<13;i++)
	{
		if(D[i]==0)printf("D %d\n",i+1);
	}	
	return 0;
}

Measured memory_bytes: 596
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int K;
  cin >> K;
  string S;

  cin >> S;

  if (K >= S.size())
    cout << S << endl;
  else
    cout << S.substr(0, K) + "..." << endl;

  return 0;
}


Measured memory_bytes: 3608
a = map(int, input().split())
input_list = list(a)

group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]
list_of_list = [group_a, group_b, group_c]

count_match = 0

for list_i in list_of_list:
    if input_list[0] in list_i and input_list[1] in list_i:
        count_match += 1
        break

if count_match == 1:
    print('Yes')
else:
    print('No')

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

int main(){
	int n, l;
	cin >> n >> l;

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

	string ans = "";
	sort(str.begin(), str.end());
	for(int i = 0; i < n; i++){
		ans += str[i];
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int A[1000];
  int N,i,j,l,v;
  scanf("%d",&N);
  for(i = 0; i < N; i++)scanf("%d",&A[i]);
  for(i = 0; i < N; i++)
  {
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v)
    {
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(l = 0; l < N; l++)
    {
      if(l>0) printf(" ");
      printf("%d",A[l]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pq_small priority_queue<int,vector<int>,greater<int> >
/**==Info==
*Program:
*Problem:
*Date:
*Algorithm:
*Stats:*/
int main(int argc,char* argv[]){
	int n,m;
	map<int,int> mp;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int b;
		cin>>b;
		mp[b]--;
		if(mp[b]<0){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}


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

map<int,int> m;
vector<int> v;

int main()
{
	int n;
	cin>>n;
	
	for (int i=1; i<=n; i++)
	{
		int x;
		cin>>x;
		if (m[x]==0) v.push_back(x);
		m[x]++; 
	} 
	
	int ans=0;
	for (int i=0; i<v.size(); i++)
	{
		if (v[i]>m[v[i]])
			ans+=m[v[i]];
		else if (v[i]<m[v[i]])
			ans+= m[v[i]]-v[i];
	}
	cout<<ans;
	return 0; 
}


Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = min(b/a, c);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
using namespace std;



char getChar(char a, char p){
    if ( (a=='R' && p=='G') || (a=='G' && p=='R')) 
        return 'B';
    if ( (a=='R' && p=='B') || (a=='B' && p=='R')) 
        return 'G';
    if ( (a=='G' && p=='B') || (a=='B' && p=='G')) 
        return 'R';

    return '?';
}

int main(){

    ll n, sum=0, k;
    char c;
    string s;
    cin >> n >> s;
    vector<int> r(n,0), g(n,0), b(n,0);
    


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

    for (int i=0; i<n-2; i++){
        for (int j=i+2; j<n; j++){
            if (s[i]!=s[j]){
                c = getChar(s[i],s[j]);
                if (c=='R') k=r[j]-r[i];
                if (c=='G') k=g[j]-g[i];
                if (c=='B') k=b[j]-b[i];
                if ((i+j)%2==0 && s[(i+j)/2]==c) sum--;
                sum+=k;
            }
        }
    }
    cout << sum;
    return 0;
}






Measured memory_bytes: 3664
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

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

  ll n,d;
  std::cin>>n>>d;

  std::vector<std::vector<ll>> x(n,std::vector<ll>(d));

  rep(i,0,n)rep(j,0,d)std::cin>>x[i][j];

  ll ans=0;

  rep(i,0,n){
    rep(j,i+1,n){
      ll sum=0;
      rep(k,0,d)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);

      rep(k,0,500){
        if(k*k==sum){
          ans++;
          break;
        }
      }
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}



Measured memory_bytes: 256