akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <climits>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAX 1000000000000000000
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define f first
#define s second
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
struct pt
{
    ll x,y;
};
double dist(ll x1,ll y1,ll x2,ll y2)
{
    double d=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
    return d;
}
double sum(pt a[],ll l,ll n)
{
    ll i;
    double s=0;
    if(l==n-1)
    {
        for(i=0;i<n-1;i++) s+=dist(a[i].x,a[i].y,a[i+1].x,a[i+1].y);
        return s;
    }
    for(i=l;i<n;i++)
    {
        swap(a[l],a[i]);
        s+=sum(a,l+1,n);
        swap(a[l],a[i]);
    }
    return s;
}
int main() 
{
	fast_io;
	ll n,i;
	cin>>n;
	pt a[n+2];
	for(i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	ll f=1;
	for(i=1;i<=n;i++) f*=i;
	double ans=sum(a,0,n)/(f*1.0);
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  double v;
  while(cin >> v){
    double t,y;
    t=v/9.8;
    y=4.9*t*t;
    y = (y+5.0)/5.0;
    if((y-(int)y)!=0)y+=1.0;
    cout <<(int)y<< endl;
}
return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
P num[100000];

int main(){
	cin >> n;
	rep(i,n){
		cin >> num[i].first;
		num[i].second = i;
	}
	sort(num,num+n);
	ll cnt = 0;
	rep(i,n){
		//cout << " " << num[i].second << endl;
		if(num[i].second%2 == i%2) continue;
		else cnt++;
		//cout << "  " << cnt <<endl;
	}
	cout << cnt/2 << endl;
}










Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int p=0, q=0, r=0;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        if(k <= a) p++;
        else if(k <= b) q++;
        else r++;
    }
    cout << min({p, q, r}) << "\n";
    return 0;
}


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

#define ll long long int

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  if(y < 2*x or y > 4*x or y % 2 == 1){
    cout << "No" << "\n";
  }else{
    cout << "Yes" << "\n";
  }

  return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
#define N 200020
#define y1 ysgh
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N];
struct Seg{
	int l,r;
	Seg(int _l=0,int _r=0){l=_l,r=_r;}
	inline bool empty(){
		return l>r;
	}
	inline Seg operator & (const Seg b){
		return Seg(max(l,b.l),min(r,b.r));
	}
	inline Seg operator ^ (const Seg b){
		return l==b.l?Seg(b.r+1,r):Seg(l,b.l-1);
	}
};
struct state{
	Seg p;
	int val;
	state(Seg _p,int _v=0){p=_p,val=_v;}
	inline state operator + (const state b){
		return state(p&b.p,val+b.val);
	} 
	inline bool operator < (const state b){
		return val<b.val;
	}
};
vector<state> dp[N],now;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	dp[0].push_back({{0,0},0});
	for(int i=1;i<=n+1;++i){
		Seg lim={0,a[i]};
		now.clear();
		for(auto u:dp[i-1]){
			state x0={Seg(u.p.l,a[i])&lim,0};
			state x1={Seg(0,u.p.l-1)&lim,1};
			state y0={Seg(a[i]-a[i-1]+u.p.l,a[i])&lim,0};
			state y1={Seg(0,a[i]-a[i-1]+u.p.l-1)&lim,1};
			state t00=x0+y0,t01=x0+y1,t10=x1+y0,t11=x1+y1;
			if(!t00.p.empty()){
				t00.val+=u.val;
				now.push_back(t00);
			}
			if(!t01.p.empty()){
				t01.val+=u.val;
				now.push_back(t01);
			}
			if(!t10.p.empty()){
				t10.val+=u.val;
				now.push_back(t10);
			}
			if(!t11.p.empty()){
				t11.val+=u.val;
				now.push_back(t11);
			}
		}
		sort(now.begin(),now.end());
		for(auto u:now){
			Seg gu=u.p;
			for(auto t:dp[i]){
				Seg d=t.p&gu;
				if(!d.empty()){
					gu=gu^d;
				}
				if(gu.empty())break;
			}
			if(!gu.empty()){
				dp[i].push_back({gu,u.val});
			}
		}
	}
	printf("%d\n",dp[n+1][0].val);
	return 0;
}



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

using namespace std;

int main() {
  string S;
  cin >> S;

  string words[4] = {"dream", "erase", "eraser", "dreamer"};

  string answer = "YES";
  int cursor = S.length();

  while (cursor > 0) {
    bool isEated = false;

    for (int i = 0; i < 4; i++) {
      string word = words[i];
      int wordLength = word.length();
      if (cursor < wordLength) {
        continue;
      }

      if (S.substr(cursor - wordLength, wordLength) == word) {
        isEated = true;
        cursor -= wordLength;
        break;
      }
    }

    if (!isEated) {
      answer = "NO";
      break;
    }
  }

  cout << answer << endl;
}


Measured memory_bytes: 512
#include "iostream"
#include "math.h"
#include "algorithm"
#include "queue"
using namespace std;

queue<pair<int, int> > Q;
int H, W;
int status[102][102];
pair<int, int> dir[2][6] = { make_pair(1,0),make_pair(0,1),make_pair(-1,1),make_pair(-1,0),make_pair(-1,-1),make_pair(0,-1),make_pair(1,0),make_pair(1,1),make_pair(0,1),make_pair(-1,0),make_pair(0,-1),make_pair(1,-1)};
int x, y;
int d_x, d_y;
int ans;

int main() {
	cin >> W >> H;
	for (int i = 0; i <= H+1; i++) {
		for (int j = 0; j <= W+1; j++) {
			status[i][j] = -1;
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> status[i][j];
		}
	}
	for (int i = 1; i <= W; i++) {
		if (status[1][i] == 0) {
			status[1][i] = -1;
			Q.push(make_pair(1, i));
			while (!Q.empty()) {
				x = Q.front().second;
				y = Q.front().first;
				for (int j = 0; j < 6; j++) {
					d_x = dir[y % 2][j].first;
					d_y = dir[y % 2][j].second;
					if (status[y + d_y][x + d_x] == 0) {
						status[y + d_y][x + d_x] = -1;
						Q.push(make_pair(y + d_y, x + d_x));
					}
				}
				Q.pop();
			}
		}
		if (status[H][i] == 0) {
			status[H][i] = -1;
			Q.push(make_pair(H, i));
			while (!Q.empty()) {
				x = Q.front().second;
				y = Q.front().first;
				for (int j = 0; j < 6; j++) {
					d_x = dir[y % 2][j].first;
					d_y = dir[y % 2][j].second;
					if (status[y + d_y][x + d_x] == 0) {
						status[y + d_y][x + d_x] = -1;
						Q.push(make_pair(y + d_y, x + d_x));
					}
				}
				Q.pop();
			}
		}
	}
	for (int i = 1; i <= H; i++) {
		if (status[i][1] == 0) {
			status[i][1] = -1;
			Q.push(make_pair(i,1));
			while (!Q.empty()) {
				x = Q.front().second;
				y = Q.front().first;
				for (int j = 0; j < 6; j++) {
					d_x = dir[y % 2][j].first;
					d_y = dir[y % 2][j].second;
					if (status[y + d_y][x + d_x] == 0) {
						status[y + d_y][x + d_x] = -1;
						Q.push(make_pair(y + d_y, x + d_x));
					}
				}
				Q.pop();
			}
		}
		if (status[i][W] == 0) {
			status[i][W] = -1;
			Q.push(make_pair(i, W));
			while (!Q.empty()) {
				x = Q.front().second;
				y = Q.front().first;
				for (int j = 0; j < 6; j++) {
					d_x = dir[y % 2][j].first;
					d_y = dir[y % 2][j].second;
					if (status[y + d_y][x + d_x] == 0) {
						status[y + d_y][x + d_x] = -1;
						Q.push(make_pair(y + d_y, x + d_x));
					}
				}
				Q.pop();
			}
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
		//	cout << status[i][j] << " ";
			if (status[i][j] == 1) {
				for (int k = 0; k < 6; k++) {
					if (status[i + dir[i % 2][k].second][j + dir[i % 2][k].first] == -1)ans++;
				}
			}
		}
		//cout << "\n";
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3108
def examA():
    C = [S() for _ in range(3)]
    ans = C[0][0]+C[1][1]+C[2][2]
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38384
#include <iostream>
#include <array>
#include <algorithm>
#include <iterator>

int main(int argc, char *argv[])
{
  std::array<int, 3> paints = {};
  for (std::size_t i = 0; i < paints.size(); i++) {
    std::cin >> paints[i];
  }

  std::sort(paints.begin(), paints.end());

  std::cout <<
    std::distance(paints.begin(), std::unique(paints.begin(), paints.end())) <<
    std::endl;
  return 0;
}


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

int main() {
  string S; cin>>S;
  int Q; cin>>Q;
  int reverse_cnt=0;

  string sl={};
  string sr={};

  rep(query, Q) {
    int type; cin>>type;
    if (type==1) reverse_cnt++;
    else {
      int f;
      char c;
      cin>>f>>c;
      if (reverse_cnt%2==0) {
        if (f==1) sl=c+sl;
        else sr=sr+c;
      }
      else {
        if (f==2) sl=c+sl;
        else sr=sr+c;
      }
    }
  }
  S=sl+S+sr;
  if (reverse_cnt%2==1) reverse(S.begin(), S.end());
  cout<<S<<endl;
}


Measured memory_bytes: 1512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  int i,j;
  for(i = 0;i < h;++i){
    cin >> a.at(i);
  }
  vector<bool> yoko(h,false);
  vector<bool> tate(w,false);
  for(i = 0;i < h;++i){
    for(j = 0;j < w;++j){
      if(a.at(i).at(j) == '#'){
        yoko.at(i) = true;
        tate.at(j) = true;
      }
    }
  }
  for(i = 0;i < h;++i){
    if(yoko.at(i)){
      for(j = 0;j < w;++j){
        if(tate.at(j)){
          cout << a.at(i).at(j);
        }
      }
      cout<< endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
  int n, kind = 0, allman=0;
  bool all=false;
  cin >> n;
  vector<int> c(8, 0);
  rep(i, n) {
    int x;
    cin >> x;
    if (x >= 3200) {
      allman++;
      all = true;
    } else {
      c[x / 400]++;
    }
  }
  rep(i, 8) {
    if (c[i]) {
      kind++;
    }
  }
  if(all){
      cout << max(kind, 1) << " " << kind+allman << endl;
  }else{
      cout << kind << " " << kind << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,K,n,m;cin>>N>>M>>K;
  for(n=0;n<=N;n++){
    for(m=0;m<=M;m++){
      if(N*m+M*n-2*m*n==K)break;
    }
    if(m!=M+1)break;
  }
  if(n!=N+1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;
Node treeMinimum(Node);
Node find(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node treeMinimum(Node x){
  while( x->left > NIL ) x = x->left;
  return x;
}

Node find(Node u, int k){
  while( u != NIL && k != u->key ){
    if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;

    if( x->key > z->key ) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }

  z->parent = y;

  if( y == NIL ){
    root = z;
  }
  else {
    if(z->key < y->key ) {
      y->left = z;
	}
    else {
      y->right = z;
    }
  }
}


void inorder(Node u){
  if( u == NIL ) return ;
  inorder( u->left );
  printf(" %d",u->key);
 
  inorder( u->right );

}

void preorder(Node u){

  if( u == NIL ) return ;
  printf(" %d",u->key);
  
  preorder( u->left );
  preorder( u->right );
 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d",&x);

      Node t = find(root, x);

      if ( t != NIL ) printf("yes\n");

      else printf("no\n");
    } 

    else if ( com[0] == 'i' ){
      scanf("%d",&x);
      insert(x);
    } 

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    } 
    else if ( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int x; cin >> x;
    multimap<int,int> m;
    for(int i = 1;i <= x;i++){
        m.insert(make_pair(i,0));
    }
    for(int i = 0;i < x-1;i++){
        int y; cin >> y;
        auto z = m.find(y);
        z->second++;
    }
    for(int i = 1;i <= x;i++){
        auto z = m.find(i);
        cout << z->second << endl;
    }
}



Measured memory_bytes: 13016
while 1:
        H,W = map(int ,input().split())
        if W == H == 0: break
        for i in range(H):
                for j in range(W):
                        if (i+1 + j+1) % 2 ==0:
                                print('#',end ="")
                        else:
                                print('.',end ="")
                print('')
        print('')



Measured memory_bytes: 7008
n = int(input())
cnt = 1
w = [input() for i in range(n)]
if len(set(w)) != len(w):
    cnt *= 0
else:
    for j in range(len(w)-1):
        if w[j][len(w[j])-1] != w[j+1][0]:
            cnt *= 0

print("Yes") if cnt else print("No")


Measured memory_bytes: 3060
N = int(input())
A = []
max1 = 0
max2 = 0
for i in range(N):
  a = int(input())
  A.append((a,i))
K = A.copy()
K.sort()
m1 = K[-1]
m2 = K[-2]
for i in range(N):
  if i == m1[1]:
    print(m2[0])
  else:
    print(m1[0])

Measured memory_bytes: 96124
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int n;
  string s;
  while(cin >> n >> s){
    int ans = 0;

    FORE(i,0,999){
      string p = to_string(i);
      if(p.size() == 1) p = "00" + p;
      else if(p.size() == 2) p = "0" + p;
      

      int j = 0;

      for(auto c : s){
        if(c == p[j]){
          ++j;

          if(j == 3) break;
        }
      }
      
      if(j == 3) ++ans;
    }
    

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
typedef long long LL;
const int N=300005;
LL an;
int x[N],t,i,j,k,n,m,L,A,B;
bool l[N],r[N];
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

int main()
{
	n=read(),L=read();
	for (i=1;i<=n;++i) x[i]=read();
	for (i=1;i<=n;++i)
		t=read(),
		an+=(t-1)/(L<<1)+1,
		t=(t-1)%(L<<1)+1,
		l[i]=t<=(x[i]<<1),
		r[i]=t<=(L-x[i]<<1);
	
	for (i=1;i<n;++i)
		if (A&&r[i])
		{
			if (l[i])
				++B;
			--A,--an;
		}
		else
			if (!l[i]&&r[i])
			{
				if (B)
					--B,++A;
			}
			else
				if (l[i])
					++A;
	if (!r[n])
		++an;
	printf("%lld\n",(LL)an*(L<<1));
	return 0;
}

Measured memory_bytes: 8320
#include<stdio.h>
using namespace std;

int b[105];
int c[105];

void print(int a[],int n)
{

        for(int i=1;i<=n;i++)
        {
            for(int p=0;p<n;p++)
                {

                    if(p!=n-1)
                        printf("%d ",a[p]);
                    else
                        printf("%d\n",a[p]);
                    }
            for(int g=0;g<i;g++)
            {

                if(a[g]>=a[i])
                {
                    int t=a[i];
                    for(int k=i;k>=g;k--)
                        a[k]=a[k-1];
                    a[g]=t;


                    break;
                }

            }
        }

    return ;
}

int main()
{
    int n;

    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    print(b,n);
    return 0;
}

Measured memory_bytes: 2748
#include <stdio.h>

int main(void) {

  int a, b;
  char ch;
  scanf("%d %c %d", &a, &ch, &b);
  while(ch != '?') {
  if(ch == '+') {
    printf("%d\n", a + b);
  } else if(ch == '-') {
    printf("%d\n", a - b);
  } else if(ch == '*') {
    printf("%d\n", a * b);
  } else if(ch == '/') {
    printf("%d\n", a / b);
  }
  scanf("%d %c %d", &a, &ch, &b);
  }
  return 0;
 
}

Measured memory_bytes: 600
x = int(input())
 
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 8964
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	string s,t;
	cin>>s>>t;
	ll ans=t.size();
	for(ll i=0;i<=s.size()-t.size();i++)
	{
		ll c=0;
		for(ll j=0;j<t.size();j++)
		{
			if(s[i+j]!=t[j])
				c++;
		}
		ans=min(ans,c);
	}
	cout<<ans<<endl;
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

ll dp[101010];

int main() {
	ll n;
	cin >> n;

	ll micnt = 0;
	ll zeroex = 0;
	ll abssum = 0;
	ll absmin = 1e9 + 5;
	rep(i, 0, n) {
		ll temp;
		cin >> temp;
		if (temp == 0)zeroex = 1;
		else if (temp < 0)micnt++;
		abssum += abs(temp);
		absmin = min(absmin, abs(temp));
	}

	if (micnt % 2 == 0 || zeroex == 1) {
		cout << abssum << endl;
	}
	else {
		cout << abssum - 2 * absmin << endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int X[4];
int main(){
        REP(i,4){
           X[i]=0;
        }
	string S;
	cin>>S;
	REP(i,S.size()){
	    if(S[i]=='W'){
	       X[0]++;
	    }
	    if(S[i]=='E'){
	       X[1]++;
	    }
	    if(S[i]=='N'){
	       X[2]++;
	    }
	    if(S[i]=='S'){
	       X[3]++;
	    }
	}
	bool c=true;
	if((X[0]>0&&X[1]==0)||(X[1]>0&&X[0]==0)||(X[2]>0&&X[3]==0)||(X[3]>0&&X[2]==0))c=false;
	if(c){
           cout<<"Yes"<<endl;
        }else{
           cout<<"No"<<endl;
        }
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    //木曜日を０とする
    int table[12][31];
    int cnt=0,day;
    for(int i=1; i<=12; i++){
        if(i == 4 || i == 6 || i == 9 || i == 11) day = 30;
        else if(i == 2) day = 29;
        else day = 31;
        for(int j=1; j<=day; j++) {
            if(cnt == 7) cnt = 0;
            table[i-1][j-1] = cnt;
            cnt++;
        }
    }
    int a,b;
    while(cin >> a >> b){
        if(a == 0 && b == 0) break;
        if(table[a-1][b-1] == 0) cout << "Thursday" << endl;
        if(table[a-1][b-1] == 1) cout << "Friday" << endl;
        if(table[a-1][b-1] == 2) cout << "Saturday" << endl;
        if(table[a-1][b-1] == 3) cout << "Sunday" << endl;
        if(table[a-1][b-1] == 4) cout << "Monday" << endl;
        if(table[a-1][b-1] == 5) cout << "Tuesday" << endl;
        if(table[a-1][b-1] == 6) cout << "Wednesday" << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n,a; cin>>n>>a;
	int x[n]; rep(i,n) cin>>x[i];

	long dp[n+1][n+1][n*50+1];
	rep(i,n+1)rep(j,n+1)rep(k,n*50+1) dp[i][j][k]=0;
	dp[0][0][0]=1;
	rep(i,n+1)rep(j,i+1)rep(k,n*50+1){
		if(i>0){
			dp[i][j][k]+=dp[i-1][j][k];
			if(j>0&&k-x[i-1]>=0) dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];
		}
	}
	long ans=0;
	rep(j,n+1)rep(k,j*50+1){
		if(j>0&&j*a==k){
			ans+=dp[n][j][k];
			//cout<<j<<" "<<k<<endl;
			//cout<<dp[n][j][k]<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long a;
  long long b=100;
  int count=0;
  cin >> a;
  
  for(int i=0; i<3760; i++)
  {
    count++;
    b=b*1.01;
    if(b>=a)
      break;
  }
	cout << count <<endl;
}


Measured memory_bytes: 3524
'use strict'
const main = input => {
  const n = parseInt(input[0]), h = input[1].split(' ').map(val => parseInt(val, 10));
  let num = 0, ans = 0;
  for(let i = 0; i < n - 1; i++){
    if (h[i] >= h[i+1]) {
      num++;
    } else {
      num = 0;
    }
    if (ans < num) {
      ans = num;
    }
    // console.log(num);
    
  }
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 17804
#include <bits/stdc++.h>
#define sc1(x) scanf("%d", &x)
#define sc2(x, y) scanf("%lld%lld", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pr(x) printf("%lld\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
ll n, s;
int main()
{
	//freopen("math.in", "r", stdin);
	//freopen("math.out", "w", stdout);
	scanf("%lld%lld", &n, &s);
	if (s == n)
	{
		printf("%lld\n", s + 1);
		return 0;
	}
	if (s > n)
	{
		printf("-1");
		return 0;
	}
	for (ll i = 2; i * i <= n; i++)
	{
		ll q = n, num = 0;
		while (q)
		{
			num += q % i;
			q /= i;
		}
		if (num == s) 
		{
			printf("%lld\n", i);
			return 0;
		}
	} 
	ll y = n - s;
	ll num;
	for (ll i = sqrt(y); i >= 1; i--)
	{
		if (y % i == 0)
		{
			num = y / i + 1;
			ll j = s - i;
			if (i < num && num >= 2 && j < num && j >= 0)
			{
				printf("%lld\n", num);
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll a,b;
	std::cin >> a >> b;
	std::cout << (a*b) << std::endl;
	return 0;
}


Measured memory_bytes: 3636
from collections import Counter
from itertools import groupby


def bin_search(k, greater_count, smaller_sum):
    l = 0
    r = n + 1
    while l < r - 1:
        m = (l + r) // 2
        gc = greater_count[m]
        ss = smaller_sum[m]
        if gc + ss // m >= k:
            l = m
        else:
            r = m
    return l


n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())

# Precompute
greater_count = [0] * (n + 2)  # Number of types of Ai same or greater than i
smaller_sum = [n] * (n + 2)  # Number of Ai smaller than i

remain = greater_count[1] = len(cnt)
total = smaller_sum[1] = 0

cnt_grp = [(c, len(list(itr))) for c, itr in groupby(cnt)]

for (c, l), (c2, _) in zip(cnt_grp, cnt_grp[1:]):
    remain -= l
    total += c * l
    for i in range(c + 1, c2 + 1):
        greater_count[i] = remain
        smaller_sum[i] = total

# print(greater_count)
# print(smaller_sum)

# Query
buf = []
for k in range(1, len(cnt) + 1):
    buf.append(bin_search(k, greater_count, smaller_sum))

buf.extend([0] * (n - len(cnt)))

print(*buf)


Measured memory_bytes: 39256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << endl
using namespace std;
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1) * a % mod;
	else return f1(a * a % mod, p / 2) % mod;
}
int n, a[123456], ans = 1, k;
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> a[i];
		if ((a[i] + 1) / 2 < i - k)//密
			ans = ans * (i - k++) % mod;
	}
	for1(i, n - k) { ans *= i; ans %= mod; }
	puts(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    long long b[n-1],a[n];
    f(i,0,n-1){
        cin>>b[i];
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    f(i,1,n-1){
        if(b[i-1]<b[i]){
            a[i]=b[i-1];
        }
        else{
            a[i]=b[i];
        }
    }
    f(i,0,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
    int N, K, X, Y;
    scanf("%d %d %d %d", &N, &K, &X, &Y);
    int s = 0;
    if(N>K){//料金へんか
        s = (N - K) * Y + K * X;
    }
    else
        s = N * X;


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

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int32_t main() {

    int n, x; cin >> n >> x;
    vector<int> l(n);
    for(int i = 0; i < n; ++i) cin >> l[i];

    int ans = 1, cur = 0;

    for(int i = 0; i < n; ++i) {
        cur += l[i];
        if(cur > x) break;
        ans++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(){
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;
	return 0;
}

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

if a >= k:
  a -= k
  print(str(a)+" "+str(b))

elif a< k and a+b >=k:
  b -= (k-a)
  a = 0
  print(str(a)+" "+str(b))

else:
  a = 0
  b = 0
  print(str(a)+" "+str(b))

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

int main(void){
	queue<int> a,b,d;
	int n, m, k;
	cin >> n;
	for(int i = 0; i < 2 * n; i++){
		d.push(i + 1);
	}
	cin >> m;
	for(int x = 0; x < m; x++){
		cin >> k;
		if(k == 0){
			for(int i = 0; i < n; i++){
				a.push(d.front());
				d.pop();
			}
			for(int i = 0; i < n; i++){
				b.push(d.front());
				d.pop();
			}
			for(int i = 0; i < n; i++){
				d.push(a.front());
				a.pop();
				d.push(b.front());
				b.pop();
			}
		}
		else{
			for(int i = 0; i < k; i++){
				a.push(d.front());
				d.pop();
			}
			while(!a.empty()){
				d.push(a.front());
				a.pop();
			}
		}
	}
	while(!d.empty()){
		cout << d.front() << endl;
		d.pop();
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

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

  for(int i=a; i<=min(a+k-1, b); i++){
    cout << i << endl;
  }

  for(int i=max(b-k+1, a+k); i<=b; i++){
    cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll comb[1005];
ll frac[1005];
ll N, K;

void prepare(){
  ll P[K+1];
  P[0] = 1;
  for(ll i=1;i<=K;++i){
    P[i] = P[i-1] * i;
    P[i] %= mod;
  }
  ll shita1, shita2, tmpshita1, tmpshita2, two, h;
  for(ll k=0;k<=K;++k){
    h = mod - 2;
    shita1 = 1;
    shita2 = 1;
    while(h>0){
      two = 1;
      tmpshita1 = P[K-k];
      tmpshita2 = P[k];
      while(2*two<=h){
        two *= 2;
        tmpshita1 *= tmpshita1;
        tmpshita1 %= mod;
        tmpshita2 *= tmpshita2;
        tmpshita2 %= mod;
      }
      h -= two;
      shita1 *= tmpshita1;
      shita1 %= mod;
      shita2 *= tmpshita2;
      shita2 %= mod;
    }
    comb[k] = P[K]*shita1%mod*shita2%mod;
  }
  h = N;
  ll tmp[K+1];
  for(int i=1;i<=K;++i) frac[i] = 1;
  while(h>0){
    two = 1;
    for(ll i=1;i<=K;++i){
      tmp[i] = i;
    }
    while(2*two<=h){
      two *= 2;
      for(int i=1;i<=K;++i){
        tmp[i] *= tmp[i];
        tmp[i] %= mod;
      }
    }
    h -= two;
    for(int i=1;i<=K;++i){
      frac[i] *= tmp[i];
      frac[i] %= mod;
    }
  }
}

int main() {
  cin>>N>>K;
  prepare();
  ll ans = 0;
  for(int k=0;k<=K;++k){
    if(k%2==0){
      ans += comb[k]*frac[K-k];
    }
    else{
      ans -= comb[k]*frac[K-k];
    }
    ans = (ans+mod)%mod;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <math.h>

using namespace std;
int a, result;
int level, calc;
string w;
int i, j;
bool f;

int times(int level,string w0);
int sum(int level,string w0){
    int buffer=0;
    w=w0;
    while(1){
    
    int k=0;
        while(w[k] == '.'){
        k++;
        }
    if(k == level){
    if(w[k]=='+'){
    cin>>w;
    i++;
    //cout<<buffer<<"  "<<level<<endl;
    buffer+=sum(level+1,w);
    if(i==a-1){return buffer;}
    }
    else if(w[k]=='*'){
    cin>>w;
    i++;
    //cout<<buffer<<"  "<<level<<endl;
    buffer+=times(level+1,w);
    if(i==a-1){return buffer;}
    }
    else if(w[k] != '+' ||w[k] != '*'|| w[k] !='.' ){buffer += (w[k]-'0');
    i++;
    //cout<<i<<endl;
    if(i==a-1){return buffer;}
    cin >> w;
    }
    } 
    else break;
    
    
    }
    return buffer;
}
int times(int level,string w0){
    int buffer=1;
    w=w0;
    while(1){
    
    int k=0;
        while(w[k] == '.'){
        k++;
        }
    if(k == level){
    if(w[k]=='+'){
    cin>>w;
    i++;
    //cout<<buffer<<"  "<<level<<endl;
    buffer*=sum(level+1,w);
    if(i==a-1){return buffer;}
    }
    else if(w[k]=='*'){
    cin>>w;
    i++;
    //cout<<buffer<<"  "<<level<<endl;
    buffer*=times(level+1,w);
    if(i==a-1){return buffer;}
    }
    else if(w[k] != '+' ||w[k] != '*'|| w[k] !='.' ){buffer *= (w[k]-'0');
    i++;
    //cout<<i<<endl;
    if(i==a-1){return buffer;}
    cin >> w;
    }
    } 
    else break;
    
    
    }
    return buffer;
}


        
    
    

int main()
{
    while(1){
    cin >> a;
    if(a==0)return 0;
    result=0;
    i = 0;
    cin>>w;
    if(a==1){
    result = w[0]-'0';
    //cout<<"inta"<<endl;
    }
    if(w == "+") {
        cin>>w;
        //cout<<"sum"<<endl;
        result=sum(1,w);}
    if(w == "*") {
        cin>>w;
        //cout<<"tiim"<<endl;
        result=times(1,w);}
    
    cout << result << endl;
    }
}



Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int main()
{
    long long int n, a[100010], b[100010];
    long long int cnt = 0;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    for (int i = n-1; i >= 0; i--) {
        if ((a[i]+cnt) % b[i]) {
            cnt += b[i] - ((a[i]+cnt) % b[i]);
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <stdio.h> 
 #include <ctype.h> 
 
 
 int main(){ 
     int count[26]={0}; 
     char ch; 
     int i, num; 
 
 
     while(scanf("%c", &ch)!=EOF){ 
         if(islower(ch)){ 
             num=ch-'a'; 
         }else if(isupper(ch)){ 
             num=ch-'A'; 
         }else{ 
             continue; 
         } 
        count[num]++; 
    } 
     for(i=0;i<26;i++){ 
         printf("%c : %d\n", 'a'+i, count[i]); 
     } 
 
 
     return 0; 
 } 



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

#define int long long
#define ld long double

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

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

void solve()
{
       int n;
       cin>>n;
       Vi a(n);
       rep(c,0,n)
       {
              cin>>a[c];
       }
       int s1=0, s2=0;
       rep(c,0,n)
       {
              s1+=(a[c]);
              s1%=M;
       }
       s1=(s1)*(s1);
       s1%=M;
       rep(c,0,n)
       {
              s2+=(((a[c])*(a[c]))%M);
              s2%=M;
       }
       int s=s1-s2;
       if(s<0)
       {
              s+=M;
       }
       if(s%2==0)
       {
              cout<<s/2;
       }
       else
       {
              cout<<(s+M)/2;
       }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}

Measured memory_bytes: 4752
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    if((a + b) % 2 == 0){
        printf("%d", (a + b) / 2);
    }else{
        printf("%d", (a + b) / 2 + 1);
    }
    
}


Measured memory_bytes: 1700
a, b = [int(x) for x in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def factorize(n):
    f = []

    div = 2
    while div ** 2 <= n:
        while n % div == 0:
            f.append(div)
            n //= div
        div += 1

    if n > 1:
        f.append(n)

    return f

g = gcd(a, b)
f = factorize(g)

print(len(set(f)) + 1)


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

int N,N2;

int main(){
  
  int i,j,c=0;
  
  scanf("%d",&N);
  
  int s[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&N2);
  
  int s2[N2];
  
  for(i=0;i<N2;i++){
    scanf("%d",&s2[i]);
  }
  
  
  for(i=0;i<N2;i++){
    for(j=0;j<N;j++){
      if(s2[i]==s[j]){
	c++;
	break;
      }
      }
    }
  

  printf("%d\n",c);
  

  return 0;
}



Measured memory_bytes: 2040
from heapq import heappush, heappop

INF = float("inf")
def dijkstra(E, r):
    D = [INF] * len(E)
    D[r] = 0

    Q = [(0, r)]
    while Q:
        dist, cur = heappop(Q)
        for nxt, cost in E[cur]:
            cand = dist + cost
            if D[nxt] > cand:
                D[nxt] = cand
                heappush(Q, (cand, nxt))

    return D


N, M, S, T, *UVAB = map(int, open(0).read().split())
A = [[] for _ in range(N + 1)]
B = [[] for _ in range(N + 1)]
for u, v, a, b in zip(*[iter(UVAB)] * 4):
    A[u].append((v, a))
    A[v].append((u, a))
    B[u].append((v, b))
    B[v].append((u, b))

A = dijkstra(A, S)
B = dijkstra(B, T)

init = 10 ** 15

ans = []
cur = INF
for a, b in zip(reversed(A[1:]), reversed(B[1:])):
    cur = min(cur, a + b)
    ans.append(init - cur)

for a in reversed(ans):
    print(a)

Measured memory_bytes: 74296
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI cnt(n+1);
    REP(i,2,n+1) {
        int num = i;
        for (int j = 2; j <= num; ++j) {
            if (num % j == 0) {
                cnt[j]++;
                num /= j;
                --j;
            }
        }
    }
    LL ans = 1;
    //REP(i,2,n+1) cout << i << " " << cnt[i] << endl;
    REP(i,2,n+1) {
        ans = (ans * (cnt[i] + 1)) % 1000000007;
    }
    cout << ans << endl;
}

int main() {
    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;
using ll = long long;

int main()
{
    int abc[3], out;
    rep(i, 3)cin >> abc[i];

    sort(abc, abc + 3);

    int dif;

    dif = (abc[2] - abc[0]) + (abc[2] - abc[1]);

    if (dif % 2 == 0) {
        out = dif / 2;
    }

    else {
        out = dif / 2 + 2;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main 
{
    public static void main(String args[])
    {
        String str;
        Scanner sc = new Scanner(System.in);
        while(true){
            str=sc.nextLine();
            if(str.equals("0")) break;
            int sum = 0;
            for(int i=0;i<str.length();i++){
                 sum+=Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
        }
        
    }
}


Measured memory_bytes: 26588
import java.util.*;

public class Main{

  public static int f(int n){
    if(n % 2 == 0){
      return n / 2;
    }else{
      return 3 * n + 1;
    }
  }

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int a = s;
    int n = 0;
    while(s != 4){
      s = f(s);
      n++;
    }
    n++;
    if(a == 1 || a == 2){
      System.out.println(4);
    }else
      System.out.println(n + 3);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
struct box{
	int win,lose;
	string s;
};
int cmp(const box &a,const box &b){
	if(a.win==b.win){
		return a.lose<b.lose;
	}else{
		return a.win>b.win;
	}
}
int main(){
	int n,w,l,p;
	string t;
	vector<box> vec;
	box pre;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>t;
			w=0;
			l=0;
			for(int j=0;j<n-1;j++){
				cin>>p;
				if(p==0)
				w++;
				else if(p==1)
				l++;
			}
			pre.win=w;
		pre.lose=l;
		pre.s=t;
		vec.push_back(pre);
		}
		stable_sort(vec.begin(),vec.end(),cmp);
		for(int i=0;i<n;i++)
		cout<<vec[i].s<<endl;
		vec.clear();
	}
	return 0;
}

Measured memory_bytes: 0
open System
open System.Numerics

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (A,B) = readPair int64 string ()

let B0 = int64 (B.[0..0])
let B1 = int64 (B.[2..2])
let B2 = int64 (B.[3..3])

let tmp = (A*B1) + (A*B2/10L)
(A*B0) + (tmp/10L)
|> printfn "%d"

Measured memory_bytes: 30148
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 3e3+2;
int dp[N][N];
signed main()
{
    fast;
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(s[i-1] == t[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i = n,j=m;
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans.pb(s[i-1]);
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else j--;
    }
    reverse(all(ans));
    cout<<ans;
}

Measured memory_bytes: 70656
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

vector <int> v[2048];
int nr = 0;
bool ap[2048];

void dfs (int nod, int dist, int tata)
{
    if (!ap[nod]) ++nr;

    ap[nod] = true;
    if (!dist) return;

    for (auto &it : v[nod])
        if (it != tata) dfs (it, dist - 1, nod);
}

int main ()
{
 //   freopen ("file.in", "r", stdin);

    int n, k;
    scanf ("%d %d", &n, &k);
    ++k;

    for (int i = 1; i < n; ++i)
    {
        int x, y;
        scanf ("%d %d", &x, &y);

        v[x].push_back (y);
        v[y].push_back (x);
    }

    int mi = 2000000000;
    for (int i = 1; i <= n; ++i)
    {
        nr = 0;
        if (k & 1)
        {
            for (int j = 1; j <= n; ++j)
                ap[j] = false;

            dfs (i, (k - 1) / 2, 0);

            mi = min (mi, n - nr);
        }

        else
        {
            for (auto &it : v[i])
            {
                nr = 0;

                for (int j = 1; j <= n; ++j)
                    ap[j] = false;

                dfs (i, (k - 1) / 2, 0);
                dfs (it, (k - 1) / 2, 0);

                mi = min (mi, n - nr);
            }
        }
    }

    printf ("%d\n", mi);

    return 0;
}


Measured memory_bytes: 384
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string C1, C2;
	std::cin >> C1 >> C2;
	std::reverse(C1.begin(), C1.end());
	if (C1 == C2)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


Measured memory_bytes: 512