akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

int K;
                            
struct edge { int to, cost; };
const int MAX_V = 100000, INF = 10000000;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  d[s] = 0;
  pque.push(Pii(0, s));


  while (!pque.empty()) {
    Pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

int main() {
  cin >> K;
  V = K;

  for (int i = 1; i < K; ++i) {
    int u = mod(i*10, K), v = mod(i+1, K);
    G[i].push_back((edge){u, 0});
    G[i].push_back((edge){v, 1});
  }

  dijkstra(1);

  cout << d[0]+1 << endl;

  return 0;
}


Measured memory_bytes: 6780
from sys import exit

n = int(input())
a = [int(input()) for _ in range(n)]

visited = [False] * n
res = 0
button = 0
while True:
    visited[button] = True
    button = a[button] - 1
    res += 1

    if visited[button]:
        print(-1)
        exit()
    
    if button == 1:
        print(res)
        exit()

Measured memory_bytes: 80788
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

int main() {
	ll N; cin >> N;
	vector<ll> p(N+1); 
	for (int i = 1; i < N + 1;i++) cin >> p[i];

	ll ans = 0;
	for (int i = 1; i < N + 1; i++) {
		if (i == N  && p[i] == i) {
			swap(p[i], p[i - 1]);
			ans++;
		}
		if (p[i] == i) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

void output(vector<int> a){
    REP(i,a.size()){
        cout << a[i];
        if (i<a.size()-1)
            cout << " ";
    }
    cout << endl;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    output(a);
    FOR(i,1,n-1){
        int v=a[i];
        int j=i-1;
        while (j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        output(a);
    }

    return 0;
}

Measured memory_bytes: 1216
n = int(input())
l = list(map(int, input().split()))
l = [0] + l + [0]

ans = 0
for i in range(1, max(l)+1):
  g = 0
  for j in range(1, n+1):
    if l[j] >= i and l[j-1] < i:
      g += 1
  ans += g
print(ans)

Measured memory_bytes: 38896
#include <stdio.h>

int main(void) {
    int N, T, c[105], t[105], i, m;
    scanf("%d %d", &N, &T);
    m=1001;
    for (i=1; i<=N; i++) {
        scanf("%d %d", &c[i], &t[i]);
        if (t[i]<=T && c[i]<m) m=c[i];
    }
    if (m!=1001) printf("%d", m);
    else printf("TLE");
    return 0;
}

Measured memory_bytes: 128
nums = list(map(int, input().split()))
s = input()

l1 = [1, 4, 6, 3]
l2 = [l1[0], 2, l1[2], 5]

for char in s:
    if char == "W":
        l1 = [l1[3], l1[0], l1[1], l1[2]]
        l2[0] = l1[0]
        l2[2] = l1[2]
    elif char == "E":
        l1 = [l1[1], l1[2], l1[3], l1[0]]
        l2[0] = l1[0]
        l2[2] = l1[2]
    elif char == "N":
        l2 = [l2[1], l2[2], l2[3], l2[0]]
        l1[0] = l2[0]
        l1[2] = l2[2]
    elif char == "S":
        l2 = [l2[3], l2[0], l2[1], l2[2]]
        l1[0] = l2[0]
        l1[2] = l2[2]

print(nums[l1[0] - 1])


Measured memory_bytes: 5608
N = int(input())
S=[]
for _ in range(N):
    S.append(input())

C = [0,0,0,0]
judge = ['AC','WA','TLE','RE']

for i in range(N):
    for j in range(4):
        if judge[j]==S[i]:
            C[j]=C[j]+1

for k in range(4):
    print(f'{judge[k]} x {C[k]}')





Measured memory_bytes: 82792
#include<stdio.h>
#include<math.h>

int main(void){
	
	double x1,x2,y1,y2,dis;
	
	double tmp;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	if(x1>x2){
		
		tmp=x1;
		x1=x2;
		x2=tmp;
		
	}
	
	if(y1>y2){
		
		tmp=y1;
		y1=y2;
		y2=tmp;
		
	}
	
	dis=sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
	
	printf("%f\n",dis);
	
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int h, int w, vector<string> pixels) {
    for (int i = 0; i < w+2; i++) {
        std::cout << "#";
    }
    std::cout << std::endl;
    for (int i = 0; i < h; i++) {
        std::cout << "#" << pixels[i] << "#" << std::endl;
    }
    for (int i = 0; i < w+2; i++) {
        std::cout << "#";
    }
    std::cout << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int h,w;

    gettimeofday(&start,NULL);

    std::cin >> h >> w;
    vector<string> pixels(h);
    for (int i = 0; i < h; i++) {
        std::cin >> pixels[i];
    }
    solve(h,w,pixels);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
//  n, k;
#define loop(i, start, end) for(int i = start; i < end; i++)
#define ll long long int
#define pb push_back
vector<ll> weight, value;
ll n, w;
// int dp[100000][4] = {0};
// int recurr(){

// }

int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	int dp[n+1][3]={0};
	for(int i=0;i<n;i++)
	{
		dp[i+1][0]=a[i]+max(dp[i][1], dp[i][2]);
		dp[i+1][1]=b[i]+max(dp[i][0], dp[i][2]);
        dp[i+1][2]=c[i]+max(dp[i][0], dp[i][1]);

	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
import sys
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A, B, K = IL()

A -= K
if A > 0:
  print(A, B)
else:
  B += A
  print(0, max(0, B))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;

using uint = unsigned int;
using ll = long long;


int main(){
    ll H, W;
    cin >> H >> W;
    constexpr ll species = 10LL;
    vector<vector<ll>> cs(species, vector<ll> (species, 0));
    for (auto &&i: boost::irange(0LL, species)){
        for (auto &&j: boost::irange(0LL, species)){
            cin >> cs.at(i).at(j);
        }
    }
    vector<ll> costs(species, numeric_limits<ll>::max());
    priority_queue<pair<ll, ll>> pq{}; // pair<ll, ll> = pair<cost, node>
    costs.at(1) = 0;

    pq.push(make_pair(0, 1));
    while (!pq.empty()){

//        for (auto &&i: boost::irange(0LL, species)){
//            cout << costs.at(i) << " ";
//        }
//        cout << endl;

        ll node_to, cost;
        tie(cost, node_to) = pq.top();
        pq.pop();
        for (ll node_from: boost::irange(0LL, species)){
            ll cost_from_to = cs.at(node_from).at(node_to);
//            cout << cost_from_to << "";
            if (costs.at(node_from) > costs.at(node_to) + cost_from_to){
                costs.at(node_from) = costs.at(node_to) + cost_from_to;
                pq.push(make_pair(costs.at(node_from), node_from));
            }
        }
//        cout << endl;
    }

//    for (auto &&i: boost::irange(0LL, species)){
//        cout << costs.at(i) << " ";
//    }
//    cout << endl;

    vector<vector<ll>> As(H, vector<ll>(W, 0LL));
    for (auto &&i: boost::irange(0LL, H)){
        for (auto &&j: boost::irange(0LL, W)){
            cin >> As.at(i).at(j);
        }
    }
    ll s{0LL};
    for (auto &&i: boost::irange(0LL, H)){
        for (auto &&j: boost::irange(0LL, W)){
            if (As.at(i).at(j) != -1)s +=costs.at(As.at(i).at(j));
        }
    }
    cout << s << endl;

}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int a,b,c=0;
    cin>>a>>b;
    if( a>b)
        cout<< (2*a)-1;
    if(b>a)
        cout<<(2*b)-1;
    if(a==b)
        cout<<a+b;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n; cin>>n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin>>d[i];
    sort(d.begin(), d.end());

    cout << d[n/2] - d[n/2-1] << endl;
}

Measured memory_bytes: 640
<?php
fscanf(STDIN,'%d',$N);
fscanf(STDIN,'%s',$S);
$W=str_split(trim($S));
$max=0;
$count=0;
for ($i=0; $i <$N ; $i++) {
  // code...
  if($W[$i]=='I'){
    $count++;
  }else{
    $count--;
  }
  if($count>$max){
    $max=$count;
  }
}
echo $max;
echo "\n";


 ?>


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

int main(void) {
    ll X; cin >> X;
    ll happy_500 = X/500;
    ll happy_5 = (X%500)/5;
    ll ans = 1000*happy_500 + 5*happy_5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void)
{
  int h,n,i;
  int a[100001];
  scanf("%d %d\n",&h,&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  
  int s=0;
  for(i=1;i<=n;i++){
    s=s+a[i];
  }
  if(s>=h){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int NOEL(){
  cout<<"Impossible"<<endl;
  return 0;
}
#define N 100010
ll n,m,a[N];
vector<ll> ans;
void Outs(){
  cout<<ans.size()<<endl;
  for(auto x:ans)cout<<x<<endl;
}
void Lend(ll x){
  if(x%2==1){
    lol(i,x/2+1)ans.push_back(2);
  }
  else{
    lol(i,x/4)ans.push_back(2);
    ans.push_back(1);
    lol(i,x/2-x/4)ans.push_back(2);
  }
  
}
void Rend(ll x){
  vector<ll> mem;
  if(x%2==1){
    lol(i,x/2)mem.push_back(2);
  }
  else{
    lol(i,x/4)mem.push_back(2);
    mem.push_back(1);
    lol(i,x/2-1-x/4)mem.push_back(2);
  }
  reverse(mem.begin(),mem.end());
  for(auto t:mem)ans.push_back(t);
}
void Centor(ll x){
  if(x==2){
    ans.push_back(2);
    return;
  }
  ans.push_back(x-4);
  ans.push_back(4);
}
int main(){
    cin>>n>>m;
    lol(i,m){
      cin>>a[i];
      if(a[i]&1)a[i]=-a[i];
    }
    sort(a,a+m);
    if(m==1){
      if(a[0]<0)a[0]=-a[0];
      Lend(a[0]);
      ans.pop_back();
      ans.push_back(1);
      cout<<a[0]<<endl;
      Outs();
      return 0;
    }
    ll cnt=0;
    lol(i,m)if(a[i]<0)cnt++,a[i]=-a[i];
    if(cnt>2)return NOEL();
    Lend(a[0]); cout<<a[0]<<endl;
    for(int i=2;i<m;i++){
      Centor(a[i]);
      cout<<a[i]<<endl;
    }
    Rend(a[1]); cout<<a[1]<<endl;
    cout<<endl;
    Outs();
    return 0;
}


Measured memory_bytes: 1268
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int a[50],b[50];
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	y=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		y+=x;
	}
	for(i=1;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	for(i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1]-1)
		{
			y+=b[a[i]];
		}
	}
	printf("%d",y);
}


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

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

    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll res = 0;
    rep(i, n-1){
        if(a[i]+a[i+1] > x){
            if(a[i] > x){
                res += a[i+1] + a[i] - x;
                a[i] = x;
                a[i+1] = 0;
            }
            else{
                res += a[i+1] - (x-a[i]);
                a[i+1] = x - a[i];
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int A[100010];

void solve(){
	int n; scanf("%d", &n);
	rep(i, n) {
		int x; scanf("%d",&x);
		rep(j, 3) A[x+j]++;
	}
	printf("%d\n", *max_element(A, A+100005));
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; i++){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

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


int N, K;
vector<int> H;


void input() {
    cin >> N >> K;
    H = vector<int>(N);
    rep(i, N) cin >> H[i];
}


int main() {
    input();
    sort(H.rbegin(), H.rend());
    ll ans = 0;
    for (int i = K; i < N; i++) ans += H[i];
    cout << ans << endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            //var h = Read<long>();
            //var n = Read<long>();
            //var m = Read<long>();
            //var s = Read();
            //var cls = Read<long>(n);
            //var bls = Read<long>(n);
            //var sls = Read(n);
            /*List<(string s, long c)> scls = new List<(string s, long c)>();
            for (int i = 0; i < m; ++i)
            {
                scls.Add((Read(), Read<long>()));
            }*/
            //List<List<long>> abls = new List<List<long>>();
            //List<long> cls = new List<long>();
            /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList();
            for (int i = 0; i < n - 1; ++i)
            {
                abls.Add(Read<long>(2));
                abls[i].Add(i);
                abls[i].Add(-1);
                --abls[i][0];
                --abls[i][1];
                //cls.Add(Read<long>());
                ++edgeNum[(int)abls[i][0]];
                ++edgeNum[(int)abls[i][1]];
            }*/

            //als.Sort((l, r) => (int)(r - l));

            var s = Read();

            Console.WriteLine(new string(s.Select(val => 'x').ToArray()));
        }

        static IEnumerator<string> input_iter;

        static IEnumerator<string> LazyLoadAllLines(bool doSplit = true)
        {
            string line;
            if (doSplit)
            {
                do
                {
                    line = Console.ReadLine();
                    foreach (var s in line.Split(' '))
                        yield return s;
                } while (line != null);
            }
            else
            {
                do
                {
                    line = Console.ReadLine();
                    yield return line;
                } while (line != null);
            }
        }
        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        static List<_T> Read<_T>(long num) where _T : struct
        {
            List<_T> res = new List<_T>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T)));
            }
            return res;
        }
        static List<string> Read(long num)
        {
            List<string> res = new List<string>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add(input_iter.Current);
            }
            return res;
        }

    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}*Node;

Node root;

/*Node treeMinimum(Node x){

}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key<x->key){
      x = x->left;
    }
    else{
      x =x->right;
    }
  }
  z->parent= y;
  if(y==NIL){
    root = z;
  }
  else if(z->key<y->key){
    y->left =z;
  }
  else{
    y->right =z;
  }
  
  
  
  
  
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    /* if ( com[0] == 'f' ){
       scanf("%d", &x);
       Node t = treeSearch(root, x);
       if ( t != NIL ) printf("yes\n");
       else printf("no\n");
      } else */if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }/* else if ( com[0] == 'd' ){
	scanf("%d", &x);
	treeDelete(treeSearch(root, x));
	}*/
  }
  
  return 0;
}

Measured memory_bytes: 24040
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;

    vector<int> K(N,0);
    vector<vector<int>> A(N,vector<int>(M,0));
    vector<int> hoge(M,0);
    for(int i=0;i<N;i++){
        cin >> K[i];
        for(int j=0;j<K[i];j++){
            cin >> A[i][j];
            hoge[(A[i][j])-1]++;
        }
    }
    int ans=0;
    for(int j=0;j<M;j++){
        if(hoge[j]==N)ans++;
    }
    

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;
int main(){
	int K,N;
	cin>>K>>N;
	vector<int>A(N);
	rep(i,N){
		cin>>A.at(i);
	}
	int sum=A.at(A.size()-1)-A.at(0);
	int mae=0;
	int max=0;
	rep(i,N){
		if(A.at(i)-mae>max){
			max=A.at(i)-mae;
		}
		mae=A.at(i);
		//sum+=A.at(i);
	}
	if(K-sum>max){
		max=K-sum;
	}
	cout<<K-max<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn count_digits(n: usize) -> usize {
    let mut ret = 0;
    let mut rem = n;
    while rem != 0 {
        ret += 1;
        rem /= 10;
    }
    ret
}

fn F(a: usize, b: usize) -> usize {
    max(count_digits(a), count_digits(b))
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut ans = INF;
    for i in (1..).take_while(|i| i * i <= N) {
        if N % i == 0 {
            ans = min(ans, F(N/i, i));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int t=sc.nextInt();
    int u=0,t1=0;
    while(u<n){
      t1=t1+t;
      u=u+x;
    }
    System.out.println(t1);
  }}

Measured memory_bytes: 35696
#include<iostream>

using namespace std;

int main(int argc, char const *argv[]) {
    int n,y;
    cin >> n >> y;
    y /= 1000;
    bool f=false;
    int a,b,c;
    for(int itiman=0;itiman<=n;itiman++){
        for(int gosen=0;gosen<=n-itiman;gosen++){
            if(y == itiman*10+gosen*5+n-itiman-gosen){
                a = itiman;
                b = gosen;
                c = n-itiman-gosen;
                f = true;
            }
        }
    }
    if(f){
        printf("%d %d %d\n",a,b,c);
    }else{
        printf("-1 -1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 256
//  Created by Sengxian on 2017/6/18.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 100 + 3;
char str[MAX_N];
int n;

int main() {
	scanf("%s", str);
	n = strlen(str);
	int ans = INT_MAX;
	for (int i = 0; i < 26; ++i) {
		int lst = -1;
		for (int j = 0; j < n; ++j) if (str[j] == 'a' + i) lst = j;
		int mx = n - lst - 1;
		for (int j = 0; j < lst; ++j) {
			int mn = INT_MAX;
			for (int k = j; k < n; ++k)
				if (str[k] == 'a' + i)
					mn = min(mn, abs(j - k));
			mx = max(mx, mn);
		}
		ans = min(ans, mx);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            if (iA > 9 || iB > 9) { iOut = -1; }
            else { iOut = iA * iB; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring> 
#include <queue>
#include <iostream>
using namespace std;
#define N 9
#define INF 0x3fffffff
#define MOD 1000003LL

long long start, end, input[N], states[MOD];
const int step[4] = {1, -1, 3, -3};
int costs[2], mincost[MOD];
bool inque[MOD];

inline long long encode(long long nums[]){
  long long res = 0;
  for(int i = 0; i < N; i++) res |= nums[i] << (i << 2);
  return res;
}

inline void decode(long long num, long long nums[], int &idx){
  for(int i = 0; i < N; i++) nums[i] = (num >> (i << 2)) & 0xfLL;
  for(int i = 0; i < N; i++) if(nums[i] == 0){ idx = i; break; }
}

inline int find_hash(long long state){
  int hash = state % MOD;
  while(states[hash] != -1)
    if(states[hash] == state) break;
    else hash = (hash + 1) % MOD;
  if(states[hash] == -1) states[hash] = state;
  return hash;
}

inline int val(long long state){
  return mincost[find_hash(state)];
}

inline bool add(long long state, int cost){
  int hash = find_hash(state);
  
  if(cost < mincost[hash]){ mincost[hash] = cost; return true; } 
  else return false;
}

inline int solve(){
  memset(states, -1, sizeof(states));
  memset(inque, false, sizeof(inque));
  for(int i = 0; i < MOD; i++) mincost[i] = INF;
  
  int idx, tmp;
  long long nums[N];
  
  queue<long long> que;
  que.push(start); add(start, 0); inque[find_hash(start)] = true;
  
  while(!que.empty()){
    long long state = que.front(); que.pop();
    int cost = val(state);
    inque[find_hash(state)] = false;
    
    if(cost >= val(end)) continue;
    if(state == end) continue;
    
    decode(state, nums, idx);
    for(int i = 0; i < 4; i++){
      int nxt = (idx + N + step[i]) % N;
      int nxtcost = cost + costs[i >> 1];
      tmp = nums[idx]; nums[idx] = nums[nxt]; nums[nxt] = tmp;
      long long nxtstate = encode(nums);
      
      if(add(nxtstate, nxtcost) && !inque[find_hash(nxtstate)]) que.push(encode(nums));
      tmp = nums[idx]; nums[idx] = nums[nxt]; nums[nxt] = tmp;
    }
  }
  return val(end);
}

int main(){
  while(scanf("%d%d", costs, costs + 1) == 2 && (costs[0]  || costs[1])){
    for(int i = 0; i < N; i++) scanf("%d", input + i);
    start = encode(input);
    for(int i = 0; i < N; i++) scanf("%d", input + i);
    end = encode(input);
    
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 14916
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	long long K;
	cin>>K;
	long long B[K+1];
	B[0]=0;
	B[1]=7%K;
	for(int i=1;i<=K;i++){
		B[i]=(10*B[i-1]+7)%K; //mod K (B[i],B[i-1]*10+7をKで割った時のあまりは等しい)
		if(B[i]==0){
			cout<<i<<endl;
			break;
			}else if(i==K){cout<<-1<<endl;}
	}
}

Measured memory_bytes: 11208
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  m = n;
  cout << n << ':';

  for (int i = 2; i * i < m; i++) {
    while (n % i == 0) {
      cout << ' ' << i;
      n /= i;
    }
  }

  if (n > 1) {
    cout << ' ' << n;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const ll Mod = 1e9 + 7;


ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}

void solve1() {
	ll k,d0,d1;
	cin >> k >> d0 >> d1;
	ll sum=d0+d1;
	ll c = ((2*sum)%10)+((4*sum)%10)+((8*sum)%10)+((6*sum)%10);
	ll n_c = (k-3)/4;
	ll tot = 0;
	if(k==2){
		tot = sum;
		}
	else{
		tot = sum+(sum%10) + (c * 1ll * n_c);
		ll l_o = (k-3)-(n_c*4);
		ll p = 2;
		for(ll i = 1 ; i <= l_o ; i++){
			tot += ((p*sum)%10);
			p = (p*2)%10;
		}
	} 
	if(tot%3)
		cout<<"NO\n";
	else
		cout<<"YES\n";
}
void solve2(){
	ll n,i=0,temp=LLONG_MIN,sum=0;
	cin >> n;
	vector<ll> hash(n);
	for(auto &x : hash)
		cin >> x;
	while(true){
		if(i >= n)
			break;
	if(hash[i] > 0){
		while(i < n && hash[i] > 0){
			temp=max(temp,hash[i]);
			i++;
		}
	}
	else{
		while(i < n && hash[i] < 0){
			temp = max(temp,hash[i]);
			i++;
		}
	}
	sum+=temp;
	temp = LLONG_MIN;
}
cout<<sum<<"\n";
	
		
}

void chmax(ll& a,ll b) {
	a=max(a,b);
	}

void solve(){
	ll n;
	cin >> n;
	vector<ll> hash(n);
	for(auto &x : hash)
		cin >> x;
	vector<vector<ll>> dp(n+1,vector<ll>(n+1,INT_MIN));
	dp[0][0] = 0;
	vector<pair<ll,ll>> p;
	for(ll i = 0 ; i < n ; i++)
		p.emplace_back(hash[i],i);
	sort(p.rbegin(),p.rend());
	for(ll i = 0 ; i < n ; i++){
		ll pi = p[i].second;
		for(ll l = 0 ; l < i+1 ; l++){
			ll r = i-l;
			chmax(dp[i+1][l+1],dp[i][l]+ll(pi-l)*hash[pi]);
			chmax(dp[i+1][l],dp[i][l]+ll((n-r-1)-pi)*hash[pi]);
		}
	}
	ll ans = 0;
	for(ll i = 0 ; i < n+1 ; i++)
		chmax(ans,dp[n][i]);
	cout<<ans<<endl;
}

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


Measured memory_bytes: 34620
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};
Int h,w;
Int a[20][20];
Int v[100];
vector<Int> G[100];
Int indeg[100];

Int idx(Int y,Int x){
  return y*w+x;
}

Int dy[]={-1,0,0,1,1,1};
Int dx[]={0,-1,1,-1,0,1};
Int in(Int y,Int x){
  return 0<=y&&y<h&&0<=x&&x<w;
}
const Int MOD = 1e9+7;

Int dfs(Int x,vector<Int> &vs){
  if(x==(Int)vs.size()) return 1;
  Int res=0;
  for(Int i=0;i<4;i++){
    Int ng=0;
    for(Int y:G[vs[x]]){
      indeg[y]--;
      if(v[y]<i) ng=1;
      v[y]-=i;
      if(!indeg[y]&&v[y]) ng=1; 
    }
    if(!ng) res+=dfs(x+1,vs);
    res%=MOD;
    for(Int y:G[vs[x]]){
      v[y]+=i;
      indeg[y]++;
    }
  }
  return res;
}

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin>>h>>w;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];

  UnionFind uf(h*w);
  memset(v,-1,sizeof(v));
  memset(indeg,0,sizeof(indeg));
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(!a[i][j]) continue; 
      v[idx(i,j)]=a[i][j];
      for(Int k=0;k<6;k++){
	Int y=i+dy[k],x=j+dx[k];
	if(!in(y,x)||a[y][x]) continue;
	indeg[idx(i,j)]++;
	G[idx(i,j)].emplace_back(idx(y,x));
	G[idx(y,x)].emplace_back(idx(i,j));
	uf.unite(idx(i,j),idx(y,x));
      }
    }
  }

  Int ans=1;
  vector<Int> used(h*w,0);
  for(Int i=0;i<h*w;i++){
    if(uf.find(i)!=i) continue;
    vector<Int> vs;
    for(Int j=0;j<h*w;j++)
      if(v[j]<0&&uf.same(i,j)) vs.emplace_back(j);
    if(vs.empty()) ans=0;
    ans*=dfs(0,vs);
    ans%=MOD;
    continue;
    cout<<i<<":"<<uf.r[i]<<":"<<dfs(0,vs)<<endl;
    for(Int k:vs) cout<<k<<" ";
    cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX=101;
bool Visited[MAX]; //??\?????????????¢??????????
vector<int> Adjacency[MAX];
int dTime[MAX]; int fTime[MAX]; //?¢??????°??¶??´????¢?????????¶??´
void dfs(int j,int& clock)
{

    stack<int> S;
    S.push(j);dTime[j]=++clock;
    Visited[j]=true;
    while(!S.empty())
    {
        int p=S.top(); //???????????¶??????
        if(Adjacency[p].size()==0)
        {
            S.pop();
            fTime[p]=++clock;
            continue;
        }
        int i=0;
        if(Adjacency[p].size())
          while(Visited[Adjacency[p][i]]==true)
          {
            i++;
            if(i==Adjacency[p].size()) //???????°??????????????±?????????????
            {
                S.pop();
                fTime[p]=++clock;
                break;
            }
          }
        if(i==Adjacency[p].size()) continue;
        //if founded
        S.push(Adjacency[p][i]); dTime[Adjacency[p][i]]=++clock;
        Visited[Adjacency[p][i]]=true;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) Visited[i]=false;

    for(int i=1;i<=n;i++)
    {
        int p;cin>>p;
        int num;
        cin>>num;

        for(int j=0;j<num;j++)
        {
            int t;
            cin>>t;
            Adjacency[p].push_back(t);
        }
    }
    int clock=0;
    for(int i=1;i<=n;i++)  //???????????????????????°DFS?£?????????????
    {
        if(Visited[i]==false) dfs(i,clock);
    }
    for(int i=1;i<=n;i++)
        cout<<i<<' '<<dTime[i]<<' '<<fTime[i]<<endl;
}

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

int main() {
	int n;
	cin>>n;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if((4*j+7*i)==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	int m,n;
	cin >> m >> n;
	cout << (m-1)*(n-1) << endl;
	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/07/16
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
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<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


struct zahyou {
    int x, y;

    bool operator<(const zahyou &another) const {
        //メンバ変数であるnum1で比較した結果を
        //この構造体の比較とする
        return x < another.x;
    }

};

int main() {
    int N, K;
    cin >> N >> K;
    vi x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    int cnt;
    int cx1, cx2;
    int cy1, cy2;
    ll ans = LONG_LONG_MAX;
    rep(xi, N) {
        FOR(xj, xi + 1, N) {
            rep(yi, N) {
                FOR(yj, yi + 1, N) {
                    cnt = 0;
                    cx1 = min(x[xi], x[xj]);
                    cx2 = max(x[xi], x[xj]);
                    cy1 = min(y[yi], y[yj]);
                    cy2 = max(y[yi], y[yj]);
                    rep(i, N) {
                        if ((cx1 <= x[i] && x[i] <= cx2) && (cy1 <= y[i] && y[i] <= cy2)) cnt++;
                    }
                    if (cnt >= K) {
                        ans = min(ans, (ll) (cx2 - cx1) * (cy2 - cy1));
                    }
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll h,w,m;
	cin>>h>>w>>m;
	vector<ll> x(m),y(m),cnt1(h,0),cnt2(w,0);
	vector<ll> g(h,0);
	rep(i,m){
		cin>>x[i]>>y[i];
		x[i]--,y[i]--;
		cnt1[x[i]]++;
		cnt2[y[i]]++;
	}
	ll ma=*max_element(begin(cnt2),end(cnt2));
	set<ll> ind;
	rep(i,w){
		if(cnt2[i]==ma){
			ind.insert(i);//最大個数ある列
		}
	}
	rep(i,m){
		if(ind.count(y[i])){
			g[x[i]]++;
		}
	}
	ll ans=0;
	rep(i,h){
		ll now=cnt1[i]+ma-1;//か+ma-1
		if(g[i]!=ind.size()) now++;
		chmax(ans,now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 29036
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;





signed main() {
	speed;
	string s;
	cin >> s;
	cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
def selection_sort(lis, l):
    times = 0
    for i in range(0, l - 1):
        minj = i
        minj_cp = minj
        for j in range(i, l):
            if lis[j] < lis[minj]:
                minj = j
        if minj_cp != minj:
            times += 1
        ele = lis[i]
        lis[i] = lis[minj]
        lis[minj] = ele
    return times

inputs = []
while True:
    try:
        inputs.append(input())
    except(EOFError):
        break

ln = int(inputs[0])
li = list(map(int, inputs[1].split()))

t = selection_sort(li, ln)

print(*li)
print(t)



Measured memory_bytes: 5608
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, Q = lr()
ABCD = [lr() for _ in range(Q)]
A = [1] * N
ABCD.sort(key=lambda x: x[3], reverse=True)
ABCD.sort(key=lambda x: x[0])
answer = 0
for a in [1]:
    for b in range(a, M+1):
        for c in range(b, M+1):
            for d in range(c, M+1):
                for e in range(d, M+1):
                    for f in range(e, M+1):
                        for g in range(f, M+1):
                            for h in range(g, M+1):
                                for i in range(h, M+1):
                                    for j in range(i, M+1):
                                        temp = 0
                                        x = [a,b,c,d,e,f,g,h,i,j]
                                        for k, l, m, n in ABCD:
                                            if x[l-1] - x[k-1] == m:
                                                temp += n
                                        if temp > answer:
                                            answer = temp

print(answer)


Measured memory_bytes: 76284