akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1010 , mod = 1e9+7;
#define int long long
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , m , cnt , del , goal , mx;
int fa[N] , head[N] , used[N << 1];
struct node{ int u , v , w; bool operator < (const node &A) const { return w < A.w; }; }E[N << 1];
struct edge{ int v , nex , c; }e[N << 1];
inline void add(int u , int v , int c) { e[++cnt].v = v; e[cnt].nex = head[u]; e[cnt].c = c; head[u] = cnt; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline int Union(int x , int y)
{
	x = find(x); y = find(y); if(x == y) return 0;
	fa[x] = y; return 1;
}

void dfs(int x , int fa , int m)
{
	if(x == goal) { mx = m; return ; }
	for(int i = head[x] ; i && mx == -1 ; i = e[i].nex) if(e[i].v != fa) dfs(e[i].v , x , max(m , e[i].c));
}

int Query(int u , int v)
{
	goal = v; mx = -1; dfs(u , 0 , 0); return mx;
}

inline int ksm(int a , int k) { a %= mod; int ans = 1; for( ; k ; k >>= 1 , a = a * a % mod) if(k & 1) ans = ans * a % mod; return ans; }

signed main()
{
	n = read(); m = read(); del = read();
	for(int i = 1 ; i <= n ; ++i) fa[i] = i;
	for(int i = 1 ; i <= m ; ++i) E[i].u = read() , E[i].v = read() , E[i].w = read();
	sort(E + 1 , E + 1 + m);
	for(int i = 1 ; i <= m ; ++i) if(Union(E[i].u , E[i].v)) add(E[i].u , E[i].v , E[i].w) , add(E[i].v , E[i].u , E[i].w) , del -= E[i].w , used[i] = 1;
	if(del < 0) { puts("0"); return 0; }
	int cnt0 = 0 , cnt1 = 0 , cnt2 = 0 , val;
	for(int i = 1 ; i <= m ; ++i) if(!used[i])
	{
		val = E[i].w - Query(E[i].u , E[i].v);
		if(val < del) cnt0++; else if(val == del) cnt1++; else cnt2++;
	}
	int ans = 2LL * (ksm(2 , cnt1) - 1) % mod * ksm(2 , cnt2) % mod;
	if(del == 0) ans = (ans + (ksm(2 , n - 1) - 2) * ksm(2 , m - n + 1) % mod) % mod;
	ans = (ans % mod + mod) % mod; cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    vector<ll> x(m), y(m);
    vector<ll> indeg(n, 0);
    vector<vector<ll>> g(n);
    REP(i, m) {
        cin >> x[i] >> y[i];
        --x[i]; --y[i]; // 0-indexed
        ++indeg[y[i]];
        g[x[i]].push_back(y[i]);
    }

    // sort the vertices topologically
    vector<ll> tps; tps.reserve(n);
    deque<ll> q;
    REP(i, n) if (indeg[i] == 0) q.push_back(i);
    while (q.size()) {
        ll u = q.front(); q.pop_front();
        tps.push_back(u);
        for (ll v : g[u]) {
            if (--indeg[v] == 0) {
                q.push_back(v);
            }
        }
    }

    // dp
    vector<ll> dp(n, 0);
    REP(i, n) {
        ll u = tps[i];
        for (ll v : g[u]) {
            chmax(dp[v], dp[u]+1);
        }
    }

    // show the answer
    cout << *max_element(ALL_OF(dp)) << endl;
    
}

Measured memory_bytes: 9600
n, m = map(int, input().split())
h = list(map(int, input().split()))
sore = [[0] for i in range(n)]
for i in range(m):
    road = list(map(int, input().split()))
    sore[road[0]-1].append(h[road[1]-1])
    sore[road[1]-1].append(h[road[0]-1])
ans = 0
for i in range(n):
    if h[i] > max(sore[i]):
        ans+=1
print(ans)

Measured memory_bytes: 25968
n = int(input())
a = list(map(int, input().split())) 
g = 0
for i in range(1, n-1):
    if a[i-1] < a[i] < a[i+1] :
        g = g + 1
    elif a[i+1] < a[i] < a[i-1]:
        g = g + 1
print(g)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - (h * W + w * (H - h)) << endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
	string s;
	cin >> s;

	int counter = 0;
	char ch = (s[0] == '1') ? '1':'0';
  	for(char c:s){
  		//cout << c << ' ' << ch << '\n';

  		if(c != ch){
  			counter++;
  		}
  		ch = (ch == '1') ? '0':'1';
  	}

	cout << counter;

    return 0;
}


Measured memory_bytes: 512
function main(input){
    abc=input.split(' ');
    abc=abc.sort();
    a=parseInt(abc[0],10)
    b=parseInt(abc[1],10)
    if (a*b%2==0){
        console.log("No")
    }else{
        console.log("Yes") 
    }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define _USE_MATH_DEFINES
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define remax(x, y) (x) = max((x), (y))
#define remin(x, y) (x) = min((x), (y))

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12);
    cin.tie(nullptr);

    int N, W;
    cin >> N >> W;

    vector<ll> w(N), v(N);
    forn(i, N)
        cin >> w[i] >> v[i];

    vector<ll> dp(W + 1);
    forn(i, N)
        for (int j = W; j >= w[i]; j--)
            remax(dp[j], v[i] + dp[j - w[i]]);
    cout << dp[W] << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = "";
		while((str=br.readLine())!=null){

			int ans = Integer.parseInt(str);

			if(ans == 0) break;

			int cnt = 0;
			while(true){
				if(ans == 1) break;

				if(ans % 2 == 0){
					ans /= 2;
				} else{
					ans = ans * 3 + 1;
				}
				cnt++;
			}

			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 24164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
ll table[200005];

void input() {
  IN(N);
  FOR(i, 1, N+1) {
    table[i] = 0;
  }
  REP(i, N-1) {
    IN(t);
    table[t] += 1;
  }
}

void solve() {
  FOR(i, 1, N+1) {
    if (i != 1) cout << " ";
    cout << table[i];
  }
  cout << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 5196
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	string str;
	cin>>str;
	if(str.size()==1){
		cout <<str<<endl;
		return 0;
	}
	bool flag =true;
	for(int i =0;i <str.length()/2;i++){
		//cout <<str[i]<<" "<<str[str.length()-1-i]<<endl;
		if(str[i]!=str[str.length()-1-i]){
			//cout <<str[i]<<" "<<str[str.length()-1-i]<<endl;
			flag =false;
			break;
		}
	}
	if(flag){
		cout <<str<<endl;
		return 0;
	}
	int n=atoi(str.c_str());
	string ans1;
	int cnt1 =0;
	for(int i =n+1;;i++){
		//cout <<"i = "<<i<<endl;
		stringstream ss;
		ss <<i;
		cnt1++;
		string tmp =ss.str();
		int k;
		ss >>k;
		bool flag =true;
		for(int j =0;j <tmp.length()/2;j++){
			if(tmp[j]!=tmp[tmp.length()-1-j]){
				flag =false;
				break;
			}
		}
		//cout <<tmp<<endl;
		if(flag){
			ans1 =tmp;
			break;
		}
	}
	string ans2;
	int cnt2 =0;
	for(int i =n-1;i >=1;i--){
		stringstream ss;
		ss <<i;
		cnt2++;
		int k;
		
		string tmp =ss.str();
		ss>>k;
		bool flag =true;
		for(int j =0;j <tmp.length()/2;j++){
			if(tmp[j]!=tmp[tmp.length()-1-j]){
				flag =false;
				break;
			}
		}
		if(flag){
			ans2 =tmp;
			break;
		}
	}
	if(cnt1>cnt2){
		cout <<ans2<<endl;
	}else if(cnt1<cnt2){
		cout <<ans1<<endl;
	}else{
		int s,t;
		s =atoi(ans2.c_str());
		t =atoi(ans1.c_str());
		if(s >t){
			cout <<t<<endl;
		}else{
			cout <<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

long[3] DR = [1, 100, 10000];

void main()
{
    auto dn = readln.split.to!(long[]);
    auto D = dn[0];
    auto N = dn[1];
    if (N == 100) ++N;
    writeln(N * DR[D]);
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
const DIV:usize = 1000000007;
const MOVES: [(i32, i32); 4] = [(1, 0), (0, 1), (-1, 0), (0, -1)];
fn main(){
    input!{
       h:usize,
       w:usize,
       field:[chars;h], 
    }
    let mut flg = true; 
    'outer: for j in 0..h {
        for k in 0..w {

            if field[j][k] == '#'{
                flg = false;
                for &mv in &MOVES {
                    let after = (k as i32 +mv.0, j as i32  +mv.1);
                    if after.0 >= 0 && after.0 < w as i32 && after.1 >= 0 && after.1 < h as i32 {
                        let after = (after.0 as usize, after.1 as usize);
                        if field[after.1][after.0] == '#' {
                            flg = true;
                        }
                    }
                }
                if !flg {
                    break 'outer;
                }
            }

        }
    }
    println!("{}", if flg {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x;
bool vis[1000009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> x;
	int cur = 7, pos = 1;
	while (1) {
		if (cur % x == 0) break;
		if (vis[cur]) break;
		vis[cur] = true;
		cur *= 10;
		cur %= x;
		cur += 7;
		cur %= x;
		pos++;
	}
	if (cur % x) cout << -1 << E;
	else cout << pos << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 4552
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,m;
int sk[3][301];
int c[301];
int dp[301][301];
int solve(int ac,int j,int i){
  int res;
  //printf("%d %d %d\n",ac,j,i);
  if(j>=n) return 0;
  else if(m < ac) return 0;
  else if(dp[ac][j]!=-1) 
    return dp[ac][j];
  else res = max(solve(ac,j+1,i),ac+c[j]<=m?solve(ac+c[j],j,i)+sk[i][j]:0);
  //printf("%d aa",res);
  return dp[ac][j]=res;
}
main(){
  while(cin >> n >> m){
    getchar();
    for(int i=0;i<n;i++){
      string name;
      getline(cin,name);
      //fgets(name,256,stdin);
      cin >> c[i] >> sk[0][i] >> sk[1][i] >> sk[2][i];
      getchar();
    }
    int res=0;
    for(int i=0;i<3;i++){
      memset(dp,-1,sizeof(dp));
      res=max(res,solve(0,0,i));
      // cout << solve(0,0,i) << endl;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1296
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int k,x;
    scanf("%d %d",&k,&x);
    for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++){
        printf("%d ",i);
    }
    printf("\n");
}

Measured memory_bytes: 256
if __name__ == '__main__':

	a,b,c = map(int,input().split())
	tmp = 0
	tmp2 = 0
	tmp3 = 0
	tmp4 = 0

	tmp = a * 7 + b
	tmp2 = int(c / tmp)
	tmp3 = c % tmp

	if tmp3 != 0:
		if tmp3 > a*7:
			tmp4 = 7
		else:
			tmp4 = int(tmp3 / a)
			if tmp3 % a != 0:
				tmp4 += 1
	if c < tmp:
		print(tmp4)
	else:
		print(tmp2*7 + tmp4)



Measured memory_bytes: 5596
#B
N = int(input())
counter = 0
result = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        counter += 1
        if counter == 3:
            result = True
    else:
        counter = 0
print("Yes" if result else "No")

Measured memory_bytes: 9164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Position { internal int x, y, depth; }

    class Puzzle
    {
        readonly int[] moveX = new int[] { -2, -2, -2, -1,  0, +1, +2, +2, +2, -1,  0, +1 };
        readonly int[] moveY = new int[] { -1,  0, +1, -2, -2, -2, -1,  0, +1, +2, +2, +2 };

        readonly int n;

        bool[,,] map;
        
        public Puzzle(int n)
        {
            this.n = n;
            map = new bool[n, 10, 10];
        }
        
        public void MakeMap(int depth,int x,int y)
        {
            for(int i = -1; i <= 1; i++)
            {
                for(int j = -1; j <= 1; j++)
                {
                    int tempX = x + j;
                    int tempY = y + i;

                    if (!IsValid(tempX, tempY)) continue;

                    map[depth, tempY, tempX] = true;
                }
            }
        }

        public bool Solve(Position pos)
        {
            Stack<Position> stk = new Stack<Position>();
            stk.Push(pos);

            bool isArrival = false;

            while (stk.Count > 0)
            {
                Position cur = stk.Pop();

                if (cur.depth == n - 1)
                {
                    isArrival = true;
                    break;
                }

                for (int i = 0; i < 12; i++)
                {
                    Position next;
                    next.x = cur.x + moveX[i];
                    next.y = cur.y + moveY[i];
                    next.depth = cur.depth + 1;
                    
                    if (IsValid(next.x, next.y) && map[next.depth, next.y, next.x])
                    {
                        stk.Push(next);
                    }
                }
            }
            return isArrival;
        }

        private bool IsValid(int x,int y)
        {
            if (x < 0) return false;
            if (x > 9) return false;
            if (y < 0) return false;
            if (y > 9) return false;
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            
            while (true)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if (input.All(a => a == 0)) break;
                
                Position pos;
                pos.x = input[0];
                pos.y = input[1];
                pos.depth = -1;

                int n = int.Parse(Console.ReadLine());

                Puzzle pz = new Puzzle(n);

                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                
                for(int i = 0; i < n; i++)
                {
                    int idx = i * 2;

                    pz.MakeMap(i, input[idx], input[idx + 1]);
                }

                sb.AppendLine(pz.Solve(pos) ? "OK" : "NA");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10024
#include <cstdio>
#include <algorithm>
const int maxn = 2e5+10;
char s[maxn+10];
int n, ans, p[maxn];
int main() {
	scanf("%d%s", &n, s+1);
	for (int i = 1; i <= n; ++i) {
		p[i] = p[i-1]+(s[i]=='#');
	}
	ans = 1e9;
	//.(i)#(n-i)
	for (int i = 0; i <= n; ++i) {
		ans = std::min(ans, p[i]+(n-i-(p[n]-p[i])));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	string str;
	cin>>str;
	if(str.length()%2==0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	bool flag=true;
	string a,b;
	a=str.substr(0,(str.length()-1)/2);
	b=str.substr(str.length()/2+1,(str.length()-1)/2);
	if(a!=b)
	  flag=false;
	else
	{
		string t1,t2;
		t1=a;
		for(int i=a.length()-1;i>=0;i--)
		  t2+=a[i];
		if(t1!=t2)
		  flag=false;
	}
	if(flag)
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
	//system("pause");
	return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
const int inf=INT_MAX;
int n,now,w[N],v[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
long long leaf;
int ans,col=inf,dep[N],_max[N];
void dfs(int x,int fa){
	int cnt=0;
	dep[x]=dep[fa]+1,ans=max(ans,dep[x]);
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa)	dfs(v[i],x),++cnt;
	_max[dep[x]]=max(_max[dep[x]],cnt);
}
int vx[N],vy[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&vx[i],&vy[i]);
		addedges(vx[i],vy[i]);
		addedges(vy[i],vx[i]);
	}
	for(int i=1;i<=n;i++){
		long long sum=1;
		ans=0,dep[i]=0,dfs(i,i);
		for(int i=1;i<ans;i++)	sum=sum*_max[i];
		if(col>ans)	col=ans,leaf=sum;
		else	if(col==ans&&sum<leaf)	leaf=sum;
		for(int i=1;i<=ans;i++)	_max[i]=0;
	}
	for(int i=1;i<n;i++){
		long long sum=2;
		ans=0;
		dep[vy[i]]=0,dfs(vx[i],vy[i]);
		dep[vx[i]]=0,dfs(vy[i],vx[i]);
		for(int i=1;i<ans;i++)	sum*=_max[i];
		if(col>ans)	col=ans,leaf=sum;
		else	if(col==ans&&sum<leaf)	leaf=sum;
		for(int i=1;i<=ans;i++)	_max[i]=0;
	}
	cout<<col<<' '<<leaf<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int a = st[0];
            int b = st[1];

            if (b >= a) {
                Console.WriteLine(a);
            } else {
                Console.WriteLine(a - 1);
            }


        }
    }
}


Measured memory_bytes: 11348
from bisect import*
r=lambda:sorted(map(int,input().split()))
N=r()[0]
A,B,C,w,i=r(),r(),r(),[0]*(N+1),N
while i:i-=1;w[i]=w[i+1]+N-bisect(C,B[i])
print(sum(w[bisect(B,A[i])]for i in range(N)))

Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n,m;
int main(){
	cin>>n>>m;
	if(2*n >= m){
		cout << m/2 << endl;
	}
	else{
		cout << (2LL*n+m)/4 << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

char s[100000][11];

int cmp(const void* a, const void* b)
{
  int x = *(int *)a, y = *(int *)b;
  return strcmp(s[x], s[y]);
}

int asort(const void *a, const void *b)
{
  char x = *(char *)a, y = *(char *)b;
  if (x > y) return  1;
  if (x < y) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int n, index[100000];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
    qsort(s[i], 10, sizeof(char), asort);
    index[i] = i;
  }

  qsort(index, n, sizeof(int), cmp);

  ll d = 0, key = index[0], cnt, ans = 0;
  while (1) {
    cnt = 0;
    while (d < n && !strcmp(s[key], s[index[d]])) {
      cnt++; d++;
    }
    ans += cnt * (cnt - 1) / 2;
    if (d >= n) break;
    key = index[d];
  }

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

  return 0;
}

  


Measured memory_bytes: 2044
import sys
input = sys.stdin.readline

n = int(input())
p = list(map(int, input().split()))
if (n==0):
    if (p[0]==1):
        print(1)
        exit()
    else:
        print(-1)
        exit()
if (p[0]!=0):
    print(-1)
    exit()
#t = [1,1,0] #最大頂点数、最下段の空いている頂点数、閉じてない頂点数
sum_p = sum(p)
eda = 1
ans = 1
for i in range(1,n+1):
    eda *= 2
    ans += eda
    eda -= p[i]
    sum_p -= p[i]
    #print(i,eda,ans,sum_p)
    if (i!=n and eda<=0):
        print(-1)
        exit()
    if (i==n and eda<0):
        print(-1)
        exit()
    if (eda>=sum_p): #広げ切った
        ans -= (eda-sum_p)
        #print(ans)
        for j in range(i+1,n+1):
            ans += sum_p
            sum_p -= p[j]
        print(ans)
        exit()
print(ans)


Measured memory_bytes: 20128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define lli long long int
#define llb double 
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(i=0; i<n; i++)
#define fk(i, k, n) for(i=k; i<n; i++)
#define fn(i, n) for(i=n-1;i>=0;i--)
template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) { //rvalue reference is new to C++ 
	((cout << args << " "<<endl), ...);
}

int main() {
	lli a, res;
    double b;
    read(a, b);
    int b_int, b_frac=0;
    b_int = floor(b)*100;
    b_frac = (b - (b_int))*100;
    b_int *= 100;
    b_int = b_int+b_frac;
    write(a*b_int/100);


    
    
	
	return 0;
}

Measured memory_bytes: 3248
// https://atcoder.jp/contests/abc058/tasks/arc071_b
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int MOD = 1000000007;
namespace mp = boost::multiprecision;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w, h, t;
    cin >> w >> h;
    vector<ll> vx(w), vy(h);
    REP(i, w) {
        cin >> t;
        vx[i] = t;
    }
    REP(i, h) {
        cin >> t;
        vy[i] = t;
    }
    ll x = 0, y = 0;
    REP(i, w) {
        x += vx[i] * i - vx[i] * (w - i - 1);
        x %= MOD;
    }
    REP(i, h) {
        y += vy[i] * i - vy[i] * (h - i - 1);
        y %= MOD;
    }
    cout << (x * y) % MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    int d,t,s;
    cin >>  d >> t >> s;
    if(d>t*s) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    vector<int>vec(N);
    REP(i,N)cin>>vec[i];
    sort(vec.rbegin(),vec.rend());
    cout<<vec[0]-vec[N-1]<<endl;
}

Measured memory_bytes: 256
n=int(input())
prev=0
val=False
for i in range(0,n):
    a,b=[int(x) for x in input().split()]
    if(a==b):
        prev+=1
        if(prev>=3):
            val=True
    else:
        prev=0
if(val):
    print("Yes")
else:
    print("No")


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

int main() {
	int N;
    cin >> N;
    rep1(i,10) {
        rep1(j,10) {
            if(i * j == N) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
    
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var dx = Console.ReadLine().Split();
        var d = int.Parse(dx[0]);
        var x = int.Parse(dx[1]);
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var j = 1;
            while (j <= d)
            {
                ans++;
                j += a[i];
            }
        }

        Console.WriteLine(ans + x);
    }
}


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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define f(n) for (int i=0;i<n;++i)
#define init(arr,m,n,value) std::fill(*arr,*arr+m*n,value)
#define low(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define up(s) transform(s.begin(),s.end(),s.begin(),::toupper)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	int n;
	cin>>n;
	f(n)cout<<"ACL";

}


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

#define K 6001

int t;

int n;
LL a[K], b[K], c[K];
string s;

void add(LL mask) {
	FOD(i, 61, 0) {
		if ((mask & ((LL)(1) << i))) {
			if (!c[i]) {
				c[i] = mask;
				
				FOD(j, i - 1, 0) if (c[i] & ((LL)(1) << j)) c[i] ^= c[j];
				FOE(j, i + 1, 61) if (c[j] & ((LL)(1) << i)) c[j] ^= c[i];
		
				return;
			}
	
			mask ^= c[i];
		}
	}
}

bool verify(LL u) {
	FOD(i, 61, 0) if (u & ((LL) 1 << i)) u ^= c[i];
	return (u == 0);
}	

void solve() {
	scanf("%d", &n);
	
	FOE(i, 1, n) scanf("%lld", &a[i]);

	cin >> s;
	FOE(i, 1, n) b[i] = (s[i - 1] == '0' ? 0 : 1);
	FOE(i, 0, 99) c[i] = 0;
	
	FOD(i, n, 1) {
		if (b[i] == 1) {
			if (!verify(a[i])) {
				printf("1\n");
				return;
			}
		} else {
			add(a[i]);	
		}
	}
	
	printf("0\n");
}

int main() {
	scanf("%d", &t);
	while (t--) solve();
}

Measured memory_bytes: 3776
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC128
{
    class Program
    {
        static int Search(int[] ss, int num, int M, List<int[]> s, int[] p)
        {
            if (num == ss.Length)
            {
                int res = 0;
                bool flag1 = true;
                for (int i = 0; i < M; i++)
                {
                    int cnt1 = 0;
                    for (int j = 0; j < s[i].Length; j++)
                    {
                        cnt1 += ss[s[i][j] - 1];
                    }
                    if (cnt1 % 2 != p[i]) flag1 = false;
                }
                if (flag1) res++;
                return res;
            }
            int[] ss1 = new int[ss.Length];
            int[] ss2 = new int[ss.Length];
            Array.Copy(ss, ss1, ss.Length);
            Array.Copy(ss, ss2, ss.Length);
            ss1[num] = 0;
            ss2[num] = 1;
            return Search(ss1, num + 1, M, s, p) + Search(ss2, num + 1, M, s, p);
        }
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            int N = int.Parse(S[0]);
            int M = int.Parse(S[1]);

            int[] k = new int[M];
            List<int[]> s = new List<int[]>();

            for (int i = 0; i < M; i++)
            {
                S = Console.ReadLine().Split(' ');
                k[i] = int.Parse(S[0]);
                int[] ss = new int[k[i]];
                for (int j = 0; j < k[i]; j++)
                {
                    ss[j] = int.Parse(S[j + 1]);
                }
                s.Add(ss);
            }
            int[] p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int res = 0;
            res = Search(new int[N], 0, M, s, p);
            
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
            int a= sc.nextInt();
            String b = sc.next();
            int c = sc.nextInt();
            int answer;


        switch(b){

        case"+":
        answer = a+c;
        break;

        case"-":
        answer = a-c;
        break;

        case"*":
        answer = a*c;
        break;
        
        case"/":
        answer = a/c;
        break;

        default:
        return;

        }
        

        System.out.println(answer);

    }
    
}
}
}


Measured memory_bytes: 26252
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 5.4.1)
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	TLong cnt = 1;
	TLong ans = 0;
	cin >> n;
	std::vector<TLong> a(n);
	std::vector<TLong> s(n + 1);

	s.at(0) = 0;
	for (int i = 0; i < n; ++i){
		cin >> a.at(i);
		s.at(i + 1) = s.at(i) + a.at(i); 
	}
	sort(s.begin(), s.end());

	for(int i = 1; i < n + 1; ++i){
		if(s.at(i) == s.at(i - 1) && i != n)	++cnt;
		else{
			if(s.at(i) == s.at(i - 1) && i == n)	++cnt;
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	OUT(ans) BR;
	RET;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(){
	int n,max=0,ans=0;
	cin>>n;
	vector<int>A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	for(int i=0;i<n;i++){
		if(A[i]>=max){
			ans++;
			max=A[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    if (N<10)
    {
        cout << N;
    }else if (10 <= N && N< 100){
        cout << 9;
    }else if (100<= N && N< 1000){
        cout << N-90;
    }else if (1000 <= N && N< 10000 ){
        cout << 909;
    }else if (10000 <= N && N<100000){
        cout << N-90-9000;
    }else{
        cout << 90909;
    }
    
}



Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


from collections import deque


# In[2]:


H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())


# In[3]:


def bfs(sx,sy):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[-1]*W for _ in range(H)]
    q = deque([])
    q.append([sx,sy])
    d[sx][sy] = 0
    ans = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != "#" and d[nx][ny] == -1:
                q.append([nx,ny])
                d[nx][ny] = d[x][y] + 1
                ans = max(ans,d[nx][ny])
    return ans


# In[5]:


ans = 0
for sh in range(H):
    if "." in S[sh]:
        for sw in range(W):
            if S[sh][sw] == ".":
                ans = max(ans,bfs(sh,sw))
print(ans)


# In[ ]:






Measured memory_bytes: 9280
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k)
	fmt.Scan(&s)
	ans := 0
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			t := s - (i + j)
			if 0 <= t && t <= k {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  long long x,y;
  cin>>x>>y;
  
  long long ans=1;
  while(1){
    x *= 2;
    if(x<=y){
      ans++;
    }else{
      break;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,t,x[100005],dp[100005];
multiset<long long>s;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&t);
	for(long long i=1;i<=n;i++)scanf("%lld",&x[i]);
	dp[0]=0;
	long long mn=1e18,pos=1;
	for(long long i=1;i<=n;i++)
	{
		s.insert(dp[i-1]);
		while(pos<=i&&2*(x[i]-x[pos])>t)
		{
			mn=min(mn,dp[pos-1]-2*x[pos]);
			s.erase(s.find(dp[pos-1]));
			pos++;
		}
		dp[i]=min(*s.begin()+t,mn+2*x[i]);
	}
	printf("%lld\n",dp[n]+m);
	return 0;
} 

Measured memory_bytes: 3840
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    if a+b>9 {
        println!("error")
    }
    else {
        println!("{}",a+b)
    }
}

Measured memory_bytes: 2104
a, b, k = map(int,input().split())
 
def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])

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

struct Combination{
    Int MOD, MAX_N;
    vector<Int> f, f_inv;

    //---------- 初期化 ----------
    Combination(Int mod, Int max_n){
        MOD = mod;
        MAX_N = max_n;

        f = factorial(MAX_N);
        rep(i,f.size()) f_inv.push_back(inv(f[i]));
    }
    
    //---------- べき乗 ----------
    Int power(Int a, Int n){
        if(a == 0) return 0;
        if(n == 0) return 1;

        Int res = 1;
        while(n > 0){
            if(n % 2 == 1) res = res * a % MOD;
            a = a * a % MOD;
            n /= 2;
        }
        return res;
    }

    //---------- 逆元 ----------
    Int inv(Int a){
        return power(a, MOD-2);
    }

    //---------- 階乗 ----------
    vector<Int> factorial(Int n){
        vector<Int> res(n+1, 1);
        rep1(i,n) res[i] = i * res[i-1] % MOD;

        return res; // nまでの階乗の配列を返す
    }


    //--------- 組み合わせ ---------
    Int comb(Int n, Int r){
        return (f[n] * f_inv[r] % MOD) * f_inv[n-r] % MOD;
    }
};


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

    if(M==1){
        if(K == N-1) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }

    Combination C(998244353, N);

    Int ans = 0;
    for(Int i=0; i<=K; i++){        
        Int tmp = M;
        tmp = tmp * C.comb(N-1,i) % C.MOD;
        tmp = tmp * C.power(M-1,N-1-i) % C.MOD;

        ans = (ans + tmp) % C.MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6828
<?php
fscanf(STDIN,'%d',$N);
$A=[];
for ($i=0; $i <$N ; $i++) { 
    # code...
    fscanf(STDIN,'%d',$K);
    $A[]=$K;
}
rsort($A);
echo array_sum($A)-$A[0]/2;
echo "\n";

?>

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else

#endif
int in()
{
	int n = 0, c = gc();

	do n = 10*n + (c & 0xf), c = gc(); 
    while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) {
        pc('0'); return; 
        }

	i = 0;

    while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

void sout(char *s) { while (*s) pc(*s++); }

typedef struct { 
    int parent;
    int depth;
    int k;
    int *c;
    } TREE;
TREE tbl[100002];

void calc_depth(int node, int d)
{
	int i;
	tbl[node].depth = d;

	for (i = 0; i < tbl[node].k; i++) 
    calc_depth(tbl[node].c[i], d+1);
}

int main(){

	int n, i, j, k, id;
	int root;

	n = in();

	for (i = 0; i < n; i++) {

		id = in(), tbl[id].k = k = in();
		tbl[id].c = malloc(k << 2);

		for (j = 0; j < k; j++) {

			int _c = in();
			tbl[_c].parent = id+1;
			tbl[id].c[j] = _c;
		}
	}

	for (root = 0; root < n; root++) {
		if (tbl[root].parent == 0) break;
	}
	
    calc_depth(root, 0);

	for (i = 0; i < n; i++) {

		sout("node "), out(i);
		sout(": parent = ");
		
        if (i == root) sout("-1");
		else out(tbl[i].parent - 1);
		
        sout(", depth = "), out(tbl[i].depth);
		sout(", ");
		
        if (i == root)          sout("root");
		else if (tbl[i].k == 0) sout("leaf");
		else                    sout("internal node");
		
        sout(", [");
		
        if (tbl[i].k > 0) {
			out(tbl[i].c[0]);
			for (j = 1; j < tbl[i].k; j++) {
				pc(','), pc(' '), out(tbl[i].c[j]);
			}
		}
		sout("]\n");
	}
	return 0;
}


Measured memory_bytes: 7440
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long n,a[200005],sum=1;
	cin>>n;
	bool f=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		  f=1;
	}
	if(f)
	{
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(ULLONG_MAX/a[i]<sum||sum*a[i]>1000000000000000000)
	  	{
	  		cout<<-1;
	  		return 0;
		  }
		sum*=a[i];
	}
	cout<<sum;
 } 

Measured memory_bytes: 4384
#include <iostream>
#include <algorithm>

#define range(i,a,b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)

using namespace std;


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int table[30][30];

int sx,sy;
int gx,gy;

int dfs(int n,int cx,int cy){
	//cout << "x "  << cx << " y " <<  cy << endl;
	int res=11;

	if(cx==gx&&cy==gy){
		//cout << "check" << endl;
		return n;
	}

	if(n>=11)
		return res;

	rep(i,4){
		int nx=cx+dx[i];
		int ny=cy+dy[i];


		if(table[nx][ny]==1)
			continue;

	
		while(table[nx][ny]==0){
			nx+=dx[i];
			ny+=dy[i];
		}

		//cout << "x "  << nx << " y " <<  ny << endl;
		//cout << table[nx][ny] << endl;


		if(table[nx][ny]==-1)
			continue;
		
		if(table[nx][ny]==1){
			table[nx][ny]=0;	
			res=min(res,dfs(n+1,nx-dx[i],ny-dy[i]));
			table[nx][ny]=1;
		}

		if(table[nx][ny]==3){
			//cout << "check" << endl;
			res=min(res,dfs(n+1,nx,ny));
		}
		//cout << res << endl;
	}
	return res;
}
int main(void){
	int w,h;
	while(cin >> w >> h,w|h){
		rep(i,30)rep(j,30) table[i][j]=-1;

		range(j,1,h+1)range(i,1,w+1){
			cin >> table[i][j];
			if(table[i][j]==2){
				sx=i;sy=j;
				table[i][j]=0;
			}
			if(table[i][j]==3){
				gx=i;gy=j;
			}
		}

		int res=dfs(0,sx,sy);
		if(res==11)
			cout << -1 << endl;
		else
			cout << res << endl;
		
	}
	return 0;
}

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

typedef long long llong ;

typedef struct
{
	llong size ;
	llong value ;

} Data ;

#define N_MAX 500000
Data art[ N_MAX ] ;

int cmp( const Data *a ,const Data *b )
{
	int ret = a->size == b->size ? a->value - b->value : -( a->size < b->size ) ;

	if( ret == 0 )
	{
		return 1 ;
	}

	return ret ;
}

inline llong max( llong a ,llong b )
{
	return a > b ? a : b ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	qsort( art ,N ,sizeof( Data ) ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

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

	return 0 ;
}


Measured memory_bytes: 17180
/*
* All my senses intensify
* Whenever you and I, we dive
*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf ((ll)1e18)
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    // fast();
    double arr[1005] = {0};
    for(ll i = 1 ; i <= 1000 ; i++)
    {
    	arr[i] = i * ( i + 1) / 2;
    	arr[i] = arr[i] / i;
    }
    ll n , k;
    cin>>n>>k;
    double foo[n];
    for(ll i = 0 ; i < n ; i++ )
    {
    	ll x;
    	cin>>x;
    	foo[i] = arr[x];
    	// cout<<foo[i]<<" ";
    }
    double ans = 0 , sum = 0;
    for(ll i = 0 ; i < k ; i++ )
    	sum+=foo[i];
    ans = sum;
    for(ll i = k ; i < n ; i++ )
    {
    	sum -= foo[i - k];
    	sum += foo[i];
    	ans = max(ans , sum);
    }
    cout.precision(12); cout<<fixed; 
    cout<<ans<<endl;
}


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

long long gcd(long long a, long long b) {
    if(a < b) {
        long long tmp = a;
        a = b;
        b = tmp;
    }
    long long r = a % b;

    while(r > 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

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


int main() {
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
A_h = (T - A) / 0.006
# print(A_h)

# print('HT', HT)
v, idx = 10**10, 0
for i in range(len(H)):
    tmp = abs(H[i] - A_h)
    if v > tmp:
        idx = i
        v = tmp
print(idx + 1)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
const int MAXC = 1E5+5;
char buff[MAXC]{ };
int L, K;

int main()
{
	scanf(" %s", buff);
	scanf("%d", &K);
	for(char * ptr = buff; *ptr && K; ++ptr)
		if((*ptr != 'a') && ('z'-*ptr+1 <= K))
		{	// Greedily Convert All NECESSARY
			K -= ('z'-*ptr+1);
			*ptr = 'a';
		}
	L = strlen(buff);
	K %= 26; // Tack onto Ending
	buff[L-1] = ((buff[L-1] - 'a' + K) % 26 + 'a');
	puts(buff);
	return 0;
}

Measured memory_bytes: 384
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())

for i in range(N-K):
    if T[K+i]==T[i]:
        T[K+i]="x"
    #絶対に次の手を邪魔しない選択ができるので,ダブったら後の手を×にしときゃ良い
ans=T.count("r")*P+T.count("s")*R+T.count("p")*S

print(ans)

Measured memory_bytes: 4084