akhauriyash/Code-Regression huggingface dataset:
x,n=map(int,input().split())
p=list(map(int,input().split()))
ans=10**18
a=[]
for i in range(-101,200):
  if i in p:continue
  d=abs(x-i)
  if d<ans:
    ans=d
    a.append([d,i])

# print(a)
a.sort(key=lambda x: x[0])
# print(a)
mnv=a[0][0]
mnidx=a[0][1]
for ai in a:
  v,idx=ai
  if mnv==v:
    if idx<mnidx:
      mnidx=idx
  else:
    break
print(mnidx)

Measured memory_bytes: 9092
let n = Int(readLine()!)!
let sn = (1...n).map { _ in readLine()! }
let result: [String: Int] = sn.reduce(["AC": 0, "WA": 0, "TLE": 0, "RE": 0]) {
    var result = $0
    result[$1]! += 1
    return result
}
print("AC x \(result["AC"]!)")
print("WA x \(result["WA"]!)")
print("TLE x \(result["TLE"]!)")
print("RE x \(result["RE"]!)")

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

int main(void)
{
	int n,m,l;
	int i,j,k;
	int **array1, **array2;
	unsigned long long int sum;

	cin >> n;
	cin >> m;
	cin >> l;

	array1 = new int*[n];
	for (i=0; i<n; i++) {
		array1[i] = new int[m];
	}
	array2 = new int *[m];
	for (i=0; i<m; i++) {
		array2[i] = new int[l];
	}
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++) {
			cin >> array1[i][j];
		}
	}
	for (i=0; i<m; i++) {
		for (j=0; j<l; j++) {
			cin >> array2[i][j];
		}
	}

	for (i=0; i<n; i++) {
		for (k=0; k<l; k++) {
			sum = 0;
			for (j=0; j<m; j++) {
				sum += array1[i][j] * array2[j][k];
			}
			cout << sum;
			if (k < (l-1)) {
				cout << " ";
			}
			else {
				cout << endl;
			}
		}
	}

	for (i=0; i<n; i++) {
		delete[] array1[i];
	}
	delete[] array1;

	for (i=0; i<m; i++) {
		delete[] array2[i];
	}
	delete[] array2;

	return 0;
}




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

using namespace std;

const int N = 1e5 + 5;
int ans[N] , k;
vector<pair<int , int> > adj[N];

void dfs (int node , int par , int col) {
    int nxt = 1;
    for (auto &c : adj[node]) {
        if (c.first == par) continue;
        nxt += nxt == col;
        k = max(k , nxt);
        ans[c.second] = nxt;
        dfs(c.first , node , nxt);
        nxt++;
    }
}

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

    int n;
    cin >> n;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v;
        cin >> u >> v;
        adj[u].push_back({v , i});
        adj[v].push_back({u , i});
    }

    dfs(1 , 1 , -1);

    cout << k << '\n';
    for (int i = 0 ;i < n - 1 ;i++)
        cout << ans[i] << '\n';
}


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



int main()
{
	int date;
	cin >> date;
	switch(date){
		case 22:cout << "Christmas Eve Eve Eve" << endl;
			break;
		case 23:cout << "Christmas Eve Eve" << endl;
			break;
		case 24:cout << "Christmas Eve" << endl;
			break;
		case 25:cout << "Christmas" << endl;
			break;
	}
}

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

int main(int argc, const char * argv[]) {
    string s, ans = "";
    int w;
    cin >> s >> w;
    for (int i = 0; i < s.length(); i++) {
        if (i % w == 0) {
            ans.push_back(s[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int temp=0,total=0;
	string a;
	cin>>a;
	a.push_back('S');
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='R')
		{ 
			total++;
		}
		else
		{
			temp=max(temp,total);
			total=0;
			}
	}
	cout<<temp;
}


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

int main() {
  long long L, R, ans=2019;
  cin >> L >> R;
  
  for(long long i=L; i<=R; i++) {
    for(long long j=i; j<=R; j++) {
      if(i!=j) ans=min(ans, (i*j)%2019);
      if(ans==0){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d10 = d//10
        d1 = d % 10
        if (d10 >= 2)and(d1 >= 2)and(d1*d10 == m):
            ans += 1
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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(){
	//input
    ll N,ans=0; cin>>N;
	vector<ll> A1(N);
    vector<ll> A2(N);
    rep(i,N) cin>>A1[i];
    rep(i,N) cin>>A2[i];

    vector<ll> s1(N+1);
    vector<ll> s2(N+1);
    rep(i,N){
        s1[i+1]=s1[i]+A1[i];
        s2[i+1]=s2[i]+A2[i];
    }

    rep(i,N){ //曲がるとこ
        ll tmp=0;
        tmp+=s1[i+1]-s1[0];
        tmp+=s2[N]-s2[i];
        chmax(ans,tmp);
    }

    cout<<ans;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int K, N; cin >> K >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];

	sort(A.begin(), A.end());

	int ma = 0;
	for (int i = 1; i < N; i++){
		int bet = A[i] - A[i - 1];
		ma = max(bet, ma);
	}

	ma = max(ma, K - A[N - 1] + A[0]);
	cout << K - ma << endl;
	return 0;
}


Measured memory_bytes: 4032
judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for j in a:
    if (ans//j)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans//2 >=0:
    sss=((M-ans//2)//ans)+1
print(sss)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,x,ans=1,sub=0;
std::vector<int> l;
int main(){
  cin >> n >> x;
  l.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> l[i];
    sub += l[i];
    if(sub <= x){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll A, B, Q;
  cin>>A>>B>>Q;
  vector<ll> S(A+1), T(B+1);
  for(ll i=0;i<A;++i) cin>>S[i];
  for(ll i=0;i<B;++i) cin>>T[i];
  S[A] = big;
  T[B] = big;
  ll ans[Q];
  ll x;
  ll indexs, indext, index;
  ll s1, s2, t1, t2;
  ll tmpans;
  for(ll i=0;i<Q;++i) {
    cin>>x;
    indexs = lower_bound(S.begin(), S.end(), x) - S.begin();
    indext = lower_bound(T.begin(), T.end(), x) - T.begin();
    if(indexs<A) {
      s2 = S[indexs];
    }
    else s2 = big;
    if(indext<B) {
      t2 = T[indext];
    }
    else t2 = big;
    if(indexs>0) s1 = S[indexs-1];
    else s1 = -big;
    if(indext>0) t1 = T[indext-1];
    else t1 = -big;
    ans[i] = big;
    tmpans = 0;
    tmpans += abs(x-s1);
    index = lower_bound(T.begin(), T.end(), s1)- T.begin();
    if(0<index && index<B) {
      tmpans += min(abs(s1-T[index]), abs(s1-T[index-1]));
    }
    else if(index==0) {
      tmpans += abs(s1-T[index]);
    }
    else tmpans += abs(s1-T[index-1]);
    ans[i] = min(ans[i], tmpans);
    tmpans = 0;
    tmpans += abs(x-s2);
    index = lower_bound(T.begin(), T.end(), s2)- T.begin();
    if(0<index && index<B) {
      tmpans += min(abs(s2-T[index]), abs(s2-T[index-1]));
    }
    else if(index==0) {
      tmpans += abs(s2-T[index]);
    }
    else tmpans += abs(s2-T[index-1]);
    ans[i] = min(ans[i], tmpans);

    tmpans = 0;
    tmpans += abs(x-t1);
    index = lower_bound(S.begin(), S.end(), t1)- S.begin();
    if(0<index && index<A) {
      tmpans += min(abs(t1-S[index]), abs(t1-S[index-1]));
    }
    else if(index==0) {
      tmpans += abs(t1-S[index]);
    }
    else tmpans += abs(t1-S[index-1]);
    ans[i] = min(ans[i], tmpans);
    tmpans = 0;
    tmpans += abs(x-t2);
    index = lower_bound(S.begin(), S.end(), t2)- S.begin();
    if(0<index && index<A) {
      tmpans += min(abs(t2-S[index]), abs(t2-S[index-1]));
    }
    else if(index==0) {
      tmpans += abs(t2-S[index]);
    }
    else tmpans += abs(t2-S[index-1]);
    ans[i] = min(ans[i], tmpans);
  }
  for(ll i=0;i<Q;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 5604
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, X, T,A;
	A = 0;
	cin >> N >> X >> T;
	if ((N%X) == 0) {
		A++;

	}
	cout << (N/ X+1-A)*T << endl;




	return 0;
}



Measured memory_bytes: 3616
import java.util.*;

public class Main {
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        long[] a = new long[n];
        
        for(int i = 0; i < n; i++){
            a[i] = Long.parseLong(sc.next());
        }
        
        int count = 0;
        
        loop: while(true){
            for(int i = 0; i < a.length; i++){
                if(a[i] % 2 != 0){
                    break loop;
                }else{
                    a[i] /= 2;
                }
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23760
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << c * 60 + d - a * 60 - b - e << endl;
	return 0;
}

Measured memory_bytes: 3644
//https://atcoder.jp/contests/dp/tasks/dp_g
//G - Longest Path
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

struct Edge {
    ll st,tr;
    Edge(ll s, ll t)
        : st(s), tr(t)
    {}
};
struct Node{
    vector<Edge> edges;
    ll cost=0;
};
using Graph = vector<Node>;

//各nodeをdfs
vector<ll> tsort_tarjan(Graph& g){
    auto num = g.size();
    enum class State { NEW, ACTIVE, FINISHED };
    vector<State> state(num, State::NEW); 
    vector<ll> res; res.reserve(num);
    function<bool(int)> dfs = [&](ll v){
        state[v]=State::ACTIVE;
        for(const auto& e : g[v].edges){
            auto w = e.tr; //接続するnodeをdfsしていく
            if (state[w] == State::ACTIVE) return false;
            else if (state[w] == State::NEW) if (!dfs(w)) return false;
        }
        state[v]=State::FINISHED;
        res.push_back(v);
        //ここで処理すると逆順に処理できる
        return true;
    };
    for (ll n=0;n<num;++n) {
        if(state[n]==State::NEW && !dfs(n)) return {}; //空を返す
    }
    std::reverse(res.begin(),res.end());
    return res;
}

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M; cin>>N>>M;
    Graph graph(N+1);
    REP(i,M){
        ll x,y; cin>>x>>y;
        graph.at(x).edges.emplace_back(x,y);
    }
    auto ord = tsort_tarjan(graph);
    dump(ord);
    for(const auto& o:ord){
        //cout<<o<<endl;
        const auto& n=graph.at(o);
        for(const auto&e: n.edges){
            chmax(graph.at(e.tr).cost,n.cost+1); 
        }
    }
    ll ans=0;
    for(const auto& o:ord){
        chmax(ans,graph.at(o).cost);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9728
#include <stdio.h>
int gcd(int a, int b){
    while(1){
        if(a>b)a%=b;
        else b%=a;
        if(a==0)return b;
        if(b==0)return a;
    }
}
int main(void){
    int n,i,g,a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(g)g=gcd(a,g);else g=a;
    }
    printf("%d",g);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0; cin >> N;
  ll y = N,x = 0,z = 0;
  vector<char>A(0);
  rep(i,20){
    x += pow(26,i+1);
    ll tmp = 0;
    tmp = y % 26;
    if(tmp < 0){
      tmp += 26;
    }
    if(tmp == 0){
      y = y/26 -1;
    }
    else{
      y /= 26;
    }
    if(tmp == 1-z){
      A.push_back('a');
    }
    if(tmp == 2-z){
      A.push_back('b');
    }
    if(tmp == 3-z){
      A.push_back('c');
    }
    if(tmp == 4-z){
      A.push_back('d');
    }
    if(tmp == 5-z){
      A.push_back('e');
    }
    if(tmp == 6-z){
      A.push_back('f');
    }
    if(tmp == 7-z){
      A.push_back('g');
    }
    if(tmp == 8-z){
      A.push_back('h');
    }
    if(tmp == 9-z){
      A.push_back('i');
    }
    if(tmp == 10-z){
      A.push_back('j');
    }
    if(tmp == 11-z){
      A.push_back('k');
    }
    if(tmp == 12-z){
      A.push_back('l');
    }
    if(tmp == 13-z){
      A.push_back('m');
    }
    if(tmp == 14-z){
      A.push_back('n');
    }
    if(tmp == 15-z){
      A.push_back('o');
    }
    if(tmp == 16-z){
      A.push_back('p');
    }
    if(tmp == 17-z){
      A.push_back('q');
    }
    if(tmp == 18-z){
      A.push_back('r');
    }
    if(tmp == 19-z){
      A.push_back('s');
    }
    if(tmp == 20-z){
      A.push_back('t');
    }
    if(tmp == 21-z){
      A.push_back('u');
    }
    if(tmp == 22-z){
      A.push_back('v');
    }
    if(tmp == 23-z){
      A.push_back('w');
    }
    if(tmp == 24-z){
      A.push_back('x');
    }
    if(tmp == 25-z){
      A.push_back('y');
    }
    if(tmp == 0){
      A.push_back('z');
    }
    if(x >= N){
      break;
    }
  }
  rep(i,A.size()){
    cout << A[A.size() - 1 - i];
  }
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(s[l-1]=='s')
    {
    s.push_back('e');
    s.push_back('s');
    }
    else
    s.push_back('s');
    cout<<s<<endl;
    return 0;
}

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

int main(){
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;
  if(0 <= x - r and x + r <= w and
     0 <= y - r and y + r <= h)
    std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
vvc<ll> G;
ll dfs(ll now){
    ll gn = G[now].size();
    if (gn == 0) return 0;

    vl A(gn);
    rep(i,gn){
        ll to = G[now][i];
        A[i] = dfs(to);
    }
    sort(all(A));

    ll id = 0;
    rep(i,gn){
        chmax(id, A[i]);
        id++;
    }
    return id;
}
int main() {
    init();
    ll N;
    cin >> N;
    G.resize(N);
    repe(i,1,N){
        ll a;
        cin >> a, a--;
        G[a].eb(i);
    }
    cout << dfs(0) << endl;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<ll> ls, rs;
ll lsum[100010], rsum[100010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; ++i){
        int L, R;
        cin >> L >> R;
        ls.emplace_back(L);
        rs.emplace_back(R);
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.begin(), rs.end());
    for(int i = 0; i < N; i++){
        lsum[i] += ls[i];
        lsum[i + 1] += lsum[i];
        rsum[i] += rs[i];
        rsum[i + 1] += rsum[i];
    }
    ll res = 0;
    for(int i = 0; i < N; i++){
        chmax(res, lsum[i] - rsum[i]);
    }
    for(int i = 1; i < N; i++){
        chmax(res, lsum[i] - rsum[i - 1]);
        chmax(res, lsum[i - 1] - rsum[i]);
    }
    cout << res * 2 << endl;
    return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    vector<ll> a(N);
    rep(i,N){
        if(i==0) a[i] = v[i]%K;
        else a[i] = (a[i-1]+v[i])%K;
    }
    rep(i,N) {
        a[i] = (a[i]-i-1)%K;
        if(a[i]<0) a[i]+=K;
    }
    map<ll,vector<ll>> m;
    m[0].push_back(0);
    rep(i,N) m[a[i]].push_back(i+1);
    ll ans = 0;
    for(auto x:m){
        int l = x.second.size();
        rep(i,l){
            auto ite = lower_bound(x.second.begin(),x.second.end(),x.second[i]+K);
            ans += (ite-x.second.begin())-i-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 28308
#include <iostream>

using namespace std;

typedef long long ll;
#define MOD ((int)(1e9+7))

int ans[22][(1<<21)];
int numOnes[1<<21];

int next_pair(int i, int g, bool* arr, int N) {
    for (int j=g+1; j<=N; j++) {
        if (arr[j])
            return j;
    }
    return -1;
}

int num_ones(int number) {
    int cnt = 0;
    while(number > 0) {
        if (number %2 == 1)
            cnt ++;
        number >>= 1;
    }
    return cnt;
}

int main() {
    int N; cin >> N;
    bool arr[N+1][N+1];
    for (int i=1; i<=N; i++)
        for (int j=1; j<=N; j++)
            cin >> arr[i][j];
    
    for (int i=0; i<N+1; i++)
        for (int j=0; j<(1<<N); j++)
            ans[i][j] = (i == 0)? 1 : 0;

    for (int i=0; i<(1<<N); i++) {
        numOnes[i] = num_ones(i);
    }
    
    // cout << "##### " << next_pair(1, 0, arr[1], N) << endl;
    // cout << "##### " << next_pair(1, 2, arr[1], N) << endl;
    for (int i=1; i<=N; i++) {
        for (int mask=0; mask < (1 << N); mask++) {
            if (i != numOnes[mask])
                continue;

            int g = 0;
            while ( (g = next_pair(i, g, arr[i], N)) != -1) {
                // present both places
                if ( (mask & (1 << g-1)) != 0) {
                    // cout << g << " ";
                    int rem_mask = mask ^ (1 << g-1);
                    ans[i][mask] += ans[i-1][rem_mask];
                    if (ans[i][mask] > MOD) ans[i][mask] -= MOD;
                }
            } // cout << endl;
            // cout << "calcing " << i << "," << mask << " = " << ans[i][mask] << endl;
        }
    }

    // cout << "printing " << N << " " << (1 << N) -1 << endl;
    cout << ans[N][(1 << N)-1] << endl;

    return 0;
}

Measured memory_bytes: 188672
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ld  = long double;
template <class Itr> auto Median(Itr first, Itr last) {
    // when value_type is double or long double , you should use "round""
    // function these Iterator must be Random Access Iterator
    typename iterator_traits<Itr>::difference_type n = distance(first, last);
    sort(first, last);
    if (n % 2 == 1) {
        return *(first + n / 2);
    } else {
        return (*(first + n / 2) + *(first + n / 2 - 1)) / 2;
    }
}
int main(){
    int N; cin >> N;
    vector<int>A(N);
    for(auto& e : A) cin >> e;
    map<int,int>mp;
    for(auto e : A)mp[e]++;
    int maxi = *max_element(A.begin(),A.end());
    vector<int>valid(maxi + 1,0);
    for(auto e : A)valid[e] += 1;
    for(int i = 1; i <= maxi; ++i){
        int t = mp[i] > 0;
        for(int j = 2; i * j <= maxi; ++j)
            valid[i * j] += t;
    }
    int res = 0;
    for(auto e : A)
        res += (valid[e] <= 1);
    cout << res << endl;
}


Measured memory_bytes: 54740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.length() >1 || b.length() >1) {
			System.out.print(-1);
		}else {
			System.out.println(Integer.valueOf(a) * Integer.valueOf(b));
		}


	}
}

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

int main(){
	ll n,m;string s,t;cin>>n>>m>>s>>t;
	ll l=n/__gcd(n,m)*m;
	map<int,char>mp;
	rep(i,n){
		mp[(l/n)*i]=s[i];
	}
	rep(i,m){
		if(mp.count((l/m)*i)&&mp[(l/m)*i]!=t[i]){
			puts("-1");return 0;
		}
	}
	cout<<l<<endl;
}

Measured memory_bytes: 4736
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC105_A solver = new ABC105_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC105_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            if (n % k == 0) {
                out.print(0);
            } else {
                out.print(1);
            }
        }

    }
}



Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define Len 10001

int main()
{
    int n;
    int a;

    scanf("%d", &n);

    a = n*(n+1)/2;
    printf("%d\n", a);
    return 0;
}

Measured memory_bytes: 128
t = input()

prev = ""
res = []
for i, x in enumerate(t):
    if x == "?":
        if prev == "" and len(t) == 1:
            res.append("D")
        elif prev == "" and (i < len(t) - 1 and t[i+1] == "P"):
            res.append("D")
        elif prev == "" or prev == "D" and (i < len(t) - 1 and t[i+1] != "P"):
            res.append("P")
        else:
            res.append("D")
    else:
        res.append(x)
    prev = res[-1]
print("".join(res))


Measured memory_bytes: 81512
#include <stdio.h>
#include <stdlib.h>

int main (){
  int A[100],N,i,j,k,v;
  
  scanf("%d",&N);
  if(N > 100){
    printf("Size is too large.\n");
    exit(1);
  }
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i] > 1000){
      printf("Value is too large.\n");
      exit(2);
    }
  }
  
  for(k=0;k<N;k++){
    if(k == N-1)printf("%d",A[k]);
    else printf("%d ",A[k]);
  }
  printf("\n");
    
  for(i=1;i<N;i++){//Insertion Sort
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;   
    }
    A[j+1] = v;
    for(k=0;k<N;k++){
      if(k == N-1)printf("%d",A[k]);
      else printf("%d ",A[k]);
    }
    printf("\n");   
  }

  
  return 0;
}




Measured memory_bytes: 2064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 55
#define ll long long
int fir[N], tar[N], nex[N], cnt;
void Add(int u, int v)
{
	++cnt;
	tar[cnt] = v;
	nex[cnt] = fir[u];
	fir[u] = cnt;
}
int n, s, d;
struct Node
{
	ll v;
	int w, d;
}A[N];
bool operator < (Node a, Node b){return a.w * b.v > b.w * a.v; }
ll dp[N * N * N];
void Dfs(int u)
{
	A[u].w = 1, A[u].d = u;
	for (int i = fir[u]; i; i = nex[i])
	{
		Dfs(tar[i]);
		A[u].v += A[tar[i]].v;
		A[u].w += A[tar[i]].w;
	}
}
int main()
{
	scanf("%d%d%d", &n, &s, &d);
	scanf("%d", &A[1].v);
	for (int i = 2; i <= n; i++)
	{
		int p;
		scanf("%d%d", &A[i].v, &p);
		Add(p, i);
	}
	Dfs(1);
	int mx = n * n * n, l = min(n, d);
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		int x = l;
		for (int j = 1; j <= x; j <<= 1)
		{
			int w = A[i].w * j;
			ll v = A[i].v * j;
			for (int k = mx; k >= w; k--)
				dp[k] = min(dp[k], dp[k - w] + v);
			x -= j;
		}
		if (x)
		{
			int w = A[i].w * x;
			ll v = A[i].v * x;
			for (int j = mx; j >= w; j--)
				dp[j] = min(dp[j], dp[j - w] + v);
		}
	}
	sort(A + 1, A + n + 1);
	while (A[n].d != 1)
		n--;
	ll ans = 0;
	for (int i = 0; i <= mx; i++)
	{
		if (dp[i] > s)
			continue;
		ll w = i, v = dp[i];
		for (int j = 1; j < n; j++)
		{
			ll c = min((ll)d - l, (s - v) / A[j].v);
			w += c * A[j].w;
			v += c * A[j].v;
		}
		ll c = (s - v) / A[n].v;
		w += c * A[n].w;
		v += c * A[n].v;
		ans = max(ans, w);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 5092
import math
a,b=map(int,input().split())
aa,bb=[],[]
while 1<a:
    c=0
    for i in range(2,int(math.sqrt(a))+1):
        if a%i==0:
            a=a//i
            aa.append(i)
            c=1
            break
    if c==0:
        aa.append(a)
        a=1
while 1<b:
    c=0
    for i in range(2,int(math.sqrt(b))+1):
        if b%i==0:
            b=b//i
            bb.append(i)
            c=1
            break
    if c==0:
        bb.append(b)
        b=1
syu=set(aa)&set(bb)
print(len(list(syu))+1)

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> S(h, vector<int>(w));
  rep(i,h) rep(j,w) {
    char c;
    cin >> c;
    S[i][j] = c - '0';
  }
  rep(i,h) rep(j,w-1) {
    S[i][j+1] += S[i][j];
  }
  rep(i,h-1) rep(j,w) {
    S[i+1][j] += S[i][j]; //累積和
  }
  int ans = 10010010;
  for (int bit = 0; bit < (1<<(h-1)); ++bit) {
    if (__builtin_popcount(bit) > ans) continue;
    vector<int> sep_h, sep_v;
    rep(i,h-1) {
      if (bit & (1<<i)) sep_h.emplace_back(i); //横の分割
    }
    sep_h.emplace_back(h-1);
    auto check = [&](int right) {
      bool ok = true;
      int num_bl = sep_h.size();
      rep(bl, num_bl) {
        int bottom = sep_h[bl];
        int numc = S[bottom][right]; //チョコの数
        if (bl > 0 && sep_v.size() > 0) {
          int upper = sep_h[bl-1]; //upperの下に境界線
          int left = sep_v.back(); //leftの右側に境界線
          numc += S[upper][left];
        }
        if (bl > 0) {
          int upper = sep_h[bl-1];
          numc -= S[upper][right];
        }
        if (sep_v.size() > 0) numc -= S[bottom][sep_v.back()];
        if (numc > k) { 
          ok = false; //NG
          break;
        }
      }
      return ok;
    };
    bool allchecked = false;
    rep(right, w) {
      if (!check(right)) {
        if (right > 0) {
          sep_v.emplace_back(right-1); //縦の分割を追加
          if (!check(right)) {
            break; //分割を追加してもNGのとき
          }
        }
        else if (right == 0) break; //実現不可
      }
      if (right == w-1) allchecked = true; //端に到達
    }
    if (allchecked) {
      int res = (sep_h.size()-1) + sep_v.size();
      ans = min(ans, res);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#input : D次元空間上のN個の点、及び座標
#output : ２点間の距離が整数値となるような点の組の数

N_D = list(map(int,input().split()))
X = []
n = 0

for i in range(N_D[0]):
    X.append(list(map(int,input().split())))

for i in range(N_D[0]-1):
    j = i + 1
    while j <= N_D[0]-1:
        distance = 0
        sum = 0
        for k in range(N_D[1]):
            sum += (X[i][k] - X[j][k])**2
        distance = sum ** (1/2)
        j += 1
        if int(distance) == distance:
            n += 1

print(n)

Measured memory_bytes: 3064
#include <stdio.h>
#define Max 2000000

int H,A[Max+1];


void maxHeapfy(int n){
  int left,right,largest;

  left=2*n;
  right=2*n +1;

  if(left<=H && A[left]>A[n]) largest = left;
  else largest = n;
  if(right<=H && A[right]>A[largest]) largest = right;

  if(largest != n){
     int x =A[n];
     A[n] = A[largest];
     A[largest] = x;
     maxHeapfy(largest);
  }
}

int main(){
  int i=0;
  
  scanf("%d",&H);

  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--) maxHeapfy(i);
  for(i=1;i<=H;i++) printf(" %d",A[i]);
  
  printf("\n");

  return 0;
}





Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
const int INF=(2e9);
const int maxn=2010;
int n,k,q,a[maxn],ans,b[maxn],res[maxn];
int solve(int x) {
	int s=-1,sz=0;
	for (int i=1;i<=n+1;i++)
		if (a[i]>=a[x]) {
			if (s==-1) s=i;
		}
		else if (s!=-1) {
			if (i-s>=k) {
				for (int j=s;j<i;j++) b[j-s+1]=a[j];
				sort(b+1,b+(i-s+1));
				for (int j=1;j+k-1<=i-s;j++) res[++sz]=b[j];
			}
			s=-1;
		}
	if (sz<q) return INF;
	sort(res+1,res+(sz+1));
	return res[q]-a[x];
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %d %d",&n,&k,&q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ans=INF;
	for (int i=1;i<=n;i++) ans=min(ans,solve(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc121/tasks/abc121_d
//D - XOR World
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
    auto calc = [](ll dif){
        ll b=0;
	    switch(dif % 4) {
	    case 0: b=dif; break;
	    case 1: b=1; break;
        case 2: b=dif+1; break;
        case 3: b=0; break;
	    }
        return b;
    };
#if LOCAL&0
    ll tmp=0;
    FOR(i,1,3+4+8+16+32+64+128+1){
        tmp ^= i;
        cout<<i<<":"<<tmp<<","<<calc(i)<<endl;
        assert(tmp==calc(i));
    }
#endif
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll A,B; cin>>A>>B;
    ll ans = calc(B) ^ calc(A-1);
    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;
typedef long long ll;
const int INF=1001001001;

int main(){
	int n,a;
	cin >> n >> a;
	if((n%500) <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long

int ans[4];

int main(void)
{
	int n;
	char s[10];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", s);
		if (s[0] == 'A')
			ans[0]++;
		else if (s[0] == 'W')
			ans[1]++;
		else if (s[0] == 'T')
			ans[2]++;
		else if (s[0] == 'R')
			ans[3]++;
		else;

		
	}
	printf("AC x %d\n", ans[0]);
		printf("WA x %d\n", ans[1]);
		printf("TLE x %d\n", ans[2]);
		printf("RE x %d\n", ans[3]);
	return 0;
}

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

const double eps = 1e-9;
inline bool equals(double a, double b) { return fabs(a - b) < eps ;}

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {};

    Point operator + (Point p) { return Point(x + p.x, y + p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < eps && fabs(y - p.y) < eps;
    }
};
typedef Point Vector;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

struct Segment {Point p1, p2;};

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

int main(void) {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Segment s = {Point(x1, y1), Point(x2, y2)};
    int q;
    cin >> q;
    while (q--) {
        double x, y;
        cin >> x >> y;
        Point ans = project(s, Point(x, y));
        printf("%.10f %.10f\n", ans.x, ans.y);
    }
    return 0;
}

Measured memory_bytes: 1236
a,b = map(int,input().split())
if a==1:
  if b==1:
    print("Draw")
  else:
    print("Alice")
elif b==1:
  if a==1:
    print("Draw")
  else:
    print("Bob")
else:
  if a > b:
    print("Alice")
  elif a < b:
    print("Bob")
  else:
    print("Draw")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int a,b;
    int arr[100], brr[100];
    cin >> a >> b;
    for(int i = 0; i < b; i++)
        arr[i] = a;
    for(int i = 0; i < a; i++)
        brr[i] = b;
    if(arr[0] < brr[0]) {
        for(int i = 0; i < b; i++)
            cout << arr[i];
    }
    else {
        for(int i = 0; i < a; i++)
            cout << brr[i];
    }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <functional>
#include <stdio.h>
using namespace std;

typedef long long ll;

ll n;

int main(int argc, const char * argv[]){
    cin>>n;
    vector<ll> vec(n, 0);
    ll s = 0;
    ll res = numeric_limits<ll>::max();
    for(int i = 0; i < n; ++i){
        cin>>vec[i];
        s += vec[i];
    }
    ll t = 0;
    for(int i = 0; i < n; ++i){
        t += vec[i];
        if(i + 1 < n)res = min(res, abs(s - 2 * t));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4752
#import sys
#sys.setrecursionlimit(500000)　マージテクをちゃんとしていればこんなものはいらないはず……

class UF:
    #経路圧縮＋マージテクのunion find木
    def __init__(self,n):
        self.n = n
        self.parents = [-1] * (n+1) #1-indexedにするために１個足している
        self.rnks = [0] * (n+1)

    def find(self,n):
        if self.parents[n] < 0:
            return n
        else:
            self.parents[n] = self.find(self.parents[n])
            return self.parents[n]

    def union(self,a,b):
        a_par = self.find(a)
        b_par = self.find(b)

        if a_par == b_par:
            return
        ##union by rank
        #if self.rnks[a_par] < self.rnks[b_par]: #ランクの高い方の根に低い方の根をつける　逆にしないように……！
        #    a_par,b_par = b_par,a_par
        #if self.rnks[a_par] == self.rnks[b_par]:
        #    self.rnks[a_par] += 1
        if self.size(a_par) < self.size(b_par): #parentsの値が負の数のとき、それはその木のサイズを表す。
            a_par,b_par = b_par,a_par
        self.parents[a_par] += self.parents[b_par]
        self.parents[b_par] = a_par

    def size(self,n):
        par = self.find(n)
        return abs(self.parents[par])

    def is_same(self,a,b):
        return self.find(a) == self.find(b)



def main():
    n,m,k = map(int,input().split())
    uf = UF(n)
    block_lst = [0 for _ in range(n+1)]
    friend_lst = [0 for _ in range(n+1)]
    #友達リスト部分
    for i in range(m):
        a,b = map(int,input().split())
        friend_lst[a] += 1
        friend_lst[b] += 1
        uf.union(a,b)
    #print(friend_lst)

    #ブロックリスト部分
    for i in range(k):
        c,d = map(int,input().split())
        if uf.is_same(c,d):#c,dが同じ友達候補グループにない限り、解答には影響しない！
            block_lst[c] += 1
            block_lst[d] += 1
    #print(block_lst)
    #メイン処理
    answer = []

    for i in range(1,n+1):
        f_o_f = uf.size(i)
        answer.append(f_o_f - friend_lst[i] - block_lst[i] - 1)


    print(" ".join(map(str,answer)))






if __name__ == '__main__':
    main()


Measured memory_bytes: 20352
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a,const void *b){
	long long t=*(long long*)a-*(long long*)b;
	if(t>0)return -1;
	if(t<0)return 1;
	return 0;
}

#define N 1000

int main(){
	int n,m,i;
	long long xyz[N][3],ans=0,kot[N],tmp=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%lld %lld %lld",&xyz[i][0],&xyz[i][1],&xyz[i][2]);
	
	for(i=0;i<n;i++)kot[i]=xyz[i][0]+xyz[i][1]+xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=-xyz[i][0]+xyz[i][1]+xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=xyz[i][0]-xyz[i][1]+xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=-xyz[i][0]-xyz[i][1]+xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=xyz[i][0]+xyz[i][1]-xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=-xyz[i][0]+xyz[i][1]-xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=xyz[i][0]-xyz[i][1]-xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	for(i=0;i<n;i++)kot[i]=-xyz[i][0]-xyz[i][1]-xyz[i][2];
	qsort(kot,n,sizeof(long long),compare_int);
	for(i=0;i<m;i++)tmp+=kot[i];
	if(ans<tmp)ans=tmp;tmp=0;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
/*----------------------------------------------------------------------------
 *	計算結果の末尾に0がいくつ続くかは
 *	結果を因数分解して現れる10の個数を調べれば良い
 *	
 *	又、関数f(x)はその性質上、構成要素が奇数のみもしくは偶数のみ
 *	であり、奇数の場合は10の倍数は出てこないので出力は必ず0になる
 *											
 *	10は素因数分解すると2 * 5となるが、偶数しか出現しないパターンにおいて
 *	2は非常に潤沢に存在しているので5の個数を数えることで	
 *	10の個数を数えることができる。
 *	
 *	f(N) = N * ..... * 8 * 6 * 4 * 2 (* 1)
 *	についてこれを2で割れば
 *	f(N) = (N/2) * .... * 4 * 3 * 2 * 1
 *	単純な階乗となり計算しやすくなる
 *	N!について素因数分解したときに出てくる5の数は例えば
 *	1 * 2 * 3 * 4 * 5 * ... * 10 * ...
 *	..* 15 * ... * 20 * ... * 25
 *	までであれば
 *	5, 10, 15, 20, 25
 *	であり、5の数は6つである。
 *	N!(N < x^2)に含まれるxの数は
 *	(N / x)
 *	で求めることができ、
 *	x^3 > N > x^2の場合は
 *	(N / x) + (N / x^2)
 *	を計算することにより求めることができる。
 *	
 *	つまり任意の整数値の入力Nに対してそのf(N)の計算結果の末尾
 *	に続く0の個数を求めるには
 *	Nを半分にしたものに対して
 *	(N / 5) + (N / 25) + (N / 125) + ...
 *	を計算すればよい
 *------------------------------------------------------------------------------*/
int main()
{
	long int	N;			/* ユーザー入力のN */
	long int	result;		/* 計算結果を格納する */
	long int	five;		/* 5の累乗を計算する */
	char		line[100];	/* ユーザーの入力行 */
	
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%ld", &N);
	result = 0;
	five = 1;
	
	/* 奇数であれば0を出力して終了 */
	if((N % 2) == 1){
		printf("0\n");
		return (0);
	}
	/* Nを半分にする */
	N = N / 2;

	for(five = 1; (five * 5) <= N;){
		five *= 5;
		result += N / five;
	}

	printf("%ld\n", result);
	return 0;
}

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

#define int         long long
#define pb          push_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 all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=15;
const int M=1e9 + 7;

int a[N][N];
int n,m;
int k;
vi v;

int solve(int i,map<int,int> mp)
{
	if(i==n)
	{
		for(int j=0;j<m;j++)
		{
			if(mp[j]<k)
				return INT_MAX;
		}
		return 0;
	}
	map<int,int> mpp=mp;
	for(int j=0;j<m;j++)
	{
		mpp[j] += a[i][j];
	}
	return min(v[i]+solve(i+1,mpp),solve(i+1,mp));
}

int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	rep(i,0,n-1)
	{
		int x;
		cin >> x;
		v.pb(x);
		rep(j,0,m-1)
		{
			cin >> a[i][j];
		}
	}
	mi mp;
	int ans = solve(0,mp);
	if(ans>=INT_MAX)
		ans  = -1;
	cout << ans;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    std::cout << "Bad" << std::endl;
  } else {
    std::cout << "Good" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if(A < B){
   for(int i = 0; i < B; i++){
    cout << A; 
   }
  }
  else {
    for(int i = 0; i < A; i++){
    cout << B; 
   }
}
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
count=0
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    ab=0
    for j in range(m):
        ab+=a[i][j]*b[j]
    if ab+c>0:
        count+=1
print(count)

Measured memory_bytes: 3064
N,K=map(int,input().split())

A=list(map(int,input().split()))

answer=0
if K==0:
  for i in A:
    answer+=0^i
  print(answer)
  exit()
  

ketalimit=1
jou=1

while 2**jou-1<K:
  ketalimit+=1
  jou+=1

ketaone=[0]*44
for i in A:
  bini=format(i,'b')
  stri=str(bini)
  for j in range(len(stri)):
    ketaone[-j-1]+=int(stri[-j-1])

answerN=0
for i in range(ketalimit+1,0,-1):
  if ketaone[-i]<=int(N/2) and answerN+2**(i-1)<=K:
  	answerN+=2**(i-1)
for i in A:
  answer+=(i^answerN)
print(answer)

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b;
    cin >> a >> b;
    int ans = ceil((b - 1) * 1.0 / (a - 1));
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3528
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int n, m, l;
vector<vector<pair<int, pair<int, int> > > > graph(101);

int solve()
{
	vector<vector<int> > result(101, vector<int>(101, mod));
	// result[i][j] : 1??????i?????§??§?§???????????????????????????????j????????????????????´????\??????????????????¢?????°
	int ans = mod;
	priority_queue<pair<int, pair<int, int> > > qu;
	// ????????£????????¢?????° / ???????????´??? / ??????
	qu.push(make_pair(0, make_pair(1, l)));
	while(!qu.empty()){
		int enemnum = -(qu.top()).first;
		int now = ((qu.top()).second).first;
		int restmoney = ((qu.top()).second).second;
		qu.pop();
		if(result[now][restmoney] <= enemnum) continue;
		result[now][restmoney] = enemnum;
		if(now == n) ans = min(ans, enemnum);
		for(int i = 0; i < graph[now].size(); i++){
			int next = graph[now][i].first;
			int d = (graph[now][i].second).first;
			int e = (graph[now][i].second).second;
			if(restmoney >= d) qu.push(make_pair(-enemnum, make_pair(next, restmoney - d)));
			qu.push(make_pair(-(enemnum + e), make_pair(next, restmoney)));
		}
	}
	return ans;
}

int main()
{
	while(1){
		cin >> n >> m >> l;
		if(n == 0 && m == 0 && l == 0) break;
		for(int i = 0; i < 101; i++){
			graph[i].clear();
		}
		for(int i = 0; i < m; i++){
			int a, b, d, e;
			cin >> a >> b >> d >> e;
			graph[a].push_back(make_pair(b, make_pair(d, e)));
			graph[b].push_back(make_pair(a, make_pair(d, e)));
		}
		cout << solve() << endl;
	}
}

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

int main(){
  int n,m,a_sum=0;
  cin >> n >> m;
  vector <int> a(m);
  for(int i=0; i<m; i++){
    cin >> a.at(i);
    a_sum += a.at(i);
  }
  if(a_sum > n) cout << -1 << endl;
  else if(a_sum <= n) cout << n - a_sum << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int x = a+b;
    if(x%2==0) cout<<x/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


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

int main(){
    int n;
    cin>>n;
    int v[n],c[n];
    int ans=0;
    
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
        ans+=max(0,v[i]-c[i]);
    }
    cout<<ans<<endl;


    
}

Measured memory_bytes: 256