akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*DSD=freopen("duliu.in","r",stdin);
	FILE*FAKE=freopen("duliu.out","w",stdout);
#endif
}

const int MAXN=1e5+7;

static int n;

static int a[MAXN],b[MAXN];

inline void init()
{
	read(n);
	static int x;x=0;
	Rep(i,1,n)read(a[i]),x^=a[i];a[n+1]=x;
	x=0;
	Rep(i,1,n)read(b[i]),x^=b[i];b[n+1]=x;
}

static int ans,e;

static tr1::unordered_map<int,int>G;

static int fa[MAXN<<1];

inline int Find(int u){return u==fa[u]?u:fa[u]=Find(fa[u]);}

static int vis[MAXN<<1];

inline void solve()
{
	Rep(i,1,n+1)if(!G[a[i]])G[a[i]]=++e;
	Rep(i,1,n+1)if(!G[b[i]])G[b[i]]=++e;
	Rep(i,1,e)fa[i]=i;
	Rep(i,1,n+1)if(a[i]^b[i])
	{
		vis[G[a[i]]]=vis[G[b[i]]]=1;
		if(i<=n)++ans;
		if(Find(G[a[i]])^Find(G[b[i]]))fa[fa[G[a[i]]]]=fa[G[b[i]]];
	}
	if(!vis[G[a[n+1]]])++ans;
	sort(a+1,a+n+2),sort(b+1,b+n+2);
	Rep(i,1,n+1)if(a[i]^b[i])return(void)puts("-1");
	Rep(i,1,e)if(i==Find(i)&&vis[i])++ans;
	printf("%d\n",ans-1);
}

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


Measured memory_bytes: 6948
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b==15) printf("+\n");
	else if(a*b==15) printf("*\n");
	else printf("x\n");
	return 0;
}

Measured memory_bytes: 3680
local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in ipairs(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

function parse_problem()
    local N = io.read("n")
    local M = io.read("n")
    local goals = {}
    for i=1,M do
        local l, _ = io.read("n")
        table.insert(goals, l)
    end
    return N, M, goals
end

function main()
    local N, M, goals = parse_problem()
    table.sort(goals)
    local INF = 10000000
    local diffs = {}
    for i=1, #goals-1 do
        diffs[i] = goals[i + 1] - goals[i]
    end
    table.sort(diffs)
    dbgpr_t(goals)
    dbgpr_t(diffs)
    if N >= M then
        print(0)
    else
        local sum = 0
        for i=1, M-N do
            sum = sum + diffs[i]
        end
        print(sum)
    end
end
main()


Measured memory_bytes: 4600
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a >= b){
      System.out.println("delicious");
    }else if ((b-a) <= x){
      System.out.println("safe");
    }else{
      System.out.println("dangerous");
    }
  }
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    ll x;
    cin>>x;
    ll year=0;
    ll p=100;
    while(true)
    {
        if(p>=x)
        break;
        
        p=p+(p*1)/100;
        year++;
    }
    cout<<year;
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = int(1e9) + 7

stair = [True] * N
for i in a:
    stair[i-1] = False

# DP
dp = [0] * N
if stair[0]:
    dp[0] = 1
if N >= 2:
    if stair[1]:
        dp[1] = dp[0] + 1
    else:
        dp[1] = 0

for i in range(2, N):
    if not stair[i]:
        dp[i] = 0
        continue
    if stair[i-1] and stair[i-2]:
        dp[i] = (dp[i-1] + dp[i-2])%MOD
    elif stair[i-1]:
        dp[i] = dp[i-1]
    elif stair[i-2]:
        dp[i] = dp[i-2]

print(dp[N-1])

Measured memory_bytes: 81648
module Main (main) where

import qualified Data.ByteString.Char8     as C8

main :: IO ()
main = do
  [x,y] <- readStrings
  print . showAnswer $ solve (x,y)

type Input  = (String, String)
type Output = Ordering

solve :: Input -> Output
solve (x,y) = compare (toInt x) (toInt y)
  where
    toInt "A" = 10
    toInt "B" = 11
    toInt "C" = 12
    toInt "D" = 13
    toInt "E" = 14
    toInt "F" = 15

showAnswer :: Output -> Answer
showAnswer = Compare

-- utils
readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | Compare Ordering

instance Show Answer where
  show (YesNo b)   = if b then "Yes" else "No"
  show (YESNO b)   = if b then "YES" else "NO"
  show (AB b)      = if b then "A"   else "B"
  show (Number i)  = show i
  show (Compare o)
    | o == EQ = "="
    | o == LT = "<"
    | o == GT = ">"

Measured memory_bytes: 380
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

inline int ctoi(char c){
  if(c == '#'){
    return 1;
  }
  else{
    return 0;
  }
}
inline char itoc(int x){
  if(x == 0){
    return '.';
  }
  else{
    return '#';
  }
}

void B(){
  int H,W;
  cin >> H >> W;
  vector<vector<int> > vec(H,vector<int>(W));
  vector<int> Hwise(H);
  vector<int> Wwise(W);
  vector<vector<int> >  sub(H,vector<int> (W));
  int cnt = 0;
  rep(i,H){
    rep(j,W){
      char c;
      cin >> c;
      vec[i][j] = ctoi(c);
    }
  }

  rep(i,H){
    rep(p,W){
    Hwise [i] += vec[i][p];
    }
  }
  rep(j,W){
    rep(q,H){
      Wwise[j] += vec[q][j];
    }
  }

  rep(i,H){
    if(Hwise[i]){// non-zero <-> no erase
      rep(j,W){
        if(Wwise[j]){
          cout << itoc(vec[i][j]);
        }
      }
      cout << endl;
    }
  }
}

int main() {
  B();
}


Measured memory_bytes: 384
# -*- coding : utf-8 -*-

import math

def is_prime_number(num):
    if num == 2:
        return True
    if num < 2 or num % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(num):
        if num % i == 0:
            return False
        i = i + 2
    return True

list_num = int(input())
count_prime = 0
for i in range(list_num):
    num = int(input())
    if is_prime_number(num):
        count_prime = count_prime + 1
print(count_prime)

Measured memory_bytes: 7768
N,M = map(int, input().split())
SC = [list(input().split()) for _ in range(M)]

ans = -1
if N==1:
    for i in range(0,10):
        i_str = str(i)
        pass_cond = True
        for sc in SC:
            s = int(sc[0])
            c = sc[1]

            if s > len(i_str) or i_str[ s-1 ] != c:
                pass_cond = False

        if pass_cond:
            ans  = i
            break
else:
    for i in range(10**(N-1), 10**N):
        i_str = str(i)
        pass_cond = True
        for sc in SC:
            s = int(sc[0])
            c = sc[1]

            if s > len(i_str) or i_str[ s-1 ] != c:
                pass_cond = False

        if pass_cond:
            ans  = i
            break


print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int N, M;
	cin >> N >> M;

	map<int, P> m;
	vector<bool>b(N, false);
	for (int i = 0; i < N;++i) {
		b[i] = false;
		m[i].first = 0;
		m[i].second = 0;
	}
	int wa = 0;
	int ac = 0;
	for (int i = 0; i < M;++i) {
		int p;  string s;
		cin >> p; cin >> s;
		 p--;
		if (!b[p]) {
			if (s == "WA") {
				m[p].second++;
			}
			else{
				ac++;
				wa += m[p].second;
				b[p] = true;
			}
		}
	}

	cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 8832
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 26;
const int D = 365;

int d;

int c[N];
int s[D][N];

vi t;

int last[N];
int evaluate(const vi& t){
    memset(last, 0, sizeof last);
    int ret = 0;
    FOR(i,t.size()){
        ret += s[i][t[i]];
        last[t[i]] = i+1;

        FOR(j,N){
            ret -= c[j] * (i+1 - last[j]);
        }
    }
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>d;
    FOR(i,N)cin>>c[i];
    FOR(i,d){
    	FOR(j,N){
    		cin>>s[i][j];
    	}
    }

    FOR(i,d){
        int x;
        cin>>x;
        t.pb(x-1);
    }

    vi tt;
    FOR(i,d){
        tt.pb(t[i]);
        cout << evaluate(tt) << endl;
    }

    return 0;
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
#include <set>

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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int k;
	cin >> k;
	vector<int>a(k+1);
	a[0]=0;
	rep1(i,k+1){
		 a[i]=(a[i-1]*10+7)%k;
		 if(a[i]==0){
			 print(i);
			 return 0;
		 }
	}
	print(-1);
}

Measured memory_bytes: 7116
n=int(input()) 
s=[]
for i in range(2,int(n**0.5)+1):
    if n%i==0:
        p=0
        while(n%i==0):
            p+=1
            n//=i
        s.append(p)
if n>1:
    s.append(1)
#1print(s)
ans=0
for i in s:
    r=1
    while(i>0):
        if i<r:
            break
        i-=r 
        r+=1
        ans+=1 
print(ans)

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  int n=s.size(),ans=10;
  auto calc=[](string s,int x){
    int n=s.size();
    int ma=0,mi=100;
    for(int i=0;i<n/x;i++){
      for(int j=0;j<x-2;j++)
	if(s[j]!=s[i*x+j]) return 10;
      int k=0;
      if(x>1) k=k*10+(s[i*x+(x-2)]-'0');
      k=k*10+(s[i*x+(x-1)]-'0');
      ma=max(ma,k);
      mi=min(mi,k);
    }
    return ma-mi;
  };
  for(int i=1;i<n;i++){
    if(n%i) continue;
    ans=min(ans,calc(s,i));
  }
  //cout<<ans<<endl;
  int dp[20][n+1];
  memset(dp,-1,sizeof(dp));
  dp[0][0]=19;
  for(int i=0;i<n;i++){
    for(int j=0;j<20;j++){
      if(dp[j][i]<0) continue;
      int k=s[i]-'0';
      //cout<<i<<" "<<j<<":"<<dp[j][i]<<" "<<k<<endl;
      dp[max(j,k)][i+1]=max(dp[max(j,k)][i+1],min(dp[j][i],k));
      if(i+1==n) continue;
      if(i==0&&i+2==n) continue;
      k=k*10+s[i+1]-'0';
      if(k>=20) continue;	       
      //cout<<i<<" "<<j<<":"<<dp[j][i]<<" "<<k<<endl;;
      dp[max(j,k)][i+2]=max(dp[max(j,k)][i+2],min(dp[j][i],k));
    }
  }
  
  //for(int i=0;i<20;i++) cout<<n<<" "<<i<<":"<<dp[i][n]<<endl;
  for(int i=0;i<20;i++)
    if(~dp[i][n]) ans=min(ans,i-dp[i][n]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11112
nums = gets.split.map(&:to_i)
result = 0
s1 = []
s1 << nums[0]
s1 << nums[2]
s2 = []
s2 << nums[1]
s2 << nums[3]
result = s2.min - s1.max if( (s2.min-s1.max)>0 )
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b;
	cin >> a >> b;
	if(a < b){
		rep(i, 1, b){
			cout << a;
		}
		cout << endl;
	}
	else{
		rep(i, 1, a){
			cout << b;
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{


        long long n,m,a,b=2,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mod=1000000007; string str,ttr,ntr;
        long long x=0,y=1,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lld %lld",&n,&k);


        for(i=1;i<=n+8;i++)
        {
            sum=sum+i;  mp[i]=sum;
        }



        for(i=k;i<=n+1;i++)
        {

            d=i;
            p=d-1;  fr=mp[p];

            sc=mp[n]-mp[n-i];  //cout<<fr<<"  "<<sc<<endl;

            tr=sc-fr+1;  ans=(ans+tr)%mod;

        }

        printf("%lld\n",ans);



        return 0;
}





Measured memory_bytes: 16192
#include<cstdio>
#include<cstring>
#include<cstdlib>

int main(){
	char a[10], b[5];
	scanf("%s %s", a, b);
	strcat(a, b);
	int x = atoi(a);
	int i = 3;
	while(i * i < x)
		i++;
	if(i * i == x)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
#define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int pow(int a, int b){
	int res = 1;
	while(b){
		if (b&1) res = (res*a) % MOD;
		a = (a*a) % MOD;
		b /= 2;
	}
	return res;
}
int n, a, b;
int C(int n, int k){
	int cnt = n - max(k, n-k);
	int tu = 1, mau = 1;
	while(cnt){
		mau = (mau*cnt) % MOD;
		tu = (tu*(n-cnt+1)) % MOD;
		cnt--;
	}
	return tu*pow(mau, MOD-2) % MOD;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> a >> b;
	int ans = pow(2, n)-1 - C(n, a) - C(n, b) + 2*MOD;
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>

#define MAX_V 100001

using namespace std;

struct edge { int to; long long cost; };
struct sets {int v, p; long long d; };
vector<edge> tree[MAX_V];
long long depth[MAX_V];

void dfs(int v, int p, long long d) {
    stack<sets> St;
    St.push(sets{v, p, d});

    while (!St.empty()) {
        sets cur = St.top(); St.pop();
        depth[cur.v] = cur.d;
        for (int i = 0; i < tree[cur.v].size(); i++) {
            edge e = tree[cur.v][i];
            if (e.to == cur.p) { continue; }
            St.push(sets{e.to, cur.v, cur.d + e.cost});
        }
    }
}

int main() {
    int N, a, b, c;
    int Q, K, x, y;

    cin >> N;

    for (int i = 0; i < N-1; i++) {
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back(edge{b, c});
        tree[b].push_back(edge{a, c});
    }

    cin >> Q >> K; K--;
    dfs(K, -1, 0);

    for (int i = 0; i < Q; i++) {
        cin >> x >> y;
        x--; y--;
        cout << depth[x] + depth[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 10736
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
#define MAX 100000
 
bool cmp(const int n1, const int n2) {
    return n1 < n2;
}
 
struct Data {
    int num;
    int i;
};
 
int main() {
    int n;
    int minValue = MAX;
    int sortAry[1000];
    Data ary[1000];
    vector<vector<int> > groups;
    int cost = 0;
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        sortAry[i] = ary[i].num = temp;
        minValue = min(minValue, temp);
    }
 
    sort(sortAry, sortAry + n, cmp);
     
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (ary[i].num == sortAry[j]) {
                ary[i].i = j;
                break;
            }
        }
    }
 
    for (int i = 0; i < n; i++) {
        vector<int> group;
        int j = i;
        int s = i;
        while (j != ary[j].i) {
            group.push_back(ary[j].num);
 
            int temp = ary[j].i;
            ary[j].i = j;
            j = temp;
        }
        if (!group.empty()) {
            groups.push_back(group);
        }
    }
 
    for (int i = 0; i < groups.size(); i++) {
        int sum = 0;
        int m = MAX;
        int num = groups[i].size();
 
        for (int j = 0; j < num; j++) {
            sum += groups[i][j];
            m = min(groups[i][j], m);
        }
 
        int c1, c2;
        c1 = sum + (num - 2) * m;
        c2 = sum + (num + 1) * minValue + m;
        cost += min(c1, c2);
    }
 
    cout << cost << endl;
 
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;   
int main(){
    int n,a[30],b[30],c[30],ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(a[i-1]+1==a[i])
            ans+=c[a[i-1]-1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
'use strict';
const main = input => {
  const n = parseInt(input[0].split(' ')[0]), m = parseInt(input[0].split(' ')[1]);
  input.shift();
  // console.log(input);
  
  let py = new Array(m);
  for(let i=0; i<m; i++) {
    py[i] = new Array(4).fill(0);
    input[i] = input[i].split(' ').map(val => parseInt(val, 10));
    py[i] = [input[i][0], input[i][1], i, 0];
  }
  
  // console.log(py);
  py.sort((a,b) => b[0]-a[0]>0?-1:a[0]-b[0]>0?1:b[1]-a[1]>0?-1:a[1]-b[1]>0?1:0);
  // console.log(py);
  let count = 1;
  for(let i=0; i<m-1; i++) {
    py[i][3] = count;
    if (py[i][0]==py[i+1][0]) {
      count++;
    } else {
      count = 1;
    }
  }
  py[m-1][3] = count;
  // console.log(py);
  py.sort((a,b) => b[2]-a[2]>0?-1:a[2]-b[2]>0?1:0);
  // console.log(py);
  for(let i=0; i<m; i++) {
    console.log(("000000"+py[i][0]).slice(-6) + ("000000"+py[i][3]).slice(-6));
    
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 81600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include<stdlib.h>
#include<cmath>
#include<list>
#define ll long long int
#define lll unsigned long long
using namespace std;
int main()
{char c[20];
scanf("%s",c);
if(strcmp(c,"Sunny")==0)
{
    printf("Cloudy\n");
}
else if(strcmp(c,"Rainy")==0)
{
    printf("Sunny\n");
}
else
{
    printf("Rainy\n");
}
return 0;
}


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

constexpr int intMax = (1 << 30) - 1 + (1 << 30);
constexpr int intHalf = intMax / 2; // > 10^9

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> hls(n);
	for (auto& h : hls)cin >> h;
	vector<int> cost_dp(n);
	int minNum;
	cost_dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		minNum = intHalf;
		for (int j = max(0, i - k); j < i; ++j) {
			minNum = min(minNum, cost_dp[j] + abs(hls[i] - hls[j]));
		}
		cost_dp[i] = minNum;
	}

	cout << cost_dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int N,K,a=0;//N为人数 K为要求升高 h每个为人的身高 a记录合格人数
    long h[100001];
    scanf("%d %d",&N,&K);
    for(int i=0; i<N; i++)
    {
        scanf("%ld",&h[i]);
    }
    for(int i=0; i<N; i++)
    {
        if(h[i]>=K)
        {
            a++;
        }
    }

    printf("%d",a);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    
    sort(a.rbegin(), a.rend());
    
    if(n==2){
        cout << a[0]-a[1] << endl;
        return 0;
    }
    if(n==3){
        cout << max(a[0]*2 -a[1] -a[2], a[0]+a[1] - 2*a[2]) << endl;
        return 0;
    }
    
    if(n%2==0){
        ll ans = 0;
        
        rep(i,n){
            if(i<n/2-1) ans += 2*a[i];
            else if(i==n/2-1) ans += a[i];
            else if(i==n/2) ans -= a[i];
            else ans -= 2*a[i];
        }
        cout << ans << endl;
        return 0;
    }
    
    ll ansm = 0, answ = 0;
    
    rep(i,n){
        if(i<n/2-1) answ += 2*a[i];
        else if(i<=n/2) answ += a[i];
        else answ -= 2*a[i];
    }
    
    rep(i,n){
        if(i<n/2) ansm += 2*a[i];
        else if(i<=n/2+1) ansm -= a[i];
        else ansm -= 2*a[i];
    }
    
    cout << max(answ, ansm) << endl;
    
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, m;
	cin >> n >> m;
	vector<int> t(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		t[a-1]++;
		t[b-1]++;
	}
	for (int x : t) {
		cout << x << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
  
    if(s==t) 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<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<vi> dp(n+1, vi(k, 0));
  dp[0][0] = 1;
  rep(i,n){
    rep(j,k){
      dp[i+1][j] |= dp[i][j];
      if (j+a[i] < k) dp[i+1][j+a[i]] |= dp[i][j];
    }
  }
  vector<vi> rdp(n+1, vi(k, 0));
  rdp[n][0] = 1;
  rrep(i,n){
    rep(j,k){
      rdp[i][j] |= rdp[i+1][j];
      if (j+a[i] < k) rdp[i][j+a[i]] |= rdp[i+1][j];
    }
  }
  
  int ans = n;
  rep(i,n){
    int sum = 0;
    int len = min(k,a[i]);
    rep(j,len){
      sum += dp[i][k-1-j];
    }

    rep(j,k){
      if (rdp[i+1][j] && sum) {
	ans--;
	break;
      }
      if (k-1-len-j >= 0) sum += dp[i][k-1-len-j];
      sum -= dp[i][k-1-j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 196096
n=int(input())
hoge=list(map(int,input().split()))
hoge.sort()
hoge.reverse()
flag="A"
alice=0
bob=0
for i in range(n):
  if(flag=="A"):
    alice+=hoge[i]
    flag="B"
  else:
    bob+=hoge[i]
    flag="A"

print(alice-bob)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	long long mn=a*(n-1)+b,mx=b*(n-1)+a;
	cout<<((a>b||(n==1&&a!=b))?0:mx-mn+1);
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    string s; cin >> s;
    for (int i = 0; i < s.length() - 1; i++) if (s[i] == 'A' && s[i + 1] == 'C') {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	p := scanInt()

	es := make([]edge, m)
	g1 := make([][]int, n)
	g2 := make([][]int, n)
	for i := 0; i < m; i++ {
		a := scanInt() - 1
		b := scanInt() - 1
		c := -scanInt() + p
		es[i] = edge{a, b, c}
		g1[a] = append(g1[a], b)
		g2[b] = append(g2[b], a)
	}

	done := make([]bool, n)
	check := make([]bool, n)

	var dfs func(g [][]int, from int)
	dfs = func(g [][]int, from int) {
		if check[from] {
			return
		}
		check[from] = true
		done[from] = true
		for _, to := range g[from] {
			if done[to] {
				continue
			}

			dfs(g, to)
		}
		done[from] = false
	}

	nes := []edge{}
	dfs(g1, 0)
	for _, e := range es {
		if check[e.from] && check[e.to] {
			nes = append(nes, e)
		}
	}
	es = nes
	nes = []edge{}

	check = make([]bool, n)
	dfs(g2, n-1)
	for _, e := range es {
		if check[e.to] && check[e.from] {
			nes = append(nes, e)
		}
	}

	dist := BellmanFord(nes, n, 0)
	if len(dist) == 0 {
		fmt.Fprintln(wr, -1)
		return
	}

	fmt.Fprintln(wr, max(0, -dist[n-1]))
	// debug(dist)
}

type edge struct {
	from, to, co int
}

// BellmanFord function
func BellmanFord(es []edge, n, st int) []int {
	inf := 1<<31 - 1
	dist := make([]int, n)
	for i := 0; i < n-1; i++ {
		dist[i] = inf
	}
	dist[st] = 0
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	for i := 0; i < n-1; i++ {
		for _, e := range es {
			if dist[e.from] == inf {
				continue
			}
			dist[e.to] = min(dist[e.to], dist[e.from]+e.co)
		}
	}
	for _, e := range es {
		if dist[e.from]+e.co < dist[e.to] {
			return []int{}
		}
	}
	return dist
}


Measured memory_bytes: 2304
N, M = map(int, input().split())
L = [[] for i in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
    
import itertools
s = [int(i) for i in range(N)]
count = 0
for p in itertools.permutations(s, N):
#     print("p",p)
    if p[0] == 0:
#         print("Yes")
        flag = True
        for i in range(N-1):
#             print(p[i+1])
#             print(L[p[i]])
            if p[i+1] not in L[p[i]]:
                flag = False
        if flag:
#             print("flag!!")
            count += 1
print(count)

Measured memory_bytes: 3064
X, Y = input().split()

alphabet = ["A", "B", "C", "D", "E", "F"]

if alphabet.index(X) == alphabet.index(Y):
    print("=")
elif alphabet.index(X) < alphabet.index(Y):
    print("<")
elif alphabet.index(X) > alphabet.index(Y):
    print(">")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF
#define endl '\n'

using namespace std;
void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
string s, s2;
int a[100001];
int dp[1001][1001];

int solve(int a, int b)
{
    //cout << a << " " << b << endl;
    if (a < 0)
        return b+1;
    if (b < 0)
        return a+1;

    int &ret = dp[a][b] ;
    if(~ret)    return ret ; 

    ret = min(solve(a - 1, b) + 1 ,
               min(solve(a, b - 1) +1 ,
                   solve(a - 1, b - 1) + (s[a] != s2[b] ) )) ;
    return ret ; 
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast();

    memset(dp, -1, sizeof dp);
    cin>>s>>s2;
    cout << solve(s.length() - 1, s2.length() - 1)<<endl ;

    return 0;
}



Measured memory_bytes: 7244
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    vector<string> c(2);
    cin>>c[0];cin>>c[1];
    for(int i=0;i<3;i++){
        if(c[0][i]!=c[1][2-i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			long X = sc.nextLong();
			long K = sc.nextLong();
			long D = sc.nextLong();
			long absX = Math.abs(X);
			long absD = Math.abs(D);
            long timesk = absX/absD;
            long amari = absX%absD;
            
            if(timesk>K) {
            	System.out.println(absX-K*D);
            	return;
            }
			
            long check = (K-timesk)%2;
            
            if(check==1) {
            	System.out.println(D-amari);
            }else {
            	System.out.println(amari);            	
            }			
	}	
}

Measured memory_bytes: 35760
#include<iostream> 
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
//int main() {
//	int N = 0;
//	int K = 0;
//	int count = 0;
//	cin >> N;
//	cin >> K;
//
//	for (int i = 1; i <= N; i += 2) {
//		count++;
//	}
//
//	if (count < K) {
//		cout << "NO" << endl;
//	}
//	else {
//		cout << "YES" << endl;
//	}
//
//}
int main() {
	int Road[6];
	int count = 0;
	for (int i = 0; i < 6; i+=2) {
		cin >> Road[i];
		cin >> Road[i + 1];
		if (Road[i + 1] == Road[i]) {
			cout << "error" << endl;
			break;
			return 0;
		}
	}

	for (int i = 0; i < 6; i++) {
		for (int j = i+1; j < 6; j++) {
			if (Road[i] == Road[j]) {
				count++;
			}
		}
	}

	if (count == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>

const int N = 100;

void print_array(const int *a, const int n) {
  for (int i = 0; i < n; i++) {
    std::cout << a[i];

    if (i < (n - 1)) {
      std::cout << " ";
    }
  }

  std::cout << std::endl;
}

int main() {
  int n = 0;
  int a[N] = {0};

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  for (int i = 1; i < n; i++) {
    print_array(a, n);
    
    int v = a[i];
    int j = i - 1;

    while ((j >= 0) && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }

    a[j + 1] = v;
  }
  
  print_array(a, n);

  return 0;
}

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

#define Khaled ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lli long long int
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define FOR(i, n) for (i = 0; i < n; i++)
#define FO(i,k,n) for(i = k; i <= n; i++)
#define ALL(arr) arr.begin(), arr.end()
#define PI acos(-1)
#define MAX 1100106
 
using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;

void solve()
{
    lli i, j, n, m, q, b, k, x, a, l;
    cin >> n >> a >> b;
    for(i = 1; n*i <= b; i++) {
        if(n*i >= a && n*i <= b) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
    return;
}

int main()
{
    Khaled
    // freopen("input", "r", stdin);
    // freopen("output" , "w" , stdout);
    int t = 1,i;
    // cin >> t;
    FO(i,1,t) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
import numpy as np
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            #if i != n // i:
                #divisors.append(n//i)
    return divisors
n = int(input())
a_b = sorted(make_divisors(n))
flag = False
for i in a_b:
  if i ** 5 == n:
    print(i, 0)
    break
  else:
    for b in range(-int(np.sqrt(n)), int(np.sqrt(n + 1))):
      if (i+b)**5-b**5 == n:
        print(i + b, b)
        flag = True
        break
  if flag:
    break

Measured memory_bytes: 27072
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio;
cin.tie(NULL);
cout.tie(NULL);
}
/*
bitset<MAX> prime;
void sieve()
{ 
prime.set();
  	prime[0]=0;
  	prime[1]=0;
    for (ll p=2; p*p<=MAX; p++) 
    { 
        if (prime[p] == 1) 
        { 
            for (ll i=p*p; i<=MAX; i += p) 
                prime[i] = 0; 
        } 
    } 
} 
bool comp(vector<ll> a,vector<ll> b)
{
	if(a[0]>b[0])
	return true;
	else if(a[0]<b[0])
	return false;
	else{
		if(a[4]>b[4])
		return true;
		else return false;
	}
}
long long power(long long a,long long b){			//(a^b)%mod
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
long long fact[200005],fact_inv[200005];			//n<=2*10^5+4
void pre(){
    fact[0]=1;
    fact_inv[0]=1;
    for(long long i=1;i<200005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inv[i]=power(fact[i],mod-2);
    }
}
long long ncr(long long n,long long r){
    if(n<0)return 1;
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
 ll exponentiation(ll base,ll exp) //fast modulo exponentiation
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % mod; 
  
    ll t = exponentiation(base, exp / 2); 
    t = (t * t) % mod; 
    if (exp % 2 == 0) 
        return t; 
  
    else
        return ((base % mod) * t) % mod; 
} 
*/
bool check(string x){
	ll n=x.length();
	for(ll i=0;i<=n/2;i++)
	if(x[i]!=x[n-i-1])
	return false;
	return true;
}
int main(){
	sync();
	
	ll t;
	t=1;
	while(t--){
		string x;
		cin>>x;
		ll n=x.length();
		string x1="";
		string x2="";
		for(ll i=1;i<=(n-1)/2;i++)x1+=x[i-1];
		for(ll i=(n+3)/2;i<=n;i++)x2+=x[i-1];
		if(check(x1)==true&&check(x2)==true&&check(x)==true)
		cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
K=[['x','x','x'],
   ['x','x','x'],
   ['x','x','x']]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,j=map(int,input().split())
N=int(input())
B=[]
for _ in range(N):
    B.append(int(input()))

for i in range(N):
  if B[i]==a:
    K[0][0]='o'
  if B[i]==b:
    K[0][1]='o'
  if B[i]==c:
    K[0][2]='o'
  if B[i]==d:
    K[1][0]='o'
  if B[i]==e:
    K[1][1]='o'
  if B[i]==f:
    K[1][2]='o'
  if B[i]==g:
    K[2][0]='o'
  if B[i]==h:
    K[2][1]='o'
  if B[i]==j:
    K[2][2]='o'

if K[0][0]==K[0][1]==K[0][2]=='o' or K[1][0]==K[1][1]==K[1][2]=='o' or K[2][0]==K[2][1]==K[2][2]=='o' or K[1][0]==K[2][0]==K[0][0]=='o' or K[0][1]==K[1][1]==K[2][1]=='o' or K[0][2]==K[1][2]==K[2][2]=='o' or K[0][0]==K[1][1]==K[2][2]=='o' or K[2][0]==K[1][1]==K[0][2]=='o' :
    print('Yes')
else:
  print('No')
            


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define double long double
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment
const double EPS = 1e-10;
const double eps = 1e-10;
double dot(P a, P b){ return real(conj(a)*b);}
double cross(P a, P b){ return imag(conj(a)*b);}
bool eq(double a,double b){return abs(a-b)<eps;}
bool eq(P a,P b){return eq(a.real(),b.real())&&eq(a.imag(),b.imag());}
double getDistanceLP(L s, P p){
 
  assert( !eq( s.first, s.second) );
 
  return abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first));
}
bool isParalell(L a,L b){return  eq(0,cross(a.second-a.first,b.second-b.first));}
 
P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}
 
vector<L> A;
bool check(P a){
  double dis = getDistanceLP(A[0],a);
 
  for(int i=0;i<(int)A.size();i++)
    if(!eq(dis,getDistanceLP(A[i],a))) return 0;
 
  return  1;
}
 
L calc(P o,P a,P b){
  a-=o,b-=o;
  return L(o,(a/abs(a) + b/abs(b)) + o);
}
 
int main(){
  int n;
  while(cin>>n,n){
    A.resize(n);
    for(int i=0,x1,y1,x2,y2;i<n;i++){
      cin>>x1>>y1>>x2>>y2;
      A[i] = L(P(x1,y1),P(x2,y2));
    }
 
 
    if(n<=2){cout<<"Many"<<endl;continue;}
     
    vector<L> B; 
    for(int i=0;i<n;i++)
      for(int j=0;j<i;j++){
    L a = A[i], b = A[j];
 
    if(isParalell(a,b)||B.size()>100)continue;
 
    P o = crossPoint(a,b);
    P va=a.second-a.first;
    P vb=b.second-b.first;
    va /= abs(va);
    vb /= abs(vb);
 
    B.push_back( L( o , o+va+vb) );
    B.push_back( L( o , o+va-vb ) );
 
      }
 
    vector<P> ans;
    for(int i=0;i<(int)B.size();i++)
      for(int j=i+1;j<(int)B.size();j++){
    L a = B[i], b = B[j];
    if(isParalell(a,b)) continue;
    P c = crossPoint(a,b);
    if(check(c)&&(ans.empty()||!eq(ans[0],c))) ans.push_back(c);
 
      }
     
    if(ans.size()>=2) cout<<"Many"<<endl;
    else if(ans.empty()) cout<<"None"<<endl;
    else printf("%Lf %Lf\n",ans[0].real(),ans[0].imag());
  }
  return 0;
}

Measured memory_bytes: 3324
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

char ans[256];
int nans;

int main()
{
    lli n;
    scanf("%lld", &n);
    while(n)
        ans[nans++] = (n+25)%26 + 'a', n=(n-1)/26;
    std::reverse(ans,ans+nans);
    printf("%s\n", ans);
    return 0;
}


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

int main()
{
    int n = 0;                                          //n習慣
    int debt = 100000;                                  //10万借金

    cin >> n;                                           //入力

    for( int i = 0; i < n; i++ )                        //n回繰り返す
    {
        debt = debt * 105 / 100;                             //5%増える
        if( debt % 1000 != 0 )                     //1~999は切り上がる
            debt = ( debt / 1000 + 1 ) * 1000;
    }

    cout << debt << endl;

    return 0;
}


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

struct P
{
	long long m, k;
};

int main() {
	int n;
	cin >> n;
	vector<P> X;
	X.push_back({1000, 0});
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		vector<P> nextX(X);
		nextX.push_back({X[0].m % a, X[0].m / a});
		for (int i = 1; i < X.size(); i++) {
			nextX[0].m = max(nextX[0].m, X[i].m + X[i].k * a);
		}
		X = move(nextX);
	}
	cout << X[0].m << endl;
	return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef pair<long long,pint> p3;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int used[100001],a[100001];
vector<int> v[100001];

void dfs(int x,int color,int k){
  if(used[x]>=k)return;
  if(a[x]==0)a[x]=color;
  used[x]=k;
  rep(i,v[x].size()){
    if(used[v[x][i]]<k-1)
      dfs(v[x][i],color,k-1);
    }
  }

struct query{int v,d,c;};

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,n){
    used[i]=-1;
    a[i]=0;
    }
  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--;y--;
    v[x].push_back(y);
    v[y].push_back(x);
    }
  int t;cin>>t;
  query q[t];
  rep(i,t){
    int x,y,z;
    cin>>x>>y>>z;
    q[i]={x-1,y,z};
    }
  for(int i=t-1;i>=0;i--){
    dfs(q[i].v,q[i].c,q[i].d);
    }
  rep(i,n)cout<<a[i]<<"\n";
  return 0;     
  }

Measured memory_bytes: 8440
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    let l = ['a'..'z'] \\ (map head $ group $ sort s)
    -- 出力
    if null l then putStrLn "None" else putChar $ head l


Measured memory_bytes: 11644
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	vector<ll> arr;
	unordered_map<int,int> freq;
	for (int i = 0; i < n; ++i)
	{
		int temp;
		cin>>temp;
		if(freq[temp]==0)
			arr.pb(temp);
		freq[temp]++;
	}
	sort(arr.begin(), arr.end());
	ll ans=0;
	n=arr.size();
	for (int i = 0; i <n ; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			for (int k = n-1; k >j ; --k)
			{
				 // cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<endl;
				if(arr[i]+arr[j]>arr[k]){
					ans+=(freq[arr[i]]*freq[arr[j]]*freq[arr[k]]);
				}
			}
		}
	}

				
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int a;
string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> s;
    if(a < 3200) cout << "red" << endl;
    else cout << s << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, a;
  cin >> n;
  bool odd = false;
  rep(i, n) {
    cin >> a;
    if (a & 1) odd = true;
  }

  cout << (odd ? "first" : "second") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    cout << N/3;
    return 0;
}

Measured memory_bytes: 256