akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
struct sion{
	ll constant;
	ll x_var;
	void display()
	{
		printf("con = %d,var = %d\n",constant,x_var);
	}
};
sion minu(sion a,sion b)
{
	sion ret;
	ret.x_var = a.x_var - b.x_var;
	ret.constant = a.constant - b.constant;
	return ret;
}
const ll maxn = 1e5 + 5;
sion in[maxn];
int main(int argc, char const *argv[])
{
	ll n;
	cin>>n;
	in[1].constant = 0;
	in[1].x_var = 1;
	for(ll i = 1;i <= n; ++i)
	{
		ll x;
		scanf("%lld",&x);
		sion now;
		now.constant = 2 * x;
		now.x_var = 0;
		in[i + 1] = minu(now,in[i]);
	}
	int x = in[n + 1].constant / (1 - in[n + 1].x_var);
	for(ll i = 1;i <= n; ++i)
	{
		printf("%lld ",in[i].constant + x * in[i].x_var);
	}
	printf("\n");
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N;
int cnt[256];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	ll ret=1;
	FOR(i,N) {
		FOR(j,256) if(S[i]!=j) ret+=cnt[j];
		cnt[S[i]]++;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(int argc, char* argv[]) {
  map<int, int> data;
  int var;
  int max = 0;
  while(cin >> var) {
    data[var]++;
    if(data[var] > max) {
      max = data[var];
    }
  }
  //cout << max << endl;
  for(map<int, int>::iterator it=data.begin(); it!=data.end(); it++) {
    if(it->second == max) cout << it->first << endl;
  }
}



Measured memory_bytes: 3092
package main

import "fmt"

func main() {
	var n, sum int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)

	for i := range v {
		fmt.Scan(&v[i])
	}
	for i := range c {
		fmt.Scan(&c[i])
	}
	for i := 0; i < n; i++ {
		t := v[i] - c[i]
		if t > 0 {
			sum += t
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;

ll M = 998244353;

ll d[100010];
ll c[100010];

ll powmod(ll x, ll y){
  if(y==0) return 1LL;
  ll t=powmod(x,y/2);
  if (y%2==0) return (t*t)%M;
  return (((x*t)%M)*t)%M;
}

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

  ll n;
  cin>>n;
  for (ll i=0; i<n; ++i) {
    cin>>d[i];
    c[d[i]]+=1;
  }
  if (d[0]!=0 || c[0]>1) {
    cout<<0<<endl;
    return 0;
  }
  ll m = *max_element(d, d+n);



  ll ans = 1;
  for (ll i=1; i<=m; ++i) {
    ans *= powmod(c[i-1], c[i]);
    ans %= M;
  }
  cout<<ans<<endl;
}

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

using namespace std;



int main(){
	int n;
	long long int a[100010];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	long long int tmp = 0;
	for(int i = 0;i < n;i++){
		tmp = (a[i]*2) - tmp;
	}
	long long int ans = tmp / 2;
	cout << ans << " ";
	for(int i = 0;i < n-1;i++){
		long long  int nextans = a[i]*2 - ans;
		cout << nextans;
		if(i != n-2)cout << " ";
		ans = nextans;
	}
	cout << endl;
}

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

int main(){
	int debt = 100000;
	int n;
	cin >> n;
	for(int i = 1;i<=n;i++){
		debt = debt *105 / 100;
		if( debt %1000 != 0 && debt % 1000 <999)
			debt = debt / 1000 *1000 +1000;
		else
			debt = debt / 1000 *1000;
	}
	cout << debt << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 10004;
char s[N];

int main() {
    int n;
    scanf("%d\n%s", &n, s);
    int m = strlen(s);
    for (int i = 0; i < m; i++) {
        int c = s[i] - 'A';
        c += n;
        c %= 26;
        s[i] = c + 'A';
    }
    printf("%s", s);
    return 0;
}


Measured memory_bytes: 3816
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String S = stdIn.next();
        stdIn.close();

        int n = S.length();

        for (int i = 0; i < (n - 1) / 2; i++) {
            if (S.charAt(i) != S.charAt(n - i - 1)) {
                System.out.println("No");
                return;
            }
        }

        for (int i = 0; i < (n - 1) / 4; i++) {
            if (S.charAt(i) != S.charAt((n - 1) / 2 - 1 - i)) {
                System.out.println("No");
                return;
            }
        }

        for (int i = 0 ; i < (n - 1) / 4; i++) {
            if (S.charAt((n + 1) / 2 + i) != S.charAt(n - 1 - i)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");

    }
}

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

int main(){
    int N = 105;
    int d[N];
    int pre = 110;
    int counter = 0;

    cin >> N;
    for(int i = 0; i < N; i ++){
        cin >> d[i];
    }
    sort(d, d + N);
    for(int i = 0; i < N; i++){
        if(pre != d[i]) counter++;
        pre = d[i];
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
count=0
for i in range(1,N//2):
    count+=A[i]
if N%2==1:
    print(A[0]+count*2+A[N//2])
else:
    print(A[0]+count*2)

Measured memory_bytes: 31584
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#include<functional>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector<vector<vector<ll>>> vvv;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;



int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	/*freopen("capitals.in", "r", stdin);
	freopen("capitals.out", "w", stdout);*/
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	string s;
	cin >> n >> s;
	vl white(n, 0), black(n, 0);
	if (s[0] == '.')
		white[0] = 1;
	else
		black[0] = 1;

	forn(i, 1, n)
	{
		if (s[i] == '.')
			white[i] = 1;
		else
			black[i] = 1;
		white[i] += white[i - 1];
		black[i] += black[i - 1];
	}

	ll res = n;
	forn(i, 0, n + 1)
	{
		ll le, ri;
		ll wc = 0, bc = 0;
		le = 0;
		ri = i - 1;
		if (ri >= le)
			wc = black[ri];
		le = i;
		ri = n - 1;
		if (ri >= le)
			bc = white[ri] - white[le] + (ll)(s[le] == '.');
		res = min(res, wc + bc);
	}


	cout << res;
	return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k < a) {
        cout << k << endl;
    } else if (k >= a && k < a + b) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean ans = true;
		String s = sc.next();
		char c[] = s.toCharArray();
if(c[a]!='-'||s.length()!=a+b+1){
	ans=false;
}
for(int i=0;i<=s.length()-1;i++){
	if(i!=a&&c[i]=='-'){
		ans=false;
	}
}
		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
    // ifstream in("data.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;

    if(A % 2 != B % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (A + B) / 2 << endl;
    }
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long L,N,min = 99999999999;
  cin >> L >> N;
  for(long long i = L;i <= N;i++){
    for(long long j = L;j <= N;j++){
      if((i * j) % 2019 < min && i != j){
		min = (i * j) % 2019;
      }
      if(min == 0){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << min << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

  uint32_t N;
  std::cin >> N;

  uint32_t c = 0;
  for (uint32_t i = 1; i <= N; i++) {
    if (i % 2 != 0) {
      uint32_t x = 0;
      for (uint32_t j = 1; j <= N >> 1; j++) {
        if (i % j == 0) {
          x++;
        }
      }
      if ((x + 1) == 8) {
        c++;
      }
    }
  }

  std::cout << c << std::endl;
}


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

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define debug(x) cout << #x << "=" << (x) << endl;

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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end
template< typename T >
struct Dijkstra{
  private:
  vector<vector<pair<T,int>>> edge;
  public:
  Dijkstra(int sz){
    edge.assign(sz,vector<pair<T,int>>(0));
  }
  void addEdge(int from,int to,T cost){
    edge[from].push_back(make_pair(cost,to));
  }
  vector<T> Execute(int st){
    const auto INF=numeric_limits< T >::max();
    vector<T> dist(edge.size(),INF);
    priority_queue<pair<T,int>,vector<pair<T,int>>,greater<pair<T,int>>> pq;
    dist[st]=0;
    pq.emplace(0,st);
    while(!pq.empty()){
      T cost;int idx;
      tie(cost,idx)=pq.top();pq.pop();
      if(cost>dist[idx])continue;
      for(auto &e :edge[idx])
        if(chmin(dist[e.second],e.first+cost))
          pq.emplace(dist[e.second],e.second);
    }
    return dist;
  }
};
void solve(){
  int V,E,r;
  cin>>V>>E>>r;
  Dijkstra<int> dij(V);
  rep(i,E){
    int s,t,d;
    cin>>s>>t>>d;
    dij.addEdge(s,t,d);
  }
  auto dist=dij.Execute(r);
  rep(i,V)
    if(dist[i]==INT_MAX)
      cout<<"INF"<<endl;
    else cout<<dist[i]<<endl;
}

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



Measured memory_bytes: 12944
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int day = sc.nextInt();
		final int ko = sc.nextInt();
		final int sa = sc.nextInt();
		final int ko_d = sc.nextInt();
		final int sa_d = sc.nextInt();
		
		final int day_ko = (int) Math.ceil(ko / (double)(ko_d));
		final int day_sa = (int) Math.ceil(sa / (double)(sa_d));
		
		System.out.println(day - (Math.max(day_ko, day_sa)));
		
	}

}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,dp[105][105],ans;
int h[105],H[105],hi[105],cnt,r[105];

int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=1ll*res*x%mod;
		x=1ll*x*x%mod,y/=2;
	}
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]),hi[i]=h[i];
	sort(hi+1,hi+n+1);
	for(int i=1;i<=n;i++) if(hi[i]!=hi[i-1]) H[++cnt]=hi[i];
	for(int i=1;i<=n;i++) r[i]=lower_bound(H+1,H+cnt+1,h[i])-H;
	for(int j=0;j<r[1];j++){
		int i=1;
		if(j) dp[i][j]=2ll*(ksm(2,H[j+1]-H[j])-1)*ksm(2,h[1]-H[j+1])%mod;
		else dp[i][j]=1ll*(ksm(2,H[j+1]-H[j])-2)*ksm(2,h[1]-H[j+1])%mod;
	}
	dp[1][r[1]]=2;
	for(int i=2;i<=n;i++){
		if(h[i]<=h[i-1]){
			for(int j=0;j<r[i];j++) dp[i][j]=dp[i-1][j];
			for(int j=r[i];j<=r[i-1];j++) (dp[i][r[i]]+=2ll*dp[i-1][j]%mod)%=mod;
		}
		else{
			for(int j=0;j<r[i-1];j++) dp[i][j]=1ll*dp[i-1][j]*ksm(2,h[i]-h[i-1])%mod;
			int S=2ll*dp[i-1][r[i-1]]%mod;
			for(int j=r[i-1];j<r[i];j++) dp[i][j]=1ll*S*(ksm(2,H[j+1]-H[j])-1)%mod*ksm(2,h[i]-H[j+1])%mod;
			dp[i][r[i]]=S;
		}
	}
	for(int i=0;i<=r[n];i++) (ans+=dp[n][i])%=mod;
	printf("%d\n",ans);
	
	return 0;
}

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

long double pi = acos(-1);

int32_t main() {

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.setf(ios::fixed);cout.precision(15);

    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angH = h*30.0;
    long double angM = m*6.0;
    angH += (angM/360.0) * 30.0;
    long double angle = fabs(angH-angM)*pi/180.0;

    long double c = sqrt( a*a + b*b - 2.0*a*b*cos(angle) );
    cout << c;

    return 0;
}

Measured memory_bytes: 4128
rs, mn, mx = map(int, raw_input().split())
rs = [str(r) for r in range(1, rs + 1)]

totals = list()
for r in rs:
    total = sum([int(_r) for _r in r])
    if mn <= total <= mx:
        totals.append(int(r))
print sum(totals)

Measured memory_bytes: 3588
N = int(input())
A = [int(input()) for _ in range(N)]

sum_A = sum(A)
MOD = 998244353

dp1 = [0] * (sum_A + 1)
dp2 = [0] * (sum_A + 1)
dp1[0] = dp2[0] = 1


for a in A:
    dp1_ = [0] * (sum_A + 1)
    dp2_ = [0] * (sum_A + 1)
    for i in range(sum_A + 1):
        if i - a >= 0:
            # R に塗れる場合
            dp1_[i] = (dp1[i - a] + dp1[i] * 2) % MOD
            dp2_[i] = (dp2[i - a] + dp2[i]) % MOD
        else:
            dp1_[i] = (dp1[i] * 2) % MOD
            dp2_[i] = dp2[i]
    dp1, dp2 = dp1_, dp2_


ans = pow(3, N, MOD)
for i in range(sum_A + 1):
    if i * 2 >= sum_A:
        ans = (ans - dp1[i] * 3 + MOD * 3) % MOD
    if i * 2 == sum_A:
        ans = (ans + dp2[i] * 3) % MOD
print(ans)


Measured memory_bytes: 119668
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

bool solve(const vector<ll> &A, const vector<ll> &F, ll cand, ll K) {
  const int N = A.size();
  REP(i,N) {
    if(A[i] * F[i] <= cand) continue;
    ll tmp = cand / F[i];
    ll d = A[i] - tmp;
    K -= d;
  }
  return K >= 0;
}

int main() {
  int N; cin>>N;
  ll K; cin>>K;
  vector<ll> A(N), F(N);
  ll sum = 0;
  REP(i,N) {
    cin>>A[i];
    sum += A[i];
  }
  if(sum <= K) {
    cout << 0 << endl;
    return 0;
  }
  REP(i,N) cin>>F[i];
  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  ll low = 0, high = 1LL<<60;
  while(low + 1LL < high) {
    ll mid = (low + high) / 2LL;
    bool ret = solve(A, F, mid, K);
    if(ret) high = mid;
    else low = mid;
  }
  cout << high << endl;
  return 0;
}


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


int main() {
    int K, X;
    cin >> K >> X;
    int all = K*500;
    if(all>=X) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    priority_queue<int> pq;
    while(true){
        string s;
        cin >> s;
        if(s == "insert"){
            int n;
            cin >> n;
            pq.push(n);
        }else if(s == "extract"){
            cout << pq.top() << endl;
            pq.pop();
        }else{
            break;
        }
    }
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
typedef complex<double> Point;
double cross(const Point& a, const Point& b){
    return (conj(a) * b).imag();
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N;
    int casenum = 0;
    while(cin >> N && N){
        casenum++;
        vector<Point> poly(N);
        rep(i, N) cin >> poly[i].real() >> poly[i].imag();
        double sum = 0;
        Point s = poly[0];
        REP(i, 1, N - 1)
          sum += cross(poly[i] - s, poly[i + 1] - s) / 2.0;
        cout << casenum << ' ' << fixed << setprecision(1) << abs(sum) << endl;
    }
    return 0;
}

Measured memory_bytes: 1308
n,m = map(int,input().split())
p = [list(map(int,input().split())) for i in range(m)]
q = int(input())
v = [list(map(int,input().split())) for i in range(q)]
v = v[::-1]
l = [[] for i in range(n+1)]
for pi in p:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
mita = [-1]*(n+1)
tugi = [set() for i in range(n+1)]
iro = [0] *(n+1)
def dfs(x,y,z):
  if iro[x] == 0:
    iro[x] = z
  if mita[x] >=y:
    return
  for i in l[x]:
    if y-1>=0:
      dfs(i,y-1,z)
  mita[x] = y
for ch in v:
  dfs(ch[0],ch[1],ch[2])
for i in range(1,n+1):
  print(iro[i])

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

typedef long long LL;
const int maxn = 100000+10;
vector<LL> p[maxn];
LL a[maxn], b[maxn];

int main(int argc, char const *argv[])
{
	int N, M;
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
		p[a[i]].push_back(b[i]);
	}
	for (int i = 1; i <= N; i++) {
		sort(p[i].begin(), p[i].end());
	}
	for (int i = 0; i < M; i++) {
		int pos = lower_bound(p[a[i]].begin(), p[a[i]].end(), b[i]) - p[a[i]].begin()+1;
		printf("%06lld%06lld\n", a[i], pos);
	}
	return 0;
}

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

int main()
{
	int n, x;

	while (true){

		cin >> n >> x;

		if (!n && !x)
			break;
		int count = 0;

		for (int i = 1; i <= n - 2; i++){
			for (int j = i + 1; j <= n - 1; j++){
				for (int k = j + 1; k <= n; k++){

					if ((i + j + k) == x)
						count++;
				}
			}
		}
		cout << count << endl;

	}
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n; cin >> n;
  n %= 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "bon" << endl;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    if (x == 7 || x == 5 || x == 3) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21588
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int c[3][3];
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }
  if(c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] -c[2][1] && c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[1][1] - c[1][2] == c[2][1] -c[2][2] && c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][1] - c[1][1] == c[0][2] - c[1][2] && c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][1] - c[2][1] == c[1][2] - c[2][2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
 
 return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

def rev_mod(num):
	pow_num = MOD - 2
	ret = 1
	while pow_num > 0:
		if pow_num % 2:
			ret *= num
			ret %= MOD
		num *= num
		num %= MOD
		pow_num /= 2
	return ret

N, A, B, C = map(int, raw_input().split())

ans = 0

for loop in range(2):
    cnt = 0
    P = 1
    comb = 1
    PA = (A * rev_mod(A + B)) % MOD
    PB = (B * rev_mod(A + B)) % MOD
    PCm = 100 * rev_mod(100 - C) % MOD
    for i in range(N - 1):
        P *= PA
        P %= MOD

    for i in range(N):
        ans += PCm * (N + i) % MOD * P % MOD * comb % MOD * PA
        ans %= MOD
        P *= PB
        P %= MOD
        comb *= N + i
        comb %= MOD
        comb *= rev_mod(i + 1)
        comb %= MOD
    A, B = B, A
print ans

Measured memory_bytes: 8040
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

ll func(ll num) {

	ll cnt = 0;
	while (num % 2 == 0) {
		cnt++;
		num /= 2;
	}
	return cnt;

}

int main() {

	ll N, cnt = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {

		int a;
		cin >> a;
		cnt += func(a);

	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int H,W;
    cin>>H>>W;
    int M[10][10];
    rep(i,0,10)rep(j,0,10)cin>>M[i][j];
    vector<vi> IN(H,vi(W));
    rep(i,0,H)rep(j,0,W)cin>>IN[i][j];
    rep(i,0,10){
        rep(j,0,10){
            rep(k,0,10){
                chmin(M[j][k],M[j][i]+M[i][k]);
            }
        }
    }
    ll res=0;
    rep(i,0,H)rep(j,0,W){
        if(IN[i][j]==-1)continue;
        else{
            res+=M[IN[i][j]][1];
        }
    }
    cout<<res<<endl;
    return 0;
}




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

int a[25] ,b[25],c[25];

int main(){
	int n ;
	cin >> n ;
	for( int i = 1 ; i <= n ; i++ ){
		cin >> a[i] ;
	}
	for( int i = 1 ; i <= n ; i++ ){
		cin >> b[i] ;
	}
	for( int i = 1 ; i <= n-1; i++ ){
		cin >> c[i] ;
	}
	int ans = 0 ;
	for( int i = 1 ; i <= n ; i++ ){
		ans += b[a[i]] ;
		if( i < n  && a[i+1] == a[i] + 1) ans += c[a[i]] ;
	}
	cout << ans << endl ;



	return 0 ;
}

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

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = 0;

            //A0 = B0, A(N - 1) = B(N - 2)より、
            ans += B[0];
            ans += B[N - 2];

            for (int i = 1; i < N - 1; i++) {
                ans += Math.Min(B[i - 1], B[i]);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15316
# https://drken1215.hatenablog.com/entry/2019/06/23/004700
# https://atcoder.jp/contests/abc131/submissions/7975278
# https://tjkendev.github.io/procon-library/python/union_find/union_find.html

def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline

    MX = 10 ** 5 + 10

    *p, = [r for r in range(MX * 2)]

    def root(x):
        if x == p[x]:
            return x
        p[x] = y = root(p[x])
        return y

    def unite(x, y):
        px = root(x)
        py = root(y)
        if px == py:
            return 0
        if px < py:
            p[py] = px
        else:
            p[px] = py
        return 1

    n = int(input())
    for _ in range(n):
        x, y = (int(x) - 1 for x in input().split())  # [1,)->[0,)
        unite(x, y + MX)

    ctr_x = Counter(root(r) for r in range(MX))
    ctr_y = Counter(root(r) for r in range(MX, MX * 2))

    rs = set(ctr_x.keys())
    rs.update(ctr_y.keys())

    ans = sum(ctr_x[r] * ctr_y[r] for r in rs) - n

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll k,a,b,ans=1;
  cin >> k >> a >> b;
  if(b-a<=2){
    cout << k+1 << endl;
    return 0;
  }
  ans+=a-1;
  k-=a-1;
  ans+=k%2;
  k-=k%2;
  ans+=(b-a)*k/2;
  cout << ans << endl;
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int a[100005], l[100005], r[100005];

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    l[0] = a[0];
    for (int i = 1; i < n; ++i)
        l[i] = gcd(a[i], l[i - 1]);
    r[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i)
        r[i] = gcd(a[i], r[i + 1]);

    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        if (i == 0)
            ans = max(ans, r[i + 1]);
        else if (i == n - 1)
            ans = max(ans, l[i - 1]);
        else
            ans = max(ans, gcd(l[i - 1], r[i + 1]));
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll a,v; cin>>a>>v;
    ll b,w; cin>>b>>w;
    ll t; cin>>t;

    ll d = abs(a-b);
    ll dv = v - w;

    if(dv <= 0) puts("NO");
    else{
        if(dv*t >= d) puts("YES");
        else puts("NO");
    }

    return 0;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, k;
        cin >> n >> k;
        if(n == k){
            cout << "0\n";
            return 0;
        }
        if(n < k){
            cout << min(n, k - n) << '\n';
            return 0;
        }
        int b = n % k;
        cout << min(b, k - b) << '\n';
    }
}

Measured memory_bytes: 31488
#include <iostream>
#include<math.h>
using namespace std;
int main(void){
    // Here your code !
    long long int N,ans=9223372036854775807;
    cin>>N;
    long long int a[N],sum[N+1];
    sum[0]=0;
    
    for(int i=0;i<N;i++){
        cin>>a[i];
        sum[i+1]=a[i]+sum[i];
    }
    
    for(int i=1;i<N;i++){
        ans=fminl(ans,labs(2*sum[i]-sum[N]));
    }
    
    cout<<ans<<endl;
}


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

long long a, b, c,d;
int main(){
	cin >> a >> b >> c >> d;
	while(1) {
		//高橋
		c -= b;
		if(c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}

		//青木attack
		a -= d;
		if(a <= 0) {
			cout << "No" << endl;
			return 0;
		}

	}

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n, a, b;
    cin >> n;

    if (n == 1)
    {
        Cout("Hello World");
    }
    else
    {
        cin >> a >> b;
        Cout(a + b);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string s;
   cin >> s;
   s[5]=' ';
   s[13]=' ';
   cout << s << endl;
 }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long GCM(long x, long y)
        {
            var s = x;
            var t = y;
            if (x < y) GCM(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return s / x * t;
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var n = input[0];
            var m = input[1];
            if (m > n)
            {
                var tmp = n;
                n = m;
                m = tmp;
            }
            if (m == 1)
            {
                if (n == 1)
                    Console.WriteLine(1);
                else
                    Console.WriteLine(n - 2);
            }
            if (m >= 2) Console.WriteLine((n - 2) * (m - 2));
                                                    
            Console.Out.Flush();
        }
    }
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

        string S;
        std::cin >> S;

        string ans = "Good";
        REP(i, S.size() - 1) {
            if(S[i] == S[i + 1]) {
                ans = "Bad";
                break;
            }
        }

        std::cout << ans << std::endl;
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 fact(int n); 
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
// Returns factorial of n 
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 










int main() {
  int A=0,B=0,C=0,X=0,count=0;
  cin >> A >> B >> C >> X;
  
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(500*i+100*j+50*k==X){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
}








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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	
	vector<char> C;
	for (char c = 'a'; c <= 'z'; c++) {
		for (int i = 0; i < s.length(); i++) {
			if (c == s[i]) goto LABEL;
		}
		C.push_back(c);
		LABEL:
		;
	}
	int csize = C.size();
	if (csize == 0) {
		cout << "None" << endl;
	} else {
		sort(C.begin(), C.end());
		cout << C[0] << endl;
	}
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-8;

int cross(pii c,pii d){
  return c.first * d.second - d.first * c.second;
}
pii line(pii c,pii d){
  return make_pair(c.first-d.first,c.second-d.second);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pii> a(n);
  REP(i,n) {
    cin >> a[i].first >> a[i].second;
  }
  sort(ALL(a));
  vi low;
  pii lineab, lineac;
  REP(i,n){
    if (i>1) {
      lineab = line(a[low.back()],a[low[low.size()-2]]);
      lineac = line(a[i],a[low[low.size()-2]]);
      while (cross(lineab,lineac) < 0) {
        low.pop_back();
        lineab = line(a[low.back()],a[low[low.size()-2]]);
        lineac = line(a[i],a[low[low.size()-2]]);
      }
    }
    low.pb(i);
  }
  vi high;
  REP(i,n){
    if (i>1) {
      lineab = line(a[high.back()],a[high[high.size()-2]]);
      lineac = line(a[i],a[high[high.size()-2]]);
      while (cross(lineab,lineac) > 0) {
        high.pop_back();
        lineab = line(a[high.back()],a[high[high.size()-2]]);
        lineac = line(a[i],a[high[high.size()-2]]);
      }
    }
    high.pb(i);
  }
  high.pop_back();
  reverse(ALL(high));
  high.pop_back();
  vi ans;
  ans = low;
  FOR(i,0,(int)high.size()) ans.pb(high[i]);
  int sz = (int)ans.size();
  REP(i,sz) ans.pb(ans[i]);
  vector<pair<pii,int>> b(n);
  REP(i,n){
    b[i] = make_pair(make_pair(a[i].second,a[i].first),i);
  }
  sort(ALL(b));
  int xxx;
  REP(i,(int)ans.size()){
    if (ans[i] == b[0].second) {
      xxx = i;
      break;
    }
  }
  cout << ans.size()/2 << endl;
  FOR(i,xxx,(int)ans.size()/2 + xxx) cout << a[ans[i]].first << " " << a[ans[i]].second << endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

int32_t main()
{
    IOS;
    int w,a,b;
    cin>>w>>a>>b;
    if((a<=b+w&&b+w<=a+w)||(b<=a+w&&b>=a))return cout<<0,0;

    int ans=min(abs(w+a-b),abs(b+w-a));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            if v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

        for i in range(N):
            ans[dist[i]] += 1
  
    for k in range(1, N):
        print(ans[k] // 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 49756
n=int(input())
a=list(map(int,input().split()))
a.sort()
ct=[0 for i in range(10**6+1)]
check=[0 for i in range(10**6+1)]
dp=[1 for i in range(10**6+1)]
for i in range(n):
  ct[a[i]]+=1
  if check[a[i]]==0:
    check[a[i]]=1
    for j in range(2,10**6+1):
      if a[i]*j<=10**6:
        dp[a[i]*j]=0
      else:
        break
ans=0
for i in range(n):
  if ct[a[i]]==1 and dp[a[i]]==1:
    ans+=1
print(ans)

Measured memory_bytes: 173916
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    bool flag = false;
    for(int i=0;i<n;i++){
        char c;
        cin >> c;
        if(c == 'Y')
            flag = true;
    }
    cout << (flag?"Four":"Three") << endl;
    return 0;
}


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

ll MOD = 1e9+7;

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

    vector<ll> a(s+4);
    a[1]=0;
    a[2]=0;
    a[3]=1;
    if(s>=4){
        for(int i=4;i<=s;i++){
            a[i]=(a[i-1]+a[i-3])%MOD;
        }
    }
    cout<<a[s]<<endl;
}

Measured memory_bytes: 3624
a, b = map(int,input().split())
if a <=0 and b >= 0:
  print("Zero")
elif (b-a) % 2 == 0 and a < 0 and b < 0:
  print("Negative")
elif a ==0 or b == 0:
  print("Zero")
else:
  print("Positive")
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)
 
#define pb push_back
#define all(in) in.begin(),in.end()
 
using ll = long long;
using ull = unsigned long long;
using namespace std;
 
int main(){
    ll n; cin >> n;
    ll ans;
    for(ll i = 1; i*i <= n; i++) if(n%i == 0) ans = i + n/i -2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#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;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll gcd (ll x, ll y) { return y ? gcd(y,x%y) : x; }

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int res = k, ans = 1;
  while (true) {
    if (res >= n) break;
    res += k-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

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

func main() {
	var s string
	fmt.Scan(&s)
	ans := 0
	for i := 0; i < len(s); i++ {
		for j := i; j < len(s); j++ {
			ss := s[i : j+1]
			ok := true
			for k := 0; k < len(ss); k++ {
				if ss[k] != 'A' && ss[k] != 'C' && ss[k] != 'G' && ss[k] != 'T' {
					ok = false
				}
			}
			if ok {
				ans = max(ans, len(ss))
			}
		}
	}
	fmt.Println(ans)
}


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

double distance(double x1, double y1, double x2, double y2);

int main(void){
  double x1, y1, x2, y2, x3, y3, px, py, r;
  double a, b, c, cos1, o[2][3], m;
  int i, n;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
    a = distance(x2, y2, x3, y3);
    b = distance(x3, y3, x1, y1);
    c = distance(x1, y1, x2, y2);
    cos1 = (b*b + c*c - a*a) / (2*b*c);
    r = a / sqrt(1 - cos1*cos1) / 2.0;

    o[0][0] = x2 * 2 - x1 * 2;
    o[0][1] = y2 * 2 - y1 * 2;
    o[0][2] = x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1;
    o[1][0] = x3 * 2 - x1 * 2;
    o[1][1] = y3 * 2 - y1 * 2;
    o[1][2] = x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1;
    if(o[0][1] != 0){
      m = o[1][1] / o[0][1];
      px = (o[1][2] - o[0][2] * m) / (o[1][0] - o[0][0] * m);
      py = (o[0][2] - o[0][0] * px) / o[0][1];
    }else{
      px = o[0][2] / o[0][0];
      py = (o[1][2] - o[1][0] * px) / o[1][1];
    }
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
  return 0;
}


double distance(double x1, double y1, double x2, double y2){
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1- y2));
}

Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int x[1000000];
int y[1000000];

int main(){
  	int n , m;
	int i;	
	cin >> n >> m;

	rep(i, m) cin >> x[i];
	sort(x, x+m);
  
	rep(i, m-1){
		y[i] = x[i+1] - x[i];
	}
	sort(y, y+m-1);
  	
  	
  	long long j = 0;
	rep(i, m-n){
		j += y[i];
	}
	cout << j << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  rep(i, b) {
    if(i * a % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> V(N);
    for (int i = 0; i < N; ++i) cin >> V[i];

    long long result = 0;
    for (int a = 0; a <= min(N, K); ++a) {
        for (int b = 0; a + b <= min(N, K); ++b) {
            vector<long long> out;
            for (int i = 0; i < a; ++i) out.push_back(V[i]);
            for (int i = 0; i < b; ++i) out.push_back(V[N-i-1]);
            sort(out.begin(), out.end());

            // 操作を行う
            long long sum = 0;
            for (auto v : out) sum += v;
            for (int i = 0; i < min(a + b, K - a - b); ++i) {
                if (out[i] >= 0) break;
                sum -= out[i]; // 詰める
            }
            result = max(result, sum);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<map>
using namespace std;

int main(int argc,char** argv)
{

	string s;
	cin >> s;
	int ans = s.size();
	int siz = s.size();

	for(int i = 0; i < siz; i++){
		s.pop_back();
		ans--;
		string a,b;
		for(int j = 0; j < s.size()/2; j++){
			a += s[j];
		}
		for(int k = s.size()/2; k < s.size(); k++){
			b += s[k];
		}
		if(a==b){
			cout << ans <<endl;
			return 0;
		}
	}

	return 0;

}

Measured memory_bytes: 256