akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int M = in.nextInt();
        ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
        for (int i=0;i<N;i++) {
            ArrayList<Integer> add = new ArrayList<Integer>();
            list.add(add);
        }
        int[] P = new int[M];
        int[] Y = new int[M];
        for (int i=0;i<M;i++) {
            P[i] = in.nextInt()-1;
            Y[i] = in.nextInt();
            list.get(P[i]).add(Y[i]);
        }
        for (int i=0;i<N;i++) {
            ArrayList<Integer> tmp = list.get(i);
            Collections.sort(tmp);
        }

        for (int i=0;i<M;i++) {
            int index = Collections.binarySearch(list.get(P[i]), Y[i]);
            String str = String.format("%06d%06d", P[i]+1, index+1);
            out.println(str);
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


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

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  int mx = *max_element(A.begin(), A.end());
  sort(B.rbegin(), B.rend());
  int ans = 0;
  for (auto b : B) {
    if (b > mx) H -= b, ans++;
    else break;
    if (H <= 0) return cout << ans << "\n", 0;
  }
  cout << ans + (H + mx - 1) / mx << "\n";
}

Measured memory_bytes: 4012
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    cin >> n;
    ll c=0;
    for(int i = 1; i < n;i++){
        c+= i%MOD;
    }
    cout << c << endl;
    

    return 0;
}

Measured memory_bytes: 256
/*
P135
POJ 2718 Smallest Difference
*/


#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
using namespace std;

int a[10];
bool read()
{
    for(int i=0; i<10; ++i)
        scanf("%d", a+i);
}

void solve()
{
    int x1=0, x2=0;
    bool ans = true;
    for(int i=0; i<10; ++i)
    {
        if(x1 < x2) swap(x1, x2);
        if(x1 < a[i]) x1 = a[i];
        else if(x2 < a[i]) x2 = a[i];
        else {ans = false; break;}
    }
    if(ans) printf("YES\n");
    else printf("NO\n");
}


//
//vector<int> L_bucket;
//vector<int> R_bucket;
//
//bool dfs2(int d){
//    if(d == 10) return true;
//    bool flag = false;
//    if(L_bucket.size() == 0 || L_bucket.back() < a[d]){
//        L_bucket.push_back(a[d]);
//        flag = dfs2(d+1);
//        L_bucket.pop_back();
//    }
//    if(flag) return true;
//    if(R_bucket.size() == 0 || R_bucket.back() < a[d]){
//        R_bucket.push_back((a[d]));
//        flag = dfs2(d+1);
//        R_bucket.pop_back();
//    }
//    if(flag) return true;
//    return false;
//}
//
//void solve2()
//{
//    if(dfs2(0)) printf("YES\n");
//    else printf("NO\n");
//}

int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        read();
        solve();
    }
}

Measured memory_bytes: 1168
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
 //   WAIT; 

 long long N;
 int K;
 long long  count=0;
 cin>>N>>K;

if(K==0) {
	cout<<N*N;
	rt0;
}
for(int j=K+1; j<=N;j++)
{
	count+=((N/j)*(j-K));
	int t=N%j;
	if(t>0)	count+=max(0,t-K+1);
}

cout<<count;
    rt0;
}


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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/


/**************************************/

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

    int n; cin >> n;
    if(n%1000==0) cout << 0 << endl;
    else{
      cout << 1000 - n%1000 << endl;
    }
  
    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3648
s=list(input())
q=int(input())
ans=0
mae=[]
ato=[]
for i in range(q):
    query=input().split()
    if query==['1']:
        ans+=1
    else:
        if query[1]=='1' and ans%2==0:
            mae.append(query[2])
        elif query[1]=='1' and ans%2==1:
            ato.append(query[2])
        elif query[1]=='2' and ans%2==0:
            ato.append(query[2])
        else:
            mae.append(query[2])
if ans%2==1:
    s.reverse()
    ato.reverse()
    s=ato+s+mae
else:
    mae.reverse()
    s=mae+s+ato
print(''.join(s))


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool isLarge(char c){
	return (c-'A' >= 0) && ('Z'-c >= 0);
}

void Main(){
	string s;
	cin >> s;
	bool ok = true;

	if(s[0] != 'A') ok = false;

	int cnt = 0;
	rep3(i,2,s.size()-2) {
		if(isLarge(s[i]) && s[i] != 'C') ok = false; 
		if(s[i] == 'C') cnt++;
	}
	if(isLarge(s[1]) || isLarge(s[s.size()-1])) ok = false;
	if(cnt != 1) ok = false;
	  
	if(ok) puts("AC");
	else puts("WA");
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a.at(i);
  sort(all(a));
  cout<<a.at(n-1)-a.at(0)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int K, A, B;

int main() {
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++)
    {
        if(i%K==0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";

    return 0;
}


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

/*** Template Begins ***/

struct custom_hash {static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x + FIXED_RANDOM);}};
// USE : unordered_map<int, int, custom_hash> m;
//     : unordered_set<int, custom_hash> s;

typedef long long    ll;
typedef pair<ll,ll>  PII;
typedef pair<ll, PII> PIII;
#define endl         '\n'
#define pb           push_back
#define INF          ll_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 

// Constants //

const int N = 1e3+7;

/*** Template Ends ***/

int n, h[N];
double tmp[N], a, t;





int main(){
	
	ios;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin >> n >> t >> a;
	for(int i = 0; i < n; i++){
		cin >> h[i];
		tmp[i] = t-0.006*(double)h[i];
	}

	double diff = INT_MAX;
	int idx = -1;
	for(int i = 0 ; i < n ; i++)
		if ( abs(a-tmp[i]) < diff )
			diff = abs(a-tmp[i]),	idx = i;

	cout << idx+1 << endl;
	
	return 0;
}














Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int n; cin >> n;
  int t[n],sum=0;
  for(int i=0;i<n;i++){
    cin >> t[i];
    sum+=t[i];
  }  
  int m; cin >> m;
  int p,x,ans;
  for(int i=0;i<m;i++){
    cin >> p >> x;
    ans=sum-t[p-1]+x;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }
    REP(i, N) {
        cin >> C[i];
    }
    SORT(A), SORT(B), SORT(C);
    ll res = 0;
    REP(i, N) {
        ll cnt1 = LI(A, B[i]);
        ll cnt2 = N - UI(C, B[i]);
        res += cnt1 * cnt2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1408
S = input()
K = int(input())
alp = '0bcdefghijklmnopqrstuvwxyza'
alp_dict = {s:i for i,s in enumerate(alp)}


cnt = 0
ans = ''
for i,s in enumerate(S):
  if cnt + (26-alp_dict[s]) <= K:
    cnt += (26-alp_dict[s])
    ans += 'a'
  else:
    ans += s

if (K-cnt)%26==0:
  print(ans)
else:
  rest = (K-cnt)%26
  print(ans[:-1]+alp[(alp_dict[ans[-1]]+rest)%26])

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

int main() {
  int N,Q; long K;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  vector<long> win(N);
  for (int i =0; i<Q; i++) {
    int a; cin >> a; A.at(i) = a;
    win.at(a-1)++;
  }
  
  for (int i =0; i<N; i++) {
    if (K - Q + win.at(i) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<int> a;
    int a_temp;
    int sum_a=0;
    REP(i,N){
        cin>>a_temp;
        a.push_back(a_temp+100);
        sum_a+=a_temp+100;
    }
    //debug(sum_a);
    int x;
    ll ans;ans=0;
    if(sum_a%N==0){
        x=sum_a/N;
        
    }else{
        x=double(sum_a)/N+0.5;
    }
    REP(i,N){
        ans+=pow(a[i]-x,2);
    }
    
    print(ans);
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int k = sc.NextInt();

        int answer = k / 2 * (k - (k / 2));

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    if (n == 1) {
      System.out.println("Hello World");
      return;
    }
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (n == 2) {
      System.out.println(a + b);
    }
  }
}

Measured memory_bytes: 23764
from collections import *

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

count_a = Counter(a).most_common()
count_a = sorted(count_a, key = lambda x:x[0], reverse=True)

if count_a[0][1] > 1:
    for i in range(n):
        print(count_a[0][0])
else:
    for i in a:
        print(count_a[0][0] if i != count_a[0][0] else count_a[1][0])

Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

bool done[51][51][51];
bool memo[51][51][51];
bool can(int x,int y,int k){	//x->y using k,k-1,..,1
	if(done[x][y][k]) return memo[x][y][k];
	if(x==y) return 1;
	if(x<y) return 0;
	if(k==0) return 0;

	bool res = can(x,y,k-1) | can(x%k,y,k-1);

	done[x][y][k] = 1;
	return memo[x][y][k] = res;
}
int main(){
	int N;
	cin>>N;
	vector<int> a(N),b(N);
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	using ll = long long;
	ll ans =0 ;
	rep(i,N){
		if(!can(a[i],b[i],50)){
			puts("-1");
			return 0;
		}
	}
	vector<vector<int>> now(N);
	rep(i,N){
		now[i] = {a[i]};
	}
	for(int k=50;k>=1;k--){
		bool need = 0;
		rep(i,N){
			bool f = 0;
			for(int v:now[i]){
				if(can(v,b[i],k-1)) f = 1;
			}
			if(!f) need = 1;
		}
		if(need){
//			show(k);
			ans += 1LL<<k;
			vector<vector<int>> nnow = now;
			rep(i,N){
				for(int v:now[i]){
					nnow[i].pb(v%k);
				}
				sort(all(nnow[i]));
				nnow[i].erase(unique(nnow[i].begin(),nnow[i].end()),nnow[i].end());
			}
			now = nnow;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int max(int a, int b)
{
   if(a>b) return a;
   else return b;
}
int min(int a, int b)
{
   if(a<b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      if(c1<c2){
         qa=min(b/c1, q2);
	 if(c1*qa+c2*max(q1-qa, 0)>b) qa=0;
	 if(qa==0) printf("NA\n");
	 else printf("%d %d\n", qa, (b-c1*qa)/c2);
	 continue;
      }

      qa=0;
      hi=q2;
      lo=1;
      while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    lo=ce+1;
	    qa=ce;
	 }
	 else hi=ce-1;
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}

Measured memory_bytes: 612
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

VV<ll> edges;

bool solve() {
    string S;
    cin >> S;
    if(S[0] == '0') return false;
    if(S.back() == '1') return false;
    for(ll i = 2; i <= S.size() - 1; i++) {
        auto idx_i = i - 1;
        auto idx_j = (S.size() - i) - 1;
        if(S[idx_i] != S[idx_j]) return false;
    }
    edges.resize(S.size());
    
    auto add_edge = [&](ll u, ll v) {
        if(u > v) swap(u, v);
        edges[u].push_back(v);
    };

    ll cur_root = 1;
    add_edge(0, 1);
    for(ll i = 1; i < S.size() - 1; i++) {
        if(S[i] == '1') {
            add_edge(cur_root, i + 1);
            cur_root = i + 1;
        } else {
            add_edge(cur_root, i + 1);
        }
    }
    return true;
}

int main() {
    if(solve()) {
        for(ll i = 0; i < edges.size(); i++) for(ll ele : edges[i]) cout << i + 1 << ' ' << ele + 1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6892
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.14159265358979323846264338)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD (1000000007ll)
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int sol = n;
    for (int i = 0;i < n - m + 1;i++) {
        int cost = 0;
        for (int j = 0;j < m;j++) {
            if (s[i + j] != t[j]) {
                cost++;
            }
        }
        sol = min(sol, cost);
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int main()
{
	double r;
	cin >> r;
	r = 2.0 * 3.1415926535897932384 * r;
	cout.precision(17);
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3784
HH, WW = ARGF.gets.chomp.split.collect {|el| el.to_i}

if 1 < HH && 1 < WW
  n0 = (HH + 1) / 2
  n1 = (HH) / 2

  w2 = WW / 2

  sum = (n0 + n1) * w2
  if (WW % 2) == 1
    sum += n0
  end
else
  sum = 1
end

puts sum


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  n++;
  int mon[n+5];
  for(int  i = 1; i <= n; i++){
    cin >> mon[i];
  }
  int hero[n+1];
  for(int i = 1; i < n; i++){
     cin >> hero[i];
  }
  long long ans = 0;
  for(int i = 1; i < n; i++){
    int temp = min(mon[i],hero[i]);
    hero[i]-=temp;
    mon[i]-=temp;
    ans+=temp;
    temp = min(mon[i+1],hero[i]);
    hero[i]-=temp;
    mon[i+1]-=temp;
    ans+=temp;
  }
  cout << ans << '\n';  
}

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

const int INF = 1e9 + 10;
const double eps = 1e-11;
double cross_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).imag();
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    vector<double> x(4), y(4);
    for (int j = 0; j < 4; j++) {
      cin >> x[j] >> y[j];
    }
    complex<double> vec1 = complex<double>{x[1] - x[0], y[1] - y[0]};
    complex<double> vec2 = complex<double>{x[3] - x[2], y[3] - y[2]};
    cout << ((abs(cross_product(vec1, vec2)) < eps) ? "YES" : "NO") << endl;
  }
}



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


Measured memory_bytes: 2108
def calc_flips(n,m):
    flips = {}
    if n==1 and m==1:
        flips[1]=1
    elif n==1 or m==1:
        flips[2]=2
        b = n if n>m else m
        flips[3]=b-2
    elif n==2 and m==2:
        flips[4]=4
    elif n==2 or m==2:
        flips[4]=4
        b = n if n>m else m
        flips[6]=(b-2)*2
    else:
        flips[4]=4
        flips[6]=((n-2)*2)+((m-2)*2)
        flips[9]=(n-2)*(m-2)
    return flips

def calc_backs(flips):
    num_backs = 0
    for k,v in flips.items():
        if k % 2 == 1:
            num_backs += v
    return num_backs

n,m = map(int, input().split())
flips = calc_flips(n,m)
num_backs = calc_backs(flips)
print(num_backs)

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    vector<char> start(26, -1);
    vector<char> goal(26, -1);

    rep(i, S.length()) {
        ll start_index = S[i] - 'a';
        ll goal_index = T[i] - 'a';
        if (start[start_index] != -1 || goal[goal_index] != -1) {
            if (start[start_index] != T[i] || goal[goal_index] != S[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        start[start_index] = T[i];
        goal[goal_index] = S[i];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int x,a;
cin >> x >> a;
if(x<a)fin(0);else fin(10);

//////////////////////////////////////////////////////
return 0;}

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf=UnionFind(N+1)
  
for i in range(M):
  a,b=map(int, input().split())
  uf.union(a,b)

print(uf.group_count()-2)

Measured memory_bytes: 12940
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 素因数分解 O(√N)
template <typename T>
vector<T> factorize(T x) {
    if (x <= 1) return vector<T>();
    vector<T> r; T x0 = x;
    while (x % 2 == 0)
        x /= 2, r.push_back(2);
    for (long long f = 3; f * f <= x0; f += 2)
        while (x % f == 0)
            x /= f, r.push_back(f);
    if (x > 1) r.push_back(x);
    return r;
}

// 処理内容
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b; cin >> a >> b;

    ll g = gcd(a, b);
    vector<ll> d = factorize(g);

    UNIQUE(d);
    cout << d.size() + 1 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, w;
  cin >> n >> h >> w;
  if (n < h or n < w) return cout << 0 << '\n', 0;
  cout << (n - h + 1) * (n - w + 1) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
// #define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	FAST_IO;
	int x, y;
	cin >> x >> y;
	int n2 = (4 * x - y) / 2;
	int n1 = x - n2;
	if (n1 >= 0 && n2 >= 0 && (4 * x - y) % 2 == 0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
 	return 0;
}

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

int main(void) {

  long x,y;
  scanf("%ld %ld", &x, &y);
  long button;
  if (labs(y) >= labs(x)) {
    if (x >= 0 && y >= 0) {
      button = y-x;
    } else if (x >= 0 && y < 0) {
      button = 1-x-y;
    } else if (x < 0 && y >= 0) {
      button = 1+y+x;
    } else {
      button = 2+x-y;
    }
  } else {
    if (x >= 0 && y > 0) {
      button = 2+x-y;
    } else if (x >= 0 && y < 0) {
      button = 1+y+x;
    } else if (x >= 0 && y == 0) {
      button = 1+x-y;
    } else if (x < 0 && y > 0) {
      button = 1-y-x;
    } else {
      button = y-x;
    }
  }
  printf("%ld\n", button);

  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
	int A=sc.nextInt();
	String op =sc.next();
	int B=sc.nextInt();
	if(op.equals("+")){
	System.out.println(A+B);
	}else{
	System.out.println(A-B);
	}
	}
	}

Measured memory_bytes: 23764
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n,k=map(int, input().split())
    A=[0]+list(map(int, input().split()))
    for i in range(k+1,n+1):
        if A[i] > A[i-k]:
            print('Yes')
        else:
            print('No') 
 
if __name__=='__main__':
    main()
  

Measured memory_bytes: 31724
W,H,N = map(int, input().split())
x_min, y_min = 0,0
x_max, y_max = W,H
for _ in range(N):
    x,y,a = map(int, input().split())
    if a==1:
        x_min = max(x_min, x)
    elif a==2:
        x_max = min(x_max, x)
    elif a==3:
        y_min = max(y_min, y)
    else:
        y_max = min(y_max, y)
width = max(0, x_max-x_min)
height = max(0, y_max-y_min)
print(width*height)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
#define LLINF 11e16
 
using namespace std;
 
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<string> str(n);
	rep(i, n){
		cin >> str.at(i);
		sort(all(str.at(i)));
	}
	
	sort(all(str));
	
	ll ans = 0;
	int tmp = 1;
	
	rep(i, n-1){
		if(str.at(i) == str.at(i + 1)){
			ans += tmp;
			tmp++;
		}
		else
			tmp = 1;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

signed main() {
    string s;
    cin >> s;
    int x, mn = 10000000;
    for (int i = 0; i < s.size() - 2; ++i) {
        x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        if (abs(753 - x) < mn) {
            mn = abs(753 - x);
        }
    }
    cout << mn;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  int ans;
  if((A == 1) && (B == 2)) ans = 3;
  if((A == 1) && (B == 3)) ans = 2;
  if((A == 2) && (B == 1)) ans = 3;
  if((A == 2) && (B == 3)) ans = 1;
  if((A == 3) && (B == 1)) ans = 2;
  if((A == 3) && (B == 2)) ans = 1;

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

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


s=list(input().split("S"))
ans=0
for i in s:
    ans=max(ans,len(i))
print(ans)

Measured memory_bytes: 77412
n,a,b,c,d=map(int,input().split())
s=str(input())
arr=[]
for i in range(len(s)):
	if(s[i]=='#'):
		arr.append(-1)
	elif(s[i]=='.'):
		arr.append(0)

a-=1
b-=1
c-=1
d-=1
flag=0
arr[a]=1
arr[b]=2
pos1=a
pos2=b
if(c<d):
	while(pos2<d):
		if(pos2+1<n and arr[pos2+1]==0):
			pos2+=1
			arr[pos2-1]=0
			arr[pos2]=2
		else:
			if(pos2+2<n and arr[pos2+2]==0):
				pos2+=2
				arr[pos2-2]=0
				arr[pos2]=2
			else:
				flag=1
				break
		#print(arr)
	while(pos1<c):
		if(pos1+1<n and arr[pos1+1]==0):
			arr[pos1]=0
			arr[pos1+1]=1
			pos1+=1
		else:
			if(pos1+2<n and arr[pos1+2]==0):
				pos1+=2
				arr[pos1-2]=0
				arr[pos1]=1
			else:
				flag=1
				break
else:
	
	#print(flag)
	while(pos2>pos1):
		if(pos1+1<n and arr[pos1+1]==0):
			arr[pos1]=0
			arr[pos1+1]=1
			pos1+=1
		else:
			if(pos1+2<n and arr[pos1+2]==0):
				pos1+=2
				arr[pos1-2]=0
				arr[pos1]=1
			else:
				if(pos2<d):
					if(pos2+1<n and arr[pos2+1]==0):
						pos2+=1
						arr[pos2-1]=0
						arr[pos2]=2
					else:
						if(pos2+2<n and arr[pos2+2]==0):
							pos2+=2
							arr[pos2-2]=0
							arr[pos2]=2
						else:
							flag=1
							break
				else:
					flag=1
					break
		#print(flag)
		#print(arr)
	if(flag==0):
		while(pos1<c):
			if(pos1+1<n and arr[pos1+1]==0):
				arr[pos1]=0
				arr[pos1+1]=1
				pos1+=1
			else:
				if(pos1+2<n and arr[pos1+2]==0):
					pos1+=2
					arr[pos1-2]=0
					arr[pos1]=1
				else:
					flag=1
					break
		while(pos2<d):
			if(pos2+1<n and arr[pos2+1]==0):
				pos2+=1
				arr[pos2-1]=0
				arr[pos2]=2
			else:
				if(pos2+2<n and arr[pos2+2]==0):
					pos2+=2
					arr[pos2-2]=0
					arr[pos2]=2
				else:
					flag=1
					break

if(flag==1):
	print("No")
else:
	print("Yes")

	


Measured memory_bytes: 5024
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
    s[i] = 'x';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=1000005;
int f[N],n,mn,sum,mx;
char s[N];

int solve(){
	n=strlen(s+1);
	per(i,n,1){
		f[i]=f[i+1];
		if(s[i]=='0') f[i]--;
		else f[i]++;
		f[i]=min(f[i],0);
	}
	mn=f[1];
	sum=mx=0;
	rep(i,1,n){
		if(s[i]=='0') sum--;
		else if(s[i]=='1') sum++;
		else{
			if(sum-1+f[i+1]<mn) sum++;
			else sum--;
		}
		mx=max(mx,sum);
	}
	return mx-mn;
}

int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	int ans=solve();
	reverse(s+1,s+n+1);
	ans=min(ans,solve());
	rep(i,1,n){
		if(s[i]=='1') s[i]='0';
		else if(s[i]=='0') s[i]='1';
	}
	ans=min(ans,solve());
	reverse(s+1,s+n+1);
	ans=min(ans,solve());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8588
#include<cstdio>
const int MaxN=200010,MaxQ=200010;
const long long inf=1ll<<61; 
int N,Q,A,B,x[MaxQ];
long long f[MaxQ],T[2][MaxN];
long long min(long long a,long long b){return a<b?a:b;}
long long dif(long long a,long long b){return a>b?a-b:b-a;}
void ins(int t,int i,long long x){for(;i<=N;i+=i&-i)T[t][i]=min(T[t][i],x);}
long long qry(int t,int i){long long s=inf;for(;i;i-=i&-i)s=min(s,T[t][i]);return s;}
int main(){
	scanf("%d%d%d%d",&N,&Q,&A,&B);
	long long sum=0,ans;
	for(int i=0;i<Q;i++)scanf("%d",x+i),i?sum+=dif(x[i],x[i-1]):1; 
	ans=sum+min(dif(*x,A),dif(*x,B));
	for(int i=1;i<=N;i++)T[0][i]=T[1][i]=inf;
	for(int i=Q;--i;){
		f[i]=-dif(x[i],x[i-1])+min(min(qry(0,x[i-1])+x[i-1],qry(1,N+1-x[i-1])-x[i-1]),0);
		ins(0,x[i],f[i]-x[i]);
		ins(1,N-x[i]+1,f[i]+x[i]); 
		ans=min(ans,sum+f[i]+min(dif(*x,A)+dif(x[i],B),dif(*x,B)+dif(x[i],A)));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5632
#include <cstdio>

int n, m, a[51], b[51];
bool gr[51][51], flg[51];



void dfs(int v)
{
    flg[v] = true;

    for (int i = 0; i < n; i++) {
        if (gr[v][i] == false || flg[i] == true) continue;
        dfs(i);
    }
}


int main()
{
    scanf("%d %d", &n, &m);
    
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a[i], &b[i]);

        a[i]--; 
        b[i]--;
        gr[a[i]][b[i]] = gr[b[i]][a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) flg[j] = false;

        gr[a[i]][b[i]] = gr[b[i]][a[i]] = false;

        dfs(0);

        bool arr = false;
        for (int j = 0; j < n; j++) if (flg[j] == false) arr = true;
        if (arr) ans++;
        
        gr[a[i]][b[i]] = gr[b[i]][a[i]] = true;
    }


    printf("%d", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<double>V(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>V[i];
  }
  sort(V.begin(),V.end());
  for(int i=0;i<=N-2;i++){
  
    V[i+1]=(V[i]+V[i+1])/2;
  }
  cout<<V[N-1];
  return 0;
}

Measured memory_bytes: 3808
import java.util.Scanner; 
import java.util.Arrays; 
import java.util.Collections; 
public class Main {
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int[] list = {a,b,c};
    int x=0;
      Arrays.sort(list);
      for(int i: list){
      System.out.print(i);
      if(x<2){
          System.out.print(" "); 
          x++;
      }
     }
     System.out.println();
    sc.close();
  }
}


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

int main(){
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
    
}



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 big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<double> v(N);
  for(int i=0;i<N;++i) cin>>v[i];
  sort(v.begin(), v.end());
  double ans = v[0];
  for(int i=1;i<N;++i) {
    ans += v[i];
    ans /= 2;
  }
  cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    int city[n]={0};
    rep(i,m){
        int a,b;
        cin>>a>>b;
        city[a-1]++;
        city[b-1]++;
    }
    rep(i,n) cout<<city[i]<<endl;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] qq = new int[q];
        for(int i=0; i<q; i++) {
            qq[i] = sc.nextInt();
        }
        long[] nn = new long[n+1];
        int c = k -q;
        for(int i=0; i<nn.length; i++) {
            nn[i] = c;
        }
        for(int i=0; i<qq.length; i++) {
            nn[qq[i]]++;
        }
        for(int i=1; i<nn.length; i++) {
            if(nn[i] > 0) System.out.println("Yes");
            else System.out.println("No");
        }

    }
}

Measured memory_bytes: 60120
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, A, B, C;
ll arr[10];

ll rec(ll ind, ll a, ll b, ll c)  {
	if(ind == N) {
		if(!a || !b || !c) {
			return MOD;
		}
		return abs(A - a) + abs(B - b) + abs(C - c);
	}
	ll ans = MOD;
	ans = rec(ind + 1, a, b, c);
	ans = min(ans, rec(ind + 1, a + arr[ind], b, c) + (a ? 10 : 0));
	ans = min(ans, rec(ind + 1, a, b + arr[ind], c) + (b ? 10 : 0));
	ans = min(ans, rec(ind + 1, a, b, c + arr[ind]) + (c ? 10 : 0));
	return ans;
}

int main() {
	scanf("%lld %lld %lld %lld", &N, &A, &B, &C);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	cout << rec(0, 0, 0, 0);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256