akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pdd;

const ll mod = 1e9 + 7;
const int N = 1e3 + 10, M = 1e5 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-4;

#define pi acos(-1)
#define mk make_pair

map<int, int> mp;

int main()
{
    int n;
    ll ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        if (i - x > 0)
        {
            ans += mp[i - x];
        }
        mp[i + x]++;
    }
    cout << ans << endl;
    return 0;
}

/*

*/

Measured memory_bytes: 14020
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
int INF = 1000000007;

int main(){
  int N,M,R;
  cin >> N >> M >> R;
  int r[R];
  for(int i=0;i<R;i++){
    cin >> r[i];
    r[i]--;
  }
  sort(r,r+R);
  int d[N][N];
  fill(d[0],d[N],INF);
  for(int i=0;i<N;i++) d[i][i] = 0;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c;
    d[b][a] = c;
  }

  //ワーシャルフロイド
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

  /*for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout << d[i][j];
    }
    cout << endl;
  }*/

  int mn = INF;
  do{
    int tmp = 0;
    for(int i=0;i<R-1;i++){
      tmp += d[r[i]][r[i+1]];
    }
    mn = min(mn,tmp);
  }while(next_permutation(r,r+R));

  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void) {
    int H, W;
    int i, j;
 
    while (1) {
        scanf("%d %d", &H, &W);
 
        if (H == 0 && W == 0) {
            break;
        }
 
        for (i = 1; i <= H; i++) {
            for (j = 1; j <= W; j++) {
                if ((i + j) % 2 == 0) {
                    printf("#");
                }
                else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

int n;
map<string,int>q;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++){
        string s;
        cin >> s;
        q[s]++;
    }
    cout << "AC x " << q["AC"] << '\n';
    cout << "WA x " << q["WA"] << '\n';
    cout << "TLE x " << q["TLE"] << '\n';
    cout << "RE x " << q["RE"] << '\n';
}


Measured memory_bytes: 3684
// ref: https://atcoder.jp/contests/abc119/tasks/abc119_a

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

int main(){
    
    int y, m, d; char c;
    cin >> y >> c >> m >> c >> d;
    int64 date_s  = y*10000 + m*100 + d;
    int64 date_th = 2019*10000 + 4*100 + 30;
    
    if(date_s <= date_th){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
using namespace std;
int stack[1000];
int top;

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

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

bool isempty()
{
	return top == 0;
}

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


Measured memory_bytes: 3232
a, b = map(int, input().split())

diff = b - a
for n in range(1000):
    if diff == n + 1:
        ans = n * (n + 1) // 2 - a
        print(ans)

# a = n * (n + 1) // 2
# b = (n * 1) * (n + 2) // 2

# b - a = (n**2 + 3 * n + 2 - N** 2 - n) // 2
# b - a = (2 * n + 2) // 2
# b - a = n + 1


Measured memory_bytes: 2940
#include<stdio.h>

int func(int, int);

int N,A[20];
int main(){

  int Q,q;
  int i;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  scanf("%d",&Q);
  for(i=0;i<Q;i++){
    scanf("%d",&q);
    if(func(0,q)==1) printf("yes\n");
    else printf("no\n"); 
  }
  
  return 0;
}

int func(int i,int q){
  int R;
  if(q==0) return 1;
  if(i>=N) return 0;
  R = func(i+1,q) || func(i+1,q-A[i]);			  
  return R;
}



Measured memory_bytes: 2140
a,b,c =map(int,input().split(" "))

if a>b:
    if a>c:
        max = a
    else:
        max = c
else:
    if a<=b:
        if c<b:
            max = b
        else:
            max = c

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

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


Measured memory_bytes: 3060
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner, n: Int, prevT: Int, prevX: Int, prevY: Int): Boolean = {
    if (n == 0) (true) else {
      val t, x, y = sc.nextInt
      if (t - prevT >= math.abs(x - prevX) + math.abs(y - prevY) && (t - prevT) % 2 == (math.abs(x - prevX) + math.abs(y - prevY)) % 2) {
        return solve(sc, n - 1, t, x, y)
      } else (false)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    println(if (solve(sc, sc.nextInt, 0, 0, 0)) ("Yes") else ("No"))
  }
}



Measured memory_bytes: 90912
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int x, int r) {
  return x * (100 + r) / 100;
}

void solve() {
  int x, y, s;
  while (cin >> x >> y >> s, x) {
    int m = 0;
    loop(i, 1, s) loop(j, 1, s) {
      if (f(i, x) + f(j, x) == s) cmax(m, f(i, y) + f(j, y));
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    string s;
    cin >> s;

    if(s[0] != s[1] || s[1] != s[2])cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 1, 1, 0, -1, -1, -1, 0 };
	static int[] DC = { -1, 0, 1, 1, 1, 0, -1, -1 };

	public static void main(String[] args) {
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0) break;
			char[][] f = new char[H][];
			for (int i = 0; i < H; ++i) {
				f[i] = sc.next().toCharArray();
			}
			ArrayList<HashSet<String>> set = new ArrayList<HashSet<String>>();
			for (int i = 0; i <= H * W; ++i) {
				set.add(new HashSet<String>());
			}
			String ans = "";
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					for (int k = 0; k < 8; ++k) {
						StringBuilder sb = new StringBuilder();
						sb.append(f[i][j]);
						int cr = i;
						int cc = j;
						boolean[][] visited = new boolean[H][W];
						visited[cr][cc] = true;
						while (true) {
							cr += DR[k];
							cc += DC[k];
							if (cr == -1) cr += H;
							if (cr == H) cr = 0;
							if (cc == -1) cc += W;
							if (cc == W) cc = 0;
							if (visited[cr][cc]) break;
							visited[cr][cc] = true;
							sb.append(f[cr][cc]);
							String str = sb.toString();
							if (str.length() > ans.length() || str.length() == ans.length() && str.compareTo(ans) < 0) {
								if (set.get(str.length()).contains(str)) {
									ans = str;
								} else {
									set.get(str.length()).add(str);
								}
							}
						}
					}
				}
			}
			System.out.println(ans.length() == 0 ? 0 : ans);
		}
	}
}

Measured memory_bytes: 196660
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll x ; 
  cin >> x;

  if((x==3)||(x==5)||(x==7))
    cout <<"YES" << endl; 

  else cout << "NO" << endl;

  

  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int A, B, M;
int a[100005], b[100005];

int main(void) {
    cin >> A >> B >> M;
    int mina=1000000000, minb=1000000000;
    rep(i, 1, A+1) {
        scanf("%d", &a[i]);
        mina=min(mina, a[i]);
    }
    rep(i, 1, B+1) {
        scanf("%d", &b[i]);
        minb=min(minb, b[i]);
    }

    ans = mina+minb;

    rep(i, 0, M) {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        ans = min(ans, a[x]+b[y]-c);

    }

    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1024
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if(a<=9&&b<=9) cout << a*b;
	else cout << -1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair <int, int>
#define ll long long
#define pdd pair <double, double>
#define pll pair <ll, ll>
#define pb push_back
#define vi vector <int>
#define vvi vector <vi>
#define PI 3.14159
int main(){
    ios::sync_with_stdio(0);cin.tie(nullptr);
    double a;
    cin>>a;
    cout<<fixed<<setprecision(3)<<(PI*2*a)<<endl;
}

Measured memory_bytes: 3788
k = int(input())

runrun = [i for i in range(1,10)]

def gen_runrun(x):
    a = x % 10
    if a in [1,2,3,4,5,6,7,8]:
        runrun.append(x * 10 + a - 1)
        runrun.append(x * 10 + a )
        runrun.append(x * 10 + a + 1)
    elif a == 0:
        runrun.append(x * 10 + a )
        runrun.append(x * 10 + a + 1)
    elif a == 9:
        runrun.append(x * 10 + a - 1)
        runrun.append(x * 10 + a )

i = 0
while len(runrun) < k + 10:
    gen_runrun(runrun[i])
    i += 1

print(runrun[k - 1])


Measured memory_bytes: 50672
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
def MI(): return map(int, input().split())
#1:set
#1_A
"""
n,q = map(int, input().split(" "))
group = [[i] for i in range(n)]
key = [i for i in range(n)]
for i in range(q):
    com, x, y = map(int, input().split(" "))
    if com == 0:
        if key[x] != key[y]:
            v = key[y]
            group[key[x]] = group[key[x]] + group[key[y]]
            for j in group[v]:
                key[j] = key[x]
            group[v] = []
    if com == 1:
        if key[x] == key[y]:
            print(1)
        else:
            print(0)
"""
#1_B
"""
def root(x,n):
    if par[x][0] == x:
        return [x,n+par[x][1]]
    return root(par[x][0],par[x][1])
def unite(x,y):
    rx = root(x)
    ry = root(y)
    if rx[0] == ry[0]:
        return
    par[rx][0] = ry[0]
    par[rx][1] += ry[1]
n,q = map(int, input().split(" "))
par = [[i,0] for i in range(n)]
for i in range(q):
    q = list(map(int, input().split(" ")))
    if q[0] == 0:

        if root(q[1],0) != root(q[])
"""
#2:range quary
#2_A
"""
n,q = map(int, input().split(" "))
k = 2**31-1
a = [float("inf") for i in range(n)]
for i in range(q):
    com, x, y = map(int, input().split(" "))
    if com == 0:
        a[x] = y
    else:
        mi = k
        for j in range(x, y+1):
            if a[j] == float("inf"):
                mi = min(mi, k)
            else:
                mi = min(mi,a[j])
        print(mi)
"""
#2_B

#2_C

#2_D

#2_E

#2_F

#2_G

#2_H

#2_I


#3:sliding window
#3_A
n,s = MI()
a = LI()
for i in range(1,n):
    a[i] += a[i-1]
a.insert(0,0)
l = 0
r = 0
ans = float("inf")
if a[1] >= s:
    print(1)
    quit()
while r < n:
    r += 1
    if a[r]-a[l] >= s:
        while a[r]-a[l] >= s and l < r:
            l += 1
        ans = min(ans, r-l+1)
if ans == float("inf"):
    print(0)
    quit()
print(ans)
#4:coordinate compression


#5:comulative sum
#5_A
"""
n,t = map(int, input().split(" "))
num = [0 for i in range(t)]
for i in range(n):
    l,r = map(int, input().split(" "))
    num[l] += 1
    if r < t:
        num[r] -= 1
for i in range(1,t):
    num[i] += num[i-1]
print(max(num))
"""

#5_B
"""
n = int(input())
lec = [[0 for i in range(1001)] for j in range(1001)]
max_x = 0
max_y = 0
for i in range(n):
    x,y,s,t = map(int, input().split(" "))
    lec[y][x] += 1
    lec[y][s] -= 1
    lec[t][x] -= 1
    lec[t][s] += 1
    max_x = max(max_x, s)
    max_y = max(max_y, t)

for i in range(max_y+1):
    for j in range(1, max_x+1):
        lec[i][j] += lec[i][j-1]

for i in range(1, max_y+1):
    for j in range(max_x+1):
        lec[i][j] += lec[i-1][j]

ans = 0
for i in range(max_y+1):
    for j in range(max_x+1):
        ans = max(ans, lec[i][j])

print(ans)
"""



Measured memory_bytes: 16404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int A = GetInt();
		int B = GetInt();
		int T = GetInt();
		WriteLine(B * (T / A));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
#include<stdio.h>

int main()
{
  long long x,y;
  
  scanf("%lld%lld",&x,&y);
  
  long long count=0;
  long long tmp;
  
  tmp=x;
  
  while(tmp<=y)
  {
    tmp*=2;
    count++;
  }
  
  printf("%lld\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (auto &s: a) cin >> s;

  vector<vector<ll> > dp(H+2, vector<ll>(W+2));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i == 0 && j == 0) dp[i+1][j+1] = 1;
      else if (a[i][j] == '.') dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1]) % MOD;
    }
  }

  cout << dp[H][W] << endl;
  return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll N, T;
  cin >> N >> T;
  vector<ll> a(N);
  REP(i,N){ cin >> a[i]; }

  // Find maximum benefit
  ll mp = a[0]; // previous minimum price index
  ll max_val = - INF;
  REP3(i,1,N){
    max_val = max(max_val, a[i] - mp);
    mp = min(mp, a[i]);
  }

  // Count maximum value pair
  ll left = a[0];
  ll num_left = 1;
  ll num_right = 0;
  ll ans = 0;
  a.push_back(-INF);
  REP3(i,1,N+1){
    if (a[i]-left == max_val){
      num_right ++;
    }
    if (a[i]<left){
      left = a[i];
      ans += min(num_left, num_right);
      num_left = 1;
      num_right = 0;
    } else if (a[i]==left){
      num_left ++;
    }
  }
  cout << ans << "\n";
  return 0;
}


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

int N, K;
vector<int> A, B;

bool C(int x) {
  int now = K;

  for (int i = 0; i < N; i++) {
    if (A[i] > x / B[i]) {
      now -= A[i] - x / B[i];
    }
  }

  if (now < 0) {
    return false;
  }

  return true;
}

signed main() {
  cin >> N >> K;
  A.resize(N);
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  sort(A.begin(), A.end(), greater<int>());
  sort(B.begin(), B.end());

  int ok = 1e13, ng = -1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{
	int s;
	cin >> s;
	
	int m = s / 60;
	s = s % 60;
	int h = m / 60;
	m = m % 60;
	
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;

void Rolling_Hash(const string& a, const string& b) {
	const ull B = 100000007;
	int al = a.length(), bl = b.length();
	if (al > bl) return;

	ull t = 1;
	for (int i = 0; i < al; i++) t *= B;

	ull ah = 0, bh = 0;
	for (int i = 0; i < al; i++) ah = ah * B + a[i];
	for (int i = 0; i < al; i++) bh = bh * B + b[i];

	for (int i = 0; i + al <= bl; i++) {
		if (ah == bh)
			cout << i << endl;
		if (i + al < bl) bh = bh * B + b[i + al] - b[i] * t;
	}
}

int main()
{
	string T, P;
	cin >> T >> P;
	Rolling_Hash(P, T);
	return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define ll long long
using namespace std;


int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	ll a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k){
		sum+=min(k,a);
		k-=min(k,a);
	}
	if(k){
		k-=min(k,b);
	}
	if(k){
		sum-=min(k,c);
		k-=min(k,c);
	}
	cout<<sum;
    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int adj[4];
int main()
{
	for(int i=1;i<=3;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a]++;
		adj[b]++;
	}
	int cnt=0;
	for(int i=1;i<=4;i++)
		if(adj[i]%2==1)
			cnt++;
	if(cnt==0||cnt==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main() {
	string s, t;
	cin >> s >> t;

	int ans = 0;
	REP(i, 3) {
		if (s[i] == t[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int a, b, h;

int main() {
	cin >> a >> b >> h;
	cout << (a + b) * h * 0.5;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> P;
typedef vector<P> G;
const double eps = 1e-10;

bool equals(double a, double b) { return fabs(a-b) < eps; }
double dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double norm(P a) { return dot(a,a); }
double abs(P a) { return sqrt(norm(a)); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }

double getDistanceLP(P s1, P s2, P p) {
  return fabs(cross(s2 - s1, p - s1)/abs(s2 - s1));
}

double getDistanceSP(P s1, P s2, P p) {
  if(dot(s2 - s1, p - s1) < 0.0) return abs(p - s1);
  if(dot(s1 - s2, p - s2) < 0.0) return abs(p - s2);
  return getDistanceLP(s1, s2, p);
}


int ccw(P p0, P a, P b) {
  a -= p0;
  b -= p0;
  if(cross(a, b) > eps) return 1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a, b) < -eps) return 2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

G tri;
P co;
double R;


bool isInC(P t, P p, double r) {
  double d = norm(t - p);
  return equals(d, r*r) || d < r*r;
}

bool isInC(G g, P p, double r) {
  for(int i = 0; i < g.size(); ++i) {
    if(!isInC(g[i],p,r)) return false;
  }
  return true;
}

bool isInG(P t, G g) {
  int n = g.size();
  for(int i = 0; i < n; ++i) {
    if(ccw(g[i], g[(i+1)%n], t) == -1) return false;
  }
  return true;
}

bool isInG(P t, double r, G g) {
  if(!isInG(t, g)) return false;
  int n = g.size();
  for(int i = 0; i < n; ++i) {
    double d = getDistanceLP(g[i], g[(i+1)%n], t);
    if(equals(d, r)) continue;
    if(d < r) return false;
  }
  return true;
}

bool isIntersect(P t, double r, G g) {
  int n = g.size();
  for(int i = 0; i < n; ++i) {
    double d = getDistanceSP(g[i], g[(i+1)%n], t);
    if(equals(d, r) || d < r) return true;
  }
  return false;
}

char solve() {
  if(isInC(tri, co, R)) return 'b';
  if(isInG(co, R, tri)) return 'a';
  if(isIntersect(co, R, tri)) return 'c';
  return 'd';
}

int main() {
  P p;
  while(cin >> p.real() >> p.imag()
	&& (p.real() || p.imag())) {
    tri.clear();
    tri.push_back(p);
    for(int i = 1; i < 3; ++i) {
      cin >> p.real() >> p.imag();
      tri.push_back(p);
    }
    if(ccw(tri[0], tri[1], tri[2]) == -1) {
      swap(tri[0], tri[1]);
    }
    cin >> co.real() >> co.imag();
    cin >> R;
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,m = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
ans = -1
for i in range(n):
  if seen[i]:
    continue
  ans += 1
  now = [i]
  while now:
    last = now
    now = []
    for x in last:
      for y in peer[x]:
        if not seen[y]:
          seen[y] = 1
          now.append(y)
print(ans)

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

int n;
long long ans;

int main() {
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		int a;
		scanf("%d", &a);
		ans+=a-1;
	}
	printf("%lld\n", ans);

	return 0;
}

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

int main() {
   int a,b;
   bool flag=true;
   cin>>a>>b;
   rep(i,a+1){
       if(flag==true)
        rep(j,a-i+1){
           if(flag==true)
           rep(k,a-i-j+1){
               if(flag==true)
                if(i*10000+j*5000+k*1000==b&&i+j+k==a){
                   cout<<i<<endl<<j<<endl<<k<<endl;
                   flag=false;
               }
           }
       }
   }
   if(flag==true){
       cout<<-1<<endl<<-1<<endl<<-1<<endl;
   }
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <regex>

#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define RFOR(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define REP(i,x) for(int i=0;i<(x);i++)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

using namespace std;

string s;

bool solve() {
    bool same_both_ends;
    bool even_length;
    same_both_ends = s.front() == s.back();
    even_length = s.length() % 2 == 0;
    return same_both_ends ^ even_length;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> s;
    cout << (solve() ? "Second" : "First") << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(sc.next());
        long k = Long.parseLong(sc.next());
        Integer[][] a = new Integer[62][n + 1];
        int t = 1;
        for (int i = 1; i <= n; i++) a[0][i] = Integer.parseInt(sc.next());
        for (int i = 0; i < 61; i++) {
            for (int j = 1; j <= n; j++) {
                a[i + 1][j] = a[i][a[i][j]];
            }
            if ((k >> i & 1) == 1) t = a[i][t];
        }
        out.println(t);
        out.flush();
    }
}

Measured memory_bytes: 126040
#include<bits/stdc++.h>
using namespace std;
const int N=100000+5;

int dp[N];
vector<int>v;

int main()
{
    memset(dp,-1,sizeof dp);
    int n;
    cin>>n;
    int a=6;
    v.push_back(1);
   // int i=6;
    while(a<=1e5)
    {
        v.push_back(a);
        a*=6;
    }
    a=9;
    while(a<=1e5)
    {
        v.push_back(a);
        a*=9;
    }
  dp[1]=1;
  dp[0]=0;
  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<v.size();j++)
      {
          if(i-v[j]>=0)
          {
              if(dp[i]!=-1)dp[i]=min(dp[i],dp[i-v[j]]+1);
              else dp[i]=dp[i-v[j]]+1;
          }
      }
  }
 // for(int i=1;i<=20;i++)cout<<dp[i]<<endl;
 cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import floor

a, b, n = map(int, readline().split())
if b > n:
    print(floor(a * n / b) - a * floor(n / b))
else:
    print(floor(a * (b - 1) / b) - a * floor((b - 1) / b))


Measured memory_bytes: 62148
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct Job {
	int day;
	int pay;
	bool operator <(const Job& b) const {
		return day < b.day;
	}
};

Job a[100010];
priority_queue<int> J;
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> a[i].day >> a[i].pay;
	sort(a, a + N);
	int j = 0;
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		while (a[j].day <= i) {
			if (j >= N) break;
			J.push(a[j].pay);
			j++;
		}
		if (!J.empty()) {
			ans += J.top();
			J.pop();
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1660
n =  input()
for i in range(2 ** 3):
    op = ["-"] * 3
    for j in range(3):
        if((i >> j) & 1):
            op[2 - j] = "+"

    fomula = ""
    for value, operator in zip(n, op + [""]):
        fomula += (value + operator)

    if eval(fomula) == 7:
        print(fomula + "=7")
        break


Measured memory_bytes: 3060
import numpy as np

N = int(input())
numbers_org = input().split()
numbers = np.zeros([1, N])
count = 0
finish = 0

for j in range(35):
    for i in range(N):
        if int(numbers_org[i]) % 2 == 0:
            numbers_org[i] = int(numbers_org[i]) / 2
        else:
            finish += 1
            break

    if finish == 1:
        break

    count += 1

print(count)

Measured memory_bytes: 12984
import collections
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

counts = collections.Counter(A_list)
ans = 0
for _, v in counts.items():
    # ans += len(list(itertools.combinations(range(v), 2)))
    if v > 1:
        ans += combinations_count(v, 2)

for k in range(1, N + 1):
    n = counts[A_list[k - 1]]
    ans_k = ans
    if n > 1:
        ans_k -= n - 1

    print(int(ans_k))

Measured memory_bytes: 26780
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	while(true){
		int n;
		int a[50010][2];
		for(int i=0;i<50010;i++)a[i][0]=a[i][1]=0;
		scanf("%d",&n);
		if(n==0)return 0;
		int x;
		int y=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&x);
			if(i%2!=0){
				if(a[y][x]!=0){
					a[y][x]++;
				}
				else{
					y++;
					a[y][x]++;
				}
			}
			else{
				if(a[y][x]!=0)a[y][x]++;
				else{
					a[y][(x+1)%2]++;
					swap(a[y][0],a[y][1]);
					if(y!=0){
						a[y-1][x%2]+=a[y][x%2];
						a[y][x]=0;
						y--;
					}
				}
			}
		}
		int ans=0;
		/*
		int z=0;
		while(z<=10){
			printf("%d %d\n",a[z][0],a[z][1]);
			z++;
		}
		*/
		for(int i=0;i<50000;i++)ans+=a[i][0];
		printf("%d\n",ans);

	}
}

Measured memory_bytes: 1576
#include <string>
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <queue>
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstring> 
#include <tuple>

using namespace std;

int n, invs, m, k;
const int mod = 1000000007;

int fac[110000];
int sumfac[110000];
int x[110000];

template <typename T>
T extGcd(T a, T b, T& x, T& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	else {
		int g = extGcd(b, a % b, y, x);
		y -= a / b * x;
		return g;
	}
}

template <typename T>
T modInv(T a, T m) {
	T x, y;
	extGcd(a, m, x, y);
	return (x % m + m) % m;
}

map<string, int> idx;
int t[110];

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

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s; int tt;
        cin >> s >> tt;
        idx[s] = i;
        t[i] = tt;
    }

    string s;
    cin >> s;
    int pp = idx[s];
    int ans = 0;
    for (int i = pp+1; i < n; i++) ans += t[i];
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int A = C - '0';
	while (isdigit(C = getchar())) A = A * 10 + C - '0';
	return A;
}

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


	int N, X;
	N = getint();
	X = getint();

	int A = 0;
	ll kotae = 0;
	rep(i, N) {
		int B = getint();
		int k = max(A + B - X, 0);
		kotae += k;
		A = B - k;
	}
	co(kotae);

	Would you please return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  if (N == 0 || M == 0) {
    cout << (N+M)*(N+M-1)/2 <<endl;
  }
  else if (N+M == 2) {
    cout << "0" << endl;
  }

  else if (N+M == 3) {
    cout << "1" << endl;
  }
  
  else{
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
  }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n;
int a[100005][4];
int dp[100005][4];

int vacation(int day, int flag)
{

	if (day == n)
		return 0;

	if (dp[day][flag] != -1)
		return dp[day][flag];

	int ma = 0;

	if (flag == 0)
	{
		ma = max(ma, a[day][1] + vacation(day + 1, 1));
		ma = max(ma, a[day][2] + vacation(day + 1, 2));
		ma = max(ma, a[day][3] + vacation(day + 1, 3));
	}
	else if (flag == 1)
	{
		ma = max(ma, a[day][2] + vacation(day + 1, 2));
		ma = max(ma, a[day][3] + vacation(day + 1, 3));
	}
	else if (flag == 2)
	{
		ma = max(ma, a[day][1] + vacation(day + 1, 1));
		ma = max(ma, a[day][3] + vacation(day + 1, 3));
	}
	else
	{
		ma = max(ma, a[day][1] + vacation(day + 1, 1));
		ma = max(ma, a[day][2] + vacation(day + 1, 2));
	}

	return dp[day][flag] = ma;
}

int32_t main()
{
	FIO();
	cin >> n;

	for (int i = 0; i < n; i++) 
	{
		for (int j = 1; j <= 3; j++) 
		{
			cin >> a[i][j];
		}
	}
 
	memset(dp, -1, sizeof dp);

	cout << vacation(0, 0) << '\n';

	return 0;
}

Measured memory_bytes: 17652
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, C, K, *T = map(int, read().split())
T.sort()

acc = 0
n_bus = 0
cnt = 0
for t in T:
    if cnt == 0:
        acc = t + .5
        n_bus += 1
        cnt = 1
        if cnt == C:
            cnt = 0
        continue

    if t - acc <= K:
        cnt += 1
    else:
        cnt = 1
        acc = t + .5
        n_bus += 1
        continue
    if cnt == C:
        cnt = 0

print(n_bus)


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

using namespace std;

int main(void)
{
	int x, t;
	cin >> x >> t;
	if (x - t > 0)
	{
		cout << x - t << endl;
	}
	else
	{
		cout << '0' << endl;
	}
	return 0;
}

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

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

if(S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
}

int cnt = 0;
for(int i = 1; i < S.size(); i++){ 
     if(isupper(S[i])){

         if(i == 1 || i == S.size() - 1 || S[i] != 'C'){
             cout << "WA" << endl;
             return 0;
         }
        ++cnt;
     }
}

if(cnt != 1) {
    cout << "WA" << endl;
    return 0;
}

cout << "AC" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >>h >>w;
  
  vector<string> s(h);
  for (int i = 0; i < h; i++)
    cin >> s[i];
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') {
        int count = 0;
        //左
        if (j != 0) {
          if (s[i][j-1] == '#')
            count ++;
        } 
        //右
        if (j != w-1) {
          if (s[i][j+1] == '#')
            count ++;
        }
        //左上
        if (j != 0 && i != 0) {
          if (s[i-1][j-1] == '#')
            count ++;
        }
        //上真ん中
        if (i != 0) {
          if (s[i-1][j] == '#')
            count ++;
        }
        //右上
        if (j != w-1 && i != 0) {
          if (s[i-1][j+1] == '#')
            count ++;
        }
        //左下
        if (j != 0 && i != h-1) {
          if (s[i+1][j-1] == '#')
            count ++;
        }
        //下真ん中
        if (i != h-1) {
          if (s[i+1][j] == '#')
            count ++;
        }
        //右下
        if (j != w-1 && i != h-1) {
          if (s[i+1][j+1] == '#')
            count ++;
        }
        
        s[i][j] = '0' + count;
      }
    }
  }
  
  for (int i = 0; i < h; i++)
    cout << s[i] << endl;
  
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	// keisan
	long long min = 0;
	for(int i=1;i<101;i++){
		long long kmin = 0;
		if(i == 1){
			for(int j=0;j<n;j++){
				min += abs(a[j]-i)*abs(a[j]-i);
			}
		}else{
			for(int j=0;j<n;j++){
				kmin += abs(a[j]-i)*abs(a[j]-i);
			}
			if(kmin < min){
				min = kmin;
			}
		}
	}
	// syutsuryoku
	cout << min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

void	prime_factorization(ll n, map<ll, ll> &factors)
{
	factors = map<ll, ll>();
	ll lim = n;
	for (ll f = 2; f * f <= lim; f++)
	{
		while (n % f == 0)
		{
			factors[f]++;
			n /= f;
		}
	}
	if (n != 1)
		factors[n]++;
}

int     main()
{
	ll a, b;
	cin >> a >> b;
	map<ll, ll> factor;
	prime_factorization(__gcd(a, b), factor);
	cout << factor.size() + 1 << endl;
}




Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int L = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            Arrays.sort(S);

            StringBuilder res = new StringBuilder();
            for (int i = 0; i < N; i++) {
                res.append(S[i]);
            }

            System.out.println(res.toString());
        }
    }
}


Measured memory_bytes: 30080
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, p, rec[200008];

int main(){
	cin >> n;
	memset(rec, 0, sizeof(rec));
	
	ll lmax = 0;
	for(ll i = 1; i <= n; i++){
		cin >> p;
		rec[p] = rec[p-1]+1;
		lmax = max(rec[p], lmax);
	}
	
	cout << n-lmax << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W,a,b,c;
  vector<string> X(100);
  
  cin >> H >> W;
  for (int i=0; i < H; i++) {
    cin >> X[i];
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
 
  for (int i=0; i < H; i++) {
    cout << '#' << X[i] << '#' << endl;
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc085.contest.atcoder.jp/tasks/abc085_d>
問題文============================================================
 あなたが散歩していると、突然一体の魔物が出現しました。
 幸い、あなたは N 本の刀、刀 1、刀 2、…、刀 N を持っていて、次の二種類の攻撃を自由な順番で行うことができます。
 
 持っている刀のうち一本を振る。
     刀 i (1≤i≤N) を振ると、魔物は ai ポイントのダメージを受ける。同じ刀を何度振ることもできる。
 持っている刀のうち一本を投げつける。
     刀 i (1≤i≤N) を投げつけると、魔物は bi ポイントのダメージを受け、あなたはその刀を失う。
     すなわち、あなたは以後その刀を振ることも投げつけることもできなくなる。
 
 魔物は、受けたダメージの合計が H ポイント以上になると消滅します。
 魔物を消滅させるには、最小で合計何回の攻撃が必要でしょうか。
=================================================================

解説=============================================================

 刀を振る時、一番大きいダメージのある刀だけを振ることを考えれば最適
 
 また、投げる時は、振るダメージの大きいもの以上の刀を投げつければいい。
 よって、先に投げつけるものだけ投げておいて、後から一番大きいダメージの刀のみでダメージを与えれば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,H; cin >> N >> H;
    vector<ll> a(N),b(N);
    for(int i = 0; i < N;i++) cin >> a[i] >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end()); reverse(b.begin(),b.end());
    ll Maxa = *max_element(a.begin(), a.end()) , cnt = 0;
    for(int i = 0; i < N;i++){
        if(H <= 0) break; if(Maxa > b[i]) break;
        cnt++; H -= b[i];
    }
    if(H <= 0){
        cout << cnt << endl; return 0;
    }
    cout << cnt + (H + Maxa-1)/Maxa << endl;
	return 0;
}


Measured memory_bytes: 1792
a=[list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
N=int(input())
b=list()
for i in range(0,N):
    b.append(int(input()))
for j in range(0,3):
    for k in range(0,3):
        for i in range(0,N):
            if a[j][k]==b[i]:
                a[j][k]=0
for i in range(0,3):
    if a[i][0]==a[i][1] and a[i][1]==a[i][2]:
        print("Yes")
        break
    elif a[0][i]==a[1][i] and a[1][i]==a[2][i]:
        print("Yes")
        break
    elif a[0][0]==a[1][1] and a[1][1]==a[2][2]:
        print("Yes")
        break
    elif a[2][0]==a[1][1] and a[1][1]==a[0][2]:
        print("Yes")
        break
else:
    print("No")



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


int main() {
    
    string s;
    getline(cin,s);
    for(ll i=0;i<s.length();i++){
       if(s[i]=='.'){
         cout<<"0";
         
       }
       else{
             
            if(s[i]=='-'&& s[i+1]=='.'){
              cout<<"1";

            }
            else if(s[i]=='-' && s[i+1]=='-'){
              cout<<"2";
            }
            }


       }
      
    
   cout<<endl;
  return 0;
}*/

#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
using namespace std;
int main(){

    int n,k;
    cin>>n>>k;
    ll arr[k];
    for(int i=0;i<k;i++){
       cin>>arr[i];
    }
   int ans=0;
    for(int i=0;i<k;i++){
       ans=ans+arr[i];
    }
    if(ans<=n){
      cout<<(n-ans)<<endl;
    }
    else{
      cout<<"-1"<<endl;
    }
  return 0;
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(){
    ll L,R;
    cin >> L >> R;
    R = min(R,L+2019*2);
    int ans = 2018;
    for(ll i=L;i<=R;i++){
      for(ll j=i+1;j<=R;j++){
          int amari = (i*j)%2019;
          ans = min(amari,ans);
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = []
    A = input().split()

    count = [0 for i in range(N)]

    for i in range(N-1):
        tmp = count[int(A[i])-1]
        count[int(A[i])-1] = tmp + 1

    for i in range(N):
        print(count[i])

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 26156
n = int(input())
a = list(map(int, input().split()))

last  = 0
count = 0
flag  = True

while flag:
    flag = False
    for i in range( n-1, last, -1 ):
        if a[i] < a[i-1]:
            t = a[i]
            a[i] = a[i-1]
            a[i-1] = t
            count += 1
            flag = True
    last += 1

print(*a)
print(count)

Measured memory_bytes: 7728