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

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >

const int M = 107;
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

ll a, b, ans;
int p1, p2;
vector < ll > v1, v2;

main(){
    cin >> a >> b;
    for (int i = 2; i <= sqrt(a); i++){
        if (a % i == 0)
            v1.pb(i);
        while (a % i == 0)
            a /= i;
    }
    if (a > 1)
        v1.pb(a);
    for (int i = 2; i <= sqrt(b); i++){
        if (b % i == 0)
            v2.pb(i);
        while (b % i == 0)
            b /= i;
    }
    if (b > 1)
        v2.pb(b);
    while (p1 != v1.size() && p2 != v2.size()){
        if (v1[p1] == v2[p2]){
            ans++;
            p1++;
            p2++;
        }
        else if (v1[p1] < v2[p2])
            p1++;
        else
            p2++;
    }
    cout << ans + 1;
}


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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg ll a = read(), b = read(), c = read(), d = read();
    reg ll res = c * d / __gcd(c, d);
    reg ll num1 = b / c - (a - 1) / c;
    reg ll num2 = b / d - (a - 1) / d;
    reg ll num3 = b / res - (a - 1) / res;
    cout << b - a + 1 - num1 - num2 + num3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{ 

 int a=0;

 int W,H,x,y,r=0;

 
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);



if(x-r>=0&&x+r<=W){
 if(y-r>=0&&y+r<=H){

   a=1;


  }


}


else{


 a=0;


}


if(a==1){


 printf("Yes\n");


}


else if(a==0){


 printf("No\n");


}


return 0;


}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e5;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ld pi = 6.28318530717958623200/2.0;
    ll r;cin>>r;
    cout<<2.0*pi*r<<"\n";
    
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> a >> b;
  while(a>=b){
   ans++;
    a/=b;
  }
  cout <<ans+1<<endl;
}
    

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

int main(void){
  int N;
  cin >> N;
  vector<pair<ll, ll> > times; // pair<deadline, take time>;
  for(int i=0; i<N; i++){
    ll t1, t2; cin >> t1 >> t2; times.push_back(make_pair(t2, t1));
  }
  sort(times.begin(), times.end());
  ll nowTime = 0;
  for(int i=0; i<N; i++){
    nowTime += times[i].second;
    if(nowTime > times[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
  
  
  
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main () {
	io_optimized
	int a,b;
	while(cin>>a>>b)
	{
		if(a==b)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}

	return 0;
}


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

int main() {
  int A, B, C, ves1, ans;
  cin >> A >> B >> C;
  
  ves1 = A - B;
  ans = C - ves1;
 
  if(ans < 0)
  {
  	ans = 0;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
inf = float('inf')

def distance(p,n,x,y):
    D = 0
    s = []
    for i in range(0,n):
        s.append(x[i]-y[i])
        if s[i]<0.0:
            s[i]*=-1.0
        D += s[i]**p 
        
    if p==inf:
        return max(s)
    else:
        return D**(1.0/p)

if __name__ == '__main__':
    n = int(input())
    x = map(int,raw_input().split())
    y = map(int,raw_input().split())
        
    print float(distance(1,n,x,y))
    print float(distance(2,n,x,y))
    print float(distance(3,n,x,y))
    print float(distance(inf,n,x,y))

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

using namespace std;

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

	long long int a,b,c,d;

	cin >> a >> b >> c >> d;

	long long int res = max(a*c,b*d);
	res = max(res,a*d);
	res = max(res,b*c);

	cout << res << '\n';

	return 0;
}


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

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

int A[500050];
char temp[500050];
t3 Q[500050];
int D[500050][27];
int ans[500050];

int up[500050][20];

void solve(){
	scanf("%s", temp+1);
	int n = (int)strlen(temp + 1);
	for(int i=1;i<=n;i++)A[i] = temp[i] - 'a';
	int q; scanf("%d", &q);
	rep(i, 27)D[n+1][i] = -1;
	for(int i=n;i;i--){
		int c = A[i];
		int pp = i;
		for(int j=c;j<26;j++){
			if(D[pp+1][j] != -1)pp = D[pp+1][j];
			else{ pp = -1; break; }
		}
		if(pp == -1)rep(j, c)D[i][j] = -1;
		else rep(j, c)D[i][j] = D[pp+1][j];
		D[i][c] = i;
		for(int j=c+1;j<=26;j++)D[i][j] = -1;
		for(int j=c, x=i+1;j<26;j++){
			int y = D[x][j];
			if(y == -1)break;
			D[i][j+1] = y;
			x = y + 1;
		}
		if(D[i][26] == -1)up[i][0] = -1;
		else up[i][0] = D[i][26] + 1;
	}
	rep(j, 20)up[n+1][j] = -1;
	
	for(int j=1;j<20;j++){
		for(int i=1;i<=n;i++){
			if(up[i][j-1] == -1)up[i][j] = -1;
			else up[i][j] = up[ up[i][j-1] ][j-1];
		}
	}
	
	rep(i, q){
		int l, r; scanf("%d%d", &l, &r);
		int ans = 0;
		for(int j=19;j>=0;j--){
			if(up[l][j] == -1)continue;
			if(up[l][j] == r+1){ans = 1; break;}
			if(up[l][j] < r+1)l = up[l][j];
		}
		printf("%s\n", ans ? "Yes" : "No");
	}
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 98560
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n; cin>>n;
    vi a(n), b(n), c(n);
    rep(i,0,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<vll> dp(n,vll(3,0));
    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
    rep(i,1,n)
    {
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 6912
import sys
from decimal import Decimal

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c = input().split()
    print("Yes" if Decimal(a) ** Decimal("0.5") + Decimal(b) ** Decimal("0.5") < Decimal(c) ** Decimal("0.5") else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5076
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){

    int n;

    cin >> n;

    double x[n];
    string u[n];

    for(int i=0; i<n; i++){
        cin >> x[i] >> u[i];
    }

    double rb = 0;
    int jpy = 0;

    for(int i=0; i<n; i++){
        if(u[i] == "JPY"){
            jpy += x[i];
        } else {
            rb += x[i];
        }
    }

    double s = jpy + (rb*380000.0);

    cout << s << endl;

}

Measured memory_bytes: 256
in_str = input().split(" ")
in_width = int(in_str[0])
in_hight = int(in_str[1])

in_x = int(in_str[2])
in_y = int(in_str[3])
in_r = int(in_str[4])

#x check
if (0 <= in_x - in_r) & (in_x + in_r <= in_width):
    #y check
    if (0 <= in_y - in_r) & (in_y + in_r <= in_hight):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 7688
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N,D = map(int, input().split())
count =0
for i in range(N):
    x,y = map(int, input().split())
    if D*D >=x*x +y*y:
        count +=1
print(count)

Measured memory_bytes: 69872
import java.util.*

fun main(args: Array<String>) {
    val scan = FastScanner()
    val n = scan.nextInt()
    val a = Array(n){LongArray(n){scan.nextLong()}}
    val scores = LongArray(1.shl(n))
    for (mask in 0 until 1.shl(n)) {
        var ret = 0L
        for (i in 0 until n) {
            for (j in i+1 until n) {
                if (mask.shr(i) and 1 == 1 && mask.shr(j) and 1 == 1)
                    ret += a[i][j]
            }
        }
        scores[mask] = ret
    }

    val dp = LongArray(1.shl(n)){ (-1L).shl(n) }
    dp[0] = 0
    for (mask in 0 until 1.shl(n)) {
        for (sub in bitSubsetsOfSubset(mask)) {
            dp[mask] = Math.max(dp[mask], dp[sub] + scores[mask - sub])
        }
    }
    println(dp[1.shl(n)-1])
}

fun bitSubsetsOfSubset(sup: Int): MutableList<Int> {
    val ret = mutableListOf<Int>()
    var sub = sup
    while (true) {
        ret.add(sub)
        if (sub == 0) {
            break
        }
        sub = (sub - 1) and sup
    }
    return ret
}

class FastScanner {
    private val printable = 33..126
    val `in` = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = `in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun nextInt(): Int {
        val nl = nextLong()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun nextDouble(): Double {
        return next().toDouble()
    }
}

Measured memory_bytes: 117052
S = input()

cnt = 0
ans = 'Yes'

for s in S:
	if cnt%2 == 0:
		if s != 'R' and s != 'U' and s != 'D':
			ans = 'No'
	else:
		if s != 'L' and s != 'U' and s != 'D':
			ans = 'No'
	cnt+=1

print(ans)

Measured memory_bytes: 2940
n = int(input())
a = input().split()
ar = list(reversed(a))
ans = []
if not n % 2:
  for i in range(0, n, 2):
    ans.append(ar[i])

  for i in range(0, n, 2):
    ans.append(a[i])

  print(' '.join(ans))
else:
  for i in range(0, n, 2):
    ans.append(ar[i])

  for i in range(1, n, 2):
    ans.append(a[i])

  print(' '.join(ans))

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<int> vint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

lint mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

int powmod(int x, int y, int m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

int main() {
    lint n, k; cin >> n >> k;
    string s; cin >> s;

    vlint a;
    char now;
    lint cnt = 0;
    rep(i, n){
        if (i == 0){
            now = s[i];
            cnt ++;
        }
        else if(now == s[i]){
            cnt ++;
        }
        else{
            a.push_back(cnt);
            cnt = 1;
            now = s[i];
        }
        if (i == n-1){
            a.push_back(cnt);
        }
    }
    lint ans = 0;
    rep(i, a.size()){
        ans += a[i] - 1;
    }
    cout << min(n-1, ans + 2 * k) << endl;

}



Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    if(str=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(str=="Cloudy")
        cout<<"Rainy"<<endl;
    else
        cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    
    String firstline = scanner.nextLine();
    String secondline = scanner.nextLine();
    String thirdline = scanner.nextLine();
    
    String fl[] = firstline.split("\\s");
    String sl[] = secondline.split("\\s");
    String tl[] = thirdline.split("\\s");
    
    int N = Integer.parseInt(fl[0]);
    int j;
    int c;
    int max = 0;
    for(int i = 0; i < N; i++){
      j = Integer.parseInt(sl[i]);
      c = Integer.parseInt(tl[i]);
      if(j > c){
        max += j - c;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21844
#include <cstdio>
using namespace std;

const int md = (1 << 23) * 17 * 7 + 1;

inline int add(int a, int b) 
{
	a += b;
	if (a >= md) a -= md;
	return a;
}
inline int mul(int a, int b) 
{
	return (long long)a * b % md;
}

const int N = 3000;
int a[N];
int dp[N + 1][N + 1];

int main() 
{
	int n, s;
	scanf("%d%d", &n, &s);
	for (int i = 0; i < n; ++i) scanf("%d", a + i);
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= s; ++j) {
			dp[i][j] = mul(dp[i - 1][j], 2);
			if (j >= a[i - 1]) dp[i][j] = add(dp[i][j], dp[i - 1][j - a[i - 1]]);
		}
	}
	printf("%d\n", dp[n][s]);
	return 0;
}


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

int main(){
    long long A, B, K;
    cin >> A >> B >> K;
    if(A >= K) cout << A-K << " " << B << endl;
    else cout << 0 << " " << max(0LL, B-(K-A)) << endl;;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
using namespace std;

vector<bool> isPrime(long long int n){
  vector<bool> p(n+1, true);
  p[1] = false;
  p[0] = false;
  for(int i=2; i<=sqrt(n); i++){
    if( !p[i] ) continue;
    for(int j=i*2; j<=n; j+=i){
      p[j] = false;
    }
  }
  return p;
}

int main(void) {

  int n;
  cin >> n;
  vector<bool> p = isPrime(100000000);


  int cnt = 0;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    cnt += p[tmp];
  }
  cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 14984
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            MyInputStream cin = new MyInputStream();

            var N = cin.ReadInt();
            var max = 0;
            var x = 0;
            for (int i = 0; i < N; ++i)
            {
                if (Read() == 'I')
                    max = Max(++x, max);
                else
                    --x;
            }
            WriteLine(max);
        }
    }

    public static class MyExtensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll N;
    cin>>N;
    VL A(N),B(N),C(N-1);
    rep(i,0,N)cin>>A[i];
    rep(i,0,N)cin>>B[i];
    rep(i,0,N-1)cin>>C[i];
    ll sum=0;
    rep(i,0,N){
        A[i]--;
        sum+=B[A[i]];
        if(i>0&&A[i-1]==A[i]-1)sum+=C[A[i-1]];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut s: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let mut que = VecDeque::new();
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                que.push_back((i, j));
            }
        }
    }

    let dx = [0, 0, -1, 1];
    let dy = [-1, 1, 0, 0];
    let mut ans = 0;
    while !que.is_empty() {
        ans += 1;
        let mut next_que = VecDeque::new();
        while let Some((y, x)) = que.pop_front() {
            let y = y as i64;
            let x = x as i64;
            for i in 0..4 {
                let nx = x + dx[i];
                let ny = y + dy[i];
                if nx >= 0 && nx < w as i64 && ny >= 0 && ny < h as i64 {
                    let nx = nx as usize;
                    let ny = ny as usize;
                    if s[ny][nx] == '.' {
                        s[ny][nx] = '#';
                        next_que.push_back((ny, nx));
                    }
                }
            }
        }
        que = next_que.clone();
    }
    println!("{}", ans - 1);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 30968
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC091-E.in", "r", stdin); 
	int n, a, b; 
	scanf("%d%d%d", &n, &a, &b); 
	if (a + b - 1 > n || (ll)a * b < n)
		puts("-1"); 
	else
	{
		int cur = 0; 
		for (int i = 0; i < a; i++)
		{
			int cnt = std::min((n - cur) - (a - i - 1), b); 
			for (int j = 0; j < cnt; j++)
				printf("%d ", cur + cnt - j);
			cur += cnt; 
		}
	}
	return 0;
}


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

typedef long long ll;

ll _stoi(string x)
{
	ll ret = 0;
	rep(i, 0, x.length()) ret = ret * 10 + x[i] - '0';
	return ret;
}

ll solve(string s, map<string,ll>& size, map<string,map<ll,ll> >& stored)
{
	if ('0' <= s[0] && s[0] <= '9') return _stoi(s);

	string a = s.substr(0, 1);
	ll b = solve(s.substr(2, s.length() - 3), size, stored);
	if (b < 0 || size[a] <= b) return -1;
	if (stored[a].find(b) == stored[a].end()) return -1;

	return stored[a][b];
}

int main()
{
	while (1)
	{
		map<string, ll> size;
		map<string, map<ll, ll> > stored;

		int line = 1;
		int ans = 0;
		while (1)
		{
			string s; cin >> s;
			if (s[0] == '.') break;
			if (ans != 0) continue;

			if (s.find("=") == string::npos)
			{
				string a = s.substr(0, 1);
				ll b = _stoi(s.substr(2, s.length() - 3));

				//printf("(dec %s -> %lld)\n", a.c_str(), b);
				size[a] = b;
			}
			else
			{
				int i = s.find("=");
				string a = s.substr(0, 1);
				ll b = solve(s.substr(2, i - 1 - 2), size, stored);
				//cout << s.substr(2, i - 1 - 2) << endl;
				if (b < 0 || size[a] <= b)
				{
					ans = line;
					continue;
				}

				ll c = solve(s.substr(i + 1, s.length() - (i + 1)), size, stored);
				if (c < 0)
				{
					ans = line;
					continue;
				}

				//printf("(ass %s[%lld] -> %lld)\n", a.c_str(), b, c);
				stored[a][b] = c;
			}

			line++;
		}
		if (line == 1) return 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3224
from collections import defaultdict
from math import log
N=int(input())
A=list(map(int,input().split()))
dict=defaultdict(int)
for a in A:
    dict[a]+=1
A.sort(reverse=True)
ans=0
for a in A:
    if dict[a]==0:
        continue
    c=int(log(a,2))
    b=~a & ((1<<(c+1)) -1)
    b+=1
    dict[a]-=1
    if dict[b]:
        ans+=1
        dict[b]-=1
    else:
        dict[a]+=1
print(ans)


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

int main() {
  int N;
  cin >> N;
  
  long cur = 1, pre = 2;
  for (int i = 0; i < N-1; i++) {
    long tmp = cur;
    cur += pre;
    pre = tmp;
  }
  cout << cur << endl;
}

Measured memory_bytes: 256
/* ALDS1_3_D: Shell Sort */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#define N 1000000
#define M 100

int G[M] = {0}, m, cnt = 0;
void insertionSort(int *A, int n, int g);
void shellSort(int *A, int n);

int main(void){
	int n, i = 0;

    int *A = (int *) malloc(sizeof(int) * N);
	scanf("%d", &n);
	while(i < n){
		scanf("%d", &A[i++]);
	}

	shellSort(A, n);

	printf("%d\n", m);
	for(i = m-1; i >= 0; i-- ){
		printf("%d", G[i]);
		if(i) printf(" ");
	}

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

	for(i = 0; i < n; i++ ){
		printf("%d\n", A[i]);
	}
	return 0;
}

void shellSort(int *A, int n){
	int i = 0;

	G[0] = 1;
	while(G[i] <= n){
		i++;
		G[i] = 3*G[i-1] + 1;
	}

	G[i] = 0;
	m = i;
	i = 0;

	for(i = m - 1; i >= 0; i--){
		insertionSort(A, n, G[i]);
	}
}

void insertionSort(int* A, int n, int g){
	int v, i = 0, j;
	
	i = g;
	while(i < n){
		v = A[i];
		j = i - g;
		while(j >= 0 && A[j] > v){
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
		i++;
	}
}


Measured memory_bytes: 5632
def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    h = min(h, 2*q)
    s = min(s, h*2)
    if s*2 <= d:
        print(s*n)
    else:
        print(d*(n//2) + s*(n%2))
resolve()

Measured memory_bytes: 9184
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    h, a = map(int, input().split())
    if h % a == 0:
        print(h // a)
    else:
        print(h // a + 1)


if __name__ == '__main__':
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int ma[101010];
int ret[101010];
vector<int> E[101010];
int N,M,Q;
int A[101010],B[101010],C[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	cin>>Q;
	FOR(i,Q) {
		cin>>A[Q-1-i]>>B[Q-1-i]>>C[Q-1-i];
		A[Q-1-i]--;
	}
	MINUS(ma);
	
	FOR(i,Q) {
		if(B[i]<=ma[A[i]]) continue;
		
		queue<int> Q;
		if(ma[A[i]]==-1) ret[A[i]]=C[i];
		ma[A[i]]=B[i];
		Q.push(A[i]);
		
		while(Q.size()) {
			x=Q.front();
			Q.pop();
			FORR(r,E[x]) if(ma[r]<ma[x]-1) {
				if(ma[r]==-1) ret[r]=C[i];
				ma[r]=ma[x]-1;
				if(ma[r]>0) Q.push(r);
			}
		}
	}
	FOR(i,N) cout<<ret[i]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main() {
  string a,b;cin>>a>>b;
  int c=a.size(),d=b.size();
  if(c>d){
    cout<<"GREATER"<<endl;
    return 0;
  }
  else if(c<d){
    cout<<"LESS"<<endl;
    return 0;
  }
  else {
    rep(i,c){
      if(a[i]==b[i])continue;
      else if(a[i]>b[i]){
        cout<<"GREATER"<<endl;
        return 0;
      }
      else {
        cout<<"LESS"<<endl;
        return 0;
      }
    }
  }
  cout<<"EQUAL"<<endl;
}


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

using namespace std;

int main(){

	string s, t;
	cin >> s >>  t;
  	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));

	
	for(int i = 0; i < s.length(); i++){
		for(int j = 0; j < t.length(); j++){
      			if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      			else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
	  	}
  	}

  	int a = s.size(), b = t.size();
  	string c = "";

  	while(dp[a][b] != 0){
  		if(dp[a][b] == dp[a - 1][b]) a--;
  		else if(dp[a][b] == dp[a][b - 1]) b--;
  		else{
  			c = c + s[a - 1];
  			a--;
  			b--;
  		}
  	}

  	for(int i = 0; i < c.length()/2; i++){
  		swap(c[i], c[c.length() - 1 - i]);
  	}

  	cout << c << "\n";

  	return 0;
}

Measured memory_bytes: 35584
N = int(input())
strings = sorted(str(sorted(input())) for _ in range(N))

ans = 0
cnt = 1
for i in range(N - 1):
    if strings[i] == strings[i + 1]:
        cnt += 1
    else:
        if cnt > 1:
            ans += cnt * (cnt - 1) // 2
        cnt = 1
print(ans) if cnt <= 1 else print(ans + cnt * (cnt - 1) // 2)


Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int nn = 2e5 + 5;
vector<pair<int, int> > adjlist[nn];
int color[nn];
bool vis[nn];

void dfs(int nod, int val) {
 if (val % 2 == 0) color[nod] = 1;
 vis[nod] = 1;
 int l1 = adjlist[nod].size();
 for (int i = 0; i < l1; i++) {
  int ttg = adjlist[nod][i].first;
  if (!vis[ttg]) dfs(ttg, val + adjlist[nod][i].second);
 }
}

int main() {
 int n, u, v, w;
 cin >> n;
 for (int i = 0; i < n - 1; i++) {
  cin >> u >> v >> w;
  adjlist[u].push_back(make_pair(v, w));
  adjlist[v].push_back(make_pair(u, w));
 }
 dfs(1, 0);
 for (int i = 1; i <= n; i++) printf("%d\n", color[i]);
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("mmx,avx,fma")
//#pragma GCC optimize ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, set<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define cont continue
#define ret return
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define fordn(i, a) for (int i = a - 1;i >= 0;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << (s_) << '\n';return 0;}
#define endl '\n'
#define makeunique(x) sort(all(x)), (x).resize(unique(all(a)) - (x).begin())
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef long double ldd;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_tree;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
////const int mod = 1e9 + 7;
//const int mod = 998244353;
//ll powq(ll a, ll n) {
//    ll res = 1;
//    while (n){
//        if (n & 1) {
//            res *= a;
//            res %= mod;
//            --n;
//        }
//        else {
//            a *= a;
//            n >>= 1;
//            a %= mod;
//        }
//    }
//    return res;
//}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    forn(i, s.size()){
        if (s[i] == '2') ans++;
    }
    cout << ans;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a%(2*b+1)!=0)
 cout << a/(2*b+1)+1 <<endl;
    if(a%(2*b+1)==0)
      cout << a/(2*b+1) <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,T;
  cin>>N>>T;
  int ans=T;
  vector<int>time(N);
  for(int i=0;i<N;i++)
  cin>>time.at(i);
  for(int i=0;i<N-1;i++){
  int time1=time.at(1+i)-time.at(i);
    if(time1<=T)
      ans+=time1;
    else
      ans+=T;
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s;
ll n,x=0;
ll maxx=-1e18;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s;n=s.size();
	maxx=max(maxx,x);
	for(int i=0;i<n;i++){
		if(s[i]=='I')x++;
		if(s[i]=='D')x--;
		maxx=max(maxx,x);
	}
	cout<<maxx;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[,] A = new int[2,N];
            int[] a1 = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int[] a2 = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            for(var i=0;i<N;i++){
                A[0,i] = a1[i];
                A[1,i] = a2[i];
            }
            int max_candy=0;
            for(var i=0;i<N;i++){
                int sum=0;
                for(var j=0;j<=i;j++){
                    sum += A[0,j];
                }
                for(var j=i;j<N;j++){
                    sum += A[1,j];
                }
                max_candy = Math.Max(sum,max_candy);
            }
            Console.WriteLine(max_candy);
        }
    } 
}

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

int main(void)
{
    int n;
    long long k;
    int a, b;
    int i;
    long long array[100010] = {};

    cin >> n >> k;

    for(i = 0; i < n; i++){
        cin >> a >> b;
        array[a] += b;
    }
    i = 1;
    while(1){
        k -= array[i];
        if(k <= 0){
            break;
        }
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from collections import deque
import marshal


class Graph:
    class Edge:
        def __init__(self, to, cost):
            """
            :param to:  終点ノード
            :param cost: 辺の重み
            """
            self.to, self.cost = to, cost

    def __init__(self, n, directed=False, decrement=True, destroy=False, edges=[]):
        self.n = n
        self.directed = directed
        self.decrement = decrement
        self.destroy = destroy
        self.edges = [[] for _ in range(self.n)]
        self.dist = [None] * self.n
        self.info = [-1]*self.n
        for x, y, cost in edges:
            self.add_edge(x, y, cost)

    def add_edge(self, x, y, cost):
        if self.decrement:
            x -= 1
            y -= 1
        self.edges[x].append(self.Edge(y, cost))
        if self.directed == False:
            self.edges[y].append(self.Edge(x, cost))

    def bfs(self, start, goal=-1, time=0, save=False):
        """
        :param start: スタート地点
        :param goal: ゴール地点
        :param save: True = 前回の探索結果を保持する
        :return: （ループがあっても）最短距離。存在しなければ -1
        """
        if self.decrement:
            start -= 1
            goal -= 1
        if not save:
            self.dist = [None] * self.n
        p, t, dist = start, time, 0
        self.dist[p] = 0
        next_set = deque([(p, t, dist)])

        while next_set:
            p, t, dist = next_set.popleft()
            for edge in self.edges[p]:
                q, cost = edge.to, edge.cost
                if self.dist[q] is not None:
                    if self.dist[q] != dist + cost:
                        print("No")
                        exit()
                    continue
                self.dist[q] = dist + cost
                next_set.append((q, t + 1, dist + cost))
        return True

##################################################################################################

N, M = map(int, input().split())
graph = Graph(N, directed=True, decrement=True, destroy=False)
for _ in range(M):
    x, y, cost = map(int, input().split())
    graph.add_edge(x, y, cost)
    graph.add_edge(y, x, -cost)
for i in range(1,N+1):
    if graph.dist[i-1] is None:
        graph.bfs(i, goal=-1, time=0, save=True)
print("Yes")

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

int main(){
  int N;
  string S,T;
  cin >> S ;
  N = S.size();
  T=S;
  int j;
  reverse(T.begin(),T.end());
  for(int i=0;i<(N-1)/2;i++){
    if(S.at(i)==T.at(i+(N+1)/2)){
      if(S.at(i)==S.at(i+(N+1)/2)){
        j++;
      }
    }
  }
  if(j==(N-1)/2){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
  
}

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

#define rep(i, n) for(int i=0;i<(int)n;++i)
using P = pair<int, int>;
const int INF = 1001001001;

int binary_brute_force(const vector<P> &vec, int G)
{
    int n = vec.size(), ans = INF, num_p, point;
    for(int i=0;i<(1 << n);++i)
    {
        num_p = 0;
        point = 0;
        for(int j=0;j<n;++j)
        {
            if((i >> j) & 1)
            {
                num_p += vec[j].first;
                point += vec[j].first * 100 * (n-j) + vec[j].second;
            }
        }

        for(int j=0;j<n;++j)
        {
            if(G <= point) break;
            if(!((i >> j) & 1))
            {
                if(G <= point + (vec[j].first-1) * 100 * (n-j)){
                    num_p += (G - point - 1) / (100 * (n-j)) + 1;
                    ans = min(ans, num_p);
                    break;
                }
                else{
                    num_p += vec[j].first - 1;
                    point += (vec[j].first-1) * 100 * (n-j);
                }
            }
        }
        if(G <= point) ans = min(ans, num_p);
    }
    return ans;
}

int dfs(const vector<P> &vec, int G, int point, int num, int index, int state)
{
    int n = vec.size();
    if(G <= point){
        return num;
    }
    if(index >= vec.size())
    {
        for(int i=0;i<n;++i)
        {
            if(!((state >> i) & 1))
            {
                if(G <= point + (vec[i].first - 1)*100*(n-i))
                {
                    num += (G - point - 1) / (100*(n-i)) + 1;
                    return num;
                }
                else{
                    num += vec[i].first - 1;
                    point += (vec[i].first - 1)*100*(n-i);
                }
            }
        }
        if(G > point) return INF;
        else return num;
    }
    // indexの問題を全部解く
    num = min(num, dfs(vec, G, point+vec[index].first*100*(n-index)+vec[index].second, num, index+1, state + (1 << index)));
    // 解かない
    num = min(num, dfs(vec, G, point, num, index+1, state));
    return num;
}

int main()
{
    int D, G;
    cin >> D >> G;
    vector<P> vec(D);
    rep(i, D) cin >> vec[i].first >> vec[i].second;
    reverse(vec.begin(), vec.end());
    cout << binary_brute_force(vec, G) << endl;
    //cout << dfs(vec, G, 0, INF, 0, 0) << endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
print(s.replace('7', '8', 1))















Measured memory_bytes: 27196
# include <cstdio>
int N;
char c;
int main (){
scanf ("%d" ,&N);
bool flag = false ;
for ( int i =0; i < N ; i ++){
scanf ("%c" ,&c );
if ( c == 'Y' ) flag = true;
}
if (flag) puts ("Four");
else puts ("Three");
}

Measured memory_bytes: 128
import math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
p1=0; p2=0; p3=0; pinf=0
for i in range(n):
    u=abs(x[i]-y[i])
    p1+=u
    p2+=pow(u,2)
    p3+=pow(u,3)
    if pinf<u:
        pinf=u
p2=math.sqrt(p2)
p3=pow(p3,1/3)
print("{0:.6f}".format(p1))
print("{0:.6f}".format(p2))
print("{0:.6f}".format(p3))
print("{0:.6f}".format(pinf))



Measured memory_bytes: 5696
# coding: utf-8
def main():
    N, M = map(int, input().split())

    a = [True] * (N+1)
    #s = [True for _ in range(N+1)]
    for _ in range(M):
        a[int(input())] = False
    #print(a)
    
    #a = []
    #for i in range(M):
    #    a.append(int(input()))
    
    dp = [0] * (N)
    dp.append(1)
    dp.append(0)
    mod = 10**9 + 7
    
    for s in reversed(range(N)):
        if a[s] == False: # xだったら
            if a[s+1] == False:
                dp[s] = 0 # 2回連続で穴があったら0返して終了
                break
            else:
                dp[s] = 0 # 無を代入
        else: # oだったら
            dp[s] = (dp[s+1] + dp[s+2]) % mod # DP!! DP!!
            
    print(dp[0])

main()

Measured memory_bytes: 45784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
	int w = 0;
	char S[10];
	scanf("%s",&S);
	int i;
	int len;
	len = strlen(S);
	for(i=0;i<len;i++){
		if(S[i] == '+') w++;
		else w--;
	}
	printf("%d",w);
	return 0;
}




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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e9
#define MOD 1000000007

ll dp[mxN+10][mxN+10];

void binomialcoeff()
{

    for(ll i = 0; i <= mxN; i++)
    {
        //cout << "I " << i << endl;
        for(ll j = 0; j <= i; j++)
        {

            //cout << "I J " << i << " " << j << endl;
            if(j == i) dp[i][j] = 1;
            else dp[i][j] = (dp[i-1][j-1]%MOD+dp[i-1][j]%MOD)%MOD;
        }
    }
    //aise;
}

int main()
{

    ll n, k;
    cin >> n >> k;
    binomialcoeff();
    //aise;
    for(ll i = 1; i <= k; i++)
    {

        ll ans = ((dp[n-k+1][i]%MOD)*(dp[k-1][i-1]%MOD))%MOD;
        cout << ans << endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N; cin >> N;

    ll ans = 800 * N - 200 * (N / 15);

    cout << ans << endl;

}


Measured memory_bytes: 256