akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> h(n+1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ": key = " << h[i];
		if (i != 1) {
			cout << ", parent key = " << h[i / 2];
		}
		if (i * 2 <= n) {
			cout << ", left key = " << h[i * 2];
		}
		if (i * 2+1 <= n) {
			cout << ", right key = " << h[i * 2+1];
		}
		cout << ", "  << endl;
	}

}


Measured memory_bytes: 3008
import collections
n=int(input())
A=list(map(int,input().split()))
q=int(input())
A.sort()
B=collections.Counter(A)
S=sum(A)
C=[]
for _ in range(q):
  b,c=map(int,(input().split()))
  C.append(B[b]*(c-b)+S)
  S+=B[b]*(c-b)
  B[c]+=B[b]
  B[b]=0

for i in C:
  print(i)

Measured memory_bytes: 27164
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		string s1,s2;
		cin>>s1>>s2;
		ll dp[55][5][5]={0};
		rep(i,0,n)
		{
			if(i==0)
			{
				if(s1[0]==s2[0])
				dp[0][0][0]=dp[0][1][1]=dp[0][2][2]=1;
				else
				dp[0][0][1]=dp[0][1][0]=dp[0][0][2]=dp[0][2][0]=dp[0][1][2]=dp[0][2][1]=1;			
				continue;
			}
			else if(s1[i-1]==s2[i-1])
			{
				if(s1[i]==s2[i])
				{
					dp[i][0][0]=(dp[i-1][1][1]+dp[i-1][2][2])%hell;
            		dp[i][1][1]=(dp[i-1][0][0]+dp[i-1][2][2])%hell;
            		dp[i][2][2]=(dp[i-1][1][1]+dp[i-1][0][0])%hell;
				}
				else
				{
		            dp[i][0][1]=dp[i-1][2][2];
		            dp[i][1][0]=dp[i-1][2][2];
		            dp[i][2][1]=dp[i-1][0][0];
		            dp[i][1][2]=dp[i-1][0][0];
		            dp[i][0][2]=dp[i-1][1][1];
		            dp[i][2][0]=dp[i-1][1][1];
				}
			}
		    else
		    {
		        if(s1[i]==s2[i])
		        {
		            dp[i][0][0]=(dp[i-1][1][2]+dp[i-1][2][1])%hell;
		            dp[i][1][1]=(dp[i-1][0][2]+dp[i-1][2][0])%hell;
		            dp[i][2][2]=(dp[i-1][1][0]+dp[i-1][0][1])%hell;
		        }
		        else if(s1[i]==s1[i-1])
		        {
		            dp[i][0][1]=dp[i-1][0][1];
		            dp[i][1][0]=dp[i-1][1][0];
		            dp[i][2][1]=dp[i-1][2][1];
		            dp[i][1][2]=dp[i-1][1][2];
		            dp[i][0][2]=dp[i-1][0][2];
		            dp[i][2][0]=dp[i-1][2][0];
		        }
		        else
		        {
		            dp[i][0][1]=(dp[i-1][1][0]+dp[i-1][2][0]+dp[i-1][1][2])%hell;
		            dp[i][1][0]=(dp[i-1][0][1]+dp[i-1][0][2]+dp[i-1][2][1])%hell;
		            dp[i][2][1]=(dp[i-1][1][2]+dp[i-1][0][2]+dp[i-1][1][0])%hell;
		            dp[i][1][2]=(dp[i-1][2][1]+dp[i-1][2][0]+dp[i-1][0][1])%hell;
		            dp[i][0][2]=(dp[i-1][1][0]+dp[i-1][2][0]+dp[i-1][2][1])%hell;
		            dp[i][2][0]=(dp[i-1][0][1]+dp[i-1][0][2]+dp[i-1][1][2])%hell;
		        }
		    }

		}
		ll ans=0;
		rep(i,0,3) rep(j,0,3) ans=(ans+dp[n-1][i][j])%hell;
		cout<<ans; 
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c >= 22)
		cout << "bust\n";
	else
		cout << "win\n";
}

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

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

ll n;

ll g1(ll n, int p){
  if(n==0) return 0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, int p){
  ll res = g1(n/2,p);
  if(p == 2) res++;
  return res;
}

int main(){
  cin >> n;
  if(n%2){
    cout << 0 << endl;
    return 0;
  }
  cout << min(g2(n,2), g2(n,5)) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long N = scanner.nextInt();
    long K = scanner.nextInt();
    long cnt = 0;
    for (long b = K + 1; b <= N; b++) {
      long i = N / b;
      cnt += i * (b - K);
      cnt += Math.max(N - (i * b + K) + 1, 0);
      if (K == 0) cnt--;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int flag=1;
	while(1)
	{
		C=C-B;
		if(C<=0)
		{
			flag=1;
			break;
		}
		
		A=A-D;
		if(A<=0)
		{
			flag=0;
			break;
		}
		
		
	}
	if(flag==1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


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

static const int MAX  = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int MinimumCostSort(int A[], int B[], int n) {
  int ans = 0;

  bool V[MAX];
  for ( int i = 0; i< n; i++ ) {
    V[i] = false;
  }

  for ( int i = 0; i < n; i++ ) T[B[i]] = i;
  for ( int i = 0; i < n; i++ ) {
    if ( V[i] ) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while ( 1 ) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S+= v;
      cur = T[v];
      if ( V[cur] ) break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }

  return ans;
}

int main() {
  cin >> n;
  s = VMAX;
  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    s = min(s, A[i]);
    B[i] = A[i];
  }
  sort(B, B + n);

  int ans = MinimumCostSort(A, B, n);

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

Measured memory_bytes: 3248
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long I = int.Parse(str[0]);
        long O = int.Parse(str[1]);
        long J = int.Parse(str[3]);
        long L = int.Parse(str[4]);
        long count = I/2*2 + O + J/2*2 + L/2*2;
        if(I >= 1 && J >= 1 && L >= 1){
            count = Math.Max(count,3+(I-1)/2*2 + O + (J-1)/2*2 + (L-1)/2*2);
        } 
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int debug = 0;
  int N,V,P;
  long long M;
  cin >> N >> M >> V >> P;
  vector<int> A(N);
  int H = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    H = max(H,A[i]);
  }
  sort(A.begin(),A.end());
  //二分探索 条件:問題が採用される
  int p = N;
  int n = -1;
  while (p-n>1){
    int m = (n+p)/2;
if (debug==1)    cout << "問題" << m << "(" << A[m] << ")について判定" << endl;
    //問題mが採用される可能性があるか判定
    int mm = m;
    while (A[mm]==A[m]) mm--;
    mm++;
if (debug==1)    cout << "問題" << mm << "(" << A[mm] << ")" << endl;    
    int S = A[mm] + M; //M人のジャッジがmm問題に投票
if (debug==1)    cout << "S=" << S << endl;
    //最初からS点より高い問題が何問あるか数える
    //二分探索 条件:問題の初期スコアがS点より高い
    int p2 = N;
    int n2 = -1;
    while (p2-n2>1){
      int m2 = (n2+p2)/2;
      if (A[m2]>S){
        p2 = m2;
      } else {
        n2 = m2;
      }
    }
    //N-p2問ある
if (debug==1)    cout << "初期スコア" << S << "点より高は" << N-p2 << "問" << endl;
    if (N-p2 >= P){
      //不可能
if (debug==1)      cout << "不可能A" << endl;
      n = m;
    } else {
if (debug==1)      cout << "L=" << M << "*(" << V << "-1-" << mm << "-" << P-1 << ")" << endl;
      long long L = M * (V - 1 - mm - (P - 1));
if (debug==1)      cout << "L=" << L << endl;
      if (L<=0){
        //各ジャッジがmと下位m-1問or上位P-1問に投票すればよい
if (debug==1)        cout << "可能A" << endl;
        p = m;
      } else {
        long long T = 0;
        for (int i = mm + 1; i <= N - P; i++){
          T += S-A[i];
if (debug==1)          cout << "問題" << i << "(" << A[i] << "), " << S-A[i] << "追加" << endl;
        }
if (debug==1)        cout << "T=" << T << endl;
        if (L<=T){
          //可能
if (debug==1)          cout << "可能B" << endl;
          p = m;
        } else {
          //不可能
if (debug==1)          cout << "不可能B" << endl;
          n = m;
        }
      }
    }
  }
if (debug==1)  cout << p << ' ' << n << endl;
  cout << N-p;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << "(DUMP) " << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> pl;
typedef pair<ll, ll> pll;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if(C >= A && C <= B) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> A >> B >> C;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;cin>>s>>t;
    int ans = 0;

    rep(i,3) if(s[i]==t[i])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    theta = math.degrees(math.atan2(b, 2*x/a/b))
else:
    theta = math.degrees(math.atan2(2*(a*b-x/a)/a, a))

print(theta)

Measured memory_bytes: 3060
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 1e5+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> adj[N];
int dp[N];

int f(int id) {
    if (dp[id] != -1) return dp[id];
    int best = 0;
    for (int u : adj[id])
        best = max(best, f(u)+1);
    return dp[id] = best;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    rep (i, 0, m) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, f(i));
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    if(S.size() % 2 == 1) {
        S = S.substr(0, S.size()-1);
    } else {
        S = S.substr(0, S.size()-2);
    }
    while(S.size() > 0) {
        string left = S.substr(0, S.size()/2);
        string right = S.substr(S.size()/2, S.size()/2);
        if(left == right) {
            cout << S.size() << endl;
            return 0;
        } else {
            S = S.substr(0, S.size()-2);
        }
    }
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int H, W, K;
int dp[110][11];
int mod = 1e9 + 7;
int comb(int x) {
    if (x <= 0)return 1;
    return (comb(x - 1) + comb(x - 2)) % mod;
}
signed main() {
    cin >> H >> W >> K;
    dp[0][1] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 1; j <= W; j++) {
            (dp[i + 1][j - 1] += (dp[i][j] * comb(j - 1 - 2) % mod * comb(W - j - 1) % mod)) %= mod;
            (dp[i + 1][j + 1] += (dp[i][j] * comb(j - 1 - 1) % mod * comb(W - j - 2) % mod)) %= mod;
            (dp[i + 1][j] += (dp[i][j] * comb(j - 1 - 1) % mod * comb(W - j - 1) % mod)) %= mod;
        }
    }
    cout << dp[H][K] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ri register int
#define ptf printf
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 2e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() getchar()//(((ib == ob) && (ob = (ib =  buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch) && !isdigit(ch)) ch = gc();
  while (isalpha(ch) || isdigit(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 998244353;//= 1e9 + 7;
  //int mod;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a - a / b * b, y, x);
  y -= a / b * x;
}
typedef pair <pii, pii> seg;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  ll a = read(), v1 = read(), b = read(), v2 = read();
  if (v1 <= v2) return puts("NO"), 0;
  ll t = (ll) Abs(v1 - v2) * read();
  if (t >= Abs(b - a)) puts("YES");
  else puts("NO");
  return 0;
}

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

using namespace std;
int arr[100005];
int main()
{
    int n;
    cin>>n;
    int num = 0;
    memset(arr,0,sizeof(arr));
    for(int i = 0;i<n;i++)
    {
        int t;
        cin>>t;
        arr[t]++;
        arr[t+1]++;
        if(t-1>=0)
            arr[t-1]++;
    }
    int maxx = 0;
    for(int i = 0;i<=100001;i++)
        maxx = max(maxx,arr[i]);
    cout<<maxx;
}


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

namespace ABC117
{
    class Polygon
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = l.Max();
            int sum = l.Sum() - max;
            Console.WriteLine(max >= sum ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 13396
n,x,m = map(int, input().split())

chk = [0 for i in range(m)]
a = x
s = x
c = 0
ary = [x]
flg = False
while True:
  if c == n:
    break
  x = (x**2)%m
  s += x
  c += 1
  if chk[x]:
    flg = True
    break
  ary.append(x)
  chk[x] = c
if flg == False:
  print (sum(ary[:-1]))
  exit()
cyc = ary[chk[x]:]
l1 = len(cyc)
ss = ary[:chk[x]]
l2 = len(ss)
tot = sum(ss) + sum(cyc)*((n-l2)//l1) + sum(cyc[:((n-l2)%l1)])
print (tot)

Measured memory_bytes: 13892
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std; 
int main() {
    cout << fixed << setprecision(6);
    int n; 
    int i;
    int tmp1;
    int sum;
    double bar,s;
    double tmp2;
    while(1){
        cin >> n;
        if(n== 0) break;
        sum = 0;
        s   = 0;
        vector<int> x;
        for (i = 0; i < n; i++)
        {
            cin >> tmp1;
            sum += tmp1;
            x.push_back(tmp1);
        }
        bar = (double)sum/n;
        for ( i = 0; i < n; i++)
        {   
            tmp2 = (double)x[i]-bar;
            s += tmp2*tmp2;
        }
        s = sqrt(s/n);
        cout << s << endl;
        
    };
        
    return 0;
}


Measured memory_bytes: 3280
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int A, B,ans=0;
	cin >> A >> B;
	if (A > B) {
		ans += A; A = A - 1;
	}
	else { ans += B; B--; }
	ans += max(A, B);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
void include3(int x, int i) {
  if(x % 10 == 3) {
    printf(" %d", i);
    return;
  }
  x /= 10;
  if(x) return include3(x, i);
  return;
}
 
int main() {
  int n;
  int i;
  int x;
 
  scanf("%d", &n);

  for(i = 1; i <= n; i++) {
    x = i;
    if(x % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    include3(x, i);
  }
  printf("\n");


 
 
  return 0;
}

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

int main(){
  int s;
  vector<int> cnt(1000001);
  
  cin >> s;
  
  cnt.at(s)++;
  for(int i = 2;;i++){
    if(s%2) s = 3*s + 1;
    else s /= 2;
    
    if(cnt.at(s)++){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 7032
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <ios>     // std::left, std::right
#include <iomanip>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
//const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};





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

    rep(i,0,x+1){
        rep(j,0,x-i+1){
            if(10000*i + 5000*j + 1000*(x-i-j) == y){
                cout << i << " " << j << " " << x-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N,K;
  cin >> N >> K;
  mat dp(K,vec(2*(ll)sqrt(N),0));
  rep(i,K){
    if(i==0){
      rep(j,(ll)sqrt(N)){
        dp.at(0).at(j)=1;
      }
      rep(j,(ll)sqrt(N)){
        if(j==0){
          dp.at(0).at(j+(ll)sqrt(N))=N/((ll)sqrt(N)-j)-((ll)sqrt(N)-j);
        }else{
          dp.at(0).at(j+(ll)sqrt(N))=N/((ll)sqrt(N)-j)-N/((ll)sqrt(N)-j+1);
        }
      }
    }else{
      ll sum=0;
      rep(j,2*(ll)sqrt(N)){
        sum+=dp.at(i-1).at(j);
        dp.at(i).at(2*(ll)sqrt(N)-1-j)=sum*dp.at(0).at(2*(ll)sqrt(N)-1-j);
        dp.at(i).at(2*(ll)sqrt(N)-1-j)%=MOD;
      }
    }
  }
  ll ans=0;
  rep(i,2*(ll)sqrt(N)){
    ans+=dp.at(K-1).at(i);
    ans%=MOD;
  }
  cout << ans << endl;
}
         

Measured memory_bytes: 53200
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define ul              unsigned long
#define db              double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vl              vector <long int>
#define vi              vector <int>
#define all(v)          (v.begin(), v.end()) 
#define rall(v)         (v.rbegin(), v.rend()) 
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9+7;
vi check(10000005);

bool prime(int n)
{
    for(int i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            check[i]++;
            if(i*i!=n)
            check[n/i]++;

            if(check[i]>1 || check[n/i]>1)
            return false;
        }
    }
    if(n!=1)
    check[n]++;
    // For(i, 1, 7) cout<<check[i]<<el;
    // cout<<el;
    if(check[n]>1)
    return false;

    return true;
}

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

void solve()
{
    int n;
    cin>>n;
    vi v(n);
    For(i, 0, n) cin>>v[i];

    check.clear();

    For(i, 0, n)
    {
        if(!prime(v[i]))
        {
            break;
        }

        if(i==n-1)
        {
            cout<<"pairwise coprime";
            return;
        }
    }

    int gg;
    gg=gcd(v[0], v[1]);

    if(gg==1)
    {
            cout<<"setwise coprime";
            return;
    }
    For(i, 2, n)
    {
        gg=gcd(gg, v[i]);
        if(gg==1)
        {
            cout<<"setwise coprime";
            return;
        }
    }
    cout<<"not coprime";
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    /***************-Code starts from here-***************/
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0; 
} 

Measured memory_bytes: 46196
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int W[N];
    for (int i = 0; i < N; ++i) cin >> W[i];
    int minD = 90000;
    for (int t = 0; t < N; ++t) {
        int S1 = 0, S2 = 0, cur = 0;
        for (int i = 0; i <= t; ++i) S1 += W[i];
        for (int i = t + 1; i < N; ++i) S2 += W[i];
        cur = abs(S1 - S2);
        minD = min(minD, cur);
    }
    cout << minD << endl;
}


Measured memory_bytes: 256
abc = sorted(list(map(int, input().split())))

ans = 0

cnt = abc[2] - abc[1]
abc[0] += cnt
abc[1] += cnt
ans += cnt

cnt = (abc[2] - abc[0]) // 2
abc[0] += cnt * 2
ans += cnt

if abc[0] != abc[2]:
    ans += 2

print(ans)


Measured memory_bytes: 3060
s = input()
l = len(s)
h = l//2
if l == 3:
    print(1)
if l%2==0:
    for i in range(1,h):
        if s[0:h-i] == s[h-i:-2*i]:
            print(len(s[:-2*i]))
            break
else:
    for i in range(1,h):
        if s[0:h-i+1] == s[h-i+1:-2*i+1]:
            print(len(s[:-2*i+1]))
            break

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        int yd = y2 - y1;
        int xd = x2 - x1;
        int x3 = x2 - yd;
        int y3 = y2 + xd;
        int x4 = x1 - yd;
        int y4 = y1 + xd;
        System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

    }

}


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

int n, k, a;

int techo (int a, int b) {
	return (a + b - 1) / b;
}

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

	cin >> n >> k;

	cout << techo(n-1,k-1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n; cin>>n;
    n%=1000;
    if(n==0){
        cout<<0;
        return 0;
    }
    cout<<1000-n;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

struct Color {
    int64_t b, w, s;
};

Color rf(vector<Color> &dp, vector<vector<int> > &tree, vector<bool> &visited, int n) {
    visited.at(n) = true;
    if (tree.at(n).empty()) {
        return dp.at(n);
    }
    for (int x: tree.at(n)) {
        if (!visited.at(x)) {
            Color color = rf(dp, tree, visited, x);
            dp.at(n).b *= color.w;
            dp.at(n).b %= MOD;
            dp.at(n).w *= color.s;
            dp.at(n).w %= MOD;
        }
    }
    dp.at(n).s = (dp.at(n).b + dp.at(n).w) % MOD;
    return dp.at(n);
}

int main() {
    int n; cin >> n;
    vector<vector<int> > tree(n);
    for (int i = 0; i < n-1; i++) {
        int x, y; cin >> x >> y;
        tree.at(x-1).push_back(y-1);
        tree.at(y-1).push_back(x-1);
    }
    Color ones = {1, 1, 2};
    vector<Color> dp(n, ones);
    vector<bool> visited(n, false);
    cout << rf(dp, tree, visited, 0).s << endl;
}

Measured memory_bytes: 20608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String strN = insBR.readLine();
			int n = Integer.parseInt(strN);
			String[] strA = new String[n];
			for(int i = 0; i < n; i++){
				strA[i] = insBR.readLine();
			}
			//int intIndex = 0;
			String[] strToranpu = new String[4];
			strToranpu[0] = "S ";
			strToranpu[1] = "H ";
			strToranpu[2] = "C ";
			strToranpu[3] = "D ";
			/*String[][] strTora ={
				{"S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13"},
				{"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13"},
				{"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13"},
				{"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"},
			};
			String[] strTora52 = {
					"S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
					"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
					"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
					"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"
			};*/
			List<String> notExistList = new ArrayList<String>();
			//List<String> list = new ArrayList<String>();
			//String[] strList = new String[52-n];
			String strCard = "";
			/*int intList = 0;
			boolean blExist = false;*/
			for(int i = 0; i < 4; i++){
				for(int j = 1; j <= 13; j++){
					strCard = strToranpu[i] + j;
					notExistList.add(strCard);
				}
			}
			for(int i = 0; i < strA.length; i++){
				notExistList.remove(strA[i]);
			}
			for(int i = 0; i < notExistList.size(); i++){
				System.out.println(notExistList.get(i));
			}
			/*for(int i = 0; i < 4; i++){
				for(int j = 1; j <= 13; j++){
					for(int h =0; h < n; h++){
						intIndex = (strToranpu[i] + j).indexOf(strA[h]);
						if(intIndex == -1){
							list.add(strToranpu[i] + j);
						}
					}
				}
			}
			for(int i = 0; i < list.size(); i++){
				System.out.println(list.get(i));
			}
*/
			/*int h = 0;
			for(int i = 0; i < 52; i++){
				blExist = strTora52[i].matches(strA[h]);
				if(blExist == false){
					for(int j = 0; j < list.size(); j++){
						System.out.println("h=" + h);
						System.out.println("j=" + j);
						//if(0 < list.size() && !strA[h].equals(list.get(j - 1))){
							list.add(strTora52[i]);
						//}
					}
					list.add(strTora52[i]);
				}
				if(h != strA.length - 1){
					h++;
				}
			}
	*/


		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



Measured memory_bytes: 24236
import collections
N = int(input())
List = [[] for _ in range(N)]
ans = [-1]*N
for i in range(N-1):
    a, b, c = map(int, input().split())
    List[a-1].append((b-1, c))
    List[b-1].append((a-1, c))
Q, K = map(int, input().split())
queue = collections.deque([K-1])
ans[K-1] = 0
while queue:
    edge = queue.pop()
    for node in List[edge]:
        index, cost = node
        if ans[index]>0:
            continue
        ans[index] = ans[edge]+cost
        queue.append(index)
for i in range(Q):
    x, y = map(int, input().split())
    print(ans[x-1]+ans[y-1])

Measured memory_bytes: 81696
h,w=map(int,input().split())
lst=[]
lst.append('.'*(w+2))
for i in range(h):
  lst.append('.'+input()+'.')
lst.append('.'*(w+2))

dx=[1,-1,0,0]
dy=[0,0,1,-1]

for i in range(1,h+1):
  for j in range(1,w+1):
    if lst[i][j]=='#':
      judge=False
      for k in range(4):
        nx=i+dx[k]
        ny=j+dy[k]
        if lst[nx][ny]=='#':
          judge=True
          
      if judge==False:
        print('No')
        exit()
        
print('Yes')

Measured memory_bytes: 69280
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 10000002
using namespace std;
int arr[MAXX];
void shieve()
{
    rep(i,MAXX+1) arr[i]=1;
    for(int i=2;i<=MAXX;i++)
    {
        for(int j=i;j<=MAXX;j+=i)
            arr[j]++;
    }
}
void trozen()
{
    shieve();
    int n;
    cin>>n;
    //cout<<arr[10]<<endl;
    //cout<<arr[MAXX]<<endl;
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=(i*arr[i]);
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 81760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, a, b);
    Cins(int, n, h);
    
    int lb = 0, ub = 1e9;
    while(ub - lb > 1){
        int m = (lb + ub) / 2;
        ll k = 0;
        For(i, n){
            ll left = h[i] - (ll)b*m;
            if(left > 0) k += (left+a-b-1)/(a-b);
        }
        ((k <= m) ? ub : lb) = m;
    }
    Cout(ub);
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static long MOD = 998244353;

  public static void main(String[] args) {
    int N = sc.nextInt();
    long A = sc.nextInt();
    long B = sc.nextInt();
    long K = sc.nextLong();
    long[] fact = new long[N + 1];
    long[] factInv = new long[N + 1];
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 0; i <= N; i++) {
      factInv[i] = inv(fact[i]);
    }
    long[] comb = new long[N + 1];
    for (int i = 0; i <= N; i++) {
      comb[i] = fact[N] * factInv[i] % MOD * factInv[N - i] % MOD;
    }
    long ans = 0;
    for (int i = 0; i <= N; i++) {
      long b = K - A * i;
      if (b % B != 0) continue;
      b /= B;
      if (b < 0 || b > N) continue;
      ans += comb[i] * comb[(int)b] % MOD;
    }
    System.out.println(ans % MOD);
  }

  static long inv(long v) {
    return pow(v, MOD - 2);
  }

  static long pow(long b, long p) {
    if (p == 0) return 1;
    if (p == 1) return b;
    long ret = pow(b, p / 2);
    ret = ret * ret % MOD;
    if (p % 2 == 1) {
      ret = ret * b % MOD;
    }
    return ret;
  }

}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B < C)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
from time import time
from random import randrange
from bisect import bisect_left
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]
start = time()
d = int(input())
c = list(map(int, input().split()))
C = sum(c)
s = [list(map(int, input().split())) for _ in range(d)]
#t = [int(input()) for _ in range(d)]
t = []
day = [[0] for _ in range(26)]
order = []

def score(t):
	res = 0
	minus = 0
	last = [0 for _ in range(26)]
	for i, x in enumerate(t):
		minus += C - c[x-1] * (i - last[x-1] + 1)
		res -= minus
		res += s[i][x-1]
		last[x-1] = i+1
		#print(res)
	return res

def tri(n):
	return n * (n-1) // 2

def change(i, to):
	diff = 0
	fr = t[i]-1
	#print(day[fr])
	#print(day[to])
	if fr == to:
		return None
	fr_ind = bisect_left(day[fr], i+1)
	diff += (tri(day[fr][fr_ind] - day[fr][fr_ind-1]) + tri(day[fr][fr_ind+1] - day[fr][fr_ind])) * c[fr]
	diff -= (tri(day[fr][fr_ind+1] - day[fr][fr_ind-1])) * c[fr]
	diff -= s[i][fr]
	
	to_ind = bisect_left(day[to], i+1)
	diff += (tri(day[to][to_ind] - day[to][to_ind-1])) * c[to]
	diff -= (tri(day[to][to_ind] - (i+1)) + tri(i+1 - day[to][to_ind-1])) * c[to]
	diff += s[i][to]

	if diff > -100:
		day[fr].pop(fr_ind)
		after = day[to][:to_ind] + [i+1] + day[to][to_ind:]
		day[to] = after
		t[i] = to+1
		#print("↓")
		#print(day[fr])
		#print(day[to])
		return diff
	else:
		return None

#score(t)
res = 0
minus = 0
last = [0 for _ in range(26)]
for i in range(d):
	minus += C
	li = sorted(list(range(26)), key=lambda x: - c[x] * (i - last[x] + 1) - s[i][x])
	order.append(li)
	M_ind = li[0]
	minus -= c[M_ind] * (i - last[M_ind] + 1)
	last[M_ind] = i+1
	res -= minus - s[i][M_ind]
	t.append(M_ind+1)
	day[M_ind].append(i+1)

for i in range(26):
	day[i].append(d+1)


#print(*t, sep="\n")
#print(score(t))
#print("↓")

priority = [0 for _ in range(d)]
while time() - start < 1.8:
	i = randrange(d)
	pr = randrange(max(0, priority[i]-3), min(26, priority[i]+4))
	diff = change(i, order[i][pr])
	if diff is not None:
		res += diff
		priority[i] = pr

print(*t, sep="\n")
#print(score(t))

Measured memory_bytes: 93968
n = int(input())
s = input()

c = 0
scount = 0
for i, si in enumerate(list(s)):
  if si == '(':
    c += 1
  else:
    c -= 1
  if c < 0:
    scount += 1
    c = 0

s = '('*scount + s
s = s + ')'*c
print(s)

Measured memory_bytes: 2940
def main():
    from fractions import gcd

    n, *a = map(int, open(0).read().split())
    a = tuple([0] + a + [0])
    l = [0 for _ in range(n + 1)]
    r = [0 for _ in range(n + 1)]
    tmpl = 0
    tmpr = 0
    for i in range(1,n+1):
        tmpl = gcd(tmpl, a[i-1])
        tmpr = gcd(tmpr, a[-i])
        l[i] = tmpl
        r[-i] = tmpr

    ans = 0
    for i, j in zip(l, r):
        g = gcd(i, j)
        ans = max(ans, g)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  vector<vector<int>> v(H, vector<int>(W));
  for(int i = 0; i < H; i++) cin >> s[i];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] != '#') continue;
      for(int x = -1; x <= 1; x++){
        if(i + x < 0 || i + x >= H) continue;
        for(int y = -1; y <= 1; y++){
          if(j + y < 0 || j + y >= W) continue;
          if(x * y != 0) continue;
          v[i][j] += (s[i + x][j + y] == '#' ? 1 : 0);
        }
      }
      if(v[i][j] == 1){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT LN.
  PERFORM N TIMES
      PERFORM VARYING j FROM cur BY 1  UNTIL LN(j:1) = SPACE
      END-PERFORM
      COMPUTE len = j - cur
      MOVE LN(cur:len) TO A
      IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
          AND FUNCTION MOD(A, 5) NOT = ZERO
          MOVE ZERO TO FLG
          EXIT PERFORM
      END-IF
      COMPUTE cur = j + 1
      ADD 1 TO i
  END-PERFORM.
  IF FLG = 1
      DISPLAY "APPROVED"
  ELSE
      DISPLAY "DENIED"
  END-IF.
  STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,i;
		string str;
		cin>>str;
		cout<<((str[2]==str[3] and str[4]==str[5]) ? "Yes" : "No")<<endl;
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
vi s;

int main() {
    fastio();

    cin >> n;
    s = vi(n);

    forn(i, n) cin >> s[i];

    sort(all(s));

    int total = accumulate(all(s), 0);

    if (total % 10 == 0) {
        auto it = find_if(all(s), [](int a) { return a % 10 != 0; });
        if (it == s.end()) {
            cout << 0 << endl;
        } else {
            cout << total - *it << endl;
        }
    } else {
        cout << total << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;

void solve() {
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];

    ll result = 0;
    
    for(int i = 0; i < 60; ++i) {
        ll zero = 0;
        ll one = 0;
        for(int j = 0; j < N ; ++j) {
            if ((A[j] >> i) & 1LL) ++one;
            else ++zero;
        }
        // cout << "i" << i << endl;
        // cout << "one:" << one << endl;
        // cout << "zero" << zero << endl;
        result += (((one * zero) % MOD) * ((1LL << i) % MOD)) % MOD;
        // cout << "result" << result << endl;
    }
    result = result % MOD;

    cout << result << endl;
    return;
}

int main() {
    solve();
    return 0;

}

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for(int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n;
    string m;
    cin >> n >> m;

    if(n >= 3200) {
        p(m);
    } else {
        p("red");
    }

    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	vector<ll> x(m), df(m-1);
	rep(i, m) cin >>x[i];
	if(n >=m){puts("0"); return 0;}
	sort(all(x));
	rep(i, m-1) df[i] = x[i+1] - x[i];
	sort(df.rbegin(), df.rend());
	
	cout << accumulate(df.begin()+n-1, df.end(), 0LL) << "\n";
	
	return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
from itertools import permutations

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

num_list = list(range(1,N+1))

a = 0
b = 0
index = 0
for v in permutations(num_list,N):
    if v == P:
        a = index
    if v == Q:
        b = index

    index += 1

print(abs(a-b))

Measured memory_bytes: 3064
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {

	ll H, W;
	cin >> H >> W;
	ll ma[10][10];
	rep(i, 10) rep(j, 10) cin >> ma[i][j];	

	vll mmin(10, INF);
	vll arr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	do {
		ll tmp = 0;
		rep(i, 10) {
			if (arr[i] == 1) {
				mmin[arr[0]] = min(mmin[arr[0]], tmp);
				break;
			}
			else tmp += ma[arr[i]][arr[i + 1]];
		}
	} while (next_permutation(arr.begin(), arr.end()));

	ll ans = 0;
	rep(i, H) rep(j, W) {
		ll A; cin >> A;
		if (A != -1) ans += mmin[arr[A]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256