akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int n;
int main(){
  cin >> n;
  vector<int> a(n+1);
  vector<int> ans;
  for(int i=0;i<n;i++) cin >> a[i+1];
  for(int i=n;i>=1;i--){
    for(int j=i+i;j<=n;j+=i){
      a[i] += a[j];
    }
    a[i] %= 2;
    if (a[i]) ans.pb(i);
  }
  cout << ans.size() << endl;
  for(int i=0;i<ans.size();i++){
    cout << ans[i];
    if (i+1<ans.size()) cout << " ";
  }
  cout << endl;
  return 0;
}
  

Measured memory_bytes: 2424
import sys
import collections

sys.setrecursionlimit(10**6)

def f(X:int, N:int):
    if N == 0:
        return 1
    if N == 1:
        if X == 1:
            return 0
        elif X in [2, 3, 4]:
            return X-1
        else:
            return 3
    l = sum(L[N-1])
    if X == 1:
        return 0
    elif 1 < X <= l+1:
        return f(X-1, N-1)
    elif X == l+2:
        return L[N-1][1] + 1
    elif l+2 < X <= sum(L[N]):
        return L[N-1][1] + 1 + f(X-2-l, N-1)
    else:
        return 2 * L[N-1][1] + 1

def main():
    global L
    N, X = map(int, input().split())
    L = [(0, 1)]
    for i in range(N):
        b, p = L[i]
        b = 2*b + 2
        p = 2*p + 1
        L.append((b, p))
    ans = f(X, N)
    print(ans)

if __name__ == "__main__":
    main()


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define REPR(i,n,m) for(int i=n;i>m;i--)
#define ALL(v) v.begin(),v.end()
#define elif else if
using ll=long long;

int gcd(int x,int y){
    int a;
    while(y!=0){
        a=x%y;
        x=y;
        y=a;
    }
    return x;
}

int lcm(int a,int b){
    return a*b/gcd(a,b);
}

/*----------template----------*/

int main(){
    int a,b;
    cin>>a>>b;

    cout<<6-(a+b)<<endl;
}


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

int main()
{
  int n, p;
  cin >> n >> p;
  char ch;
  char arr[n];
  for (int i = 0; i < n; i++)
  {
    cin >> ch;
    if (i == p-1)arr[i] = tolower(ch);
    else arr[i] = ch;
  }
  for (int i = 0; i < n; i++)
  {
    cout << arr[i];
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll rec(int n,ll x){
    if(n==0) return 1;
    ll len=(1LL<<(n+1))-3;
    ll num=(1LL<<n)-1;
    if(x==1) return 0;
    else if(x<=len+1) return rec(n-1,x-1);
    else if(x==len+2) return num+1;
    else if(x<=(len+1)*2) return num+1+rec(n-1,x-len-2); 
    else return num*2+1;
}

int main(){
    int n;
    ll x;
    cin>>n>>x;
    cout<<rec(n,x)<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

//#include <windows.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int tmp = to_string(i).length();
		if (tmp % 2 == 1) ans++;


	}

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, X, Y, Z;
const int MOD = 1e9 + 7;
ll dp[44][2][1<<18];

void add(ll &a, ll b) { a = (a + b) % MOD; }

int main() {
	scanf("%d%d%d%d", &N, &X, &Y, &Z);
	dp[0][0][0] = 1;
	for(int i=0;i<N;i++) rep(k, 2) {
		rep(u, 1<<18) if(dp[i][k][u]) {
			for(int R=1;R<=10;R++) {
				int nu = ((u|1<<18) >> R);
				int nk = k;
				if((1<<(18+R-Z) & (u|1<<18)) && (1<<(18+R-Z-Y) & (u|1<<18)) && (1<<(18+R-Z-Y-X) & (u|1<<18))) nk = 1;
				add(dp[i+1][nk][nu], dp[i][k][u]);
			}
		}
	}
	ll ans = 0;
	rep(u, 1<<18) add(ans, dp[N][1][u]);
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
  int i, j, x, y;

  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;

    for(i = 0; i < x; i++){
      for(j = 0; j < y; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int gcd(long long int x, long long int y);
int is_prime(long long int n){
  if(n == 1 || n == 2){
    return 1;
  }
  
  if(n%2 == 0){
    return 0;
  }
  
  for(long long int i = 3; i*i <= n; i+=2){
    if(n%i == 0){
      return 0;
    }
  }
  
  return 1;
}


int main(){
  long long int A, B;
  scanf("%lld%lld", &A, &B);
  
  long long int C = gcd(A, B);
  
  std::vector<long long int> factor;
  for(long long int i = 1; i*i <= C; i++){
    if(C%i == 0){
      factor.push_back(i);
      if(i*i != C){
        factor.push_back(C/i);
      }
    }
  }
  
  long long int ans = 0;
  for(long long int i = 0; i < factor.size(); i++){
    ans += is_prime(factor[i]);
  }
  
  std::cout << ans << std::endl;
  return 0;
}

long long int gcd(long long int x, long long int y){
  if(y == 0){
    return x;
  }
  else{
    return gcd(y, x%y);
  }
   
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> v(10,vector<int>(10,0));
    REP(i,n){
        int x=i+1;
        string s=to_string(x);
        v[s.front()-'0'][s.back()-'0']++;
    }
    ll ans=0;
    for(int i=1;i!=10;i++){
        for(int j=1;j!=10;j++){
            ans+=v[i][j]*v[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    string s;
    cin >> s;
    ll len = s.size();
    ll alph[26];
    fill(alph, alph+26, 0);
    for (int i = 0; i < len; i++) {
        alph[s[i] - 'a']++;
    }

    ll ret = len * (len - 1) / 2 + 1;
    for (int i = 0; i < 26; i++) {
        ret -= alph[i] * (alph[i] - 1) / 2;
    }

    cout << ret << "\n";
    return 0;
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll n,a[200001],h,g,minf=2*1e5*INF;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		cin>>a[i];
		g+=a[i];
	}
	rep(i,n-1){
		h+=a[i];
		g-=a[i];
		minf=min(minf,abs(h-g));
	}
	cout<<minf;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	map<string,int> mp;
	int n,m;
	cin >> n;
	rep(i,n){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	rep(i,m){
		string s;
		cin >> s;
		mp[s]--;
	}
	int nax = -INF;
	for(auto it:mp){
		if(nax<it.second)
			nax = it.second;	
	}	
	cout << max(nax,0) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int W, H, x, y, r; cin >> W >> H >> x >> y >> r;
	if (
		x - r >= 0 &&
		x + r <= W &&
		y - r >= 0 &&
		y + r <= H
	) {
		puts("Yes");
	} else {
		puts("No");
	}
}

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



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

class Cube{
public:
    int 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){
        int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

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

Cube C[100]; int n;

bool check(){
    for(int i=0; i<n-1; i++)
        for(int j=i+1; j<n; j++) if(equal(C[i], C[j])) return false;
    return true;
}

int main(){
    cin >> n;
    for(int j=0; j<n; j++)
        for(int i=0; i<6; i++) cin >> C[j].f[i];
    
    if(check()) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[100005], sz[100005];
long long ans[100005];
priority_queue <pair <int, int> > pq;

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		sz[i] = 1;
		cin >> a[i];
		pq.push(mp(a[i], i));
	}
	while((int)pq.size() > 1)
	{
		int temp = pq.top().fi, id = pq.top().se;
		pq.pop();
		int temp2 = pq.top().fi, id2 = pq.top().se;
		pq.pop();
		ans[id] += 1ll * sz[id] * (temp - temp2);
		pq.push(mp(temp2, min(id, id2)));
		sz[min(id, id2)] += sz[max(id, id2)]; 
	}
	ans[1] += 1ll * n * pq.top().fi;
	for(int i = 1; i <= n; i++)
	{
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 5572
#include<stdio.h>
#include<string.h>

int main(){
  int i,j=0,k=0;
  char S[200];
  
  scanf("%s",S);
  
  for(i=0;i<strlen(S);i++){
    if(S[i] == 'C' && k==0){
      j=1;
    }
    if(S[i]=='F' && j == 1){
      k=1;
    }
    if(j==1 && k==1){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
double dist(double xp, double yp, double xq, double yq) { return sqrt((xp - xq) * (xp - xq) + (yp - yq) * (yp - yq)); }
signed main() {
	double x1, x2, y1, y2, r1, r2;
	cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
	double d = dist(x1, y1, x2, y2);
	if (r1 > r2)swap(r1, r2);
	if (r1 + d < r2)cout << 0 << endl;
	else if (r1 + d == r2)cout << 1 << endl;
	else if (r1 + r2 > d)cout << 2 << endl;
	else if (r1 + r2 == d)cout << 3 << endl;
	else if (r1 + r2 < d)cout << 4 << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  string s, t;
  cin >> s >> t;
  int ans=0;
  for(int i=0;i<=s.length()-t.length();i++){
    int count=0;
  	for(int j=0;j<t.length();j++){
    	if(s[i+j]==t[j]){
         	count++; 
        }
    }
    if(count>ans){
    	ans=count;
    }
  }
  cout << t.length()-ans << endl;
}



Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

struct robot
{
	int x,l,L,R;
};

bool cmp(robot a,robot b)
{
	return a.x<b.x;
}

int main()
{
	int n;
	cin >> n;
	vector<robot> vec(n);
	rep(i,n)
	{
		int foo,fooo;
		cin >> foo >> fooo;
		vec[i].x=foo;
		vec[i].l=fooo;
		vec[i].L=foo-fooo;
		vec[i].R=foo+fooo;
	}
	int cnt = 1;
	sort(ALL(vec),cmp);
	robot now = vec[0];
	for(int i=1;i<n;i++)
	{

		if(vec[i].R<=now.R)
		{
			
			now = vec[i];
			continue;
		}
		if(now.R<=vec[i].L)
		{
			now=vec[i];
			cnt++;
			continue;
		}

	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1792
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  [s, t] <- BS.words <$> BS.getLine
  BS.putStrLn $ BS.append t s

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

int main(){
    int v[6];
    int menor_tempo, soma=0;
    int menor = 11, interador, m, resto;
    for(int i=0; i<5; i++){
        cin >> v[i];
        menor_tempo = v[i]%10;
        if(menor_tempo<menor && menor_tempo!=0){
            menor = menor_tempo;
            interador = i;
            m = v[i];
        }
    }
    for(int i=0; i<=4; i++){
        if(i!=interador && v[i]%10!=0){
            resto = v[i]%10;
            resto = 10 - resto;
            v[i] = v[i] + resto;
        }
        soma = soma+v[i];
    } 
    cout << soma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL k, a, b;
  cin>>k>>a>>b;
  LL ans=0;
  if(a>=b-2){
    cout<<k+1<<endl;
  }
  else{
    k-=a-1;
    ans += (k/2)*(b-a);
    ans += a;
    if(k%2) ans+=1;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

l = []
cnt = 0
for i in range(1,n+1):
    cnt = sum(a1[:i])+sum(a2[i-1:])
    l.append(cnt)
    cnt = 0
print(max(l))


Measured memory_bytes: 3060
# frozen_string_literal: true

a = []
a.push gets.split.map(&:to_i)
a.push gets.split.map(&:to_i)
a.push gets.split.map(&:to_i)

n = gets.to_i
b = n.times.map { gets.to_i }

c = Array.new(3) { Array.new(3) { false } }

b.each do |e|
  (0..2).each do |i|
    j = a[i].index(e)
    c[i][j] = true if j
  end
end

(0..2).each do |i|
  if c[i][0] && c[i][1] && c[i][2]
    puts 'Yes'
    exit
  end
end

(0..2).each do |i|
  if c[0][i] && c[1][i] && c[2][i]
    puts 'Yes'
    exit
  end
end
if (c[0][0] && c[1][1] && c[2][2]) || (c[0][2] && c[1][1] && c[2][0])
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    ll n,k;cin >> n >>k;
    UnionFind uf(n);
    vl lang(k,-1);
    rep(i,n){
        ll x;cin >> x;
        rep(j,x){
            ll l;cin >> l;l--;
            if(lang[l]==-1)lang[l]=i;
            else{
                if(!uf.same(lang[l],i))uf.merge(lang[l],i);
            }
        }
    }
   if(uf.size(0)!=n)cout << "NO" <<endl;
   else cout << "YES" <<endl;
}

Measured memory_bytes: 1408
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        edge[i].append((x-1,y))

ans = 0
for i in range(2**N):
    # 1: 正直者
    state = [0] * N
    for j in range(N):
        state[j] = (i >> j) & 1
    
    # 真偽を確かめる
    flag = True
    for j in range(N):
        if state[j] == 0:
            continue
        for x,y in edge[j]:
            if state[x] == y:
                continue
            flag = False
            break
        if not flag:
            break
    if not flag:
        continue

    ans = max(ans, state.count(1))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int c[110000];
int d[110000];
long long segtree[262144];
long long query(int a){
	long long ret=0;
	a+=131072;
	while(a){
		ret=max(ret,segtree[a]);
		a/=2;
	}
	return ret;
}
void update(int a,int b,int c,int d,int e,long long f){
	if(d<a||b<c)return;
	if(c<=a&&b<=d){
		segtree[e]=max(segtree[e],f);
		return;
	}
	update(a,(a+b)/2,c,d,e*2,f);
	update((a+b)/2+1,b,c,d,e*2+1,f);
}
long long dp[110000];
long long x[110000];
long long z[110000];
 
long long ans[2][110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",c+i,d+i);
		c[i]*=2;
		if(d[i]==1&&c[i]>b){
			printf("-1\n");return 0;
		}
	}
	for(int t=0;t<2;t++){
		for(int i=0;i<a;i++){
			x[i+1]=x[i]+c[i];
		}
		for(int i=0;i<=a;i++){
			z[i]=x[i]%b;
		}
		std::sort(z,z+a+1);
		for(int i=0;i<262144;i++)segtree[i]=0;
		for(int i=0;i<110000;i++)ans[t][i]=inf;
		ans[t][0]=0;
		for(int i=0;i<a;i++){
			int at=lower_bound(z,z+a+1,x[i+1]%b)-z;
			int la=query(at);
			if(la==0){
				ans[t][i+1]=x[i+1];
			}else{
				ans[t][i+1]=ans[t][la]+(long long)((x[i+1]-x[la]+b-1)/b)*b;
			}
 
			if(d[i]==1){
				long long L=(x[i]+1)%b;
				long long R=x[i+1]%b;
				int l=lower_bound(z,z+a+1,L)-z;
				int r=lower_bound(z,z+a+1,R)-z;
				if(L>R){
					update(0,131071,0,r,1,i+1);
					update(0,131071,l,131071,1,i+1);
				}else{
					update(0,131071,l,r,1,i+1);
				}
			}
		//	printf("%d: %lld\n",i+1,ans[t][i+1]);
		}
 
		reverse(c,c+a);
		reverse(d,d+a);
	}
	long long ret=inf;
	for(int i=0;i<=a;i++){
		ret=min(ret,ans[0][i]+ans[1][a-i]);
	}
 
	printf("%lld\n",ret);
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

//ÂIÂCÂÂÂ[ÂÃÂÃÂÃÂÂÂÃ°ÂpÂÂ¢ÂÃÂÃ°ÂÂ­
//ÂÃ¯ÂÂÂÂ´ÂÂÂÃÂÂ©ÂgÂÃÂÃÂÃ ÂÃ°ÂÂ¯ÂÃ©ÂH

int euler[1000002];
ll ans[1000002];

void euler_phi2(){
  for(int i=0;i<1000001;i++) euler[i] = i;
  for(int i=2;i<1000001;i++){
    if(euler[i] == i){
      for(int j=i;j<1000001;j+=i) euler[j] = euler[j] / i * (i - 1);
    }
  }
}

int main(void){
  euler_phi2();
  for(int i=1;i<=1000000;i++){
    ans[i] = ans[i-1] + (ll)euler[i];
  }

  int T;
  cin>>T;

  while(T--){
    int n;
    cin>>n;
    cout<<ans[n]+1<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  string s;
  cin>>s;
  cout<<getString(s[0])+getString(s[1])+getString(s[2])<<endl;
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 3576
N = int(input())
count = 0
ans = 0
for i in range(1, N+1):
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
    if count == 8 and i % 2 == 1:
        ans += 1
    count = 0
    
print(ans)

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

using namespace std;

int main()
{
	double w, h, c, d;
	cin >> w >> h >> c >> d;
	double ans;
	ans = (w * h) / 2.0;
	printf("%.6f ", ans);
	if(c * 2 == w && d * 2 == h)
		puts("1");
	else
		puts("0");
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl x(n);
  rep(i, n) {
    cin >> x[i];
  }

  sort(all(x));
  ll ans = 1LL<<60;;
  rep(i, 101) {
    ll cnt = 0;
    rep(j, n) {
      cnt += abs(i-x[j])*abs(i-x[j]);
    }
    cmin(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
const  ll modo=1e9+7;

ll dp[100005][13]={0};




int main()
{
    faf;
    string s;
    cin>>s;
    int len=s.length();
    int i;
   // for(i=0;i<13;i++)dp[len+1][i]=1;
    int j;ll pp;int k;
    ll mm=1;int aa;ll tt;
    for(i=len;i>=1;i--)
    {
        if(s[i-1]=='?')
        {
            for(j=0;j<10;j++) {
                pp=(j*mm)%13;
                if(i!=len){
                for(k=0;k<13;k++)
                {
                    tt=(pp+k)%13;
                    dp[i][tt]+=dp[i+1][k];
                    dp[i][tt]%=modo;
                }}
                else{
                    dp[i][pp]++;
                }
            }
        }
        else{
            aa=s[i-1]-48;
            pp=(aa*mm)%13;
            //cout<<pp<<endl;
            if(i!=len)
            {
            for(j=0;j<13;j++)
            {
                tt=(pp+j)%13;
                dp[i][tt]+=dp[i+1][j];
                dp[i][tt]%=modo;
            }
            }
            else{
                //cout<<pp<<endl;
                dp[i][pp]++;
            }
        }
        mm=(mm*10)%13;
    }
   /* for(i=1;i<=len;i++)
    {
        for(j=0;j<13;j++)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[1][5]<<endl;
}

Measured memory_bytes: 10704
def insertionSort(A, n, g, cnt):
    for i in xrange(1,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt

def shellSort(A, n):
    cnt = 0
    G = [1]
    idx = 0
    for i in range(1,len(A)):
        if 3*G[idx]+1 < len(A):
            G.append(3*G[idx]+1)
            idx += 1
    G = list(reversed(G[:]))
    #print G
    m = len(G)
    print m
    print ' '.join(map(str,G))
    newA = A[:]
    for i in range(0,m):
        newA, cnt = insertionSort(newA[:],len(A),G[i],cnt)
    return newA, cnt

def main():
    n = int(input())
    A = [int(input()) for i in xrange(n)]
    newA, cnt = shellSort(A, n)
    print cnt
    for i in range(len(newA)):
        print newA[i]
    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 77756
from collections import Counter
from operator import itemgetter

N = int(input())
A = Counter(map(int,input().split()))
A1 = list(A.items())
A1 = sorted(A1,key=itemgetter(1),reverse = True)
A1 = sorted(A1,key=itemgetter(0),reverse = True)
#print(A1)

#正方形の場合
B =[]
for i in range(len(A1)):
    if A1[i][1] > 3:
        B.append(A1[i][0])
        if len(B) == 1:
            break
C =[]
for i in range(len(A1)):
    if A1[i][1] > 1:
        C.append(A1[i][0])
        if len(C) == 2:
            break

if len(C) == 0:
    print(0)
elif len(B) !=0:
    print(max(B[0]*B[0],C[0]*C[1]))
else:
    print(C[0]*C[1])


Measured memory_bytes: 24104
src = input()

request_n = int(input())

for _ in range(request_n):
    request_lst = input().split()
    
    command = request_lst[0]
    start = int(request_lst[1])
    end = int(request_lst[2])
    
    if command == "print":
        print(src[start:end + 1])
    
    elif command == "reverse":
        rev = src[start:end + 1]
        src = src[:start] + rev[::-1] + src[end + 1:]
    
    elif command == "replace":
        target = request_lst[3]
        src = src[:start] + target + src[end + 1:]


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,a[(int)1e5+100];

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

    int i,j;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    if(n%2==1)
        cout<<0<<endl;
    else
        cout<<a[n/2]-a[n/2-1]<<endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define MOD 924844033
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 2e3 + 10;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
int N, K, tot, arr[maxn << 1], f[maxn * 2][maxn][2], fac[maxn];
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    N = read(), K = read();
    fac[0] = 1;
    for (ri i = 1; i <= N; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
    }
    for (ri i = 1; i <= K; ++i) {
        for (ri j = i; j <= N; j += K) {
            arr[++tot] = j;
        }
        for (ri j = i; j <= N; j += K) {
            arr[++tot] = j;
        }
    }
    f[1][0][0] = 1;
    for (ri i = 2; i <= N * 2; ++i) {
        for (ri j = 0; j <= i / 2; ++j) {
            f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % MOD;
            if (arr[i] - arr[i - 1] == K && j > 0) {
                f[i][j][1] = f[i - 1][j - 1][0];
            }
        }
    }
    int ans = 0;
    for (ri i = 0; i <= N; ++i) {
        int sig = (i & 1) ? -1 : 1;
        int num = (f[2 * N][i][0] + f[2 * N][i][1]) % MOD;
        int tmp = num * fac[N - i] % MOD;
        if (sig > 0) {
            ans = (ans + tmp) % MOD;
        } else {
            ans = (ans - tmp + MOD) % MOD;
        }
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 124160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if (str.length() == 2) {
            System.out.println(str);
        } else {
            System.out.print(str.charAt(2));
            System.out.print(str.charAt(1));
            System.out.print(str.charAt(0));
            System.out.println();
        }

    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
AC
辺に関するdp（辺より先の部分木に関するdp）
dp[p][i] = pから出るi番目の辺より奥の部分木の塗り方の総数。
	v[p][i]が白のとき、それ以降はすべて白なので1通り。
	v[p][i]が黒のとき、v[p][i]から出る辺で行き先がp以外ものについての塗り方の制約は無い。
実はこのままだとTLEする。
隣接点が極端に多い点があったら、掛け算の回数がn^2に近くなってしまう。mが素数ならmod mでの逆元を用いて計算量を短縮できるが、ここではmは一般の数なのでそれも出来ない。
解決方法：配列のうち 1 要素を除いた積を取る
	順方向と逆方向の累積積を持っておけば[$ O(1)]で求まる
	ru:順方向
	ru2:逆方向

変数は全部long long使うべき
*/

ll n,m,visited[100010]={};
vector<ll> v[100010],v_rev[100010],dp[100010],ru[100010],ru2[100010];

ll f(ll p,ll rev,bool begin){
	ll next=1;
	int k = v[p].size();
	if(k==0 || visited[p]<k){//pに隣接する未探索の辺があったら
		rep(i,k){
			if(i==rev)continue;
			if(dp[p][i]==-1){
				dp[p][i] = (f(v[p][i], v_rev[p][i], false) + 1) % m;
				visited[p]++;
			}
			next=(next*dp[p][i]) % m;
		}
	}else{//pに隣接する全ての辺についてdpが確定したら
		if(visited[p]==k){//累積和未計算
			ru[p][0]=dp[p][0];
			reg(i,1,k-1)ru[p][i]=(dp[p][i]*ru[p][i-1]) % m;
			ru2[p][k-1]=dp[p][k-1];
			irep(i,k-1)ru2[p][i]=(dp[p][i]*ru2[p][i+1]) % m;
			visited[p]+=10;
		}
		if(begin){//最初だけは全方向の積が答え
			next=ru[p][k-1];
		}else{
			if(rev>0)next=ru[p][rev-1];
			if(rev<k-1)next=(next*ru2[p][rev+1]) % m;
		}
	}
	return next;
}

int main(void){
	cin>>n>>m;
	rep(i,n-1){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
		v_rev[x].push_back(v[y].size()-1);
		v_rev[y].push_back(v[x].size()-1);
		dp[x].push_back(-1);
		dp[y].push_back(-1);
		ru[x].push_back(-1);
		ru[y].push_back(-1);
		ru2[x].push_back(-1);
		ru2[y].push_back(-1);
	}
	//
	reg(i,1,n){
		cout<<f(i,1e9,true)<<endl;
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

const int N = 2e5 + 1;
const ll MOD = 1e9 + 7;
ll f[N];


ll bp(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * 1ll * a) % MOD;
        a = (a * 1ll * a) % MOD;
        n >>= 1;
    }
    return res;
}

ll inv(ll x) {
    return bp(x, MOD - 2);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (bp(2ll, n) + MOD - 1) % MOD;
    f[0] = 1;
    forab(i, 1, N) f[i] = (f[i - 1] * 1ll * i) % MOD;
    ll c1 = 1;
    forab(i, n - a + 1, n + 1) c1 = (c1 * 1ll * i) % MOD;
    c1 = (c1 * 1ll * inv(f[a])) % MOD;
    ans = (ans + MOD - c1) % MOD;
    ll c2 = 1;
    forab(i, n - b + 1, n + 1) c2 = (c2 * 1ll * i) % MOD;
    c2 = (c2 * 1ll * inv(f[b])) % MOD;
    ans = (ans + MOD - c2) % MOD;
    cout << ans << "\n";
    return 0;

}

Measured memory_bytes: 1792
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";



function Main(input){
	input = [].concat(...input.trim().split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  var S = strShift();
  
  var o = [];
  
  for(var j = 1; j < N; j++){
  	var bef = Array.from({length:26},()=>false);
  	var aft = Array.from({length:26},()=>false);
  	for(var i = 0; i < j;i++){
  		var t = parseInt(S[i],36)-10;
      bef[t]=true;
  	}
    for(var i = j; i < N;i++){
    	var t = parseInt(S[i],36)-10;
      aft[t]=bef[t];
    }
    o.push(aft.filter(a=>a).length);
  }
  
  return ~~Math.max(...o);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir
`);

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

using namespace std;

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#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 fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	int n;cin>>n;
	int cost[n+1];
	fill(cost,0);
	int h[n+1];
	rep(i,1,n) cin>>h[i];
	cost[1] = 0;
	if(n==1) return 0*printf("0");
	cost[2] = abs(h[2]-h[1]);
	rep(i,3,n)
	{
		cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
	}
	int ans = cost[n];
	cout<<ans<<"\n";

}

Measured memory_bytes: 1024
from bisect import bisect_left
import random
import time
import math


#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
#初期解
T = []
for _ in range(D):
    t = random.randrange(26)
    T.append(t)


last_day = [[-1] for _ in range(26)]
for d in range(D):
    test = T[d]
    last_day[test].append(d)
for i in range(26):
    last_day[i].append(D)


T0 = 5000
time_start = time.perf_counter()
while True:
    time_now = time.perf_counter()
    if time_now - time_start > 1.80:
        break
    #時間を正規化して温度を設定
    time_n = (time_now - time_start) / 1.80
    T1 = T0 ** (1 - time_n)
    for _ in range(100):
        #ランダムな日のテストをランダムに入れ替え
        d = random.randrange(365)
        q = random.randrange(26)
        old = T[d]
        T[d] = q
        #日程dでの元のテストold
        l = last_day[old]
        ind_old = l.index(d)
        dd_left = l[ind_old] - l[ind_old-1] - 1
        dd_right = l[ind_old+1] - l[ind_old] - 1
        dd = l[ind_old+1] - l[ind_old-1] - 1
        dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
        #日程dでのテストq
        l = last_day[q]
        ind_q = bisect_left(last_day[q],d)
        dd_left = d - l[ind_q-1] - 1
        dd_right = l[ind_q] - d - 1
        dd = l[ind_q] - l[ind_q-1] - 1
        dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
        #変更による差
        dif_s = dif_old + dif_q - S[d][old] + S[d][q]
        if (dif_s > 0) or (math.exp(dif_s / T1) > random.random()):
            del last_day[old][ind_old]
            last_day[q].insert(ind_q,d)
        else:
            T[d] = old
for d in range(365):
    print(T[d] + 1)



Measured memory_bytes: 88436
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

typedef unsigned long long int ull;

inline ull gcd(ull a,ull b) {
	ull n[2] = {min(a,b),max(a,b)};
	ull t;
	while(n[0] != 0) {
		t = n[0];
		n[0] = n[1] % n[0];
		n[1] = t;
	}
	return n[1];
}

inline ull lcm(ull a,ull b) {
	return a / gcd(a,b) * b;
}

int main(int argc,char** argv) {
	int n;
	ull t,res = 1;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> t;
		res = lcm(res,t);
	}
	cout << res;
}


Measured memory_bytes: 256
import numpy as np
from scipy import sparse

n, m = map(int, input().split())
ab = np.array([list(map(int, input().split())) for _ in range(m)])

g = sparse.csr_matrix(([1]*m, (ab[:, 0]-1, ab[:, 1]-1)), shape=(n, n))
_bfo, predecessors = sparse.csgraph.breadth_first_order(g, 0, directed=False)
if all(predecessors[1:] >= 0):
    print('Yes')
    for p in predecessors[1:]:
        print(p+1)
else:
    print('No')


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

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());

  int minv = 1e9 + 2;
  for (int i = 0; i + k - 1 < n; i++) {
    minv = min(minv, h[i + k - 1] - h[i]);
  }
  cout << minv << '\n';
}

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

int main()
{
    string str[3]={"Sunny","Cloudy","Rainy"};
    string now;
    cin >> now;
    if(now == str[0]){
        cout << str[1];
    }else if(now == str[1]){
        cout << str[2];
    }else{
        cout << str[0];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int m1 = fs.nextInt();
        int d1 = fs.nextInt();
        int m2 = fs.nextInt();
        int d2 = fs.nextInt();
        if (m1 != m2 && d1 + 1 != d2) {
            System.out.println("1");
        } else {
            System.out.println("0");
        }
    }
}


Measured memory_bytes: 83412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;



int main(){
    ll N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    deque<int> Q; 
    Q.push_front(A[0]);
    int i = 1;
    bool flag = true;
    while(i < N){
        Q.push_front(A[i]);
        i++;
        if(i < N){
            Q.push_back(A[i]);
            i++;
        }
        else flag = false;
    }
    if(!flag){
        while(!Q.empty()){
            int x = Q.front(); Q.pop_front();
            cout << x << " ";
        }
        cout << endl;
    }
    else {
        while(!Q.empty()){
            int x = Q.back(); Q.pop_back();
            cout << x << " ";
        }
        cout << endl;
    }

    
    
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int size=200010;
const int A=26;
int N,Q;
string s;
char t[size],d[size];

vector<int> pos[A];

bool checkL(int idx)
{
    char cur=s[idx];
//  cout<<idx<<' '<<cur<<endl;
    REP(i,Q){
	if(cur!=t[i]) continue;
	if(d[i]=='L'){
	    if(idx==0) return true;
	    else idx--,cur=s[idx];
	}
	if(d[i]=='R'){
	    if(idx==N-1) return false;
	    else idx++,cur=s[idx];
	}
//	cout<<idx<<' '<<cur<<endl;
    }
    return false;
}

bool checkR(int idx)
{
    char cur=s[idx];
    REP(i,Q){
	if(cur!=t[i]) continue;
	if(d[i]=='L'){
	    if(idx==0) return false;
	    else idx--,cur=s[idx];
	}
	if(d[i]=='R'){
	    if(idx==N-1) return true;
	    else idx++,cur=s[idx];
	}
    }
    return false;
}

signed main()
{
    cin>>N>>Q>>s;
    REP(i,Q) cin>>t[i]>>d[i];

    REP(i,N){
	pos[s[i]-'A'].push_back(i);
    }

/*
    REP(i,3){
	REP(j,SZ(pos[i])) cout<<pos[i][j]<<' ';
	cout<<endl;
    }
*/
    int ans=0;
    REP(i,A){
	int ngL=-1,okL=SZ(pos[i]);
	while(okL-ngL>1){
	    int mid=(okL+ngL)/2;
	    if(checkL(pos[i][mid])) ngL=mid;
	    else okL=mid;
	}

	int okR=-1,ngR=SZ(pos[i]);
	while(ngR-okR>1){
	    int mid=(okR+ngR)/2;
	    if(checkR(pos[i][mid])) ngR=mid;
	    else okR=mid;
	}
	ans+=max(ngR-ngL-1,0LL);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+20;
int n,ans,top; char s[N],st[N];
int main(void)
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for (int i=1;i<=n;i++)
        if ( s[i] != s[i-1] ) ans++;
    printf("%d\n",ans);
    return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int X, t; cin >> X >> t;
	int ans = max(X-t,0);

	cout << ans << endl;


	return 0;

}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	int x,k;
	cin>>k>>x;

	for (int i = x-k+1; i < x+k ; ++i){
		if(i<-1000000 || i>1000000)continue;
		if(i==x+k-1)
			cout<<i<<endl;
		else
			cout<<i<<" ";
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin >> s >> t ;
    cout << t << s;
    return 0;
}

Measured memory_bytes: 3640