akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> A(N,vector<int>(M));
    rep(i,N)rep(j,M){
        cin >> A[i][j];
        A[i][j]--;
    }
    vector<int> id(N);
    vector<vector<bool>> used(N,vector<bool>(M,false));
    int ans = INF;
    while(true){
        vector<int> s(M);
        bool ok = true;
        rep(i,N){
            while(used[i][id[i]]){
                id[i]++;
                if(id[i] >= M) ok = false;
            }
            if(!ok) break;
            s[A[i][id[i]]]++;

        }
        if(!ok) break;
        int now = 0;
        int dame = 0;
        rep(i,M){
            if(now < s[i]){
                now = s[i];
                dame = i;
            }
        }
        rep(i,N)rep(j,M){
            if(A[i][j] == dame) used[i][j] = true;
        }
        ans = min(ans,now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <limits>
#include <vector>
#include <stack>
#include <algorithm>
#include <array>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cassert>

typedef uint_fast64_t u64;
typedef int_fast64_t i64;
typedef uint_least32_t u32;
typedef int_fast32_t i32;
typedef uint_least16_t u16;
typedef int_fast16_t i16;
typedef uint_least8_t u8;
typedef int_fast8_t i8;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  u64 n, cnt=0;
  std::cin >> n;
  for (u64 i=1; i*i<=n;++i) {
    if (n%i==0 && i < n/i-1) cnt+=(n/i-1);
  }
  std::cout << cnt<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

	int n, r;
	cin >> n >> r;

	if (n >= 10) {

		cout << r << endl;
	}
	else {
		cout << r + (100 * (10 - n)) << endl;
	}



	return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    ll ans =0;
    if(N%11 >=1)ans++;
    if(N%11 >=7)ans++;
    cout<<(N/11)*2+ans;
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

int mod=1e9+7;
struct Mint {
    int val;
    Mint inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x){if((val=x%mod)<0)val+=mod;}
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
    int h,w,t; scanf("%d%d%d",&h,&w,&t);
    int g1=__gcd(h,t),g2=__gcd(w,t);
    h/=g1; w/=g2; int g=__gcd(h,w);
    Mint ans=Mint(2).pow(g)-1+Mint(2).pow(h)+Mint(2).pow(w)-2;
    ans=ans.pow(1LL*g1*g2); printf("%d\n",ans.val);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n,m;
    cin>>n>>m;
    priority_queue<ll> pq;
    rep(i,0,n){
        int in;cin>>in;
        pq.push(in);
    }
    rep(i,0,m){
        ll a=pq.top();
        pq.pop();
        pq.push(a/2);
    }
    ll ans=0;
    while(!pq.empty()){
        ll a=pq.top();
        pq.pop();
        ans+=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	while(a!=0&&b!=0){
		for(int i=0;i<b;i++){
			cout<<"#";
		}
		cout<<endl;
		for(int g=0;g<a-2;g++){
			cout<<"#";
			for(int h=0;h<b-2;h++){
				cout<<".";
			}
			cout<<"#"<<endl;
		}
		for(int j=0;j<b;j++){
			cout<<"#";
		}
		cout<<endl<<endl;
		cin>>a>>b;
	}
}



Measured memory_bytes: 3096
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = scanner.nextInt();
        }
        List<Integer> g = new ArrayList<Integer>();
        int h = 1;
        while (h <= n) {
            g.add(h);
            h = 3 * h + 1;
        }
        int cnt = shellSort(a, g);
        System.out.println(g.size());
        print(g);
        System.out.println(cnt);
        for (int i : a) {
            System.out.println(i);
        }
    }

    private static int insertionSort(int[] a, int g) {
        int cnt = 0;
        for (int i = g; i < a.length; i++) {
            int v = a[i];
            int j = i - g;
            while (j >= 0 && a[j] > v) {
                a[j + g] = a[j];
                j -= g;
                cnt++;
            }
            a[j + g] = v;
        }
        return cnt;
    }

    private static int shellSort(int[] a, List<Integer> g) {
        int cnt = 0;
        for (int i = g.size() - 1; i >= 0; i--) {
            cnt += insertionSort(a, g.get(i));
        }
        return cnt;
    }

    private static void print(List<Integer> g) {
        for (int i = g.size() - 1; i >= 0; i--) {
            System.out.print(g.get(i));
            if (i < g.size() - 1) {
                System.out.print(" ");
            } else {
                System.out.println("");
            }
        }
    }
}

Measured memory_bytes: 298660
#include<stdio.h>
#include<math.h>
int main(){
	double r=0, S=0, L=0;
	scanf("%lf", &r);
	S = r * r * M_PI;
	L = (r + r) * M_PI;
	printf("%lf %lf\n", S, L);
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<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++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}




Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int[] list = new int[N];
			for(int i = 0; i < N; i++){
				list[i] = sc.nextInt();
			}
			Arrays.sort(list);
			System.out.println(list[N-1] - list[0]);
		}catch(Exception e){
			e.printStackTrace();
		}
	} 
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4],b[4],c[4][4];
	for(int i=1;i<4;i++)
		for(int j=1;j<4;j++)
			cin >> c[i][j];
	a[1]=0;
	for(int i=1;i<4;i++)
		b[i]=c[1][i]-a[1];
	for(int i=1;i<4;i++)
		a[i]=c[i][1]-b[1];
	for(int i=1;i<4;i++)
		for(int j=1;j<4;j++)
			if(a[i]+b[j] != c[i][j])
			{
				puts("No");
				return 0;			
			}	
	puts("Yes");
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

#define N 2000001

int B[N], C[N];

void countingSort(int A[], int B[], int k, int n){
  int i, j;

  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }   
  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  } 
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i != n) printf(" ");
  }
  printf("\n");

}

int main(){
  int A[N];
  int i, j, n, k = 0;

  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }

  countingSort(A, B, k, n);

  return 0;
}



Measured memory_bytes: 17512
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Substring
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

char s[MAX_N + 4], t[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);
  int n = strlen(s), m = strlen(t);

  int mind = INF;
  for (int i = 0; i + m <= n; i++) {
    int d = 0;
    for (int j = 0; j < m; j++)
      if (s[i + j] != t[j]) d++;
    if (mind > d) mind = d;
  }

  printf("%d\n", mind);
  return 0;
}


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

int n, num[30][100];

int main(){
  cin >> n;
  rep(i, n){
    string s; cin >> s;
    rep(j, s.size()){
      num[s.at(j) - 'a'][i]++;
    }
  }
  string res = "";
  rep(i, 26){
    int m = 100000;
    rep(j, n) m = min(num[i][j], m);
    rep(j, m) res.push_back('a' + i);
  }
  cout << res << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	ll n; cin >> n;
	vector<ll>l(n);
	rep(i, n)cin >> l[i];
	sort(all(l));

	ll ans = 0;

	for (ll i = 0; i < n; i++) {
		for (ll j = i + 1; j < n; j++) {
			ll k = lower_bound(all(l), l[i] + l[j]) - l.begin();

			if (k - (j + 1) > 0)ans += k - (j + 1);

		}
	}


	cout << ans << endl;
}

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

int main() {
  int A, B;
  int C = 0;
  cin >> A >> B;
  for (int i = A; i <=  B; i++) {
    int b = i / 10000;
    int c = (i - (b * 10000)) / 1000;
    int d = (i - (b * 10000) - (c * 1000)) / 100;
    int e = (i - (b * 10000) - (c * 1000) - (d * 100)) / 10;
    int f = (i - (b * 10000) - (c * 1000) - (d * 100) - (e * 10)) / 1;
    if (i == b + (c * 10) + (d * 100) + (e * 1000) + (f * 10000) && f != 0) {
      C += 1;
    }
    else {
      continue;
    }
  }
  cout << C << endl;
}

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

using namespace std;

#define mod 1000000007
#define mp make_pair
typedef long long ll;
const int oo = 0x3f3f3f3f;

int main(void)
{
	int n;
	cin >> n;
	int a[n];
	// cin >> n;
	int none = 0, four = 0;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		none = (a[i] % 2 != 0) ? none + 1 : none;
	for(int i = 0; i < n; i++)
		four = (a[i] % 4 == 0) ? four + 1 : four;
	if(none + four == n)
	{
		if(none > four + 1)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
		return 0;
	}
	if(none > four)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;

using namespace std;
const int maxn=2e5+100;
int n,t;
int w[maxn],r[maxn];
char s[maxn];
ll ans;
int main(){
//	freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    int st=1,ed=n;
    while(st<ed){
		if(s[st]=='W'){
			while(ed!=st&&s[ed]=='W')--ed;
			if(ed!=st){
				++ans;++st;--ed;
//				cout<<st<<" "<<ed<<endl;
			}
//			else{
//				++ans;break;
//			}
		}
		else ++st;
		
		  		
	  }
  
    printf("%lld",ans);





    return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define ip pair<int, int>

#define N 3000007
#define inf 10000000
#define MOD 1000000007
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

using namespace std;

int f[100007][26];
signed main()
{
	fast;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans = 0;
	
	memset(f, 0, sizeof(f));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<26;j++)
			f[i][j] = f[i-1][j];
		f[i][s[i]-'a']++;
	}

	for(int i=0;i<n;i++)
	{
		int k = 1;
		for(int j=0;j<26;j++)
		{
			if(s[i]-'a' != j)
			{
			    //cout<<j<<" "<<f[n-1][j]<<" "<<f[i][j]<<endl;
				k *= (f[n-1][j] - f[i][j]+1);
              	k %= MOD;
              	k =(k+MOD)%MOD;
			}
		}
		ans += k;
		ans %= MOD;
	}
  	ans %= MOD;
  	ans = (ans+MOD)%MOD;
	cout<<ans;
  	return 0;
}


Measured memory_bytes: 20816
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc165_a.cpp"

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

  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3612
n = int(input())
h = [0.0] + list(map(float, input().split())) + [float("inf")]
ans = 0
ans_local = 0

for i in range(n+1):
    if h[i] >= h[i+1]:
        ans_local +=1
    else:
        ans = max(ans, ans_local)
        ans_local = 0

print(ans)    

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  auto nfind = [&](int i) {
    for (int j = i; j < n; j++) {
      if (h[j] > 0) return j;
    }
    return -1;
  };

  int ans = 0;
  while (true) {
    int l = -1, r = n - 1;
    for (int i = 0; i < n; i++) {
      if (h[i] > 0) {
        l = i;
        break;
      }
    }
    for (int i = l; i < n; i++) {
      if (h[i] == 0) {
        r = i - 1;
        break;
      }
    }
    if (l == -1) break;
    ans++;
    for (int i = l; i <= r; i++) h[i]--;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
N,D = map(int,input().split())
para=[[i for i in map(int,input().split())] for j in range(N)]
def dist(a,b):
    ans = 0
    for i in range(D):
        ans += (a[i] - b[i])**2
    k = 0 
    while k**2 <= ans :
        if k**2 == ans :
            return True
        else :
            k += 1
    return False
p = 0 
for i in range(N):
    for j in range(N-i-1):
        if dist(para[i],para[i+j+1]) :
            p += 1
print(p)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
using namespace std;
vector<int> a[100000];
int c[100000], col = 0, s[100000];
void dfs(int cur){
	c[cur] = col;
	s[col]++;
	for (auto e : a[cur]){
		if (c[e] == -1) dfs(e);
	}
}
int main(){
	int n, m, k, x, y;
	scanf("%d %d %d", &n, &m, &k);
	int f[n];
	fill(f, f + n, -1);
	for (int i = 0; i < m; i++){
		scanf("%d %d", &x, &y);
		a[x - 1].emplace_back(y - 1);
		a[y - 1].emplace_back(x - 1);
		f[x - 1]--;
		f[y - 1]--;
	}
	fill(c, c + n, -1);
	fill(s, s + n, 0);
	for (int i = 0; i < n; i++){
		if (c[i] == -1){
			dfs(i);
			col++;
		}
	}
	for (int i = 0; i < n; i++) f[i] += s[c[i]];
	for (int i = 0; i < k; i++){
		scanf("%d %d", &x, &y);
		x--, y--;
		if (c[x] == c[y]) f[x]--, f[y]--;
	}
	for (int i = 0; i < n; i++) printf("%d ", f[i]);
}

Measured memory_bytes: 7808
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
sumA = sum(A)
numlist = [0]*(10**5 + 1)
for Aele in A:
    numlist[Aele] += 1
for i in range(Q):
    (B,C) = map(int,input().split())
    Bs = numlist[B]
    sumA = sumA + C*Bs - B*Bs
    numlist[B] = 0
    numlist[C] += Bs
    print(sumA)

Measured memory_bytes: 21056
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N;
    int a[100];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> a[i];
    sort(a,a+N,greater<int>());
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < N; ++i){
        if( i%2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    int n;
    cin >>n;

    for (int i = 1; i < 10; i++){
        if(n%i == 0 && (n/i) < 10)flag=true;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, i, j, x, a;

    scanf("%d", &n);

    a = 0;
    for(i=1; i<=n; i=i+2){
        x = 0;
        for(j=1; j<=i; j++){
            if(i%j == 0){
                x++;
            }
        }
        if(x == 8){
            a++;
        }
    }
    printf("%d\n", a);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	for(int i=0;i<k;i++){
		if(a>b&&a>c){
			a=a*2;
		}
		else if(b>a&&b>c){
			b=b*2;
		}
		else{
			c=c*2;
		}
	}
	cout<<a+b+c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<string> siri(N);
  for( int i = 0; i < N; i++ ){
    cin >> siri.at(i);
  }
  
  for( int i = 0; i < N-1; i++ ){
    if( siri.at(i).back() != siri.at(i+1).at(0) ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  for( int i = 0; i < N; i++ ){
    for( int j = i+1; j < N; j++ ){
      if( siri.at(i) == siri.at(j) ){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
k = int(input())
a, b = map(int, input().split())
ans1 = a//k
ans2 = b//k

if ans1 == a/k:
    print("OK")
elif ans2 == b/k:
    print("OK")
elif ans1 < ans2:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 61744
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut s=0;
    let mut i=1;
    let n=read::<i32>();
    while i*i<=n{
        s=i*i;
        i+=1;
    }
    println!("{}",s)
}


Measured memory_bytes: 4352
import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

A, B, C, X, Y = na()
ans = 10**10
for ab in range((10**5+1)*2):
    cost = ab * C
    cost += max(0, X - ab//2) * A
    cost += max(0, Y - ab//2) * B
    ans = min(ans, cost)
print(ans)


Measured memory_bytes: 3064
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
h.reverse!
(n-1).times do |i|
  if h[i+1] - h[i] == 1
    h[i+1] -= 1
  elsif h[i+1] - h[i] > 1
    puts 'No'
    exit
  end
end
puts 'Yes'

Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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(){
  long double a, b;
  cin >> a >> b;

  cout << (ll)(a*b) << endl;

  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define MAX 100
class Cube {
public:
	string f[6];
	Cube() {
	}
	void roll_z() {
		roll(1, 2, 4, 3);
	}
	void roll_y() {
		roll(0, 2, 5, 3);
	}
	void roll_x() {
		roll(0, 1, 5, 4);
	}
	void roll(int i, int j, int k, int l) {
		string t = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}
};
Cube C[MAX];
int n;
bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])
			return false;
	return true;
}

bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))
				return true;
			c1.roll_z();
		}
		if (i % 2 == 0)
			c1.roll_y();
		else
			c1.roll_x();
	}
	return false;
}
main() {
	while( cin >> n && n ) {
		for(int i = 0;i<n;i++) for(int j = 0;j<6;j++) cin >> C[i].f[j];
		int cnt = 0;
		for(int i = 0;i<n;i++) {
			bool hasSame = false;
			for(int j=i+1; j<=n-1;j++) if (equal(C[i],C[j])) {hasSame =
				true;break;}
			if ( !hasSame ) cnt++;
		}
		cout << n - cnt << endl;
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int n, ac = 0, wa = 0, tl = 0, re = 0;
    string r;
    cin >> n;
    while (n--) {
		cin >> r;
		if (r == "AC") ac++;
		else if (r == "WA") wa++;
		else if (r == "TLE") tl++;
		else re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tl << "\n";
	cout << "RE x " << re << "\n";
    
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>

#define M 1000000

long long StrToID(std::string str){
	long long id = 0;
	for (int i = 0; i < str.length(); ++i){
		switch(str[i]){
			case 'A': id = 1 + id*10; break; 
			case 'C': id = 2 + id*10; break;
			case 'G': id = 3 + id*10; break;
			case 'T': id = 4 + id*10; break;
			default : break;
		}
	}
	return id;
}

bool includeNum(long long fig, std::vector<long long> S){
	for (int i = 0; i < S.size(); ++i){
		if(S[i]==fig) return true;
	}
	return false;
}

int main(int argc, char const *argv[]){
	std::vector< std::vector<long long> > Dictionary(M);
	int N,key;
	long long id;
	std::string cmd,str;
	std::cin >> N;

	for (int i = 0; i < N; ++i){
		std::cin >> cmd >> str;
		id = StrToID(str);
		key = id % M;
		if(cmd=="insert"){
			if(!includeNum(id,Dictionary[key])) Dictionary[key].push_back(id);
		}else if(cmd=="find"){
			if(includeNum(id,Dictionary[key])){
				std::cout << "yes" << std::endl;
			}else{
				std::cout << "no" << std::endl;
			}
		}else{
			//exception
		}
	}
	return 0;
}


Measured memory_bytes: 30232
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, k, x;
		cin >> n >> k;
		vector<ll>pos, neg, zero;
		for (int i = 0; i < n; i++) {
			cin >> x;
			if (x > 0) pos.pb(x);
			else if (x < 0) neg.pb(-x);
			else zero.pb(0);
		}
		ll p = sz(pos);
		n = sz(neg);
		sort(all(pos));
		sort(all(neg));
		ll z = sz(zero);
		if (p * n >= k) {
			ll l = 0, h = (1ll << 60);
			ll  ans = 0;
			while ( h > l + 1) {
				ll mid = l + (h - l) / 2, cnt = 0;
				ll id = n;
				for (int i = 0; i < p; i++) {
					while (id > 0 && pos[i]*neg[id - 1] >= mid)id--;
					cnt += (n - id);
				}
				if (cnt >= k) {
					ans = l;
					l = mid;
				}
				else {
					h = mid ;
				}
			}
			cout << -l << '\n';
			return 0;
		}
		if (p * n + (p + n)*z + z * (z - 1) / 2 >= k) {
			cout << "0\n";
			return 0;
		}
		ll l = 0, h = 1e18, ans;
		k -= p * n + (p + n) * z + z * (z - 1) / 2;
		while (l <= h) {
			ll mid = l + (h - l) / 2;
			ll cnt = 0, id = p - 1;
			for (int i = 0; i < p; i++) {
				while (id > i && (pos[i]*pos[id]) > mid) {
					id--;
				}
				if (id >= i)
					cnt += (id - i);
				else break;
			}
			id = n - 1;
			for (int i = 0; i < n; i++) {
				while (id > i && (neg[i]*neg[id]) > mid) {
					id--;
				}
				if (id >= i)
					cnt += (id - i);
				else break;
			}
			if (cnt < k) {
				l = mid + 1;
			}
			else {
				ans = mid;
				h = mid - 1;
			}
		}
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 5560
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    ll A[5] = {};

    FOR(i, 0, N){
        string name;
        cin >> name;
        char c = name[0];
        if(c=='M') A[0]++;
        if(c=='A') A[1]++;
        if(c=='R') A[2]++;
        if(c=='C') A[3]++;
        if(c=='H') A[4]++;
    }

    ll count = 0;
    count += A[0] * A[1] * A[2];
    count += A[0] * A[1] * A[3];
    count += A[0] * A[1] * A[4];
    count += A[0] * A[2] * A[3];
    count += A[0] * A[2] * A[4];

    count += A[0] * A[3] * A[4];
    count += A[1] * A[2] * A[3];
    count += A[1] * A[2] * A[4];
    count += A[1] * A[3] * A[4];
    count += A[2] * A[3] * A[4];

    p(count);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1];
int l[5];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;

//stack<int> s;
set<int> s;
map<int,int> p;
vector<P> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}


int main()
{
  scanf("%lld %lld %lld",&z,&y,&x);
  if(x>y) swap(x,y);
  if((x-y)%2==0) printf("%lld",(y-x)/2);
  else
  {
    printf("%lld",min(x-1,z-y)+(y-x+1)/2);
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple

ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if(n&1==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
int k[1000100];
int main(){
  int n; cin >> n;
  rep(i,n){
    int tmp; cin >> tmp;
    k[tmp]++; k[tmp+1]++;
    if(tmp > 0) k[tmp-1]++;
  }
  int ans = 0;
  rep(i,1000001)
    ans = max(ans,k[i]);
  cout << ans << endl;
}

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

int main(){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  if(b=='T')cout<<'A'<<endl;
  if(b=='G')cout<<'C'<<endl;
  if(b=='C')cout<<'G'<<endl;

  return 0;
}

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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n,x;
    cin>>n>>x;
    int l[n+1];
    for(int i = 1;i <= n;i++) cin>>l[i];
    int d[n+2];
    d[1] = 0;
    for(int i = 2;i <= n+1;i++) d[i] = d[i-1] + l[i-1];
    int ans = 0;
    for(int i = 1;i <= n+1;i++) {
        if(d[i] <= x) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

int tx[] = {0,1,1,1,0,-1,-1,-1};
int ty[] = {-1,-1,0,1,1,1,0,-1};


int gSum=0;

string shrink(const string& stage,int x1,int y1,int x2,int y2){
	string res="";
	int pos1 = y1*4+x1;
	int pos2 = y2*4+x2;

	for(int i=0;i<stage.size();i++){

		if( i % 4 == x1 && i / 4 == y1) continue;
		if( i % 4 == x2 && i / 4 == y2) continue;
		res.push_back(stage[i]);
	}

	res.push_back('-');
	res.push_back('-');
	return res;
}

void dfs(const string& stage,map<string,char>& visited,int count){
	for(int y=0;y<5;y++){
		for(int x=0;x<4;x++){
			char c = stage[y*4+x];
			if(c=='-') continue;
			for(int i=0;i<8;i++){
				int dx = x + tx[i];
				int dy = y + ty[i];
				if(dx < 0 || dx >= 4 || dy < 0 || dy >= 5) continue;
				if(stage[dy*4+dx] == '-') continue;
				if(c == stage[dy*4+dx]){
					string next = shrink(stage,x,y,dx,dy);
					if(visited.find(next) != visited.end()) continue;
					if(visited.find(next) != visited.end() && visited[next] >= count+1) continue;
					visited[next] = count+1;
					dfs(next,visited,count+1);
					gSum = max(count+1,gSum);
				}
			}
		}
	}
}

int main(){
	int n;
	string stage;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			gSum = 0;
			for(int y=0;y<5;y++){
				for(int x=0;x<4;x++){
					string str;
					cin >> str;
					stage += str;
				}
			}

			map<string,char> visited;

			dfs(stage,visited,0);
			stage="";
			printf("%d\n",20-gSum*2);
		}
	}

}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int a[3],ans=0,parity=0;
int main(void){
    cin>>a[0]>>a[1]>>a[2];
    int  x=max(a[0],max(a[1],a[2]));
    for(int i=0;i<3;i++) {
    ans+=(x-a[i])/2;
    parity+=(x-a[i])%2;
    a[i]+=((x-a[i])/2)*2;
    }
    if(parity) ans+=(3-parity);
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n),ans(n);
  ll ans0=0;
  rep(i,n){
    cin>>a[i];
    if(i%2==0) ans0+=a[i];
    else ans0-=a[i];
  }
  ans[0]=ans0/2;
  for(int i=1; i<n; i++){
    ans[i]=a[i-1]-ans[i-1];
  }
  rep(i,n) cout<<ans[i]*2<<endl;
}

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

using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

const double pi=acos(-1);
const int mod=1e9+7;
const int maxn=1e6+10;
string ss[maxn],ans[maxn];
int a[maxn];
int main()
{
    string n;
    while(cin>>n)
    {
        ll ans=0;
        mem(a,0);
        for(int i=n.length()-1; i>0; i--)
        {
            a[i]+=(n[i]-'0');
            if(a[i]<5||(a[i]==5&&n[i-1]<'5'))
                ans+=a[i];
            else if(a[i]>5||(a[i]==5&&n[i-1]>='5'))
            {
                ans+=10-a[i];
                n[i-1]++;
            }
            //cout<<ans<<endl;
        }
        a[0]+=(n[0]-'0');
        if(a[0]<=5)
            ans+=a[0];
        else
            ans+=10-a[0]+1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 20868
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let l = sc.parse::<i64>();
    let t = sc.parse::<i64>();

    let mut x: Vec<i64> = vec![0; n];
    let mut w: Vec<usize> = vec![0; n];

    for i in 0..n {
        x[i] = sc.parse::<i64>();
        w[i] = sc.parse::<usize>();
    }

    let cross_count = (0..n)
        .map(|i| {
            let w0 = w[0];
            let wi = w[i];
            if w0 == wi {
                return 0;
            }

            let interval;
            if w0 == 1 {
                interval = x[i] - x[0];
            } else {
                interval = x[0] + l - x[i];
            }

            if interval > t * 2 {
                return 0;
            }

            let time = t * 2 - interval;
            let count;
            if time % l == 0 && w[0] == 1 {
                count = time / l;
            } else {
                count = time / l + 1;
            }
            return count;
        })
        .collect::<Vec<i64>>();

    let count_sum: i64 = cross_count.iter().sum::<i64>() % (n as i64);
    let position;
    let num;
    if w[0] == 1 {
        position = (x[0] + t) % l;
        num = count_sum;

    } else {
        position = (x[0] - (t % l) + l) % l;
        num = (n as i64) - count_sum;
    }

    let mut positions: Vec<i64> = (0..n)
        .map(|i| {
            let p;
            if w[i] == 1 {
                p = (x[i] + t) % l;
            } else {
                p = (x[i] - (t % l) + l) % l;
            }
            return p;
        })
        .collect::<Vec<i64>>();
    positions.sort();

    let mut a = 0;
    for i in 0..n {
        if positions[i] == position {
            a = i;
            break;
        }
    }

    let mut ans = (0..n)
        .map(|idx| {
                 let i = (idx + n - ((num as usize) % n)) % n;
                 let p = (a + i as usize) % n;
                 return positions[p];
             })
        .collect::<Vec<i64>>();

    for a in &ans {
        println!("{}", a);
    }

}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 9468
#Kは黒で塗られた医師の数を表す
#Xは座標Xが黒で塗られていることを表す
K,X = map(int, input().split())

for i in range(X-K+1,X+K):
    #結果を改行せずに表示
    if i < X+K-1:
        print(i,end=' ')
    else:
        print(i)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v(3);
    REP(i, 3) cin >> v[i];
    sort(ALL(v));
    cout << v[0] + v[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define rc(s) return cout<<s,0
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
int n;
int p , streak , r;
int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    int a;
    for(int i = 1 ; i <= n ; i++){
        cin >> a;
        if(a <= p){
            streak ++;
            p = a;
        }else{
            r = max(r,streak);
            streak = 0;
            p = a;
        }
    }
    r = max(r,streak);
    cout << r;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;
 class Main{
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    Point p1 = new Point(0.0, 0.0);
    Point p2 = new Point(100.0, 0.0);
    System.out.printf("%.8s %.8s\n",p1.x,p1.y);
    koch(n, p1, p2);
    System.out.printf("%.8s %.8s\n",p2.x,p2.y);
  }
  static void koch(int d, Point p1, Point p2){
    if(d==0)return;
    double rad = 60*Math.PI/180.0;//Math.toRadians(60);
    Point s = new Point((2.0*p1.x+1.0*p2.x)/3.0, (2.0*p1.y+1.0*p2.y)/3.0);
    Point t = new Point((1.0*p1.x+2.0*p2.x)/3.0,(1.0*p1.y+2.0*p2.y)/3.0);
    Point u = new Point((t.x-s.x)*Math.cos(rad)-(t.y-s.y)*Math.sin(rad)+s.x, (t.x-s.x)*Math.sin(rad)+(t.y-s.y)*Math.cos(rad)+s.y);
    koch(d-1, p1, s);
    System.out.printf("%.8s %.8s\n",s.x,s.y);
    koch(d-1, s, u);
    System.out.printf("%.8s %.8s\n",u.x,u.y);
    koch(d-1, u, t);
    System.out.printf("%.8s %.8s\n",t.x,t.y);
    koch(d-1, t, p2);
  }
}

class Point{
  double x = 0.0;
  double y = 0.0;
  Point(double x, double y){
    this.x = x;
    this.y = y;
  }
  Point(){
    this.x = 0.0;
    this.y = 0.0;
  }
}


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

int main()
{
  vector<int> t(5);
  while (cin >> t[0] >> t[1] >> t[2] >> t[3] >> t[4]) {
    if (t[0] == 0)
      break;

    for (int i = 0; i < 5; ++i) {
      int w = 0, l = 0;
      for (int j = 0; j < 5; ++j) {
	if (i == j || t[i] == t[j])
	  continue;
	if (t[i] == 1) {
	  if (t[j] == 2)
	    ++w;
	  else
	    ++l;
	} else if (t[i] == 2) {
	  if (t[j] == 1)
	    ++l;
	  else
	    ++w;
	} else {
	  if (t[j] == 1)
	    ++w;
	  else
	    ++l;
	}
      }
      if (w > 0 && l == 0)
	cout << "1" << endl;
      else if (w == 0 && l > 0)
	cout << "2" << endl;
      else
	cout << "3" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll mod = 1000000007;
ll n,k;
ll f1[maxn],f2[maxn],inv[maxn];

void init(){
    inv[1] = 1;
    for(int i = 2;i<maxn;i++) inv[i] = mod-mod/i*inv[mod%i]%mod;
    f1[0] = f2[0] = 1;
    for(int i = 1;i<maxn;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = f2[i-1]*inv[i]%mod;
    }
}

ll C(ll n,ll k){
    return f1[n]*f2[k]%mod*f2[n-k]%mod;
}

int main(){
    init();
    cin>>n>>k;
    ll res = 0;
    for(ll i = 0;i<=min(n-1,k);i++){
        res = (res + C(n,i)*C(n-1,n-i-1)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,x,ans=0;cin>>n>>x;
  vll a(n);
  rep(i,0,n){cin>>a[i];}
  if(a[0]>x){ans+=a[0]-x;a[0]=x;}
  rep(i,0,n-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      a[i+1]-=(a[i]+a[i+1]-x);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int n,h,w;
	std::cin>>n>>h>>w;
	std::cout<<1+(n-h)+(n-w)+(n-h)*(n-w);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,l;
string s[1000];
int32_t main(){
CODE_START;
cin>>n>>l;
for(ll i=0;i<n;i++)
    cin>>s[i];
sort(s,s+n);
for(ll i=0;i<n;i++)
    cout<<s[i];
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n;
  cin>>n;
  
  
  
  vector<int> vec(n);
for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
}
  vector<int> dif(n-1);
  
  int s1,s2;
 for(int i=0; i<vec.size()-1; i++){
   s1=0;
   s2=0;
   
   for(int j=0;j<i+1; j++){
     s1+=vec.at(j);}
   
   for(int j=i+1;j<n;j++){
     s2+=vec.at(j);}
   
   if(s1>s2){
     dif.at(i)=s1-s2;}
   else{dif.at(i)=s2-s1;}
   
 }
   
  sort(dif.begin(),dif.end());
  
  cout<<dif.at(0)<<endl;
}
  
    
   

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
typedef long long LL;
int main()
{
    char str[105];
    scanf("%s",str);
    int len = strlen(str);
    int ans = 0;
    for(int i = 0; i < len; i++) {
        if( str[i] == '+') ans++;
        else ans--;
    }
    cout<<ans<<endl;
}


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

#define fi first
#define se second

using namespace std;

typedef pair<int, int> ii;

int n, w, v[105], we[105];
long long dp[100005][105];

long long recur(int cap, int i)
{
	if(i > n)
		return 0;
	if(cap < we[i])
		return recur(cap, i + 1);
	else
		return max(v[i] + recur(cap - we[i], i + 1), recur(cap, i + 1));
}
int main()
{
	cin >> n >> w;
	for(int i = 1; i <= n; ++i)
		cin >> we[i] >> v[i];
	for(int i = 0; i <= w; ++i)
		dp[i][0] = 0;
	for(int i = 0; i <= n; ++i)
		dp[0][i] = 0;
	for(int i = 1; i <= w; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			if(we[j] > i)
				dp[i][j] = dp[i][j - 1];
			else
				dp[i][j] = max(v[j] + dp[i - we[j]][j - 1], dp[i][j - 1]);
		}
	}
	cout << dp[w][n];
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	S[K-1] += 'a' - 'A';
	cout << S << endl;
}


Measured memory_bytes: 256