akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vector<char>> s(h, vector<char>(w, '\0'));
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }

  ll ans = 0;
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      if (s[i][j] == '#') continue;

      vector<vector<ll>> mark(h, vector<ll>(w, -1));
      queue<pair<ll, ll>> q;
      // i as y
      // j as x
      q.push(make_pair(i, j));
      mark[i][j] = 0;
      while (q.size() > 0) {
        auto pos = q.front();
        q.pop();
        ll count = mark[pos.first][pos.second];

        bool move = false;
        vector<pair<ll, ll>> d = {
          make_pair(1, 0),
          make_pair(-1, 0),
          make_pair(0, -1),
          make_pair(0, 1),
        };
        for (auto itr = d.begin(); itr != d.end(); ++itr) {
          ll y = pos.first + itr->first;
          ll x = pos.second + itr->second;

          if (x < 0 || x >= w) continue;
          if (y < 0 || y >= h) continue;
          if (s[y][x] == '#') continue;
          if (mark[y][x] >= 0) continue;
          
          move = true;
          mark[y][x] = count + 1;
          ans = max(ans, mark[y][x]);
          q.push(make_pair(y, x));
        }
      }
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    bool fl = true;
    FOR(i,2,sqrt(a)+1){
      if(a%i==0){
        fl = false;
        break;
      }
    }
    if(fl) ++ans;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll A, B, C;

int main(){
  cin >> A >> B >> C;
 
  if(A * B * C % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min(A * B, min(B * C, C * A)) << endl;
  }



  return 0;
}


Measured memory_bytes: 256
N = int(input())
ARR = [int(s) for s in input().split(" ")]

def calculate(n,arr):

    dict = {}

    for ar in arr:
        if dict.get(ar) == None:
            dict.__setitem__(ar,1)
        else:
            tmp = dict.get(ar)
            tmp = tmp + 1
            dict.__setitem__(ar,tmp)

    sum = 0
    for k in dict.keys():

        if dict.get(k) == k:
            continue

        if dict.get(k) < k:
            sum = sum + dict.get(k)

        if dict.get(k) > k:
            sum = sum + (dict.get(k) - k)


    print(sum)


calculate(N,ARR)



Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int K;
    cin >> K;
    vector<int> es[K][2];
    rep(i, K){
        es[i][0].pb((i*10)%K);
        es[i][1].pb((i+1)%K);
    }
    int d[K];
    fill(d, d+K, inf);
    d[1] = 1;
    deque<int> que;
    que.push_back(1);
    while(!que.empty()){
        int i = que.front(); que.pop_front();
        for(auto &e: es[i][0]){
            if(chmin(d[e], d[i])) que.push_front(e);
        }
        for(auto &e: es[i][1]){
            if(chmin(d[e], d[i]+1)) que.push_back(e);
        }
    }
    cout << d[0] << endl;
}

Measured memory_bytes: 15112
A = list(map(int, input().split()))
S = input()

C = A[1]
D = A[0]
ans = ""

B = S[C-1]

#print(B)

if(B == "A"):
    B = "a"
elif(B == "B"):
    B = "b"
else:
    B = "c"

#print(B)

for i in range(D):
    if (i == C-1 ):
        ans = ans + B
        continue
    ans = (ans + S[i]) 

print(ans)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		long mod = 1_000_000_007;
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long blue = k;
		long red = n-blue;
		long ans = 0;
		for(int i=1; i<=k; i++){
			if(i == 1){
				ans = (modCombination(red+1,i,mod)*i)%mod;
				System.out.println(ans);
			} else {
				ans = (modCombination(red+1,i,mod)*modCombination(blue-1, i-1, mod))%mod;
				System.out.println(ans);
			}
		}

	}
		// modPow 全てlongで渡す
		public static long modPow(long base, long exp, long mod) {
			if (exp == 0)
				return 1;
			if (exp == 1)
				return base % mod;
			if (exp % 2 == 1)
				return (base * modPow(base, exp - 1, mod) % mod);
			long tmp = modPow(base, exp / 2, mod);
			return (tmp * tmp) % mod;
		}
	
		// nCrの値を引数で渡したmodで割った余りをlong型で返す。フェルマーの小定理の条件により、modは素数に限る
		public static long modCombination(long n, long r, long mod) {
			long top = 1;
			long bottom = 1;
			for (int i = 1; i <= r; i++) {
				top *= n;
				top %= mod;
				n--;
				bottom *= i;
				bottom %= mod;
			}
			bottom = modPow(bottom, mod-2, mod);
			return (top * bottom) % mod;
		}
}


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

using ll = long long;
using ull = unsigned long long;

using namespace std;

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

    string a,b,c;
    ll n;

    cin>>n>>a>>b;

    for(ll i=0;i<n;i++)
    {
        c.push_back(a[i]);
        c.push_back(b[i]);
    }

    cout<<c<<'\n';

    return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  int res=0;

  if(A>=13) res=B;
  else if(A>=6) res=B/2;

  cout << res << endl;
}

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

#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
//#define int long long

typedef  long long ll;

using namespace std;


int main()
{
    ioss
    int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  // int a=v[0];int b=v[n-1];
  // d[i]= min(d[i-1]-d[i],d[i-2]-d[i]);
  int d[100005]={0};d[0]=0;d[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++)
  {
    d[i]=min(d[i-1]+abs(v[i-1]-v[i]),d[i-2]+abs(v[i-2]-v[i]));
  }
  cout<<d[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
mod=10**9+7
ans=0
MOD=10**9+7

factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))
 
 
# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD
for i in range(n-k+1):
    ans-=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod
a=a[::-1]
for i in range(n-k+1):
    ans+=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod

print(ans%mod)

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

int N;
int a[10100];

int main() {
  cin >> N;
  rep(i, N)
    cin >> a[i];
  
  int res = 0;
  rep(i, N) {
    while( a[i] % 2 == 0 ) {
      a[i] /= 2;
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
A = [input().split() for _ in range(3)]
n = int(input())
B = [input() for _ in range(n)]
ans = False
bng = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                bng[j][k] = 1

for i in range(3):
    if bng[i][0] == bng[i][1] == bng[i][2] == 1:
        ans = True
    if bng[0][i] == bng[1][i] == bng[2][i] == 1:
        ans = True

if bng[0][0] == bng[1][1] == bng[2][2] == 1:
    ans = True
if bng[0][2] == bng[1][1] == bng[2][0] == 1:
    ans = True

if ans:
    print("Yes")
else:
    print("No")

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
   int h, w;
   int c[10][10];

   cin >> h >> w;
   for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
         cin >> c[i][j];
      }
   }

   for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
            c[i][j] = 
               min(c[i][j], c[i][k] + c[k][j]);
         }
      }
   }

   ll sum = 0;
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
         int x;
         cin >> x;
         if (x != -1) {
            sum += c[x][1];
         }
      }
   }

   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 256
N = int(input())
LList = list(map(int,input().split()))

max_L = max(LList)
isFirstMax_L = 0
sumOtherL = 0

for i in LList :
    if i == max_L and isFirstMax_L == 0:
        isFirstMax_L = 1
        continue
    sumOtherL += i

if max_L < sumOtherL :
    print("Yes")
else :
    print("No")

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

const int SZ = 1123456;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}


ll solve(int X, int Y, int K) {
  if (X < 0 || Y < 0) return 0;
  if (X + Y != K) return 0;
  ll res = choose(K, Y);
  return res;
}

int main2() {
  int X = nextInt();
  int Y = nextInt();
  ll ans = 0;
  for (int k = 0; k <= 1000000; k++) {
    ans += solve(X - k, Y - k, k);
    ans %= MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 26624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication8
{
	class Program
	{
		static void Main(string[] args)
		{
			int n;
			n = int.Parse(Console.ReadLine());
			if (n == 25)
				Console.WriteLine("Christmas");
			if (n == 24)
				Console.WriteLine("Christmas Eve");
			if (n == 23)
				Console.WriteLine("Christmas Eve Eve");
			if (n == 22)
				Console.WriteLine("Christmas Eve Eve Eve");
			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.InputStreamReader;
//ツ挿ツ禿シツソツーツト
//public class Problem0018_SortingFiveNumbers {
public class Main {
	public static void main(String[] args) {
		try {
		//	Problem0018_SortingFiveNumbers test = new Problem0018_SortingFiveNumbers();
			Main test = new Main();
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String line;
			while((line = reader.readLine()) != null) {
				try {
					String[] textArray = line.split(" ");
					int[] numbers = new int[5];
					for(int i = 0; i < numbers.length; i++) {
						numbers[i] = Integer.parseInt(textArray[i]);
					}
					test.sort(numbers);
					for(int i = 0; i < numbers.length-1; i++) {
						System.out.print(numbers[i] + " ");
					}
					System.out.println(numbers[numbers.length-1]);
				} catch(Exception e) {
					break;
				}
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	/*
		Problem0018_SortingFiveNumbers test = new Problem0018_SortingFiveNumbers();
		for(int i = 0; i < 200; i++) {
			int[] array = new int[5];
			for(int j = 0; j < array.length; j++) {
				array[j] = (int)(Math.random() * 100);
			}
			test.shuffle(array);
			for(int number : array) {
				System.out.print(number +" ");
			}
			System.out.println();
			test.sort(array);
			for(int number : array) {
				System.err.print(number +" ");
			}
			System.err.println();
		}
	*/
	}
	void sort(int[] array) {
		int[] numbers = array;
		for(int i = 1; i < numbers.length; i++) {
			for(int j = i; j > 0; j--) {
				if(numbers[j-1] < numbers[j]) {
					int temporary = numbers[j];
					numbers[j] = numbers[j-1];
					numbers[j-1] = temporary;
				} else {
					break;
				}
			}
		}
	}
	void shuffle(int[] targetArray) {
		int[] array = targetArray;
		for(int i = 0; i < array.length; i++) {
			int position = (int)(Math.random() * (i+1));
			
			int temporary = array[position];
			array[position] = array[i];
			array[i] = temporary;
		}
	}
}

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

from collections import Counter


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


n = int(readline())
memo = prime_decomposition(n)
cnt = 0
for v in Counter(memo).values():
    c = 1
    while v > 0:
        if v >= c:
            cnt += 1
            v -= c
        else:
            break
        c += 1
print(cnt)



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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - (a + b) << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int calc(int x) {
    int ret = 0;
    while(x % 100 == 0) {
        ret++;
        x /= 100;
    }
    return ret;
}

int main() {
    int d, n;
    cin >> d >> n;
    int ans = 0;
    int cnt = 0;
    while (cnt < n) {
        ans++;
        if (calc(ans) == d) {
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    cout<<fixed<<setprecision(10);
    int n;
    cin>>n;
    vector<double> t(n+1),v(n+2);
    rep(i,n) cin>>t[i+1];
    rep(i,n) cin>>v[i+1];
    
    
    rep(i,n) {
        chmin(v[i+1],v[i+2]+t[i+1]);
        chmin(v[i+1],v[i]+t[i+1]);
    }
    rrep(i,n) {
        chmin(v[i+1],v[i+2]+t[i+1]);
        chmin(v[i+1],v[i]+t[i+1]);
    }

    double ans=0;
    FOR(i,1,n) {
        if(v[i-1]<=v[i] && v[i]<=v[i+1]) {
            ans+=v[i]*t[i]-pow((v[i]-v[i-1]),2)/2;
        }
        else if(v[i-1]>=v[i] && v[i]>=v[i+1]) {
            ans+=v[i]*t[i]-pow((v[i]-v[i+1]),2)/2;
        }
        else if(v[i-1]<v[i] && v[i]>v[i+1]) {
            double d=v[i+1]-v[i-1];
            ans+=t[i]*(v[i-1]+t[i]/2+d/2)-(pow(t[i]/2+d/2,2)+pow(t[i]/2-d/2,2))/2-pow(max(0.0,v[i-1]+t[i]/2+d/2-v[i]),2);
        }
        else {
            ans+=v[i]*t[i];
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int ull;
#define INF 1LL << 63

struct pos {
	ll x, y;
};
int main(){
	int N, K;
	cin >> N >> K;
	vector<pos> dots(N);
	for (auto &x : dots) {
		ll a, b;
		cin >> a >> b;
		x = { a,b };
	}
	ull ans = INF;
	if (K >= 4) {
		for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)for (int s = 0; s < N; s++) {
				if (i == j || j == k || k == s || i == s || i == k || s == j)continue;
				ll x1 = min(min(dots[i].x, dots[j].x), min(dots[k].x, dots[s].x));
				ll y1 = min(min(dots[i].y, dots[j].y), min(dots[k].y, dots[s].y));
				ll x2 = max(max(dots[i].x, dots[j].x), max(dots[k].x, dots[s].x));
				ll y2 = max(max(dots[i].y, dots[j].y), max(dots[k].y, dots[s].y));
				int cnt = 0;
				for (int t = 0; t < N; t++) {
					if (dots[t].x >= x1 && dots[t].x <= x2 && dots[t].y >= y1 && dots[t].y <= y2)cnt++;
				}
				if (cnt >= K) {
					ull tmp = (ull)abs((x2 - x1))*(ull)abs((y2 - y1));
					ans = min(tmp, ans);
				}
			}
	}
	else if (K == 3) {
		for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)for (int k = 0; k < N; k++) {
				if (i == j || j == k || i == k)continue;
				ll x1 = min(min(dots[i].x, dots[j].x), dots[k].x);
				ll y1 = min(min(dots[i].y, dots[j].y), dots[k].y);
				ll x2 = max(max(dots[i].x, dots[j].x), dots[k].x);
				ll y2 = max(max(dots[i].y, dots[j].y), dots[k].y);
				int cnt = 0;
				for (int t = 0; t < N; t++) {
					if (dots[t].x >= x1 && dots[t].x <= x2 && dots[t].y >= y1 && dots[t].y <= y2)cnt++;
				}
				if (cnt >= K) {
					ull tmp = (ull)abs((x2 - x1))*(ull)abs((y2 - y1));
					ans = min(tmp, ans);
				}
			}
	}
	else if (K == 2) {
		for (int i = 0; i < N; i++)for (int j = 0; j < N; j++){
				if (i == j)continue;
				ll x1 = min(dots[i].x, dots[j].x);
				ll y1 = min(dots[i].y, dots[j].y);
				ll x2 = max(dots[i].x, dots[j].x);
				ll y2 = max(dots[i].y, dots[j].y);
				int cnt = 0;
				for (int t = 0; t < N; t++) {
					if (dots[t].x >= x1 && dots[t].x <= x2 && dots[t].y >= y1 && dots[t].y <= y2)cnt++;
				}
				if (cnt >= K) {
					ull tmp = (ull)abs((x2 - x1))*(ull)abs((y2 - y1));
					ans = min(tmp, ans);
				}
			}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if (a-b-c==-a && b==c) {
        printf("1\n");
    } else if (a==b || a==c || b==c) {
        printf("2\n");
    } else {
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 500;
const int inf = (1<<20);
int cap[N][N];
int flow[N][N];
bool vis[N];

int fordFulkerson(const int n,const int t,int now,int fl){
  if (now == t)return fl;
  if (vis[now])return 0;
  vis[now]=true;
  int tmp=0;
  rep(i,n){
    int &next=i;
    if (cap[now][i] - flow[now][i] > 0){
      tmp=fordFulkerson(n,t,next,min(fl,cap[now][i]-flow[now][i]));
      if (tmp != 0){
	flow[now][next]+=tmp;
	flow[next][now]=-flow[now][next];
	return tmp;
      }
    }
  }
  return 0;
}

int maxFlow(int n,int s,int t){
  int tmp=0,ret=0;
  rep(i,n)vis[i]=false;
  while((tmp = fordFulkerson(n,t,s,inf)) != 0){
    ret+=tmp;
    rep(i,n)vis[i]=false;
  }
  return ret;
}

bool dfs(int n,int now,int t){
  if (now == t)return true;
  if (vis[now])return false;
  vis[now]=true;
  rep(i,n){
    int &next=i;
    if (flow[now][next] < 0){
      if (dfs(n,next,t)){
	flow[now][next]=flow[next][now]=0;
	return true;
      }
    }
  }
  return false;
}

int dfs2(int n,int now,int t){
  if (now == t)return 1;
  if (vis[now])return 0;
  vis[now]=true;
  rep(i,n){
    int &next=i;
    if (cap[now][next]-flow[now][next] > 0){
      if (dfs2(n,next,t)){
	flow[now][next]+=1;
	flow[next][now]=-flow[now][next];
	return 1;
      }
    }
  }
  return 0;
}


main(){
  int n,e,q;
  while(cin>>n>>e>>q){
    const int s = 0,t=n-1;
    rep(i,n)rep(j,n)cap[i][j]=0,flow[i][j]=0;
    rep(i,e){
      int f,t;
      cin>>f>>t;
      f--;t--;
      cap[f][t]=1;
      cap[t][f]=1;
    }
    int prev=maxFlow(n,s,t);
    rep(i,q){
      int a,from,to,tmp;
      cin>>a>>from>>to;
      from--;to--;
      if (a == 1){//add
	cap[from][to]=cap[to][from]=1;
	tmp = maxFlow(n,s,t);
#ifdef DEBUG1
	cout <<"add:";
#endif
	cout << prev+tmp << endl;
	prev=prev+tmp;
      }else if (flow[from][to] == 0){
#ifdef DEBUG1
	cout <<"noflow:";
#endif
	cap[from][to]=cap[to][from]=0;
	cout << prev << endl;
      }else {//delete
#ifdef DEBUG1
	cout <<"del:";
#endif
	if (flow[from][to] < 0)swap(from,to);
	cap[from][to]=cap[to][from]=0;
	flow[from][to]=flow[to][from]=0;

	rep(j,n)vis[j]=false;
	tmp=dfs2(n,from,to);
	if (tmp != 0){
	  cout << prev << endl;
	  prev=prev;//keep
	}else {
	  rep(j,n)vis[j]=false;
	  dfs(n,from,s);
	  rep(j,n)vis[j]=false;
	  dfs(n,t,to);
	  cout << prev-1 << endl;
	  prev=prev-1;
	}
      }
    }
#ifdef DEBUG
    cout << "end " << endl;
#endif
  }
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;

const int N = 200005;

int n, arr[N], ans[N], ord[N];
vector<int> graph[N];
int curr;

void dfs(int src, int par)
{
    int pos = -1, val = 0;
    pos = lower_bound(ord, ord+n+1, arr[src])-ord;
    val = ord[pos];
    ord[pos] = min(ord[pos], arr[src]);
    for (int v: graph[src])
    {
        if (v == par)
            continue;
        dfs(v, src);
    }
    ans[src] = lower_bound(ord, ord+n+1, 0x3f3f3f3f)-ord-1;
    ord[pos] = val;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> arr[i];
    }
    for(int i=0; i<n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].PB(b);
        graph[b].PB(a);
    }
    memset(ord, 0x3f, sizeof(ord));
    ord[0] = 0;
    dfs(1, 1);

    for(int i=1; i<=n; i++)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}


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



long long mod = 1000000007;



bool dp[100005];
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	dp[0] = true;
	
	int v[6] = {100,101,102,103,104,105};
	
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 6;j++){
			if(i - v[j] >= 0){
				if(dp[i-v[j]]) dp[i] = true;
			}
		}
	}
	
	if(dp[n]) cout << 1;
	else cout << 0;
	
	
}


Measured memory_bytes: 384
n, m, c = map(int, input().strip().split())
b = list(map(int, input().strip().split()))
a = [list(map(int, input().strip().split())) for _ in range(n)]

res = 0
for i in range(n):
    sum = c
    for j in range(m):
        sum += a[i][j] * b[j]
    if sum > 0:
        res += 1

print(res)


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

inline void swap(int &a, int &b) { int t = a; a = b; b = t; }

int main()
{
  int n;
  int a, b, c;

  cin >> n;
  for (int i = 0; i<n; i++)
  {
    cin >> a >> b >> c;
    if (c < a) swap(c, a);
    if (c < b) swap(c, b);
    if (c*c == a*a + b*b) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int h, w;
    int[][] s;
    int[] ans;
    int next;
    HashMap<Integer, Integer>  Answers;
    int max = Integer.MAX_VALUE;

    void run(){
	int ca = 0;
	while(sc.hasNext()){
	    h = sc.nextInt();
	    if(h!=0){
		if(ca>0)System.out.println();
		put();
		//show();	
		solve();
		ca++;
	    }
	}
    }

    void put(){
	w = sc.nextInt();
	s = new int[h+2][w+2];
	for(int i=1; i<(h+2); i++){
	    for(int k=1; k<(w+2); k++){
		String t = sc.next();
		if(t.equals("?")){
		    s[i][k] = max;
		    s[i][0]++; s[0][k]++;
		    s[0][0]++;
		}
		else s[i][k] = Integer.parseInt(t);
	    }
	    //System.out.println();
	}
	ans = new int[s[0][0]];
	next = 0;
	Answers = new HashMap<Integer, Integer>();
    }

    void solve(){
	boolean con = check();
	boolean did = false;

	while(con && s[0][0]>0){
	    for(int i=1; i<s.length; i++)
		if(s[i][0]==1){
		    int k = 1;
		    while(s[i][k]!=max)k++;
		    calc(i, k, "x"); 
		    did = true;
		}
	    for(int k=1; k<s[h].length; k++)
		if(s[0][k]==1){
		    int i = 1;
		    while(s[i][k]!=max)i++;
		    calc(i, k, "y"); 
		    did = true;
		}
	    con = check();
	    if(!did) con = false;
	}
	Arrays.sort(ans);
	if(s[0][0]==0)
	    for(int i=0; i<ans.length; i++)
		System.out.println(Answers.get(ans[i]));
	else
	    System.out.println("NO");
    }

    void calc(int h, int w, String t){
	int a = 0;
	if(t.equals("y")){
	    for(int i=1; i<s.length; i++){
		if(i==s.length-1) a += s[i][w];
		else if(i!=h) a -= s[i][w];
	    }
	}
	else {
	    for(int k=1; k<s[h].length; k++){
		if(k==s[h].length-1) a += s[h][k];
		else if(k!=w) a -= s[h][k];
	    }
	}
	ans[next++] = (h-1)*s[h].length+w;
	Answers.put((h-1)*s[h].length+w, a);
	s[h][w] = a;
	s[0][w]--; s[h][0]--; s[0][0]--;
	//System.out.println("*"+h+" "+w+" "+t);
    }

    boolean check(){
	int count = 0;
	for(int i=1; i<s.length; i++)
	    if(s[i][0]==1) count++;
	for(int k=1; k<s[h].length; k++)
	    if(s[0][k]==1) count++;
	return count>0 ? true : false;
    }

    void show(){
	for(int i=0; i<s.length; i++){
	    for(int k=0; k<s[i].length; k++)
		System.out.print(s[i][k]+" ");
	    System.out.println();
	}
    }
}


			    

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

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> data(N, vector<int>(2));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 2; j++)
    {
      cin >> data[i][j];
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += data[i][1] - data[i][0] + 1;
  }
  cout << sum << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> s;

    for (int i = 0; i < n; i++)
    {
        string key;
        cin >> key;
        s[key] += 1;
    }

    int maxv = 0;
    for (auto &x : s)
    {
        int v = x.second;
        if (maxv < v)
            maxv = v;
    }

    for (auto it = s.begin(); it != s.end(); it++)
    {
        if (it->second == maxv)
        {
            cout << it->first << endl;
        }
    }
    return 0;
}

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

int main() {
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  sort(vec.begin(),vec.end());
  cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
  return 0;
}


Measured memory_bytes: 3120
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  ll ans = -10000;
  maxch(ans,n-m);
  maxch(ans,n+m);
  maxch(ans,n*m);
  cout<<ans<<endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, d, r;
	double f;
	
	scanf("%d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	
	printf("%d %d % 5f\n",d, r, f);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<stdio.h>
#include<cstdio> 

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	ll n;
	cin>>n;
	vector<ll> vl(n);
	FOR(i,0,n)cin>>vl[i];
	ll cnt = 0;
	FOR(i,0,n)
	{
		FOR(j,i+1,n)
		{
			FOR(k,j+1,n)
			{
				ll a = vl[i],b = vl[j],c = vl[k];
				if(a==b||a==c||b==c)continue;
				if(a+b>c&&a+c>b&&b+c>a)cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
  int n, k;
  cin >> n;
  while(n--) {
    cin >> k;
    if (k % 2) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c, long long d){
    cout << (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ? YES : NO) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <unordered_map>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;

LL A, B, C, D;
std::unordered_map<LL, LL> mp;
LL f(LL x) {
	if (x == 0) return 0;
	if (x == 1) return D;
	if (mp.count(x)) return mp[x];
	LL ret = x <= Infll / D ? x * D : Infll;
	ret = std::min(ret, x % 2 * D + A + f(x / 2));
	ret = std::min(ret, x % 3 * D + B + f(x / 3));
	ret = std::min(ret, x % 5 * D + C + f(x / 5));
	if (x % 2) ret = std::min(ret, (2 - x % 2) * D + A + f(x / 2 + 1));
	if (x % 3) ret = std::min(ret, (3 - x % 3) * D + B + f(x / 3 + 1));
	if (x % 5) ret = std::min(ret, (5 - x % 5) * D + C + f(x / 5 + 1));
	return mp[x] = ret;
}

int main() {
	int Tests;
	scanf("%d", &Tests);
	while (Tests--) {
		LL N;
		scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
		mp.clear();
		printf("%lld\n", f(N));
	}
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n,l;cin>>n>>l;
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=(l+i-1);
    }
    
    int ans=INF;
    int la;
    for(int i=1;i<=n;i++){
        if(ans>abs((l+i-1))){
            ans=abs((l+i-1));
            la=sum-(l+i-1);
        }
    }
    
    cout<<la;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>

using namespace std;

#define long long long

const long INF = 1e18;

long h, w;

long Solve(long h, long w)
{
    long res = INF;
    for (long i = 1; i < h; ++i)
    {
        long s1 = (h - i) * w;
        long s2, s3;
        if ((i & 1) && (w & 1)) 
        {
            if (i > w) s2 = i / 2 * w, s3 = (i / 2 + 1) * w;
            else s2 = w / 2 * i, s3 = (w / 2 + 1) * i;
        }
        else s2 = s3 = i * w / 2;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    return res;
}

int main()
{
    scanf("%lld%lld",&h,&w);
    printf("%lld",min(Solve(h, w), Solve(w, h)));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long m[1000001];
int main()
{
    long long s=0,n,x,y,i=1;
    cin>>n>>x>>y;
    while(n--){
    	cin>>m[i];
    	if(i>=2){
    		int t=min((m[i]-m[i-1])*x,y);
    		s+=t;
		}
		++i;
	}
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> ans(h, vector<ll>(w,-1));
    ll now = 1;
    ll fl = 1;
    for (int i = 0; i < h; i++) {
        string n;
        cin >> n;
        ll flag = 1;
        for (int j = 0; j < w; j++) {
            if (n[j] == '#')flag=0;
        }
        if (flag == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = now;
                if (n[j] == '#')now++;
            }
            if (n[w - 1] == '.') {
                for (int j = w - 1; j > -1; j--) {
                    if (n[j] == '#')break;
                    ans[i][j] = now - 1;
                    
                }
            }
            if (fl == 1) {
                for (int j = 0; j < i; j++) {
                    for (int k = 0; k < w; k++) {
                        ans[j][k] = ans[i][k];
                    }
                }
            }
            fl = 0;
        }
        else if (fl == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = ans[i-1][j];
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j];
            if (j != w - 1)cout << " ";
        }
        cout << endl;
    }
}

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

int main()
{
    string s;
    char c[3]={};
    int k,ans=999;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)
    {
        c[0]=s[i];
        c[1]=s[i+1];
        c[2]=s[i+2];
        k=atoi(c);
       // cout<<"k = "<<k<<'\n';
        ans=min(abs(k-753),ans);
    }
    cout<<ans;
    return 0;
}




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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int a, b, c; cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);

  if (s.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  cin >> S;

  for (int i = 1; i <= S.size(); i++) {
    string t = S.substr(0, S.size() - i);
    string s = t.substr(0, t.size() / 2);
    if (t == s + s) {
      cout << t.size() << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{ 
    int n;
    ll h;
    cin >> h >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    ll res = 0;
    rep(i,n)res+= a[i];
    if(res >= h)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}   

Measured memory_bytes: 640
#include <stdio.h>

int main(void){

  int A[100];
  int i,j,n,v,k;

  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(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k < n-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

ll check(ll mid, vector<ll> A, vector<ll> F) {
    ll n = A.size();
    ll ans = 0;
    REP(i, n) {
        ll mul = A[i] * F[i];
        if (mul > mid) {
            if ((mul - mid) % F[i] == 0) {
                ans += (mul - mid) / F[i];
            } else {
                ans += (mul - mid) / F[i] + 1;
            }
        }
    }
    return ans;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    REP(i, N) { cin >> A[i]; }
    REP(i, N) { cin >> F[i]; }

    sort(ALL(A));
    sort(ALL(F), greater<ll>());
    /*
        REP(i, N) { cout << A[i] << " "; }
        cout << endl;
        REP(i, N) { cout << F[i] << " "; }
        cout << endl;
    */
    ll l = -1, r = 3 * 1e17;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        ll need = check(mid, A, F);
        // printf("l:%lld, mid:%lld, r:%lld, need:%lld\n", l, mid, r, need);
        if (need <= K) { // (l,mid]
            r = mid;
        } else { // (l,r]
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 6552
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long;
using namespace std;
using pii = pair<int, int>;

int main(){
	int n;
	scanf("%d", &n);
	while(n > 0){
		if(n % 10 == 7){
			return !printf("Yes\n");
		}
		n /= 10;
	}
	printf("No\n");
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i =0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int sum =0;
	for(int i =0; i<k; i++)
	{
	sum+=a[i];
	}
	
	cout<<sum<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100002] = {};
ll s[100002] = {};
int main() {
	ll n; cin >> n;
	ll sum = 0;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] = a[i] - a[i - 1];
		sum += abs(a[i] - a[i - 1]);
	}
	s[n + 1] = -a[n];
	sum += abs(a[n]);
	repe(i, 1, n) {
		if (a[i - 1] <= a[i] && a[i] <= a[i + 1] &&
			a[i - 1] >= a[i] && a[i] >= a[i + 1]) {
			cout << sum << endl;
		}
		else {
			ll b = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
			ll c = abs(a[i - 1] - a[i + 1]);
			cout << sum - (b - c) << endl;
		}
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> R(N);
  for(int i = 0; i < N; ++i) cin >> R[i];
  int mini = R[0];
  int ans = INT_MIN;
  for(int i = 1; i < N; ++i) {
    ans = max(ans, R[i] - mini);
    mini = min(mini, R[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1796