akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,m = map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(m)]
    res = []
    visited = [0]*n

    def dfs(node):
        visited[node-1]=1
        if sum(visited)==n:
            res.append(1)
            return
        for x,y in edge:
            if x == node:
                if not visited[y-1]:
                    dfs(y)
                    visited[y-1] = 0
            if y == node:
                if not visited[x-1]:
                    dfs(x)
                    visited[x-1] = 0

    for a,b in edge:
        if a==1:
            dfs(a)
            print(len(res))
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.*;

public class Main {

    private static int[] g;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[N+1];
        for (int i = 1; i <= N; i++) {
            p[i] = sc.nextInt();
        }
        g = new int[N+1];
        for (int i = 1; i <= N; i++) {
            g[i] = i;
        }
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            unite(x,y);
        }

        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i <= N; i++) {
            list.add(new ArrayList<>());
        }
        for (int i = 1; i <= N; i++) {
            list.get(root(i)).add(i);
        }

        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (list.get(i).isEmpty()) continue;
            Set<Integer> set = new HashSet<>();
            for (int idx : list.get(i)) {
                set.add(p[idx]);
            }
            for (int idx : list.get(i)) {
                if (set.contains(idx)) ans++;
            }
        }

        System.out.println(ans);
    }

    private static void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        g[ry] = rx;
    }

    private static int root(int x) {
        if (g[x] == x) return x;
        return g[x] = root(g[x]);
    }
}


Measured memory_bytes: 100712
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
if(a >= c+e && c-e >=0 && b >= d+e && d - e >= 0){
  cout <<"Yes" << endl;
}else{
cout << "No" << endl;
}
}



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
const int MAX = 100000, mod = 1e9+7;
int A[MAX];
int main(){
    int n, maxi = 0;
    long long sum = 1;
    cin >> n;
    A[0] = 3;
    
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        sum = (sum * A[a]) % mod;
        A[a]--;
        A[a+1]++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 640
// Aizu Vol-5 0566: Soccer
// 2017.8.31 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int n, p, o; } T;
T team[102];

int cmp1(T *a, T *b) { if (b->p - a->p) return b->p - a->p; return a->n - b->n; }
int cmp2(T *a, T *b) { return a->n - b->n; }

int main()
{
	int n, m, a, b, c, d, i;

	scanf("%d", &n);
	m = n*(n-1)/2;
	while (m-- > 0) {
		for (i = 1; i <= n; i++) team[i].n = i;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if      (c > d)  team[a].p += 3;
		else if (c < d)  team[b].p += 3;
		else if (c == d) team[a].p++, team[b].p++;
	}
	qsort(team+1, n, sizeof(T), cmp1);
	team[1].o = 1;
	for (i = 2; i <= n; i++)
		if (team[i].p == team[i-1].p) team[i].o = team[i-1].o;
		else team[i].o = i;
	qsort(team+1, n, sizeof(T), cmp2);
	for (i = 1; i <= n; i++) printf("%d\n", team[i].o);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int a, b;
  int tmp;
  int r0, r1, r2, r3, r4;
  int num;
  int cnt=0;
  cin >> a >> b;

  for(int i=a; i<=b; i++){
    string s=to_string(i);
    string ss=s;
    reverse(ss.begin(),ss.end());
    if(s == ss)cnt++;

    i=stoi(s);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <cassert> 
#include <vector> 
#include <cmath> 
#include <ctime> 
#include <cstdlib> 
#include <fstream> 
#include <string> 
#include <sstream> 
#include <iterator> 
#include <map> 
#include <algorithm> 
#include <memory> 
#include <iomanip> 
#include <limits> 
#include <typeinfo> 
#include <queue> 

//------------------------

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


using namespace std;

int main()
{
   int N,K;
   long long sum;

   cin >> N >> K;

   vector<int> cnt(N, 0);
    int A;

   for(int i=0;i<N;i++){
        cin >> A;
        cnt[A - 1]++;
   }

   sort(cnt.begin(), cnt.end(),std::greater<int>());

   sum = 0;
   for(int i=0;i<K;i++){
       sum+=cnt[i];
        //cout << cnt[i] << ":" << sum << endl;
   }

   cout << N - sum << endl;

   return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    string s;
    cin >> s;
    for(int i = 0; i < 4;i++) {
        cout << s[i];
    }
    cout << " ";
    for(int i = 4; i < s.length(); i++) {
        cout << s[i];
    }
    cout << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin >> s
#define pr(r) cout << r << endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout << a[j] << " "
#define wh(t) ll t; cin >> t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define arr(a,n) vl a(n, 0); fab(i, 0, n) cin >> a[i]
#define prs(u) cout << u << " "
#define fab(i,a,b) for(ll i = a; i < b; i++)
#define fba(i,b,a) for(ll i = b; i >= a; i--)
#define fa(i, x) for(auto i: x)
#define mem(s, j) memset(s, j, sizeof(s))
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pl>
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define vvl vector<vl>
#define vvpl vector<vpl>
#define mxe(x) *max_element(x)
#define mne(x) *min_element(x)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N = (ll)3e5;
const ll inf = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.second > b.second);}
bool sort2(const pair<ll, ll> &a,const pair<ll, ll> &b){ return (a.second < b.second);}

vector<char> dir = {'L', 'R', 'U', 'D'};
vl dx = {-1, 1, 0, 0};
vl dy = {0, 0, -1, 1};

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}

ll sm(vl a) {
    ll sum = 0;
    for(auto i: a)
        sum += i;
    return sum;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}

ll isPal(string s) {
    string k = s; 
    reverse(all(k));
    if(s == k)
        return 1;
    return 0;
}

int main()
{
	sup;
    
    ll l;
    cin >> l;
    double d = double(l) / 3 ;
    cout << setprecision(10) << fixed << d * d * d;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_v = min(a)
min_i = a.index(min_v)

cnt = 0
cnt += (min_i+ k-2) // (k - 1)
i = max(min_i + 1, (min_i+ k-2) // (k - 1) * (k - 1) + 1)
while i < n:
    while a[i] == min_v:
        i += 1
        if i >= n:
            break
    if i >= n:
        break
    cnt += 1
    i += (k - 1)

print(cnt)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n; cin>>n;
    vector <vector<int>> g(n,vector <int>());
    rep(i,n){
        string s; cin>>s;
        rep(j,i+1){
            //cout<<s[j]<<endl;
            if(s[j] == '1') g[i].push_back(j), g[j].push_back(i);
        }
    }
    int ans = -1;
    for(int i=0;i<n;i++){
        queue <pair <int,int>> q;
        vector <int> v(n,-1);
        q.push({i,0});
        bool ok = true;
        int ma = -1;
        while(!q.empty()){
            int now = q.front().F, cost = q.front().S; q.pop();
            
            
            q.empty();
            if(v[now] != -1){
                //cout<<now<<' '<<v[now]<<' '<<cost<<endl;
                if(v[now]+1 == cost) {ok = false; break;}
                else continue;
            }else{
                v[now] = cost;
                chmax(ma, cost+1LL);
            }
            for(int j=0;j<g[now].size();j++){
                q.push({g[now][j], cost+1});
            }
        }
        if(ok) chmax(ans, ma);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1360
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  readln.chomp.count!(x=>x=='1').writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double ans,w;
int x[10],y[10],vis[10],n;
long double dis(int u,int v){
	return v!=-1?sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v])):0;
}
void dfs(int x,int pre){
	if(!x){ans+=w;return;}
	for(int i=0;i<n;i++){
		if(vis[i])continue;
		vis[i]=1,w+=dis(i,pre);
		dfs(x-1,i);
		vis[i]=0,w-=dis(i,pre);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",x+i,y+i);
	dfs(n,-1);
	for(int i=2;i<=n;i++)ans/=i;
	printf("%.10Lf",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem082a(a, b))
}

fun problem082a(a: Int, b: Int): Int {
    return (((a + b).toDouble() / 2) + 0.9).toInt()
}

Measured memory_bytes: 29468
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ld>
typedef long long int ll;
typedef long double ld;
using namespace std;
#include <iomanip>
ld INF = 100000000000000000;
ld ans=INF;
vll h{INF, -INF}, v{INF, -INF};
vll l{INF, -INF}, r{INF, -INF}, u{INF, -INF}, d{INF, -INF};

vll zero_y, zero_x;
void calc(ld t){
  ld min_x = min({l[0] - t, r[0] + t, v[0]});
  ld max_x = max({l[1] - t, r[1] + t, v[1]});
  ld min_y = min({u[0] + t, d[0] - t, h[0]});
  ld max_y = max({u[1] + t, d[1] - t, h[1]});
  ans = min((max_x-min_x)*(max_y-min_y), ans);
}
void get(ld a, ld b){
  ld ret = (ld)((b - a)/2.0);
  calc(abs(ret));
}
void g(ld a, ld b){
  ld ret = abs(b - a);
  calc(ret);
}
int main(int argc, char const *argv[]) {
  ld n, x, y;std::cin >> n;
  char k;
  for(int i=0;i<n;i++){
    std::cin >> x >> y >> k;
    if(k=='R'||k=='L') h = vll{min(h[0], y), max(h[1], y)};
    if(k=='D'||k=='U') v = vll{min(v[0], x), max(v[1], x)};
    if(k=='R') r = vll{min(r[0], x), max(r[1], x)};
    if(k=='L') l = vll{min(l[0], x), max(l[1], x)};
    if(k=='D') d = vll{min(d[0], y), max(d[1], y)};
    if(k=='U') u = vll{min(u[0], y), max(u[1], y)};
  }
  calc(0);
  get(r[0], l[0]);
  get(r[1], l[0]);
  get(r[1], l[1]);
  get(r[0], l[1]);
  get(u[0], d[0]);
  get(u[1], d[0]);
  get(u[1], d[1]);
  get(u[0], d[1]);

  g(u[0], 0);
  g(u[1], 0);
  g(r[0], 0);
  g(r[1], 0);
  g(l[0], 0);
  g(l[1], 0);
  g(d[0], 0);
  g(d[1], 0);

  g(l[0], v[0]);
  g(l[1], v[0]);
  g(l[0], v[1]);
  g(l[1], v[1]);
  g(r[0], v[0]);
  g(r[1], v[0]);
  g(r[0], v[1]);
  g(r[1], v[1]);

  g(u[0], h[0]);
  g(u[1], h[0]);
  g(u[0], h[1]);
  g(u[1], h[1]);
  g(d[0], h[0]);
  g(d[1], h[0]);
  g(d[0], h[1]);
  g(d[1], h[1]);



  std::cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}


Measured memory_bytes: 1016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<P>> graph(100010, vector<P>());
vector<int> ans(100010);

void dfs(int n, int p, int col) {
	ans[n] = col;
	for (P i : graph[n]) {
		if (i.first == p) continue;
		dfs(i.first, n, col^i.second);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	rep(i, n - 1) {
		int u, v, d;
		cin >> u >> v >> d;
		u--; v--; d %= 2;
		graph[u].pb(P(v, d));
		graph[v].pb(P(u, d));
	}
	dfs(0, -1, 0);
	rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 10240
<?php
//前提条件$size>=2
$size = fgets(STDIN);
$v = fgets(STDIN);
//$vを配列にする
$array = explode(" ", $v);

//配列内に0があれば出力は配列絶対値の和
if(in_array(0,$array)){
  $allPlus = true;
}else{
  $allPlus = false;
}

$arrayAbs = [];
if($allPlus){
  foreach($array as $n){
    if($n < 0){
      $n = abs($n);
    }
    $arrayAbs[] = $n;
  }
  echo array_sum($arrayAbs);
//配列内のマイナスの数が偶数なら出力は絶対値合計、奇数なら絶対値最小値のみマイナス
}else{
  $min = abs($array[0]);
  $minusCounter = 0;

  foreach($array as $n){
    if($n < 0){
      $n = abs($n);
      $minusCounter++;
    }
    if(abs($min) > abs($n)){
      $min = $n;
    }
    $arrayAbs[] = $n;
  }
  if($minusCounter%2 === 0){
    echo array_sum($arrayAbs);
  }else{
    echo array_sum($arrayAbs)-2*$min;
  }
}

Measured memory_bytes: 36852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main(){
    int x;
    cin>>x;
    int ans;
    if(400<=x&&x<600) ans=8;
    else if(600<=x&&x<800) ans=7;
    else if(800<=x&&x<1000) ans=6;
    else if(1000<=x&&x<1200) ans=5;
    else if(1200<=x&&x<1400) ans=4;
    else if(1400<=x&&x<1600) ans=3;
    else if(1600<=x&&x<1800) ans=2;
    else if(1800<=x&&x<2000) ans=1;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 9;
const LL LLINF = 1e18;

int N;
VI T, v;
int M;
VPII PX;

int main(void) {
	cin >> N;
	T.resize(N);
	for_each(ALL(T), [](int &e){cin >> e;});
	cin >> M;
	PX.resize(M);
	int ma = accumulate(ALL(T), 0);
	REP(i, M) {
		int p, x;
		cin >> p >> x;
		p--;
		PX[i] = MP(p, x);
		cout << ma - (T[p] - x) << endl;
	}
	//cout << ma - v[0] << endl;
}


Measured memory_bytes: 256
/*  ex5_4
    Y_Aizaki  */

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

#define SIZE 20

int main(void){
    char string[SIZE];
    // 標準入力から文字列を受け取る配列

    scanf("%s", string);

    int length = 0;
    // 部分文字列の長さをカウント
    int answer = 0;
    // lengthの内、最長の長さ

    char *ptr = string;

    // null文字までループ
    while (*ptr)
    {
        //　部分列の長さをカウント
        if (*ptr == 'A'
        ||  *ptr == 'C'
        ||  *ptr == 'G'
        ||  *ptr == 'T')
        {
            length += 1;
        }
        //　部分列が途切れたらlengthを更新
        else
        {
            length = 0;
        }

        // answerに適宜代入
        if (answer < length)
        {
            answer = length;
        }

        ptr++;
        
    }

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

    return 0;
    
}

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

int main() {
  int D , N , A = 1 ;
  cin >> D >> N ;

if ( N ==  100 ){
N += 1;
}
  for (int i = 0; i < D; i++) {
A *= 100 ;
}

cout << A * N << endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{	
	int K;
	cin >> K;

	queue<ll> q;
	reple(i, 1, 9) q.push(i);

	int cnt = 0;
	while (true)
	{
		auto n = q.front(); q.pop();
		cnt++;

		if (cnt == K)
		{
			cout << n << endl;
			return 0;
		}

		int d = n % 10;

		if (d > 0) q.push(10 * n + (d - 1));

		q.push(10 * n + d);

		if (d < 9) q.push(10 * n + (d + 1));
	}

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);

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

  sort(v.begin(), v.end(), greater<int>());
  int len=accumulate(v.begin(), v.begin()+k, 0);

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

Measured memory_bytes: 256
#include <stdio.h>

int A[6], B[6], C[6];
int in[3], out[3], times[3];
int ans[3][3];

int main(void) {
	for (int i = 0; i < 6; ++i) { scanf("%d", &A[i]); }
	for (int i = 0; i < 6; ++i) { scanf("%d", &B[i]); }
	for (int i = 0; i < 6; ++i) { scanf("%d", &C[i]); }

		in[0] += A[0] * 3600;
		in[0] += A[1] * 60;
		in[0] += A[2];
		in[1] += B[0] * 3600;
		in[1] += B[1] * 60;
		in[1] += B[2];
		in[2] += C[0] * 3600;
		in[2] += C[1] * 60;
		in[2] += C[2];
		out[0] += A[3] * 3600;
		out[0] += A[4] * 60;
		out[0] += A[5];
		out[1] += B[3] * 3600;
		out[1] += B[4] * 60;
		out[1] += B[5];
		out[2] += C[3] * 3600;
		out[2] += C[4] * 60;
		out[2] += C[5];

	for (int i = 0; i < 3; ++i) {
		times[i] = out[i] - in[i];
	}

	for (int i = 0; i < 3; ++i) {
		ans[i][0] = times[i] / 3600;
		times[i] %= 3600;
		ans[i][1] = times[i] / 60;
		times[i] %= 60;
		ans[i][2] = times[i];
	}

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (j != 2) {
				printf("%d ", ans[i][j]);
			}
			else { printf("%d\n", ans[i][j]); }
		}
	}
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
                
                
        if(N%(2*D+1)==0){
        	System.out.println(N/(2*D+1));
        }else {
        	System.out.println(N/(2*D+1)+1);
        }
			
			

	}

}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static const int kHashSize = 244140624;
static const size_t kP[] = {
  1,
  5,
  25,
  125,
  625,
  3125,
  15625,
  78125,
  390625,
  1953125,
  9765625,
  48828125,
  244140625,
};

static int Id(char c) {
  switch (c) {
    case 'A':
      return 1;
    case 'C':
      return 2;
    case 'G':
      return 3;
    case 'T':
      return 4;
  }
  // should not reach here.
  return 0;
}

static size_t Encode(const char* k, size_t n) {
  size_t h = 0;
  size_t i;
  for (i = 0; i < n; ++i) {
    h += kP[i] * Id(k[i]);
  }
  return h;
}

typedef struct Dictionary Dictionary;
struct Dictionary {
  int* table;
};

static void dictionary_init(Dictionary* d) {
  d->table = (int *)malloc(sizeof(int) * kHashSize);
  if (!d->table) {
    return;
  }
}

static void dictionary_destroy(Dictionary* d) {
  free(d->table);
}

static void dictionary_insert(Dictionary* d, const char* k, size_t n) {
    const size_t i = Encode(k, n);
    d->table[i] = 1;
}

static int dictionary_find(const Dictionary* d, const char* k, size_t n) {
  return d->table[Encode(k, n)] > 0;
}

int main() {
  int n;
  int i;
  char op[7];
  char str[13];
  Dictionary d;

  scanf("%d", &n);
  dictionary_init(&d);

  for (i = 0; i < n; ++i) {
    scanf("%s %s", op, str);
    const char c = op[0];
    const size_t len = strnlen(str, 13);
    if (c == 'i') {
      dictionary_insert(&d, str, len);
      continue;
    }

    if (dictionary_find(&d, str, len)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
  dictionary_destroy(&d);

  return 0;
}

Measured memory_bytes: 39840
#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=1001001001;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i,4){
		if(s[i] == '+'){
			ans++;
		}else{
			ans--;
		}
	}
	cout << ans << endl;

	return 0;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int count = 0;
	
	static int gcd(int a,int b){
		count++;
		int r = a%b;
		if(r == 0) {
			return b;
		}else {
			return gcd(b,r);
		}
	}


	void main() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a + b == 0) break;
			if(a<b) {
				int temp = a;
				a = b;
				b = temp;
			}
			int ans = gcd(a,b);
			System.out.println(ans +" " + count);
			count = 0;
		}
		
	}

	public static void main(String[] args) {
		new Main().main();
	}

}



Measured memory_bytes: 32260
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

const int MAX_V = 1010;
const int INF = 0x3f3f3f3f;

int M, N;

// 辺を表す構造体（行き先、容量、逆辺）
struct edge { int to, cap, rev; };

class MF {
public:
  vector<edge> G[MAX_V];  // グラフの隣接リスト表現
  bool used[MAX_V];   // DFSですでに調べたかのフラグ

  // fromからtoへ向かう容量capの辺をグラフに追加する
  void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
  }

  // 増加パスをDFSで探す
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0) {
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
      memset(used, 0, sizeof(used));
      int f = dfs(s, t, INF);
      if(f == 0) return flow;
      flow += f;
    }
  }
};

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

int main() {
  while (true) {
    vi Bs, Rs;
    cin >> M >> N;
    if (M==0 && N==0) {
      break;
    }
    MF mf;
    for (int i = 0; i < M; i++) {
      int b; cin >> b;
      Bs.pb(b);
      mf.add_edge(0, i+1, 1);
    }
    for (int i = 0; i < N; i++) {
      int r; cin >> r;
      Rs.pb(r);
      mf.add_edge(i+M+1, M+N+1, 1);
    }
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < N; j++) {
        if (gcd(Bs[i], Rs[j]) != 1) {
          // cout << i+1 << ", " << j+1 << endl;
          mf.add_edge(i+1, j+M+1, 1);
        }
      }
    }
    cout << mf.max_flow(0, M+N+1) << endl;
  }

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  if (N/100 == 7) {
    cout << "Yes" << endl;
  } else if ((N/10)%10 == 7) {
    cout << "Yes" << endl;
  } else if (N%10 == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


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

int main() {
    int cnt;
    int num;
    while (cin >> num) {
        cnt=0;
        for (int a=0; a<10; a++) {
            for (int b=0; b<10; b++) {
                for (int c=0; c<10; c++) {
                    for (int d=0; d<10; d++) {
                        if (a+b+c+d==num) {
                            cnt++;
                        }
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,M;
  cin>>N>>M;
 vector<vector<ll>> A(2,vector<ll>(N));
  for(ll i=0;i<N;i++) {
cin>>A[0][i]>>A[1][i];
  }
  vector<vector<ll>> B(2,vector<ll>(M));
  for(ll i=0;i<M;i++) {
cin>>B[0][i]>>B[1][i];
  }
  
  for(ll i=0;i<N;i++) {
    ll place;
    ll L=10000000000;
    
for(ll j=0;j<M;j++) {
  if(L>abs(A[0][i]-B[0][j])+abs(A[1][i]-B[1][j])) {
place=j+1;
    L=abs(A[0][i]-B[0][j])+abs(A[1][i]-B[1][j]);
                               }
                               }
cout<<place<<endl;
                               }
                               }

  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=1e6;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,q,k,c=0;
void solve(){
    cin>>n>>k;
    while(n--){
        cin>>q;
        if(q>=k) c++;
    }
    cout<<c;
}
int main(){
    IO
    //TEST
    solve();

    return(0);
}
/*
1
aabce
ace
*/


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int h,w;
vector<vector<char > >matrix(1000,vector<char >(1000,'.'));
vector<vector<int > >memo(1000,vector<int >(1000,0));
int main(){
	cin>>h>>w;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)cin>>matrix[i][j];
  memo[0][0]=1;
  int modul0 = 1000000007;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
    	if(i==0 && j==0 )continue;
      	if(matrix[i][j]=='#'){memo[i][j]=0;continue;}
      	if(i-1>=0)memo[i][j]+=memo[i-1][j];
      	if(j-1>=0)memo[i][j]=(memo[i][j]+memo[i][j-1])%modul0;
    }
  cout<<memo[h-1][w-1];
}

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

int main(){
  int n, ans = 0, a = 0, b = 0, uresii = 0;
  cin >> n;
  string s[n+10];
  rep(i, n) {
    cin >> s[i];
    // 数える
    rep(j, s[i].length()-1) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') {
        ans += 1;
      }
    }
    if (s[i][0] == 'B') {
      b += 1;
    }
    if (s[i][s[i].length()-1] == 'A') {
      a += 1;
    }
    if (s[i][0] == 'B' && s[i][s[i].length()-1] != 'A') {
      uresii += 1;
    }
    if (s[i][0] != 'B' && s[i][s[i].length()-1] == 'A') {
      uresii += 1;
    }
  }
  // cout << a << " " << b << endl;
  if (uresii == 0 && min(a,b) >= 1) {
    cout << ans + min(a, b) -1 << endl;
  }else {
    cout << ans + min(a, b) << endl;
  }
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	vector<int> a;
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		a.pb(t);
	}

	int f = n % 2;

	list<int> ans;
	for(int i=0; i<n; i++){
		if(i % 2 == f){
			ans.push_back(a[i]);
		}else{
			ans.push_front(a[i]);
		}
	}

	int cnt = 0;
	for(auto x : ans){
		if(cnt != n-1)printf("%d ", x);
		else printf("%d\n", x);
		cnt++;
	}

	
	return 0;
}


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s,r;
    while(cin>>s>>r){
        int d=s.size();
        //cout<<d<<endl;
        if(s==r.substr(0,d))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int h,w,i,j;
	cin>>h>>w;
	char ma[h][w];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>ma[i][j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(ma[i][j]=='#'){
				if((i-1>=0&&ma[i-1][j]=='.')&&(j-1>=0&&ma[i][j-1]=='.')&&(i+1<h&&ma[i+1][j]=='.')&&(j+1<w&&ma[i][j+1]=='.')){
					cout<<"No"<<endl;
                  return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vel a(N); 
    rep(i,N) {
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(all(a));
    ll k;
    if(N % 2 == 0) k = a[N / 2 - 1];
    else k = a[N/2];
    
    ll ans = 0;
    rep(i,N) {
        ans += abs(a[i] - k);
    }
    cout << ans << endl;
    return 0;
}



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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    int x = abs(A-B), y = V-W;
    if (x == 0) cout << "YES" << '\n';
    else if (y <= 0) cout << "NO" << '\n';
    else if ((x+y-1)/y > T) cout << "NO" << '\n';
    else cout << "YES" << '\n';
}



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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    int mx = 0;
    unordered_map<int,int> count;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mx = max(mx, a[i]);
        count[a[i]]++;
    }

    int res = 0;
    vector<bool> good(mx + 1, true);

    // sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        int cur = a[i];
        if(!good[cur]) continue;
        for(int j = a[i] + cur; j <= mx; j += cur){
            good[j] = false; 
        }
    }


    for(int i = 0; i < n; i++){
        // cout << a[i] << " " << count[a[i]] << " " << good[a[i]] << endl;
        if(count[a[i]] > 1 || !good[a[i]]){
            continue;
        }

        res++;
    }

    cout << res << endl;
}

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

    solve();
    
    return 0;
}



Measured memory_bytes: 12228
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define Test ll t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define loopS(i,a,b,step) for(ll i=a;i<b;i+=step)
#define loopRS(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define pll pair<ll,ll>
#define puu pair<ull, ull>
#define V vector
#define M map
#define UM unordered_map
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define inf INT_MAX
#define S3(a,b,c) cin >> a >> b >> c
#define S2(a,b) cin >> a >> b
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

void input(ll n, ll arr[]) {
	rep(i, 0, n)cin >> arr[i];
}
ll dp[3001][3001];
ll maximumX(ll arr[], ll st, ll end, ll n) {
	if (st > end)return 0;
	if (dp[st][end] != -1)return dp[st][end];
	// arr ki indexing 1 se hoti tu n karte.
	ll pos = (n - 1) - (end - st);
	// debug(pos);
	if (!(pos & 1)) {
		return dp[st][end] = max(maximumX(arr, st + 1, end, n) + arr[st], maximumX(arr, st, end - 1, n) + arr[end]);
		// even hai tu tiro try kar raha max karne ki.
	}
	return dp[st][end] = min(maximumX(arr, st + 1, end, n) - arr[st], maximumX(arr, st, end - 1, n) - arr[end]);
	// dusra try kar raha hai min aaye minus isliye kiya kyunki ye use ho gaya koi ek hi aayega ans mai.
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout.tie(NULL);
	ll n; cin >> n; ll arr[n];
	input(n, arr);
	ll sum = 0;
	// rep(i, 0, n)sum += arr[i];
	// debug(sum);
	rep(i, 0, 3001) {
		rep(j, 0, 3001)dp[i][j] = -1;
	}
	rep(i, 0, n)sum += arr[i];
	cout << maximumX(arr, 0, n - 1, n);
}


Measured memory_bytes: 70784
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    string s;
    cin >> s;
    ll l=sz(s),a,b,i;
    a=0;
    b=(l-1)/2 - 1;
    // cout << a << " " << b << endl;
    for(i=a;i<=b;i++)
    {
        if(s[i]!=s[b-i+a])
            break;
    }
    if(i<=b)
    {
        cout << "No";
        return;
    }

    a=(l+3)/2 - 1;
    b=l-1;
    // cout << a << " " << b << endl;
    for(i=a;i<=b;i++)
    {
        // cout << s[i] ;
        if(s[i]!=s[b-i+a])
            break;
    }

    if(i<=b)
    {
        cout << "No";
        return;
    }

    a=0;
    b=l - 1;
    // cout << a << " " << b << endl;
    for(i=a;i<=b;i++)
    {
        if(s[i]!=s[b-i+a])
            break;
    }
    if(i<=b)
    {
        cout << "No";
        return;
    }

    cout << "Yes" ;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,a[10001];
main(){
    cin>>n;
    r(i,n)cin>>a[i];
    sort(a,a+n);
    if(a[0]!=1){
        cout<<1<<endl;
        return 0;
    }
    r(i,n-1)if(a[i]+1<a[i+1]){
        cout<<a[i]+1<<endl;
        return 0;
    }else{
        a[i+1]+=a[i];
    }
    cout<<a[n-1]+1<<endl;
}

Measured memory_bytes: 3236
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << endl;
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define mp(n, o) map<n, o>
#define so(n) sort(n.begin(), n.end())
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N, X, a = 0;
  ci(N, X);
  ve(int) L(N), D(N + 1);
  rep(i, N) {
    ci(L.at(i));
  }
  D.at(0) = 0;
  repi(i, 1, N + 1) {
    D.at(i) = D.at(i - 1) + L.at(i - 1);
  }
  rep(i, N + 1) {
    if(X >= D.at(i)) {
      a++;
    }
  }
  co(a);
} 

Measured memory_bytes: 256
import queue as Q
a = list(map(int,input().split()))
b = [[] for i in range(a[0])]
c = [[] for i in range(a[0])]
qs = [None,None]
qs[0]= Q.Queue()
qs[1]= Q.Queue()
arounds=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
for i in range(a[0]):
	b[i]=list(input())
	for j in range(a[1]):
		c[i].append(0)
		if b[i][j]!='.':
			b[i][j]=int(b[i][j])
for i in range(1,a[0]-1):
	for j in range(1,a[1]-1):
		for k in arounds:
			if b[i+k[0]][j+k[1]]=='.':
				c[i][j]+=1
ans=0
for i in range(a[0]):
	for j in range(a[1]):
		if b[i][j]!='.' and b[i][j]<=c[i][j]:
			b[i][j]='.'
			qs[0].put((i,j))
if qs[0].empty():
	quit()
q=0
while not qs[q].empty():
	while not qs[q].empty():
		p=qs[q].get()
		for k in arounds:
			c[p[0]+k[0]][p[1]+k[1]]+=1
			if b[p[0]+k[0]][p[1]+k[1]]!='.' and b[p[0]+k[0]][p[1]+k[1]]==c[p[0]+k[0]][p[1]+k[1]]:
				b[p[0]+k[0]][p[1]+k[1]]='.'
				qs[q^1].put((p[0]+k[0],p[1]+k[1]))
	q^=1
	ans+=1
print(ans)


Measured memory_bytes: 26380
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m && n && m) {
		vector<int> p;
		for (int i = 1; i <= n; i++)
			p.push_back(i);
		vector<int>::iterator it = p.begin();
		while (p.size() > 1) {
			for (int i = 1; i < m; i++) {
				it++;
				if (it == p.end())
					it = p.begin();
			}
			it = p.erase(it);
			if (it == p.end())
				it = p.begin();
		}
		cout << p.front() << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint n;
  cin>>n;
  vector<lint> a(n),x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    x[i]=i+1+a[i];
    y[i]=i+1-a[i];
  }
  unordered_map<lint,lint> y_count;
  for(auto v:y){
    y_count[v]++;
  }
  lint result=0;
  for(int i=0;i<n;i++){
    result+=y_count[x[i]];
    y_count[y[i]]--;
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 23304
s = input().rstrip()
s += "T"
x, y = map(int, input().split())
cnt = 0
dir = 0
P = [{0},{0}]
first = True
for i in range(len(s)):
    if s[i]=="F":
        cnt+=1
    else:
        tmp = set()
        if first:
            for p in P[dir%2]:
                tmp |= {p+cnt}
            first=False
        else:
            for p in P[dir%2]:
                tmp |= {p+cnt, p-cnt}
        P[dir%2] =tmp
        dir += 1
        cnt = 0
if x in P[0] and y in P[1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 94924
#include<bits/stdc++.h>
#define ll long long
#define mod7 1000000007
using namespace std;

void myfunc() {
    
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<ll> v;
    v.push_back(a*c);
    v.push_back(a*d);
    v.push_back(b*c);
    v.push_back(b*d);
    //for(int x: v)
    //cout << x << endl;
    
    cout <<  *max_element(v.begin(),v.end()) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
struct NODE{
	int to , dist , cost , used;
	NODE(int a,int b,int c,int d){
		to = a , dist = b , cost = c , used = d;
	}
};
bool operator < (const NODE &a,const NODE &b){
	return a.dist != b.dist ? a.dist > b.dist : a.cost > b.cost;
}

int main(){
	int n,m;
	while(cin >> n >> m && (n||m) ){
		vector< vector<NODE> > g(n);
		bool use[20001] = {0} , done[10001] = {0};
		int cst[20000];
		rep(i,m){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			a--,b--;
			g[a].push_back(NODE(b,c,d,i));
			g[b].push_back(NODE(a,c,d,i));
			cst[i] = d;
		}
		priority_queue <NODE> Q;
		Q.push(NODE(0,0,0,m));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(done[q.to])continue;
			else done[q.to] = true , use[q.used] = true;
			rep(i,g[q.to].size()) Q.push(NODE(g[q.to][i].to,q.dist+g[q.to][i].dist,g[q.to][i].cost,g[q.to][i].used));
		}
		int ans = 0;
		rep(i,m) if(use[i])ans += cst[i];
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 0