akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        if(S == "AAA" || S == "BBB")
        {
            WriteLine("No");
        }
        else
        {
            WriteLine("Yes");
        }
        //ReadLine();
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int S, a, b;
  int index = 1;
  vector<int> flag(1000001, false);
  cin >> S;

  a = S;
  flag[a] = true;
  while (1) {
    index++;
    if (a % 2 == 0) {
      b = a / 2;
    } else {
      b = 3 * a + 1;
    }
    if(flag[b] == true){
      cout << index << endl;
      break;
    } else {
      flag[b] = true;
    }
    a = b;
  }

  return 0;
}


Measured memory_bytes: 4224
/*
* @Author: Samson
* @Date:   2018-06-14 14:39:51
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-14 15:11:56
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10;

int n,color[105],d[105];
vector<pair<int,int> > a[105];

void dijkstra()
{
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > que;
	memset(color,0,sizeof color);
	memset(d,INF,sizeof d);
	d[0] = 0;
	que.push(make_pair(0,0));
	while(que.size())
	{
		pair<int,int> p = que.top();
		que.pop();
		int u = p.second;
		color[u] = 1;

		if(d[u] < p.first)	continue;

		for(int i = 0; i < a[u].size(); ++i)
		{
			int v = a[u][i].first;
			if(color[v])	continue;
			if(d[v] > d[u]+a[u][i].second)
			{
				d[v] = d[u]+a[u][i].second;
				que.push(make_pair(d[v],v));
			}
		}
	}
	for(int i = 0; i < n; ++i)
		cout<<i<<' '<< (d[i]==INF?-1:d[i])<<'\n';
}
int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	int u,k,v,w;
	for(int i = 0; i < n; ++i)
	{
		cin>>u>>k;
		for(int j = 0; j < k; ++j)
		{
			cin>>v>>w;
			a[u].push_back(make_pair(v,w));
		}
	}
	dijkstra();
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  string s;
  cin>>n>>s;
  REP(i, s.size()){
    for(char a='A'; a<='Z'; ++a){
      if(a-s[i]==n || s[i]-a==26-n){
        cout<<a;
        break;
      }
    }
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define x first
#define y second

const int N=1e5+5,C=5;
int n,a[N],ans[N];
set<int> rest;
map<int,int> du;

void dfs(int x,int last,set<int> rest){
	if(x>n){
		for(int i=1;i<=n;i++) write(ans[i]),putchar(' ');
		exit(0);
	}
	for(auto i:rest) if(i!=last){
		ans[x]=i;
		set<int> tp=rest;
		tp.erase(i);
		dfs(x+1,a[i],tp);
	}
}

int check(){
	if(du.size()==2) for(auto i:du) if(i.y==rest.size()-1&&rest.count(i.x)) return i.x;
	return 0;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) du[read(a[i])]++,rest.insert(i);
	if(n==2) return write(-1),0;
	int last=0;
	for(int i=1;i<=n-C;i++){
		int cur=check();
		if(cur) ans[i]=cur;
		else{
			auto it=rest.begin();
			if(*it==last) it++;
			ans[i]=*it;
		}
		if(!--du[a[ans[i]]]) du.erase(a[ans[i]]);
		rest.erase(ans[i]);
		last=a[ans[i]];
	}
	dfs(max(1,n-C+1),last,rest);
	write(-1);
}

Measured memory_bytes: 13740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  ll k,a,b,c;
  ll ans=0;
  cin >> a >> b >> c >>k;
  if(k<=a){
    ans =k;
    cout << ans << endl;
    return 0;
  }
  else ans += a;
  
  if(k <=(a+b)){
    cout << ans << endl;
  }
  else cout << a-(k-a-b) << endl;

  
}

Measured memory_bytes: 3596
#include <string>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<pair<int,int> >vpii;
char m[99][99];

char dfs(int i, int j, vpii&v){
	if(m[i][j]=='B')return 1;
	if(m[i][j]=='W')return 2;
	if(m[i][j]=='X')return 0;
	int ret=0;
	v.push_back(make_pair(i,j));
	if(find(v.begin(),v.end(),make_pair(i-1,j))==v.end())ret|=dfs(i-1,j,v);
	if(find(v.begin(),v.end(),make_pair(i+1,j))==v.end())ret|=dfs(i+1,j,v);
	if(find(v.begin(),v.end(),make_pair(i,j-1))==v.end())ret|=dfs(i,j-1,v);
	if(find(v.begin(),v.end(),make_pair(i,j+1))==v.end())ret|=dfs(i,j+1,v);
	return ret;
}

main(){
	int w,h,i,j,k,r,s;
	for(;scanf("%d%d",&w,&h),w;printf("%d %d\n",r,s)){
		r=s=0;
		memset(m,'X',sizeof(m)); //Iron Puyo
		for(i=1;i<=h;i++)scanf("%s",m[i]+1),m[i][w+1]='X',m[i][w+2]=0;
		for(i=1;i<=h;i++)
			for(j=1;j<=w;j++)
				if(m[i][j]=='.'){
					vpii v;
					char x=dfs(i,j,v);
					for(k=0;k<v.size();k++)
					m[v[k].first][v[k].second]=x;
				}
		for(i=1;i<=h;i++)
			for(j=1;j<=w;j++)
				if(m[i][j]==1)r++;
				else if(m[i][j]==2)s++;
	}
}

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

int main(){
  string s,t;
  cin>>s>>t;
  int dif=0,ans=1001;
  rep(i,s.length()-t.length()+1){
    rep(j,t.length())
      if(s[i+j]!=t[j])dif++;
    ans=min(ans,dif);
    dif=0;
  }
  cout<<ans<<endl;

   return 0;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n; cin >> n;
    if (n >= 30) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  string X;
  int i,j;
  int ans=0;
  cin >> X;
  rep(i,X.size()){
    if(X[i]=='C'){
      for(j=i;j<X.size();j++){
	if(X[j]=='F'){
	  ans=1;
	}
      }
    }
  }
  if(ans==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  } 
  return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    ll s; cin>>s;
    if(s==(ll)1000000000000000000){
        cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<0<<" "<<1000000000<<endl;
        return 0;
    }
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<1000000000 - s%(ll)(1000000000)<<" "<<s/1000000000+1<<endl;
    // cout<<(ll)311114771*1000000000-435958503<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<map>

using namespace std;

#define ll long long 

int main(){

    int n;
    cin>>n;
    long double arr[n];


    for(int i=1;i<=n;i++) cin>>arr[i];

    long double dp[n+1][n+1];

    for(int i=0;i<=n;i++) dp[0][i] = 0;
    dp[0][0] = 1;
    for(int i=1;i<=n;i++) dp[i][0] = 1;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = arr[i]*dp[i-1][j-1] + (1-arr[i])*dp[i-1][j];
        }
    }

    cout<<fixed<<setprecision(10)<<dp[n][(n/2)+1];

    return 0;   

}

Measured memory_bytes: 144376
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextLong()
    val op = sc.next()
    val b = sc.nextLong()
    val out = op match {
      case "+" => a + b
      case "-" => a - b
    }
    println(out)
  }
}


Measured memory_bytes: 22204
local bls, brs = bit.lshift, bit.rshift
local mmi, mma = math.min, math.max
local bxor = bit.bxor

local function grayCode(x)
  return bxor(x, brs(x, 1))
end

-- add_func(idx), rm_func(idx), work_func()
local function grayWalk(size, add_func, rm_func, work_func)
  local prv = 0
  local total = bls(1, size) - 1
  local bpos = {}
  for i = 1, size do
    bpos[bls(1, i - 1)] = i
  end
  for i = 1, total do
    local v = grayCode(i)
    if prv < v then
      prv, v = v, v - prv
      add_func(bpos[v])
    else
      prv, v = v, prv - v
      rm_func(bpos[v])
    end
    work_func()
  end
end

local n = io.read("*n")
local v, w = {}, {}
for i = 1, n do
  v[i], w[i] = io.read("*n", "*n")
end
local head_tbl = {}
local box = {}
local ten5 = 100000

local tgt = 0
local weight, val = 0, 0
local tbl = nil
local function add_func(idx)
  weight = weight + w[brs(tgt, idx - 1)]
  val = val + v[brs(tgt, idx - 1)]
end
local function rm_func(idx)
  weight = weight - w[brs(tgt, idx - 1)]
  val = val - v[brs(tgt, idx - 1)]
end
local function work_func()
  if weight <= ten5 then
    tbl[weight] = mma(tbl[weight], val)
  end
end

for i = 512, mmi(n, 1023) do
  tgt = i
  head_tbl[i - 511] = {}
  tbl = head_tbl[i - 511]
  for j = 1, ten5 do
    tbl[j] = 0
  end
  weight, val = 0, 0
  grayWalk(10, add_func, rm_func, work_func)
  for i = 2, ten5 do
    tbl[i] = mma(tbl[i], tbl[i - 1])
  end
end
-- print(os.clock(), collectgarbage("count"))
local q = io.read("*n")
local ans, wlim = 0, 0
local function work_func2()
  if weight <= wlim then
    ans = mma(ans, val)
  end
end
local function work_func3()
  if weight <= wlim then
    ans = mma(ans, val)
  end
  if weight < wlim then
    ans = mma(ans, val + tbl[wlim - weight])
  end
end
for iq = 1, q do
  -- if iq % 10000 == 0 then
  --   print(iq, os.clock())
  -- end
  local pos, wlim_tmp = io.read("*n", "*n")
  wlim = wlim_tmp
  local deg = 0
  do
    local tmp = pos
    while 0 < tmp do
      deg, tmp = deg + 1, brs(tmp, 1)
    end
  end
  if pos < 512 then
    ans = 0
    weight, val = 0, 0
    tgt = pos
    grayWalk(deg, add_func, rm_func, work_func2)
    print(ans)
  elseif pos < 1024 then
    print(head_tbl[pos - 511][wlim])
  else
    deg = deg - 10
    local basepos = pos
    for i = 1, deg do
      basepos = brs(basepos, 1)
    end
    tbl = head_tbl[basepos - 511]
    ans = tbl[wlim]
    weight, val = 0, 0
    tgt = pos
    grayWalk(deg, add_func, rm_func, work_func3)
    print(ans)
  end
end
-- print(os.clock())


Measured memory_bytes: 562840
#include <stdio.h>
int main()

{
	int a, b, c;
	int temp;
	scanf("%d %d %d", &a, &b, &c);

	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}

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

	return 0;
}


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

using namespace std;

int main(void) {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);
    for(int i = 0; i< a; ++i) {
        cin >> A[i];
    }
    for(int i = 0; i< b; ++i) {
        cin >> B[i];
    }
    int les = 1000000;
    for(int i = 0; i< m; ++i) {
        int tmp1, tmp2,tmp3;
        cin >> tmp1 >> tmp2 >> tmp3;
        les = min(les,A[tmp1-1]+B[tmp2-1]-tmp3);
    }
    int tmpmin =  *min_element(A.begin(),A.end()) +  *min_element(B.begin(),B.end());
    les = min(tmpmin,les);
    cout << les << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    int n,k;
    int INF = 1000000007;
    cin >> n >> k;
    vector<int> h(n+1);
    vector<int> dp(n + 1,INF);
    rep(i, n) cin >> h[i + 1];
    dp[1] = 0;

    for (int i = 1; i <= n; i++) {
        int l = min(k, i);
        for (int j = 1; j <= l;j++){
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    int ans = dp[n];
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M 1000000007
#define INF 1000000000000000000
struct SEG{
  ll seg[1<<18];
  SEG(void){for(int i=0;i<1<<18;i++)seg[i]=0;}
  void add(int a,ll x){
      a+=(1<<17)-1;
      seg[a]=(seg[a]+x)%M;
      while(a>0){
          a=(a-1)/2;
          seg[a]=(seg[a*2+1]+seg[a*2+2])%M;
      }
  }
  ll sum(int a,int b,int l,int r,int k){
      if(r<a||b<l)return 0;
      if(a<=l&&r<=b)return seg[k];
      return (sum(a,b,l,(l+r-1)/2,k*2+1)+sum(a,b,(l+r+1)/2,r,k*2+2))%M;
  }
};
ll n,A,B,ae,be,s[100005];
SEG a,b;
int main(void){
    scanf("%lld%lld%lld",&n,&A,&B);
    s[0]=-INF;
    for(int i=1;i<=n;i++)scanf("%lld",s+i);
    a.add(0,1);
    b.add(0,1);
    for(int i=2;i<=n;i++){
        int p=upper_bound(s,s+n+1,s[i]-A)-s;
        if(p-1>=0&&be<=p-1)a.add(i-1,b.sum(be,p-1,0,(1<<17)-1,0));
        p=upper_bound(s,s+n+1,s[i]-B)-s;
        p=min(p,i-1);
        if(p-1>=0&&ae<=p-1)b.add(i-1,a.sum(ae,p-1,0,(1<<17)-1,0));
        if(s[i]<s[i-1]+A)ae=i-1;
        if(s[i]<s[i-1]+B)be=i-1;
    }
    printf("%lld\n",(a.sum(ae,n,0,(1<<17)-1,0)+b.sum(be,n,0,(1<<17)-1,0))%M);
}


Measured memory_bytes: 5120
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef pair<int,int> P;

const double INF = 10000000;
struct Node{
  int x,y;
  vector<int> to;
  vector<double> cost;
  vector<int> root;
};
int N,M;
int V;
Node G[1001];
int d[1001];
bool visit[1001];

inline double dist(Node a, Node b){
  return sqrt((double)((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)));
}

void init(){
  for(int i=1; i<=1001; ++i){
    G[i-1].root.clear();
    d[i-1] = INF;
    visit[i-1] = false;
  }
}
void makeEdge(){
  for(int i=1; i<=N; ++i){
    G[i].to.clear();
    G[i].cost.clear();
    for(int j=1; j<=N; ++j){
      if(i == j) continue;
      if(dist(G[i],G[j]) <= 50){
//        printf("%d -> %d dist::%d \n",i,j,dist(G[i],G[j]));
        G[i].to.push_back(j);
        G[i].cost.push_back(dist(G[i],G[j]));
      }
    }
//    printf("%d\n",G[i].to.size());
  }
}

void dijkstra(int e){
  int cnt = 1;
  while(cnt <= N){
    double m = INF;
    vector<int> m_r;
//    printf("cnt:%d\n",cnt);
    for(int i=1; i<=N; ++i){
      if(visit[i] == false) continue;
      for(int j=0;j<G[i].to.size();++j){
        if(visit[G[i].to[j]] == true) continue;
//        printf("%d->%d\n",i,G[i].to[j]);
        if(d[i] + G[i].cost[j] < m){
          m = d[i] + G[i].cost[j];
          m_r.assign(G[i].root.begin(), G[i].root.end());;
          m_r.push_back(G[i].to[j]);
          
        }
      }
    }
    if(m == INF) break;
    G[m_r.back()].root.assign(m_r.begin(), m_r.end());
    d[m_r.back()] = m;
    visit[m_r.back()] = true;
//    printf("%d  (cost:%lf)\n",m_r.back(),m);

    if(m_r.back() == e){
      cout << G[m_r.back()].root[0];
      for(int i=1; i<G[m_r.back()].root.size(); ++i){
        cout << " " << G[m_r.back()].root[i];
      }
      cout << endl;
      return;
    }
    cnt++;
  }
  cout << "NA" << endl;
  return;
}

int main(){
  while(cin >> N && N){
    for(int i=1; i<=N; ++i){
      int id;
      cin >> id;
      cin >> G[id].x >> G[id].y;
    }
    makeEdge();
    
    cin >> M;
    
    for(int i=1; i<=M; ++i){
      init();
      int s,e;
      cin >> s >> e;
      visit[s] = true;
      d[s] = 0;
      G[s].root.push_back(s);
      dijkstra(e);
    }
    
  }
  return 0;
}

Measured memory_bytes: 1312
using System.Text;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var q = int.Parse(Console.ReadLine().Trim());
        var sb = new StringBuilder();
        for (int i = 0; i < q; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var Lb = LowerBound(a, k);
            var ub = UpperBound(a, k);
            sb.Append(string.Format("{0} {1}\n", Lb, ub));
        }
        Console.Write(sb);
    }
    public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int UpperBound<T>(T[] arr, T value) => UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    static int LowerBound<T>(T[] arr, T value) where T : IComparable => LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}




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

const int p[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
int x;

int main(){
  cin >> x;
  int res = 0;
  for(int i = 2; i <= 31; i++){
    int num = pow(i, 2);
    while(num <= x){
      res = max(num, res);
      //cerr << num << endl;
      num *= i;
    }
  }
  if(x <= 3){
    res = 1;
  }
  cout << res << endl;
}


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

def shellSort(A, n):
    cnt = 0
    
    G = [1]
    flag=True
    while flag:
        g = G[0]*3+1
        if g < n:
            G = [g] + G
        else:
            flag=False
    m = len(G)
    
    for i in range(m):
        tmp_cnt,tmp_A = insertionSort(A, n, G[i])
        cnt += tmp_cnt
    print(m)
    G_str = (list(map(lambda x:str(x),list(G))))
    print(" ".join(G_str))
    print(cnt)
    for a in A:
        print(a)
    #print(A)
    
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A, n)


Measured memory_bytes: 45516
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	string S;

	cin >> S;

	if(S[0]!=S[1] || S[1]!=S[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



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

int main(){
  string s, p;
  cin >> s >> p;
  s += s;

  string ans = "No";
  for (int i = 0; i < s.size(); i ++) {
    if (s.substr(i, p.size()) == p) {
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3216
import Data.Array.IO
import Control.Monad

main = do
  s <- getLine
  let [n,m] = map (read::String->Int) . words $ s
  s <- replicateM n getLine
  t <- replicateM m getLine

  let mult x = show $ sum $ zipWith (*) (map (read::String->Int) . words $ x) (map (read::String->Int) $ t)
  mapM_ putStrLn $ map mult s

Measured memory_bytes: 7436
#include<iostream>
using namespace std;
long long int dp[102][100003];
long long int n;
long long int w[103], v[103];
long long int ks(long long int idx, long long int u)
{
	if(u < 0)
	return -100000000000000;
	if(u == 0)
	return 0;
	if(idx == n)
	return 0;
	if(dp[idx][u] != -1)
	return dp[idx][u];
	
long long int p1 = v[idx]+ks(idx+1, u-w[idx]);
long long int p2 = ks(idx+1, u);

return dp[idx][u] = max(p1, p2); 
}
main(){

long long int u;
cin >> n >> u;
long long int i;
for(i=0;i<n;i++)
cin >> w[i] >> v[i] ;
for(i=0;i<100002;i++)
for(long long int j=0;j<102;j++)
dp[j][i] = -1;
cout << ks(0, u);

return 0;
}


Measured memory_bytes: 80000
#include<iostream>
using namespace std;
int main() {
    string s;
    int days;
    cin >> s;

    if(s == "SUN") days = 7;
    else if(s == "MON") days = 6;
    else if(s == "TUE") days = 5;
    else if(s == "WED") days = 4;
    else if(s == "THU") days = 3;
    else if(s == "FRI") days = 2;
    else if (s == "SAT") days = 1;

    cout << days << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db ERR = 1e-8;
const int MAXN = 1e7;

int main(int argc, char const *argv[]){
    int a[5];
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    int ans=0;
    int t=a[1]-a[0];
    ans+=t/2;
    a[0]+=(t/2)*2;
    if(a[0]==a[1]){
        ans+=a[2]-a[1];
    }
    else{
        ans+=a[2]-a[0]+1;
    }
    printf("%d\n",ans);
    return 0;
}


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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=5e4+10, lg=21, mod=998244353, inf=1e18;

ll n,m,q,par[maxn],A[maxn],B[maxn],C[maxn],comp;
ll gpar(ll v){return par[v]==v ? v:par[v]=gpar(par[v]);}
void mrg(ll v,ll u){
	v=gpar(v), u=gpar(u);
	if(v==u) return;
	comp--;
	par[v]=u;
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	iota(par,par+maxn,0);
	cin>>n>>m>>q; comp=n;
	for(int i=0;i<q;i++){
		cin>>A[i]>>B[i]>>C[i];
		if(C[i] && m==n-1) return cout<<"No",0;
		if(!C[i]) mrg(A[i],B[i]);
	}
	if(m==n-1) return cout<<"Yes",0;
	for(int i=0;i<q;i++)if(C[i] && gpar(A[i])==gpar(B[i])) return cout<<"No",0;
	cout<<(m<=n-comp+comp*(comp-1)/2 ? "Yes":"No");
	
	return 0;
}



 


Measured memory_bytes: 6788
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1234576891234601LL;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

bool dp[1001][1001][2];

int main() {
	for (int k = 1; k <= 1000; k++)
		for (int e = 0; e <= k; e++)
			for (int x = 0; x <= 1; x++) {
				int o = k - e;
				dp[e][o][x] = (k == 1);
				if (e >= 2 && !dp[e - 1][o][!x]) dp[e][o][x] = true;
				if (o >= 2 && !dp[e + 1][o - 2][x]) dp[e][o][x] = true;
				if (e && o && !dp[e - 1][o][!x]) dp[e][o][x] = true;
				if (x && !dp[e][o][!x]) dp[e][o][x] = true;
			}
	int N; cin >> N;
	int M = 0;
	union_find uf(N);
	for (int u = 0; u < N; u++) {
		string s; cin >> s;
		for (int v = u + 1; v < N; v++)
			if (s[v] == 'Y') {
				M++;
				uf.unite(u, v);
			}
	}
	int e = 0, o = 0, unko = 0;
	for (int u = 0; u < N; u++)
		if (uf.find(u) == u) {
			int n = uf.size(u);
			if (n % 2 == 0) e++;
			else o++;
			unko += n * (n - 1) / 2;
		}
	bool ok = dp[e][o][(unko - M) % 2];
	cout << (ok ? "Taro" : "Hanako") << endl;
}

Measured memory_bytes: 5184
l1 :: String -> Bool
l1 ('A':xs) = True
l1 _ = False

l2 :: String -> Bool
l2 (_:_:xs) = length (filter ('C'==) a) == 1
    where
        a = (tail. reverse) xs

l3 :: String -> Bool
l3 = all (`elem` ['a'..'z']) . filter (not . flip elem ['A', 'C'])

main = do
    x <- getLine
    putStrLn $ if l1 x && l2 x && l3 x  then "AC" else "WA"


Measured memory_bytes: 380
import java.util.*;

public class Main {
    static ArrayList<Path>[] graph;
    static int n;
    static int k;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		graph = new ArrayList[n];
		for (int i = 0; i < n; i++) {
		    graph[i] = new ArrayList<Path>();
		}
		Path[] colors = new Path[n - 1];
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    Path p = new Path();
		    colors[i] = p;
		    graph[a].add(p);
		    graph[b].add(p);
		}
		for (int i = 0; i < n; i++) {
		    k = Math.max(k, graph[i].size());
		}
		for (int i = 0; i < n; i++) {
		    TreeSet<Integer> used = new TreeSet<>();
		    for (Path p : graph[i]) {
		        if (p.color != 0) {
		            used.add(p.color);
		        }
		    }
		    int c = 1;
		    for (Path p : graph[i]) {
		        if (p.color == 0) {
		            while (used.contains(c)) {
		                c++;
		            }
		            p.color= c;
		            c++;
		        }
		    }
		}
		StringBuilder sb  = new StringBuilder();
		sb.append(k).append("\n");
		for (int i = 0; i < n - 1; i++) {
		    sb.append(colors[i].color).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path {
	    int color = 0;
	}
}


Measured memory_bytes: 98340
import sys;sys.setrecursionlimit(10**6)
    #双方向に連結しろ！！！！！！！
from collections import *
    #双方向に連結しろ！！！！！！！
d=defaultdict(list)
    #双方向に連結しろ！！！！！！！
n=int(input())
    #双方向に連結しろ！！！！！！！
start=float("inf")
    #双方向に連結しろ！！！！！！！
for i in range(n-1):
    #双方向に連結しろ！！！！！！！
    a,b=map(int,input().split())
    #双方向に連結しろ！！！！！！！
    d[a].append(b)
    #双方向に連結しろ！！！！！！！
    d[b].append(a)
    #双方向に連結しろ！！！！！！！
    start=min(start,a)
    #双方向に連結しろ！！！！！！！
*p,=sorted(map(int,input().split()))
    #双方向に連結しろ！！！！！！！
ans=[0 for i in range(n)]
    #双方向に連結しろ！！！！！！！
def DFS_dict(point,TFlist):
    #双方向に連結しろ！！！！！！！
    if all(TFlist):
    #双方向に連結しろ！！！！！！！
        return 1
    #双方向に連結しろ！！！！！！！
    for i in d[point]:
    #双方向に連結しろ！！！！！！！
        if TFlist[i-1]:
    #双方向に連結しろ！！！！！！！
            continue
    #双方向に連結しろ！！！！！！！
        TFlist[i-1]=True
        ans[i-1]=p.pop()
    #双方向に連結しろ！！！！！！！
        DFS_dict(i,TFlist)
    #双方向に連結しろ！！！！！！！
        TFlist[i-1]=False
    #双方向に連結しろ！！！！！！！
    return ans
    #双方向に連結しろ！！！！！！！
TFlist=[False]*n
    #双方向に連結しろ！！！！！！！
TFlist[start-1]=True
    #双方向に連結しろ！！！！！！！
score=sum(p)-max(p)
    #双方向に連結しろ！！！！！！！
ans[start-1]=p.pop()
    #双方向に連結しろ！！！！！！！
ans=DFS_dict(start,TFlist)
    #双方向に連結しろ！！！！！！！
print(score)
    #双方向に連結しろ！！！！！！！
print(*ans)

Measured memory_bytes: 11416
#include <queue>
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int H, W, ax, ay, bx, by, x[53][53], dp[53][53][53][53];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int main() {
	while(cin >> W >> H >> ax >> ay >> bx >> by) {
		for(int i = 0; i < H + 2; i++) {
			for(int j = 0; j < W + 2; j++) {
				x[i][j] = 1;
				if(i && i != H + 1 && j && j != W + 1) cin >> x[i][j];
			}
		}
		memset(dp, -1, sizeof(dp)); dp[ay][ax][by][bx] = 0;
		queue<vector<int> > que; que.push({ax, ay, bx, by});
		bool flag = false;
		while(!que.empty()) {
			vector<int> v1 = que.front(); que.pop();
			for(int i = 0; i < 4; i++) {
				vector<int> v2 = v1;
				if(!x[v1[1] + dy[i]][v1[0] + dx[i]]) v2[0] += dx[i], v2[1] += dy[i];
				if(!x[v1[3] - dy[i]][v1[2] - dx[i]]) v2[2] -= dx[i], v2[3] -= dy[i];
				if(v2[0] == v2[2] && v2[1] == v2[3]) {
					flag = true; break;
				}
				if(dp[v2[1]][v2[0]][v2[3]][v2[2]] == -1) {
					dp[v2[1]][v2[0]][v2[3]][v2[2]] = dp[v1[1]][v1[0]][v1[3]][v1[2]] + 1;
					que.push(v2);
				}
			}
			if(flag) {
				cout << dp[v1[1]][v1[0]][v1[3]][v1[2]] + 1 << endl; break;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
}

Measured memory_bytes: 34556
import math
from functools import reduce
import itertools
import numpy as np

def solve():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n-2):
        if s[i:i+3] == "ABC":
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 12464
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

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


Measured memory_bytes: 592
#include <stdio.h>

int main(){
    
    long long n;
    long long sum = 0;
    scanf("%lld", &n);
    
    for(long long i = 1 ; i <= n ; i++){
    	if(i%3 != 0 && i%5 != 0){
    		sum+=i;
		}
	}
    printf("%lld\n", sum);
    
    return 0;
}


Measured memory_bytes: 1732
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int N, K, A[110];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> K;
	for (int i = 0; i < K; ++i)
	{
		int v;
		cin >> v;
		for (int j = 0; j < v; ++j)
		{
			int t;
			cin >> t;
			A[t] = 1;
		}
	}
	cout << count(A + 1, A + N + 1, 0);
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#define INF 1000000000

using namespace std;

struct edge{int to,cost;};
typedef pair<int,int> P;

int v,e,r;
int s[500003],t[500003],c[500003];
int d[100003];
vector<edge> G[500003];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+v,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p=que.top(); que.pop();
    int u=p.second;
    if(d[u]<p.first) continue;
    for(int i=0;i<G[u].size();i++){
      edge e=G[u][i];
      if(d[e.to]>d[u]+e.cost){
        d[e.to]=d[u]+e.cost;
        que.push(P(d[e.to],e.to));
      }}}}


int main(){
  scanf("%d%d%d",&v,&e,&r);
  for(int i=0;i<e;i++){
    scanf("%d%d%d",&s[i],&t[i],&c[i]);
    edge tmp={t[i],c[i]};
    G[s[i]].push_back(tmp);
  }


  dijkstra(r);

  for(int i=0;i<v;i++){
    if(d[i]==INF) printf("INF\n");
    else printf("%d\n",d[i]);
  }
  return 0;

}

Measured memory_bytes: 26532
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        NX N = NextLong(), M = NextLong();
        NX[] a = LineLong();
        NX lcm = a[0] / 2;
        for (int i = 1; i < N; i++) lcm = LCM(lcm, a[i] / 2);
        NX gcd = a[0] / 2;
        for (int i = 1; i < N; i++) gcd = GCD(gcd, a[i] / 2);
        if (lcm / gcd % 2 == 0) Console.WriteLine(0);
        else Console.WriteLine(Math.Ceiling((M / lcm) / 2.0));
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    public static long GCD(long a, long b)
    {
        if (a < b) GCD(b, a);
        long d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(long a, long b)
    {
        return a / GCD(a, b) * b;
    }

    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 27484
# -*- coding: utf-8 -*-
n=raw_input()
ina=int(n)
des=0
for x in range(26):
    for y in range(16):
        ans=4*x+7*y
        if ans==ina:
            des=des+1
if des>0:
    print "Yes"
else:
    print"No"


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

int main(){
  int k;
  long long ans = 0;
  cin >> k;

  for(int i=1; i<=k; i++){
    for(int j=1; j<=k; j++){
      for(int o=1; o<=k; o++){
    	int ij = gcd(i, j);
    	//cout << gcd(ij, o);
        ans += gcd(ij, o);
      }
    }
  }
  cout << ans;
}

int gcd(int p, int q){
  if(p % q == 0)return q;
  return (gcd(q, p%q));
}

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

int main() {
    int N,R;
    cin >> N >> R;
    int ans = 0;
    if (N>=10) {
        ans = R;
    }
    else {
        ans = R+100*(10-N);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(){
int n[4];
int i;
scanf("%d%d%d%d",&n[0],&n[1],&n[2],&n[3]);

for(i=0;i<4;i++){
 if(n[i] == 1) break;
}
if(i>=4){printf("NO\n"); return 0;}

for(i=0;i<4;i++){
 if(n[i] == 9) break;
}
if(i>=4){printf("NO\n"); return 0;}

for(i=0;i<4;i++){
 if(n[i] == 7) break;
}
if(i>=4){printf("NO\n"); return 0; }

for(i=0;i<4;i++){
 if(n[i] == 4) break;
}
if(i>=4){printf("NO\n"); return 0;}

printf("YES\n");
return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    ll n, a[100010], S = 0, ev_fw[50005] = {}, od_fw[50005]= {}, ev_bk[50005] = {}, od_bk[50005] = {};
    cin >> n;
    int m = n/2;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        S += a[i];
    }
    for (int i = 0; i < m; i++)
    {
        ev_fw[i+1] = ev_fw[i] + a[2*i];
        od_fw[i+1] = od_fw[i] + a[2*i+1];
        ev_bk[i+1] = ev_bk[i] + a[n-1-2*i];
        od_bk[i+1] = od_bk[i] + a[n-2*i-2];
     }
    ev_fw[m+1] = ev_fw[m] + a[n-1];
    ev_bk[m+1] = ev_bk[m] + a[0];

    for (int i = 0; i < m; i++)
    {
        cout << S - 2*ev_fw[i] -2*od_bk[m-i] << " " << S - 2*od_fw[i] -2*ev_bk[m-i] << " " ;
    }
    cout << S - 2*ev_fw[m] -2*od_bk[0] << endl;
    //cout << ev_fw[0] << " " << od_bk[1];


    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
vector<long long>a;
map<long long,long long>d;
int n;
int main(){
    int i,j;
    long long sum=0,num=0;
    cin>>n;
    d[0]=1;
    for(i=0;i<n;i++){
        long long m;
        cin>>m;
        a.push_back(m);
    }
    for(i=0;i<n;i++){
        num+=a[i];
        if(d[num]!=0){
            sum+=d[num];
            d[num]++;
        }
        else
            d[num]=1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 14320
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	
	int a[26] = {};
	for (int i = 0; i < n; i++) {
		a[s[i] - 'a']++;
	}
	
	const int mod = 1'000'000'007;
	long long ans = 1;
	for (int i = 0; i < 26; i++) {
		ans *= a[i] + 1;
		ans %= mod;
	}
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = a * b;
        int d = 2 * (a + b);

        String s = String.valueOf(c + " " + d);
        System.out.println(s);

    }
}

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

int main() {
	while (1) {
		int x, y, s;
		int ans = 0;
		cin >> x;
		cin >> y;
		cin >> s;
		if ( s == 0 ) break;
		for ( int i = 1; i < 999; i++ ) {
			for ( int j = 1; j < 999; j++ ) {
				if ( i * ( 100 + x ) / 100 + j * ( 100 + x ) / 100 == s ) {
					if ( i * ( 100 + y ) / 100 + j * ( 100 + y ) / 100 > ans ) ans = i * ( 100 + y ) / 100 + j * ( 100 + y ) / 100;
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
N = int(input())
s = []
for _ in range(N):
    s.append(input().rstrip())
M = int(input())
t = []
for _ in range(M):
    t.append(input().rstrip())
from collections import Counter
cs = Counter(s)
ct = Counter(t)
ans = {}
for i in cs.keys():
    ans[i] = cs[i] - ct[i]
ans_max = max(ans.values())
print(max(0, ans_max))

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  char prev = s[0];
  int count = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != prev) {
      count++;
      prev = s[i];
    }
  }
  
  cout << count;
  return 0;
}

Measured memory_bytes: 512
from math import ceil


def main():
    passengers, capacity, waiting_limit = map(int, input().split())
    arrive_time = [int(input()) for _ in range(passengers)]
    arrive_time.sort()
    count = 0
    waiting = 0
    waiting_since = -1
    for t in arrive_time:
        if waiting_since > 0 and waiting_since + waiting_limit < t or capacity <= waiting:
            count += ceil(waiting / capacity)
            waiting = 0
            waiting_since = -1
        waiting += 1
        if waiting_since < 0:
            waiting_since = t
    count += ceil(waiting / capacity)
    print(count)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, X, T; cin >> N >> X >> T;



  cout << (N+X-1)/X*T << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int N , A , B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int a = 0 , b = 0;
    for(int i = 0; i < N; i++){
        if(S.at(i) == 'a' && a + b < A + B){
            cout << "Yes" << endl;
            a++;
        }
        else if(S.at(i) == 'b' && a + b < A + B && b < B){
            cout << "Yes" << endl;
            b++;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
int main()
{
	FastIO;
	long long int r,d,x;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++)
	{
		cout<<r*x-d<<"\n";
		x=r*x-d;
	}
}

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

#define INF 2147483647

void initRMQ(int);
void update(int, int);
int findMin(int, int);
int query(int, int, int, int, int);

int n;
int D[1000000];

int main(){
  int n_, q, k, a, b, com, ans;

  cin >> n_ >> q;
  initRMQ(n_);

  for(int i = 0; i < q; ++i){
    cin >> com >> a >> b;
    if(com == 0) update(a, b);
    else {
      ans = findMin(a, b);
      cout << ans << endl;
    }
  }


  return 0;
}

void initRMQ(int n_){
  n = 1;
  while(n < n_) n *= 2;

  for(int i = 0; i < 2*n-1; ++i) D[i] = INF;
}

void update(int k, int a){
  k += n - 1;
  D[k] = a;
  while(k > 0){
    k = (k - 1) / 2;
    D[k] = min(D[k*2+1], D[k*2+2]);
  }
}

int findMin(int a, int b){
  return query(a, b+1, 0, 0, n);
}

int query(int a, int b, int k, int l, int r){
  int vl, vr;

  if(r <= a || b <= l) return INF; // case 1
  if(a <= l && r <= b) return D[k]; // case 2

  // case 3
  vl = query(a, b, k*2+1, l, (l + r)/2);
  vr = query(a, b, k*2+2, (l + r)/2, r);
  return min(vl, vr);
}



Measured memory_bytes: 4088
import scala.io.StdIn.readLine

case class Dice(var d:Array[String]) {

  def rollOnce(dir:Char)  =
    dir match {
      case 'S' => Array(4,0,2,3,5,1)
      case 'N' => Array(1,5,2,3,0,4)
      case 'W' => Array(2,1,5,0,4,3)
      case 'E' => Array(3,1,0,5,4,2)
    }

  def roll(dirs:String) = d = dirs.foldLeft(Array(0,1,2,3,4,5)) { (x,y) => rollOnce(y).map(x) }.map(d)

  override def toString() = d(0)
}

object Main extends App {
  val faces = readLine.split(" ")
  val dice = Dice(faces)
  dice.roll(readLine)

  println(dice)
}

Measured memory_bytes: 43976
import math


def solve(N, As, Bs):
    sa = sum(As)
    sb = sum(Bs)
    if sa > sb:
        return "No"
    splus = sum([math.ceil((b - a) / 2) for a, b in zip(As, Bs) if b - a >= 0])
    if sa + splus > sb:
        return "No"
    else:
        return "Yes"

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    Bs = list(map(int, input().split(" ")))
    print(solve(N, As, Bs))


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string n;
  int count =0;
  cin >>n;
  int a;
  a = n.size();
  for (int i=0;i<(n.size()/2);i++){
    if(n[i] != n[a-i-1]){
        count+=1;
    }
  }    
  cout << count << endl;
  

}

Measured memory_bytes: 256
def D_Lamp():
    import numpy as np
    # input & init
    h, w = map(int, input().split())
    S = np.array([list(input()) for _ in range(h)]) == "."
    L = np.zeros((h,w), dtype=int)
    R = np.zeros((h,w), dtype=int)
    U = np.zeros((h,w), dtype=int)
    D = np.zeros((h,w), dtype=int)
    # calc row
    for row in range(h):
        D[row] =(D[row - 1] + 1) * S[row]
        U[-row - 1] = (U[-row] + 1) * S[-row -1]
    # calc col
    for col in range(w):
        R[:, col] = (R[:, col - 1] + 1) * S[:, col]
        L[:, -col - 1] = (L[:, -col] + 1) * S[:, -col-1]
    num_max = 0
    print(np.max(L+R+U+D) - 3)

if __name__ == "__main__":
    D_Lamp()

Measured memory_bytes: 221872
import java.util.Scanner;

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

    int n = scanner.nextInt();
    int[] d = new int[4];
    int i = 0;
    while (n > 0) {
      d[i] = n % 10;
      i++;
      n /= 10;
    }
    for (int j = -1; j < 2; j += 2) {
      for (int k = -1; k < 2; k += 2) {
        for (int l = -1; l < 2; l += 2) {
          if (d[3] + d[2] * j + d[1] * k + d[0] * l == 7) {
            System.out.printf("%d%c%d%c%d%c%d=7\n", d[3], j < 0 ? '-' : '+', d[2],
                k < 0 ? '-' : '+', d[1], l < 0 ? '-' : '+', d[0]);
            return;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 23252
import java.util.Scanner;
public class Main {
   public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String checker = "abcdefghijklmnopqrstuvwxyz";
      int leng = checker.length();
      String answer="None";

      String checks[] = new String[leng];
      for(int i=0;i<leng;i++){
         checks[i] = checker.substring(i,i+1);
      }
      
      for(int i=0;i<leng;i++){
         if(s.indexOf(checks[i])==-1){

            answer = checks[i];
            break;
         }else{
            continue;
         }
      }
      System.out.println(answer);
}
}

Measured memory_bytes: 24264