akhauriyash/Code-Regression huggingface dataset:
// Problem : Red Scarf
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc171_e
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    int n;
    cin >> n;
    vl v(n);
    in(v);
    ll tot=0;
    lp(i,0,n)
    	tot^=v[i];
    //(n-1)time ai occurs in net xor since n is even n-1 is odd and only once it would remain
    lp(i,0,n){
    	//solving xor equation
    	//x^(remall)=total
    	cout<<(tot^v[i])<<" ";
    }
}

Measured memory_bytes: 4796
#include <cstdio>
int main () {
    int n,k,a,b,c;
    scanf("%d%d%d",&n,&k,&b);
    c=k=0,n--;
    while(n--){
        scanf("%d",&a);
        if (a-b==c) k++;
        else if (a-b>c) k=1,c=a-b;
        else if (a<b) b=a;
    }
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 128
class Dice:
    D = {'E': (3, 1, 0, 5, 4, 2),
         'W': (2, 1, 5, 0, 4, 3),
         'S': (4, 0, 2, 3, 5, 1),
         'N': (1, 5, 2, 3, 0, 4)}
    def __init__(self, a, b, c, d, e, f):
        self.nbrs = [a, b, c, d, e, f]
    def rll(self, dr):
        self.nbrs = [self.nbrs[i] for i in self.D[dr]]
    def issame(self, othrdice):
        for i in 'NNNN':
            self.rll(i)
            for j in 'EEEE':
                self.rll(j)
                for k in 'NNNN':
                    self.rll(k)
                    if self.nbrs == othrdice.nbrs:
                        return True
        return False


n = int(input())
dices = []
for _ in range(n):
    a, b, c, d, e, f = input().split()
    dice = Dice(a, b, c, d, e, f)
    dices.append(dice)
for x in range(n - 1):
    for y in range(x + 1, n):
        if dices[y].issame(dices[x]):
            print('No')
            exit()
print('Yes')


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

int ans[200001];
int data[200001];
int main(){
    int N;
    cin>>N;
    for(int i=1;i<=N;i++){
        int x;
        cin>>x;
        data[i]=x;
    }

    int M=0;

    for(int i=N;i>0;i--){
        int p=N/i;
        int c=0;
        for(int j=1;j<=p;j++) c+=ans[j*i];
        if(c%2!=data[i]) {ans[i]=1; M++;}
    }

    cout<<M<<endl;

    if(M){
    for(int i=1;i<=N;i++){
        if(ans[i]) cout<<i<<' ';
    }
    cout<<endl;
    }

}

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

using namespace std;

int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	cout <<  ((a % 2 && b % 2 && c % 2) ? min(min(1ll*a*b, 1ll*b*c), 1ll*a*c) : 0); 
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const lList = input[1].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const X = numList0[1];

    var currentX = 0;
    var count = 0;
    if (currentX <= X) {
        count++;
    }

    for (var i = 0; i < N; i++) {
        currentX += lList[i];
        if (currentX <= X) {
            count++;
        }
    }

    console.log(count);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n = int(input())
u,x,y = 0,0,0

for i in range(n):
    t,a,b = map(int,input().split())
    dis = abs(x-a) + abs(y-b)
    if dis%2!=(t-u)%2 or dis>t:
        print('No')
        exit()
    u,x,y = t,a,b
print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    ll N,K; cin >> N >> K;
    vector<ll> H(N); rep(i,N) cin >> H[i];
    sort(ALL(H));
    ll sum = 0;
    rrep(i,N){
        if(K <= 0) sum += H[i];
        --K;
    }
    
    print(sum);
    
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		for(int i = 0; i < M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			int p = 0;
			int min = 0;
			for(int j = 0; j < M; j++) {
				int x = Math.abs(a[i] - c[j]);
				int y = Math.abs(b[i] - d[j]);
				if(j == 0) {
					min = x + y;
					p = j;
				} else {
					if(x + y < min) {
						min = x + y;
						p = j;
					}
				}
			}
			System.out.println(p + 1);
		}
	}
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n, a, b, c;
		cin >> n >> a >> b >> c;
		vector<string> ans(n);
		bool f2 = (a + b + c == 2);
		vector<string> q(n);
		for (int i = 0; i < n; i++) cin >> q[i];
		for (int i = 0; i < n; i++) {
			if (q[i] == "AB") {
				if (a == 1 && b == 1 && f2 && i != n - 1) {
					if (q[i + 1] == "AB" || q[i + 1] == "AC") {
						a++;
						b--;
						ans[i] = "A";
					} else {
						b++;
						a--;
						ans[i] = "B";
					}
				} else if (a == 0 && b == 0) {
					cout << "No\n";
					return;
				} else if (a < b) {
					ans[i] = "A";
					a++;
					b--;
				} else {
					ans[i] = "B";
					b++;
					a--;
				}
			} else if (q[i] == "BC") {
				if (b == 1 && c == 1 && f2 && i != n - 1) {
					if (q[i + 1] == "AB" || q[i + 1] == "BC") {
						b++;
						c--;
						ans[i] = "B";
					} else {
						c++;
						b--;
						ans[i] = "C";
					}
				} else if (b == 0 && c == 0) {
					cout << "No\n";
					return;
				} else if (b < c) {
					ans[i] = "B";
					b++;
					c--;
				} else {
					ans[i] = "C";
					c++;
					b--;
				}
			} else {
				if (a == 1 && c == 1 && f2 && i != n - 1) {
					if (q[i + 1] == "AB" || q[i + 1] == "AC") {
						a++;
						c--;
						ans[i] = "A";
					} else {
						c++;
						a--;
						ans[i] = "C";
					}
				} else if (a == 0 && c == 0) {
					cout << "No\n";
					return;
				} else if (a < c) {
					ans[i] = "A";
					a++;
					c--;
				} else {
					ans[i] = "C";
					c++;
					a--;
				}
			}
		}
		cout << "Yes\n";
		for (int i = 0; i < n; i++) cout << ans[i] << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int A,B,K;
cin >> A >> B >> K;

vi D;

int R = min(A,B);
rrep(i,R) {
    if( A%i == 0 && B%i == 0 ) D.push_back(i);
}
sort(all(D), greater<int>());
cout << D[K-1] << endl;
return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	string S;
	cin >> S;
	int ch=0;
	REP(i, S.size()-1){
		if(S[i]!=S[i+1]) ch++;
	}
	cout << ch << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int ans=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        ans+=abs(A[i]);
    }
    sort(A.begin(), A.end());
    if(N==2){
        cout << A[1] - A[0] << endl;
        cout << A[1] << ' ' << A[0] << endl;
    }else if(A[0]>=0){
        cout << ans-A[0]*2 << endl;
        int tmp=A[0]-A[N-1];
        cout << A[0] << ' ' << A[N-1] << endl;
        for(int i=1; i<=N-3; i++){
            cout << tmp << ' ' << A[i] << endl;
            tmp-=A[i];
        }
        cout << A[N-2] << ' ' << tmp << endl;
    }else if(A[N-1]<=0){
        cout << ans+A[N-1]*2 << endl;
        cout << A[N-1] << ' ' << A[0] << endl;
        int tmp=A[N-1]-A[0];
        for(int i=1; i<=N-2; i++){
            cout << tmp << ' ' << A[i] << endl;
            tmp-=A[i];
        }
    }else{
        cout << ans << endl;
        int flag;
        for(int i=0; i<N; i++){
            if(A[i]>0){
                flag=i;
                break;
            }
        }
        
        for(int i=N-2; i>=flag; i--){
            cout << A[flag-1] << ' ' << A[i] << endl;
            A[flag-1]-=A[i];
        }
        for(int i=0; i<=flag-1; i++){
            cout << A[N-1] << ' ' << A[i] << endl;
            A[N-1]-=A[i];
        }
    }



    return 0;
}

Measured memory_bytes: 2304
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var n int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	A := make([]int, n)
	ma := make(map[int]int, n)
	for i := 0; i < n; i++ {
		A[i] = nextInt()
		ma[A[i]]++
	}

	all := 0
	for _, v := range ma {
		all += v * (v - 1) / 2
	}
	//fmt.Println(ma)
	for k := 0; k < n; k++ {
		v := ma[A[k]]
		before := v * (v - 1) / 2
		after := (v - 2) * (v - 1) / 2
		fmt.Println(all - (before - after))
	}
}


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

int main(void){
  char S[11];
  char T[12];
  cin >> S;
  cin >> T;
  int num=0;
  int NUM_S = strlen(S);

  for(int i=0;i<NUM_S;i++){
    if(S[i]==T[i]) continue;
    else num++;
  }
  if (num==0)  printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

 
int main() {
   int n,k,q;
   cin>>n>>k>>q;
   vector<ll> P(n,k-q);
   rep(i,q){
       int a;
       cin>>a;
       P[a-1]++;
   }
   rep(i,n){
       if(P[i]>0)cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
   }
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

bool s[22][52];
bool uni[52];

int main() {
	int n; cin >> n;
	vector<vector<pair<int, int>>> edg(50, vector<pair<int, int>>(50));
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		edg[u][v] = edg[v][u] = { 1, i };
	}
	int m; cin >> m;
	auto func = [&](auto& self, int t, int a, int from, int goal) -> bool {
		if (a == goal) return true;
		for (int i = 0; i < n; i++) {
			if (i == from) continue;
			if (edg[a][i].first == 0) continue;
			bool ret = self(self, t, i, a, goal);
			if (ret) {
				s[t][edg[a][i].second] = true;
				return true;
			}
		}
		return false;
	};

	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		func(func, i, a, -1, b);
	}

	ll ng = 0;
	for (int t = 1; t < (1 << m); t++) {
		int bcnt = 0;
		for (int i = 0; i < m; i++) {
			bcnt += (t >> i) & 1;
		}
		for (int i = 0; i < n; i++) {
			uni[i] = false;
		}
		for (int c = 0; c < m; c++) {
			if (!((t >> c) & 1)) continue;
			for (int i = 0; i < n; i++) {
				uni[i] |= s[c][i];
			}
		}
		ll pcnt = 0;
		for (int i = 0; i < n; i++) {
			pcnt += uni[i];
		}
		ll c = 1LL << (n - 1 - pcnt);
		if (!(bcnt & 1)) c *= -1;
		ng += c;
	}
	cout << (1LL << (n - 1)) - ng << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

s = [int(x) for x in stdin.readline().rstrip()]
n = len(s)

#0番目を1にする
res = 0
for i,name in enumerate(s):
    if i%2 == 0 and name == 0:
        res += 1
    elif i%2 == 1 and name == 1:
        res += 1

#0番目を0にする
res2 = 0
for i,name in enumerate(s):
    if i%2 == 0 and name == 1:
        res2 += 1
    elif i%2 == 1 and name == 0:
        res2 += 1
print(min(res,res2))

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int n, a[10] = { 0 };
int f[100][10];
ll p[100][11];
ll ans = -1e9;

void dfs(int i) {
	if (i == 10) {
		int e = 0;
		ll d = 0;
		FOR(j, n) {
			int x = 0;
			FOR(k, 10) {
				if (a[k] && f[j][k]) {
					x++;
					e++;
				}
			}
			d += p[j][x];
		}
		if (!e)return;
		ans = max(ans, d);
		return;
	}
	a[i] = 0;
	dfs(i + 1);
	a[i] = 1;
	dfs(i + 1);
}

int main() {

	cin >> n;
	
	FOR(i, n) {
		FOR(j, 10)cin >> f[i][j];
	}
	FOR(i, n) {
		FOR(j, 11)cin >> p[i][j];
	}
	dfs(0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
int dp[514][100001], n;
vector<int> v(262144 + 1, 0), w(262144 + 1, 0);
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i, j, q;
    cin>>n;
    for(i = 1; i <= n; i++) {
    	cin>>v[i]>>w[i];
    }
	for(i = 1; i <= min(n, 512); i++) {
		for(j = 0; j <= 100000; j++) {
    		dp[i][j] = dp[i/2][j];
    		if(w[i] <= j) {
    			dp[i][j] = max(dp[i][j], dp[i/2][j - w[i]]+v[i]);
    		}
    	}
    }
    cin>>q;
    while(q--) {
    	int x, l, ans = 0;
    	vector<int> cur;
    	cin>>x>>l;
    	while(x > 512) {
    		cur.pb(x);
    		x /= 2;
    	}
    	int len = cur.size();
    	for(int i = 0; i < (1 << len); i++) {
    		int cur_val = 0, cur_weight = 0;
    		for(int j = 0; j < len; j++) {
    			if(i & (1 << j)) {
    				cur_val += v[cur[j]];
    				cur_weight += w[cur[j]];
    			}
    		}
    		if(cur_weight > l) {
    			continue;
    		}
    		ans = max(ans, cur_val + dp[x][l-cur_weight]);
    	}
    	cout<<ans<<"\n";
    }
}

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

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    if(h>w){
        int i=0;
        int painted = 0;
        while(1){
            i++;
            painted += h;
            if(painted >= n)break;
        }
        cout << i << endl;
    }else{
        int i=0;
        int painted = 0;
        while(1){
            i++;
            painted += w;
            if(painted >= n)break;
        }
        cout << i  << endl;
    }
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc043/tasks/arc059_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    int rou = round((double)accumulate(ALL(v), 0LL) / n);
    int ans = 0;
    for (auto &x : v)
        ans += abs(x - rou) * abs(x - rou);
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };

int main() {
  ll N,M;cin>>N>>M;
  vector<string> pic1(N);
  vector<string> pic2(M);
  REP(i,N) cin>>pic1[i];
  REP(i,M) cin>>pic2[i];

  // 単純にずらしていくだけ
  REP(i,N-M+1)REP(j,N-M+1) {
    bool tmp = true;
    REP(a,M)REP(b,M) {
      if (pic1[i+a][j+b]!=pic2[a][b]) tmp = false;
    }
    if (tmp) {
      OUT("Yes");
      return 0;
    }
  }
  OUT("No");

  return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
ans=[]
for aa in range(31):
  for bb in range(31):
    w=100*(aa*a+bb*b)
    if w>f:break
    n=min(f-w,e*(aa*a+bb*b))
    for cc in range(3001):
      s=cc*c
      if s>n:break
      nn=n-s
      ss=d*(nn//d)
      su=s+ss
      wa=w
      if wa+su==0:continue
      ans.append([100*su/(wa+su),wa,su])
ans.sort(reverse=1)
_,w,s=ans[0]
print(w+s,s)

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 9;
ll d[N], c[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  ll len = 0, sum = 0;
  for(int i = 1; i <= n; i ++ ){
    cin >> d[i] >> c[i];
    sum += d[i] * c[i];
    len += c[i];
  }
  ll ans = len - 1;
  if(sum >= 9)
    ans += (sum - 1) / 9;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3456
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()

	nn := make([]int, 0, n)
	for i := 0; i < n; i++ {
		nn = append(nn, nextInt())
	}

	var re int

	r := 2
	for i := 0; r < n; i++ {
		nums := make([]int, 0, 3)
		for index := i; index <= r; index++ {
			nums = append(nums, nn[index])
		}

		tmp := nums[1]
		if Min(nums...) != tmp && Max(nums...) != tmp {
			re++
		}
		r++
	}

	fmt.Println(re)
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		} else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){

	int n,m;
	cin>>n>>m;
	int l[m],r[m];
	for(int i=0;i<m;i++)cin>>l[i]>>r[i];

	int a[n]={ };
	for(int i=0;i<m;i++){
		a[l[i]-1]++;
		a[r[i]]--;
	}

	int count=0;
	if(a[0]==m)count++;
	for(int i=0;i<n-1;i++){
		a[i+1]+=a[i];
		if(a[i+1]==m)count++;
	}

	cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 1408
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var M = one[1];
  var list = [];
  for(var i = 0; i < M; i++){
    var tmp = myconv(next(),4);
    tmp.shift();
    list.push(tmp);
  }
  var p = myconv(next(),4);
  var output = 0;
  //スイッチの状態0~2^N-1
  for(var i = 0; i < (1 << N); i++){
    //電球がついてる個数(これ==Mになったらパターン+1)
    var allon = 0;
    
    //ある電球がついてるかどうか。
    for(var j = 0; j < M; j++){
      
      //電球とつながってるスイッチがONの個数
      var on = 0;
      for(var k = 0; k < list[j].length; k++){
        if((i & (1 << (N - list[j][k]))) != 0){
          //myerr(i.toString(2) + " & (1 << " + (list[j][k] - 1) + ") = " + (i & (1 << (list[j][k] - 1))));
           on++;
        }
      }
      if(on % 2 == p[j]){
        //myerr(j + "個目の電球がついた" + i.toString(2) + " " + on);
         allon++;
      }
    }
    if(allon == M){
      //myerr(i.toString(2) + " 全部の電球がついた");
      output++;
    }
  }
  myout(output);
}

Measured memory_bytes: 7372
//package A;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a,b,c;
        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();
        if (a+b+c==17)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 35752
N = int(input())

ans = [0]*N
for i in range(N-1):
  c, s, f = map(int,input().split())
  ans[i] += c + s
  for j in range(i):
    ans[j] = max((ans[j]+f-1)//f*f, s)+c
for a in ans:
  print(a)

Measured memory_bytes: 3060
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,a,b; cin >> n >> a >> b;
    int k;
    if(a+b>=n){
        k = a+b-n;
    } else {
        k=0;
    }


    cout << min(a,b) << " " << k << endl;
    return 0;

}


Measured memory_bytes: 256
N = int(input())
a = [int(_) for _ in input().split()]
count = 0
while a != []:
    for i in range(len(a)):
        if a[i]%2 == 1:
            a[i] = 0
        else:
            a[i] = int(a[i]/2)
    while 0 in a:
        a.remove(0)
    count += len(a)
print(count)                

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> hoge(n,0);

	for(int i=0;i<n-1;i++){
		int fuga;
		cin>>fuga;
		hoge.at(fuga-1)++;
	}

	for(auto a:hoge) cout<<a<<endl;

	return 0;
}


Measured memory_bytes: 4052
// Problem : K - Stones
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_k
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n,k;
int dp[N];

void solve(){
    cin>>n>>k;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j : a){
            if(i-j >= 0) dp[i] |= !dp[i-j];
        }
    }
    cout<<(dp[k] ? "First" : "Second");
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4396
use std::io::stdin;
use std::collections::HashMap;

fn main() {
  let mut onceNum = String::new();
  stdin().read_line(&mut onceNum).unwrap();
  let num: i32 = onceNum.trim().parse().unwrap();

  let mut map = HashMap::new();
  map.insert("AC", 0);
  map.insert("WA", 0);
  map.insert("TLE", 0);
  map.insert("RE", 0);
  
  for _i in 0..num {
    let mut onceStr = String::new();
    stdin().read_line(&mut onceStr).unwrap();
    let name = onceStr.trim();
    
    match name {
      "AC" => { map.insert("AC", map["AC"]+1); },
      "WA" => { map.insert("WA", map["WA"]+1); },
      "TLE" => { map.insert("TLE", map["TLE"]+1); },
      "RE" => { map.insert("RE", map["RE"]+1); },
      _ => (),
    };
  }
  
  println!("AC x {}", map["AC"]);
  println!("WA x {}", map["WA"]);
  println!("TLE x {}", map["TLE"]);
  println!("RE x {}", map["RE"]);
}

Measured memory_bytes: 2156
#include <stdio.h>
#include<math.h>
int main(){
  int n,x[102],y[102],i,j,k,D1=0,D4=0;
  double D2=0.0,D3=0.0;
  scanf("%d",&n);
  for(i=0; i<n; i++)scanf("%d",&x[i]);
  for(i=0; i<n; i++)scanf("%d",&y[i]);
  for(i=0; i<n; i++)D1+=abs(x[i]-y[i]);
  for(i=0; i<n; i++)D2+=pow(x[i]-y[i],2);
  D2=pow(D2,(double)1/2);
  for(i=0; i<n; i++)D3+=pow(abs(x[i]-y[i]),3);
  D3=pow(D3,(double)1/3);
  for(i=0; i<n; i++)if(D4<abs(x[i]-y[i]))D4=abs(x[i]-y[i]);
  printf("%lf\n%lf\n%lf\n%lf\n",(float)D1,D2,D3,(float)D4);
  return 0;
}

Measured memory_bytes: 696
#include<stdio.h>
int main(void)
{
	int a,b,c,i,cnt;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;
	for(i=a;i<=b;i++){
		if(c%i==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n;
    cin >> n;
    vl a(n + 1), b(n);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        if (b[i] > a[i]) {
            ret += a[i];
            b[i] -= a[i];
        } else {
            ret += b[i];
            b[i] = 0;
        }
        if (b[i] > a[i + 1]) {
            ret += a[i + 1];
            a[i + 1] -= a[i + 1];
        } else {
            ret += b[i];
            a[i + 1] -= b[i];
        }
    }
    cout << ret << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)){cout << 'A' << endl;}
    else cout << 'B' << endl;

    return 0;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
a = n.times.map{[]}

q.times do
  com = gets.split.map(&:to_i)
  if com[0] == 0
    a[com[1]].push com[2]
  elsif com[0] == 1
    puts a[com[1]][0] if !a[com[1]].empty?
  else
    a[com[1]].shift if !a[com[1]].empty?
  end
end


Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i];
    }

    int _max;
    int sum_prim = 0;
    for (int j = 0; j < k; j++)
    {
        sum_prim += ps[j];
    }
    _max = sum_prim;
    for (int i = 0; i < n - k; i++)
    {
        sum_prim = sum_prim - ps[i] + ps[i + k];
        _max = max(_max, sum_prim);
    }

    double ans = (double)(_max + k) * 0.5;
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define INF (int)1e9
#define MIN(a,b) (((a)<(b)) ? (a):(b))

int root[102][102];

void init() {
	long i, j;

	FOR(i,0,102){
		FOR(j,0,102){
			if(i == j) {
				root[i][j] = 0;
			} else {
				root[i][j] = INF;
			}
		}
	}
}


int main(){
	int n,m,a[1002],b[1002],c[1002];

//	memset(root,INF,sizeof(root));
//	FOR(i,0,102) root[i][i] = 0;

	init();

	scanf("%d %d",&n,&m);
	FOR(i,0,m){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		root[a[i]][b[i]] = MIN(root[a[i]][b[i]],c[i]);
		root[b[i]][a[i]] = MIN(root[b[i]][a[i]],c[i]);
	}

	FOR(k,1,n+1)	//中継点
		FOR(i,1,n+1)	//始点
			FOR(j,1,n+1)	//終点
				root[i][j] = MIN(root[i][j],root[i][k]+root[k][j]);

	int ans = m;

	FOR(k,0,m){	//判定する辺
		FOR(i,1,n+1){	//始点
			FOR(j,1,n+1){	//終点
				if(root[i][j] == root[i][a[k]] + c[k] + root[b[k]][j] ||
						root[i][j] == root[j][a[k]] + c[k] + root[b[k]][i]){
					ans--;
					goto NEXT;
				}
			}
		}
		NEXT:;
	}



//			FOR(i,1,n+1)	//始点
//				if(root[i][a[k]] + c[k] == root[i][b[k]]){	//最短経路に使用済み
//					ans--;
//					break;
//				}


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

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

using namespace std;

int main(void){
  char X,Y;
  cin >> X >> Y;
  if(X-Y>0){
    cout << ">" << endl;
  }
  else if(X-Y<0){
    cout << "<" << endl;
  }
  else{
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll n,a,b,c,d[10],e[10],ans=INF;
void cal(){
	ll A=0,B=0,C=0,sum=0;
	for(int i=0;i<n;i++){
		if(e[i]==1){
			if(A!=0){
				sum+=10;
			}
			A+=d[i];
		}
		else if(e[i]==2){
			if(B!=0){
				sum+=10;
			}
			B+=d[i];
		}
		else if(e[i]==3){
			if(C!=0){
				sum+=10;
			}
			C+=d[i];
		}
	}
	if(A==0||B==0||C==0){
		return;
	}
	sum+=abs(A-a)+abs(B-b)+abs(C-c);
	ans=min(sum,ans);
}
void dep(ll now){
	if(now==n){
		cal();
		return;
	}
	e[now]=0;dep(now+1);
	e[now]=1;dep(now+1);
	e[now]=2;dep(now+1);
	e[now]=3;dep(now+1);
}
int main() {
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
from itertools import product
S=input()
N=len(S)
fa=0

def asum(X):
    ans=0
    pre=0

    for i in range(len(X)):
        if X[i]==1:
            ans+=int(S[pre:i+1])
            pre=i+1
    else:
        ans+=int(S[pre:])
    return ans

for A in product(range(2),repeat=N-1):
    fa+=asum(A)
print(fa)

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

int main() {
  int N;
  int Y = 0;
  cin >> N;
  
  for (int  i = 0 ; i < N ; i++){
    string S;
    cin >> S;
    if ( S == "Y" ) {
      Y ++;
      break;
    }
  }
  if ( Y == 1){
    cout << "Four" << endl;
  }
  else cout << "Three"<< endl;
}


    

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

int A,B,K;

int main(){
    cin >> A >> B >> K;
    int g=min(A,B);
    vector<int> v;
    for(int i=g;i>0;i--){
        if(A%i==0&&B%i==0) v.push_back(i);
    }
    cout << v[K-1];
}

Measured memory_bytes: 256
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for(int i = 0; i < n; ++i)
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = stdIn.nextInt();
			a *= a;
			b *= b;
			c *= c;
			if(a + b == c || a + c == b || b + c == a)
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    double d;
    cin >> d;
    double ans = d * sqrt(2.0);
    FOR(i,1,3){
        double e = sqrt(d*d-i*i);
        if (e < -1e-9) continue;
        if (e < 1.0) ans = fmax(ans, 1.0+i);
        else ans = fmax(ans, e+i);
    }

    printf("%.16f\n", ans);

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int A[333][333];

bool ex[333];
vint lis[333];
int pos[333];
bool C(int x){
    rep(i,M)ex[i]=true;
    rep(i,M)lis[i].clear();
    rep(i,N)lis[A[i][0]].pb(i);
    rep(i,N)pos[i]=0;
    while(true){
        int cnt=0;
        int ma=0,mav;
        rep(i,M){
            if(!ex[i])continue;
            if(ma<lis[i].size()){
                ma=lis[i].size();
                mav=i;
            }
            cnt++;
        }
        if(ma<=x)return true;
        if(cnt==1)return false;
        ex[mav]=false;
        for(auto v:lis[mav]){
            while(!ex[A[v][pos[v]]])pos[v]++;
            lis[A[v][pos[v]]].pb(v);
        }
    }
}

signed main(){
    cin>>N>>M;
    rep(i,N)rep(j,M)cin>>A[i][j],A[i][j]--;


    int lb=0,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }
    cout<<ub<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll a,b,c,k; cin>>a>>b>>c>>k;
	cout << (k%2 ? b-a : a-b) << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
N,K = map(int,input().split())
P = [(int(i) + 1) / 2 for i in input().split()]
ans = []
hope = [0] + list(accumulate(P))

for j in range(N-K+1):
  ans.append(hope[j+K]-hope[j])
print(max(ans))

Measured memory_bytes: 23616
fun main(args: Array<String>) {
    val (x1, y1, x2, y2) = readLine()!!.split(' ').map(String::toInt)
    val x = Math.max(x1, x2) - Math.min(x1, x2)
    val y = Math.max(y1, y2) - Math.min(y1, y2)

    if (x2 >= x1 && y2 >= y1) {
        println("${x2 - y} ${y2 + x} ${x1 - y} ${y1 + x}")
    }else if(x1 >= x2 && y2 >= y1){
        println("${x2 - y} ${y2 - x} ${x1 - y} ${y1 - x}")
    }else if(x1 >= x2 && y1 >= y2){
        println("${x2 + y} ${y2 - x} ${x1 + y} ${y1 - x}")
    }else{
        println("${x2 + y} ${y2 + x} ${x1 + y} ${y1 + x}")
    }
}


Measured memory_bytes: 36504
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	int a, b; cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,sum=0,mod=1e9+7,ans=0;
    cin>>n;
    long long arr[n],dp[n];
    for(long i=0;i<n;i++){
    cin>>arr[i];
    sum=(sum+arr[i])%mod;
    dp[i]=sum;
    }
    for(long i=0;i<n;i++){
    ans=(ans+(arr[i]*(sum-dp[i]+mod)%mod)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6696
from collections import Counter
N, K = map(int, input().split())
A = list(map(int,input().split()))
B = set(A)
C = Counter(A).most_common()[::-1]
pre_color = len(B)
ans = 0
if pre_color <= K:
    print(0)
    exit()
else:
    dec = pre_color - K
    for i in range(dec):
        ans += C[i][1]
print(ans)

Measured memory_bytes: 50600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
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() {
  cout << fixed << setprecision(10);
  int x,y;
  cin >> x >> y;
  int a = y-2*x;
  if(a%2==0&&a>=0&&x-a/2>=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3632
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int edge = sc.nextInt();
		int[] masterNodeList= new int[V];
		ArrayDeque<Integer> noticeQueue = new ArrayDeque<Integer>();
		List<Integer>[] edgeList = new ArrayList[V + 1]; //各nodeが持つedgeを集約して集合化
		for (int i = 0; i < edgeList.length; i++) {
			edgeList[i] = new ArrayList<Integer>();
		}

		for (int i = 0; i < edge; i++) {
			int edge_a = sc.nextInt();
			int edge_b = sc.nextInt();
			edgeList[edge_a].add(edge_b);
			edgeList[edge_b].add(edge_a);
		}

		Arrays.fill(masterNodeList, -1);

		noticeQueue.add(1);

		int target;

		while (!noticeQueue.isEmpty()) {
			target = noticeQueue.poll();

			for (Integer edges : edgeList[target]) {
				if (masterNodeList[edges - 1] == -1) {
					masterNodeList[edges - 1] = target;
					noticeQueue.add(edges);
				}
			}
		}

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

Measured memory_bytes: 77464
#include <stdio.h>
int main()
{
	int H, W, N, sum = 0, now = 0;
	scanf("%d%d%d", &H, &W, &N);
	int temp = (H>=W) ? H : W;
	while(now<N)
	{
		now += temp;
		sum++;
	}
	printf("%d\n", sum);
	return 0;
}

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

struct node{
  int x, p;
  vector<node> son;
  node(int x){
    this->x = x;
    this->p = 0;
  }
  void cmp(int peso){
    p = max(p,peso);
  }
  void add(int u){
    son.push_back(u);
  }
};

vector<node> g;
int dfs(node a){
  if(g[a.x].p>0){
    return g[a.x].p;
  }
  int pro = 0;
  for(int i = 0; i<g[a.x].son.size();i++){
    if(g[a.x].son[i].p>0){
      pro = max(g[a.x].son[i].p+1,pro);
    }else{
      pro =max(dfs(g[a.x].son[i])+1,pro);
    }
  }
  g[a.x].p = pro;
  return pro;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  for(int i = 0; i<=n;i++){
    node l =  node(i);
    g.push_back(l);
  }
  int x,y;
  for(int i = 0; i<m;i++){
    cin >> x >> y;
    g[x-1].add(y-1);
  }
  int ans = 0;
  for(int i = 0; i<n;i++){
    ans = max(ans,dfs(g[i]));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n, -1);
  bool dif = false;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s--;
    if (A[s] == -1 || A[s] == c) A[s] = c;
    else dif = true;
  }
  if ((n > 1 && A[0] == 0) || dif) {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n) {
    if (A[i] != -1) cout << A[i];
    else if (n > 1 && i == 0) cout << 1;
    else cout << 0;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import product

A1 = []
for _ in range(3):
    A1.append(list(map(int, input().split())))

N = int(input())

B = []
for _ in range(N):
    b = int(input())
    for i, j in product(range(3), repeat=2):
        if A1[i][j] == b:
            A1[i][j] = 0
            continue

A2 = [
    [A1[0][0], A1[1][0], A1[2][0]],
    [A1[0][1], A1[1][1], A1[2][1]],
    [A1[0][2], A1[1][2], A1[2][2]]
]

A3 = [
    [A1[0][0], A1[1][1], A1[2][2]],
    [A1[2][0], A1[1][1], A1[0][2]]
]

AA = A1 + A2 + A3

R = 'No'
for aa in AA:
    if sum(aa) == 0:
        R = 'Yes'
        break

print(R)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        double num;
        cin >> num;
        ans += (1 / num);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[210000];
int f[1100000];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)  scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int cnt=0;
	for(int i=1;i<=n;++i){
		if(f[a[i]]==0 && (i==n || a[i]!=a[i+1]))  ++cnt;
		for(int j=1;a[i]*j<=a[n];++j)
			f[a[i]*j]=1;
	}
	cout<<cnt<<endl;
	return 0;
}
 

Measured memory_bytes: 8248