akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t,c;
	inline void gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			c=s==t?EOF:*s++;
		}else c=*s++;
	}
	template<class IT>inline void gi(IT &x){
		x=0;gc();while(c<'0'||c>'9')gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
	}
	char buf0[20];int a;
	template<class IT>inline void pi(IT x){
		if(x<0){putchar('-');x=-x;}
		do buf0[++a]=x%10+48;while(x/=10);
		while(a)putchar(buf0[a--]);
		putchar('\n');
	}
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=5005;
char c[N<<1],a[N],b[N];
int main(){
	int n,i,j,k,m,t=0,x=0,len,nle,sta,f;char ming='z';
	scanf("%d%d%s",&n,&k,c+1);m=n<<1|1;
	rep(i,1,n)b[i]='z';
//	puts(b+1);
	rep(i,1,n)cmin(ming,c[m-i]=c[i]);
	REP(i,1,m){
		if(c[i]==ming)cmax(x,++t);
		else t=0;
	}
	if(k>13||(len=(x<<(k-1)))>=n){rep(i,1,n)putchar(ming);return 0;}
	nle=n-len;
	sta=len-(x+n);
	t=0;
	REP(j,1,m){
		++sta;
		if(c[j]==ming){
			if(x==(++t)&&j>n){
				f=0;
				per(i,nle,1)a[i]=c[i+sta];
//				printf("j=%d sta=%d nle=%d\n",j,sta,nle);
//				puts(a+1);printf("len=%d\n\n",strlen(a+1));
				per(i,nle,1)if(a[i]!=b[i]){
					f=(a[i]<b[i]);
					break;
				}
//				printf("i=%d f=%d\n\n",i,f);
				if(f)per(i,nle,1)b[i]=a[i];
			}
		}
		else t=0;
	}
	per(i,len,1)putchar(ming);
	per(i,nle,1)putchar(b[i]);
	return 0;
}

Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		vector<double> in(n+1,0);
		vector< vector<double> > dp(n+1, vector<double> (n+1,1.0));
		rep(i,1,n+1)cin>>in[i];
		rep(pos,1,n+1)
		{
			dp[pos][0]=dp[pos-1][0]*(1.0-in[pos]);

			rep(cnt,1,pos)
			{
				dp[pos][cnt]=dp[pos-1][cnt]*(1.0-in[pos]) + dp[pos-1][cnt-1]*in[pos];				
			}

			dp[pos][pos]=dp[pos-1][pos-1]*in[pos];

		}        
		double ans=0.0;
		rep(i,n/2+1,n+1)ans+=dp[n][i];
		cout<<fixed<<setprecision(12)<<ans<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3904
n = gets.to_i

OP0 = 0
OP1 = 1

list = []
while n > 0
	r = n % 2
	
	if r == 0
		list << OP1
		n = n - 1
	end
	list << OP0
	n = (n - 1) / 2
end

a = []
b = []
x = 1

#p list.reverse

first = true
list.reverse.each{|op|
	if op == OP0
		a << x
		b << x
		x += 1
	else
		a << x
		b.unshift(x)
		x += 1
	end
}

ans = a + b
puts ans.length
puts ans.join(" ")



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

const string YES = "Yes";
const string NO = "No";
using ll = long long;

void solve(long long A, long long B, long long C, long long K){
    while(A >= B){
        B *= 2;
        K--;
    }
    while(B >= C){
        C *= 2;
        K--;
    }
    if(K >= 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010,P=1e9+7;
int n,x,y,eg,hd[MAXN],ver[2*MAXN],nx[2*MAXN],siz[MAXN],f[MAXN];
void add_edge (int x,int y) {
	ver[++eg]=y;
	nx[eg]=hd[x];
	hd[x]=eg;
	return;
}
int qpow (int a,int b) {
	int res=1;
	while (b) {
		if (b&1) {res=(1ll*res*a)%P;}
		a=(1ll*a*a)%P,b>>=1; 
	}
	return res;
}
void dfs1 (int x,int fa) {
	siz[x]=1;
	for (int i=hd[x];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		dfs1(ver[i],x);
		siz[x]+=siz[ver[i]];
	}
	f[1]=(1ll*f[1]*siz[x])%P;
	return;
}
void dfs2 (int x,int fa) {
	for (int i=hd[x];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		f[ver[i]]=(1ll*f[x]*((1ll*(n-siz[ver[i]])*qpow(siz[ver[i]],P-2))%P))%P; 
		dfs2(ver[i],x);
	}
	return;
}
int main () {
	scanf("%d",&n);
	f[1]=1;
	for (int i=1;i<=n-1;i++) {
		scanf("%d%d",&x,&y);
		add_edge(x,y),add_edge(y,x);
	}
	dfs1(1,0);
	dfs2(1,0);
	int tmp=1;
	for (int i=1;i<=n;i++) {tmp=(1ll*tmp*i)%P;}
	for (int i=1;i<=n;i++) {printf("%d\n",(1ll*tmp*qpow(f[i],P-2))%P);}
	return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define sc second
#define mod 1000000007
using namespace std;
ll n, v[400001], a, b;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    if(b>=a)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, 0);
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        --t;
        a[t]++;
    }

    for (int i = 0; i < n; ++i) {
        int t = k - (q - a[i]);
        if (t > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define N 100
int main(void){
	int ans,i,A[N];
	char str[N];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		ans=5;
		for(i=0;i<9;i++){
			if(str[i]=='o')
				A[i+1]=1;
			else if(str[i]=='x')
				A[i+1]=0;
			else if(str[i]=='s')
				A[i+1]=5;
		}
		for(i=1;i<8;i+=3){
			if(A[i]==A[i+1] && A[i+1]==A[i+2] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		for(i=1;i<4;i+=1){
			if(A[i]==A[i+3] && A[i+3]==A[i+6] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		if(A[1]==A[5] && A[5]==A[9] && A[1]!=5){
			ans=A[1];
			goto out;}
		if(A[3]==A[5] && A[5]==A[7] && A[3]!=5){
			ans=A[3];
			goto out;}
		out:;
		if(ans==1)
			printf("o\n");
		else if(ans==0)
			printf("x\n");
		else
			printf("d\n");
	}
	return 0;
}

Measured memory_bytes: 520
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const mod = 1000000007

// 乗数計算（MOD)
func mpow(x, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % mod
		}
		x = x * x % mod
		n = n >> 1
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	b := make([][]int, 61)
	for i := 0; i < 61; i++ {
		b[i] = make([]int, N+1)
		for j := 0; j < N; j++ {
			b[i][j+1] = b[i][j] + (a[j]>>uint(i))%2
		}
	}

	ans := 0
	for k := 0; k < 61; k++ {
		cnt := 0
		for j := 0; j < N-1; j++ {
			s := (a[j] >> uint(k)) % 2
			n := N - (j + 1)
			n1 := b[k][N] - b[k][j+1]
			n0 := n - n1
			if s == 0 {
				cnt += n1
			} else {
				cnt += n0
			}
			// out(s, n, n1, n0, cnt)
		}
		for i := 0; i < k; i++ {
			cnt *= 2
			cnt %= mod
		}
		// out(cnt)
		ans += cnt
		ans %= mod
	}
	out(ans)
}


Measured memory_bytes: 154496
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}


Measured memory_bytes: 34448
n = int(input())
a = input()
b = input()
c = input()

if a == b == c:
  print(0)
  exit()

al = list(a)
bl = list(b)
cl = list(c)

cnt = 0
for i in range(n):
  # all match no count
  if al[i] == bl[i] == cl[i]:
    continue
  # two is match
  if al[i] == bl[i]:
    cnt += 1
    continue
  elif al[i] == cl[i]:
    cnt += 1
    continue
  elif bl[i] == cl[i]:
    cnt += 1
    continue
  cnt += 2
print(cnt)

Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

H,W = map(int,input().split())
N = H*W
def num(i,j):
    return i*W+j
def coo(num):
    i = num // W
    j = num % W
    return(i,j)

uf = UnionFind(N)
color = [-1]*N
grid = []
for i in range(H):
    grid.append(list(input()))
for i in range(H):
    for j in range(W):
        color[num(i,j)]= grid[i][j]
for i in range(H):
    for j in range(W-1):
        if grid[i][j] != grid[i][j+1]:
            uf.union(num(i,j),num(i,j+1))
for i in range(H-1):
    for j in range(W):
        if grid[i][j] != grid[i+1][j]:
            uf.union(num(i,j),num(i+1,j))
ans = 0
BW = [[0,0] for _ in range(N)]
for i in range(N):
    root = uf.find(i)
    if color[i] == "#":
        BW[root][0] += 1
    else:
        BW[root][1] += 1
for root in uf.roots():
    ans += BW[root][0]*BW[root][1]
print(ans)

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

N, K = map(int, input().split())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = [0]
while Q:
    i = Q.pop()
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            Q.append(a)

mod = 10**9+7
fa = [1]
for i in range(1, 10**5+100):
    fa.append(fa[-1]*i%mod)
    
def p(n, k):
    if k > n: return 0
    return fa[n] * pow(fa[n-k], mod-2, mod) % mod

ans = K * p(K-1, len(X[0])) % mod
for i in range(1, N):
    ans = ans * p(K-2, len(X[i])) % mod

print(ans)

Measured memory_bytes: 65988
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n,m;
struct Node{
	int a,b;
}r[100010];

bool cmp(Node A,Node B){
	return A.a<B.a;
}
int tot;
ll ans;

int main() {
	n=read();
	m=read();
	for(int i=1;i<=n;i++){
		r[i].a=read();
		r[i].b=read();
	}
	sort(r+1,r+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(tot+r[i].b>=m){
			ans+=(ll)(m-tot)*(ll)r[i].a;
			break;
		} else {
			tot+=r[i].b;
			ans+=(ll)r[i].a*(ll)r[i].b;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    long long int k;
    cin>>k;
    cout<<50<<endl;
    long long int s = k/50;
    long long int m = (50-(k%50));
    for(int i = 0; i <= 50; i++){
        if(i != m){
            cout<<1LL*(s+i)<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, i;
  float money, total = 0;
  char type[4];
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%f %s", &money, type);
    if(strcmp(type, "BTC") == 0) {
      money *= 380000.0;
    }
    total += money;
  }
  printf("%f\n", total);
  return 0;
}


Measured memory_bytes: 128
X=int(input())
if X>=1800:
  print(1)
elif X>=1600:
  print(2)
elif X>=1400:
  print(3) 
elif X>=1200:
  print(4)
elif X>=1000:
  print(5)
elif X>=800:
  print(6)
elif X>=600:
  print(7)
else:
  print(8)

  
  


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

int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a, a + N);
  int answer = 0;
  for (int i = 0; i < N; i++) {
    x -= a[i];
    if (x < 0 || (i == N - 1 && 0 < x)) break;
    answer++;
  }
  cout << answer << endl;
}


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

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 85, MAXM = 1e5 + 5;

int main() {
	int n; cin >> n;
	bool ok = false;
	while(n) {
		ok |= (n%10) == 7;
		n /= 10;
	}
	cout << (ok ? "Yes" : "No") << endl;

}

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

int main() {
    int A;
    int B;
    cin >> A >> B ;

    if (A > 9) {
        cout <<  -1 << endl;
        return 0;
    }
    if (B > 9) {
        cout <<  -1 << endl;
        return 0;
    }

    cout <<  A * B << endl;

    return 0;
}



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

typedef long long int llint;

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

  cin>> a >> b >> c >> x >> y;

  if(a + b <= c * 2) {
    cout<< a * x + b * y <<endl;
  } else {
    int cnt = 0;
    int big, sml, price;
    if(x > y) big = x, sml = y, price = a;
    else      big = y, sml = x, price = b;
    
    cnt += sml * c * 2;
    if((big - sml) * price < (big - sml) * c * 2) cnt += (big - sml) * price;
    else cnt += (big - sml) * c * 2;
    
    cout<< cnt <<endl;
  }
    

  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
maze = [input() for _ in range(h)]
total = 0
for maz in maze:
    for m in maz:
        if m == "#":
            total += 1

ans = False
def search(x,y,count):
    global ans
    if x == w-1 and y == h-1 and maze[y][x] == "#" and total == count:
        ans = True
        return
    if x < w-1 and maze[y][x+1] == "#":
        search(x+1,y,count+1)
    if y < h-1 and maze[y+1][x] == "#":
        search(x,y+1,count+1)

if maze[0][0] == "#":
    search(0,0,1)
if ans:print("Possible")
else:print("Impossible")

Measured memory_bytes: 3064
#include <iostream>

int main()
{
  int N;
  int t[110000], x[110000], y[110000];
  std::cin >> N;
  t[0] = x[0] = y[0];
  for (int i=1; i<=N; i++)
    std::cin >> t[i] >> x[i] >>y[i];

  bool can = true;
  for (int i=0; i<N; i++){
    int dt   = t[i+1] + t[i];
    int dist = std::abs(x[i+1] -x[i])
                + std::abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist%2 != dt%2) can = false;
  }

  if (can) std::cout <<"Yes" << '\n';
  else std::cout << "No" << '\n';
}


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

int N,H[100010],dp[100010] = {0};

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> H[i];
		dp[i] = 1e9;
	}
	dp[1] = 0;
	for(int i=1;i<N;i++){
		dp[i+1] = min(dp[i+1],dp[i]+abs(H[i]-H[i+1]));
		dp[i+2] = min(dp[i+2],dp[i]+abs(H[i]-H[i+2]));
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
L,R=map(int,input().split())
ans=2018
if R-L>=673:
    print(0)
    exit()
for i in range(R-L):
    for j in range(i+1,R-L+1):
        if ans>((L+i)*(L+j))%2019:
            ans=((L+i)*(L+j))%2019
print(ans)

Measured memory_bytes: 3060
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 7660
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000};

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  int N, L;
  cin >> N >> L;
  int answer {};
  int minest_abs {L+1-1};
  srep(i,2,N+1) {
    int t = L+i-1;
    if (std::abs(t) < std::abs(minest_abs)) {
      answer += minest_abs;
      minest_abs = t;
    } else {
      answer += t;
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 888
import java.io.*;// 从这行开始复制，这是第一行
import java.util.*;

public class Main {

    /**
     * TODO 提交的时候一定要设置为 true
     */
    private boolean submitFlag = true;

    private void solve() {
        int ans = 0;


        System.out.println(ans);
    }


    private void run() throws IOException {
        setReader();

        //TODO 从这里开始读入题目输入
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }

        for (int i = 0; i < k; i++) {
            int[] b = new int[n + 1];
            for (int x = 0; x < n; x++) {
                int left = Math.max(0, x - a[x]);
                b[left]++;
                if (x + a[x] + 1 < n) {
                    b[x + a[x] + 1]--;
                }
            }
            boolean flag = true;
            a[0] = b[0];
            if (a[0] != n) {
                flag = false;
            }
            for (int j = 1; j < n; j++) {
                a[j] = a[j - 1] + b[j];
                if (a[j] != n) {
                    flag = false;
                }
            }
            if (flag) {
                System.out.print(a[0]);
                for (int ii = 1; ii < n; ii++) {
                    System.out.print(" " + a[ii]);
                }
                return;
            }

        }

        System.out.print(a[0]);
        for (int ii = 1; ii < n; ii++) {
            System.out.print(" " + a[ii]);
        }
    }


//    main以及输入输出========================================================================

    public static void main(String[] args) throws IOException {
        Main solution = new Main();
        solution.run();
        solution.reader.close();
    }

    /**
     * TODO 存档时，改一下moduleName
     */
    String moduleName = "atcoder-race";

    /**
     * 注意不同题目这里路径要设一下
     *
     * @throws IOException
     */
    private void setReader() throws IOException {
        if (submitFlag) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            String projectPath = System.getProperty("user.dir");
            String modulePath = projectPath + "/" + moduleName + "/src/main/java/";
            String className = this.getClass().getPackage().getName().replace(".", "\\");
            reader = new BufferedReader(new FileReader(modulePath + className + "\\input.txt"));
        }
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String next() throws IOException {
        return nextToken();
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 60492
s = list(input())
ans = []
answer = ''
# print(s)
# print(type(s))
for i in range(len(s)):
    if s[i] == '0':
        ans.append(0)
    elif s[i] == '1':
        ans.append(1)
    else:
        if len(ans) == 0:
            continue
        else:
            del ans[-1]

for i in range(len(ans)):
    answer = answer + str(ans[i])
print(answer)


Measured memory_bytes: 3060
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var A = Number.parseInt(inputStr[1]);
  var B = Number.parseInt(inputStr[2]);
  //AとBの小さい値に人数を掛けて計算する
  console.log(Math.min(A,(B/N)) * N);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
// 17.07.2017


# include <iostream>
# include <algorithm>


using namespace std;

# define lint long long int

//# define __TRR__

const int N = 200100;

lint a [N], n, k, m, mi;

int main ()
{
# ifdef __TRR__
   freopen ("C.TXT", "r", stdin);
   freopen ("C.OUT", "w", stdout);
# endif

   cin >> n;

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

   k = a [0], m -= k;
   mi = abs (m - k);
   for ( int i = 1; i < n-1; i++ )
   {
      k += a [i], m -= a [i];
      if ( abs (m - k) < mi )
         mi = abs (m - k);
   }

   cout << mi;

   return 0;
}


Measured memory_bytes: 1792
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
 
ans = 0
twopow = 1
for n in range(60):
    one = 0
    for i in range(N):
        one += A[i] & 1
        A[i] >>= 1
    zero = N - one
    ans = (ans + (one * zero) * twopow) % MOD
    twopow = twopow << 1 % MOD

print(ans)

Measured memory_bytes: 122808
# 「xor 和と加算和とが等しい」という条件が、「条件を満たす区間の部分区間も条件を満たす」
n = int(input())
a = list(map(int,input().split()))
res = 0
r = 0
s = 0
for l in range(n):
    while (r < n and s^a[r] == s+a[r]):
        s += a[r]
        r += 1
    res += r-l
    if l == r:
        r += 1
    else:
        s -= a[l]
print(res)

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

int main() {
    long long n, d, ans=0;
    cin >> n >> d;
    for(int i=0; i<n; i++){
        long long x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3632
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース


*/

//main.cpp----------------------------
#define MAX 100000

int a[5];

int main() {

  rep(i, 5) cin >> a[i];

  int min = 11, index = -1;
  rep(i, 5) {
    if((min>a[i]%10)&&(a[i]%10!=0)) {
      min = a[i]%10;
      index = i;
    }
  }
  int sum = 0;
  rep(i, 5) {
    if(i!=index) {
      sum += a[i];
      if(a[i]%10!=0) sum += 10-a[i]%10;
    }else sum += a[i];
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <numeric>
#include <iterator>

using namespace std;

//mergesort to count tentou-suu
long merge_sort(const vector<int>::iterator beg, const vector<int>::iterator end){
  if(beg+1 >= end) return 0;

  //divide
  const auto mid = beg+(end-beg)/2;
  long inversion_count =
    merge_sort(beg, mid) +
    merge_sort(mid, end);
  
  //conquer
  vector<int> buff(end - beg);
  auto h1 = beg, h2 = mid;
  for(int& s : buff){
    if(h1 == mid){
      s = *(h2++);
    }
    else if(h2 == end){
      s = *(h1++);
    }
    else{
      inversion_count += (*h1 <= *h2 ? 0 : mid - h1);
      s = (*h1 <= *h2 ? *(h1++) : *(h2++));
    }
  }
  auto itr = beg;
  for(auto s : buff){
    //*(itr++) = s;
    *itr = s;
    ++itr;
  }

  return inversion_count;
}


int main(){
  ios::sync_with_stdio(false);
  
  int n;
  vector<int> a;
  cin >> n;
  for(int i = 0; i<n; ++i){int a_i; cin >> a_i; a.push_back(a_i);}
  
  //calc
  long inversion_count = merge_sort(a.begin(), a.end());
  
  // for(unsigned int i=0; i<a.size(); ++i){
  //   cout << (i==0?"":" ") << a[i];
  // }
  // cout << endl;
  cout << inversion_count << endl;
  return 0;
}

Measured memory_bytes: 2860
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=(f,F),(f,-F),;H=(F,f),(-F,f),
for i in r(n):*a,c=I();R+=(a,c),;Y+=c,;X+=a
for i in r(m):a,*b=I();H+=(a,b),;X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*-~K for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]-=1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]-=1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in(-1,0),(1,0),(0,1),(0,-1),:
  c=x+e;d=y+f
  if 1-v[d][c]and(U[(f>0)+y][x]*f+V[y][(e>0)+x]*e)==0:q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

Measured memory_bytes: 551256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  const int mod=1000000007;
  int n,m,a,i;
  vector<int> dp(100010,0);
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> a;
    dp.at(a)=-1;
  }
  dp.at(0)=1;
  if (dp.at(1)!=-1) dp.at(1)=1;
  for (i=2;i<=n;i++) if (dp.at(i)!=-1){
    if (dp.at(i-2)!=-1) dp.at(i)=(dp.at(i)+dp.at(i-2))%mod;
    if (dp.at(i-1)!=-1) dp.at(i)=(dp.at(i)+dp.at(i-1))%mod;
  }
  cout << dp.at(n) << endl;
  return 0;
}

Measured memory_bytes: 768
module Point = struct

  type t = { x : float; y : float }

  let make x y = { x; y }

  let equal a b = abs_float (a.x -. b.x) < 1e-10 && abs_float (a.y -. b.y) < 1e-10

  let sum a b = { x = a.x +. b.x; y = a.y +. b.y }

  let diff a b = { x = a.x -. b.x; y = a.y -. b.y }

  let multi p k = { x = p.x *. k; y = p.y *. k }

  let div p k = { x = p.x /. k; y = p.y /. k }

  let norm p = p.x *. p.x +. p.y *. p.y

  let abs p = norm p |> sqrt

  let dot a b = a.x *. b.x +. a.y *. b.y

  let cross a b = a.x *. b.y -. a.y *. b.x

  let project p1 p2 p =
    let base = diff p2 p1 in
    dot (diff p p1) base /. norm base
    |> multi base
    |> sum p1

  let reflect p1 p2 p =
    multi (diff (project p1 p2 p) p) 2.
    |> sum p

end

open Point

let eps = 1e-10

let ccw p0 p1 p2 =
  let a = diff p1 p0 in
  let b = diff p2 p0 in
  let c = cross a b in
  if c > eps then "COUNTER_CLOCKWISE"
  else if c < (-. eps) then "CLOCKWISE"
  else if dot a b < (-. eps) then "ONLINE_BACK"
  else if norm a < norm b then "ONLINE_FRONT"
  else "ON_SEGMENT"

let () =
  let x0, y0, x1, y1 = Scanf.scanf "%f %f %f %f " (fun a b c d -> a,b,c,d) in
  let p0 = make x0 y0 in
  let p1 = make x1 y1 in
  let q = Scanf.scanf "%d " (fun i -> i) in
  for _ = 0 to q - 1 do
    let x, y = Scanf.scanf "%f %f " (fun x y -> x,y) in
    make x y |> ccw p0 p1 |> print_endline
  done

Measured memory_bytes: 2784
#include <stdio.h>
int main()
{
    char a[4];
    int count=0,result,i;
    scanf("%s",a);
    for(i=0;i<3;i++)
        {
        if(a[i]=='o')
        count++;
        }
        result=700+count*100;
        printf("%d\n",result);
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define maxn 200010
char s[maxn];
int main(){
	int n,l,r,cnt;
	scanf("%d%s",&n,s+1);
	l=1,r=n,cnt=0;
	while(l<r){
		while(s[l]=='R')l++;
		while(s[r]=='W')r--;
		if(l<r)cnt++,s[l]='R',s[r]='W';
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1868
L, = map(int, raw_input().split())
A = [0]*L
dp = []
for i in xrange(L):
  A[i], = map(int, raw_input().split())
  dp.append([float("inf")]*5)
i=0
e = 2-A[i] if A[i]<2 else A[i]%2
o = 1 if A[i]==0 else (A[i]+1)%2
dp[0][0] = A[0]
dp[0][1] = e
dp[0][2] = o
dp[0][3] = e
dp[0][4] = A[0]
for i in xrange(1, L):
  e = 2-A[i] if A[i]<2 else A[i]%2
  o = 1 if A[i]==0 else (A[i]+1)%2
  dp[i][0] = min(dp[i-1][:1]) + A[i]
  dp[i][1] = min(dp[i-1][:2]) + e
  dp[i][2] = min(dp[i-1][:3]) + o
  dp[i][3] = min(dp[i-1][:4]) + e
  dp[i][4] = min(dp[i-1][:5]) + A[i]
print min(dp[-1])

Measured memory_bytes: 62852
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main(void)
{
    int N;
    cin >> N;

    long long ans = 1;
    for (long long i = 1; i <= N; i++)
    {
        ans *= i;
        ans %= (1000000000 + 7);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define forn1 for(i=1; i<=n; i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    x=100;
    while(x<n)
    {
        x+=(x*.01);
        c++;
    }
    cout<<c<<endl;
}


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

using namespace std;
int main() {
  
  string S;
  
  
  cin >> S;
  
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) {
    cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
  }

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

typedef pair<int,int>P;
#define fi first
#define se second


int n,k ;

vector<P>A;

void dfs(vector<int> v,int now){
  r(i,v.size()){
    A.push_back(P(v[i],now));
  }
  if(now*2+1<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+1);
  }
  if(now*2+2<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+2);
  }
}

//int x=0;

string output(int num){

  //cerr<<"aaa:"<<num<<endl;
  //if(x++==10)exit(0);

  cout<<num<<endl;

  string s;
/*
  const int atari = 3;

  if(atari == num)return "Yes";

  r(i,A.size()){
    if(A[i].fi==num-1 && A[i].se+1 == atari)return "Near";
    if(A[i].se==num-1 && A[i].fi+1 == atari)return "Near";
  }
  return "No";
*/
  cin>>s;
  return s;
}

int main(){

  cin>>n>>k;

  vector<int>init;

  dfs(init,0);

  cout<<A.size()<<'\n';

  r(i,A.size()){
    cout<<A[i].fi+1<<' '<<A[i].se+1;
    if(i!=(int)A.size())cout<<'\n';
    else cout<<endl;
  }

  while(k--){

    int idx=0,p=0,F=-1,S=0;

    while(1){

      if(!p){
        string s=output(idx+1);
        if(s=="Yes"){
          S++;
          break;
        }
        p++;
      }

      int nex=idx*2+1;

      if(nex>=n)break;

      string s=output(nex+1);

      if(s=="No"){
        F=nex+1;
        idx=idx*2+2;
      }

      else if(s=="Yes"){
        S++;
        break;
      }

      else{
        idx=idx*2+1;
      }
      if(idx>=n)break;
    }

    if(!S){

      //cout<<F<<endl;

      if(F+1<=n){
        string s=output(F+1);
        //cout<<s<<endl;
        if(s=="Yes")continue;
      }

      if(F-1>=1){
        string s=output(F-1);
        if(s=="Yes")continue;
      }
      //cout<<"ERROR"<<endl;
      //exit(1);
    }

  }

}


Measured memory_bytes: 3348
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readLongList()
    val aList = readIntegerList().map { it - 1 }

    val counts = IntArray(n.toInt())
    var current = 0
    var i = 0
    while (counts[current] == 0) {
        counts[current] = i
        val next = aList[current]
        current = next
        i++
    }

    val ans = if (k <= counts[current]) {
        current = 0
        repeat(k.toInt()) { current = aList[current] }
        current + 1
    } else {
        val tmp = k - counts[current]
        val loopCount = counts.max()!! - counts[current] + 1
        val ansIndex = tmp % loopCount
        repeat(ansIndex.toInt()) { current = aList[current] }
        current + 1
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 65352
N,M=map(int,input().split())
s=[]
for j in range(M):
    x=list(map(int,input().split()))
    if N in x and 1 in x:
        print("POSSIBLE")
        exit()
    if N in x:
        x.remove(N)
        s+=x
    if 1 in x:
        x.remove(1)
        s+=x
if len(list(set(s)))!=len(s):
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE") 

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

const int N = 8e5+5;

void solve(){
 ll d,t,s;
 cin>>d>>t>>s;
 if(s*t >= d){
   cout<<"Yes";
 }
 else{
   cout<<"No";
 }
}
int main(){
  // freopen("input.txt", "r",stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin>>t;
  t = 1;
  while(t--){
    solve();
  }
}
























/*
  1 2 3 4 5 6 7 8

  6 7 8 1 2 3 4 5


*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define N 1001
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
int n;
char G[N][N];

typedef pair<P,int>PP;
int getIdx(const vector<PP>&V,PP &a,PP &b){
  int f = (a.first.first + b.first.first)%4;
  int s = (a.first.second + b.first.second+1)%2;
  for(int i=0;i<(int)V.size();i++)  if(V[i].first == P(f,s)) return i;
  assert(0);
}

int judge(vector<PP> sta,int turn){
  vector<P> v;
  for(PP p:sta) while(p.second--) v.push_back(p.first);
  assert((int)v.size()==2);
  P a = v[0], b = v[1];
  return
    turn ^ a.second ^ b.second ^
    (a.first==2 || a.first == 3) ^
    (b.first==2 || b.first == 3);
}

map<vector<PP>,bool> mem;
int dfs(vector<PP> sta,int turn){
  int sum = 0;
  for(PP p:sta) sum += p.second;
  if(sum == 2) return judge(sta,turn);
  if(mem.count(sta)) return mem[sta];

  int res = turn;
  for(PP &a:sta)
    for(PP &b:sta){
      a.second--; b.second--;
      if(a.second < 0 || b.second < 0) {a.second++;b.second++;continue;}
      int idx = getIdx(sta,a,b); sta[idx].second++;
      int result = dfs(sta,!turn);
      turn == 0? (res |= result):(res &= result);
      a.second++, b.second++, sta[idx].second--;
    }
  return mem[sta] = res;
}

void visit(int pos,int num,vector<int> &used,vector<int> &par){
  par[pos] = num;
  if(used[pos]++) return;
  for(int to=0;to<n;to++) if(G[pos][to]=='Y') visit(to,num,used,par);
}

vector<PP> prepare(){
  vector<int> par(n),used(n,0);
  int cnt = 0;
  for(int i=0;i<n;i++) if(used[i] == 0) visit(i,cnt++,used,par);

  vector<P> A(cnt,P(0,0)); //nodes,edges;
  for(int i=0;i<n;i++){
    A[par[i]].first++;
    for(int j=0;j<n;j++) A[par[i]].second+=G[i][j] == 'Y';
  }
 
  //for(P &a:A) cout<<a.first<<" "<<a.second<<endl; 
  for(P &a:A) a.first%=4, a.second=(a.second/2)%2;
  
  map<P,int> M;
  for(int i=0;i<4;i++)
    for(int j=0;j<2;j++) M[P(i,j)] = 0;
  for(P a:A) M[a]++,M[a]%=4;
  vector<PP> V;
  for(PP m:M) V.push_back(m);
  return V;
}


signed main(){
  cin >> n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) cin>>G[i][j];
  
  vector<PP> v = prepare();
  int ans = dfs(v,0);
  cout<<(ans?"Taro":"Hanako")<<endl;
  return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  repr(i, 0, n) {
    if (i < n - 1)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}



Measured memory_bytes: 3224
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

s = input()
n = len(s)

l = [0]*(n+1)
cnt=0
for i in range(n):
    if s[i]=="<":
        cnt+=1
    else:
        cnt=0
    l[i+1] = cnt

for i in range(n)[::-1]:
    if s[i]==">":
        cnt+=1
    else:
        cnt=0
    l[i] = max(l[i],cnt)

print(sum(l))

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

namespace Beg097D
{
    public class UnionFind
    {
        public static int[] pars;

        public UnionFind(int N)
        {
            pars = new int[N];
            for (int i = 0; i < N; i++) pars[i] = i;
        }

        private int root(int x)
        {
            if (pars[x] == x) return x;
            else
            {
                pars[x] = root(pars[x]);
                return pars[x];
            }
        }

        public void unit(int x, int y)
        {
            var rx = root(x);
            var ry = root(y);
            if (rx != ry)
            {
                pars[ry] = rx;
            }
        }

        public bool isSame(int x,int y)
        {
            return root(x) == root(y);
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];
            var ps = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var tree = new UnionFind(N);

            for (int i = 0; i < M; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                if (!tree.isSame(read[0] - 1, read[1] - 1)) tree.unit(read[0] - 1, read[1] - 1);
            }

            int ans = 0;
            for(int i=0;i<N;i++)
            {
                if (tree.isSame(ps[i] - 1, i)) ans++;
            }

            Console.WriteLine(ans);
        }

    }
}


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

#define COLS 12
#define ROWS 12

using namespace std;

void dfs(int map[][COLS+2], int i, int j){
	int di[] = {1,0,0,-1};
	int dj[] = {0,-1,1,0};

	if( map[i][j] == 0 ) return ;
	else map[i][j] = 0;
	for(int m = 0; m < sizeof(di)/sizeof(di[0]); m++)
		dfs(map, i + di[m], j + dj[m]);
}

int main(void){
	while( true ){
		int cnt = 0;
		int map[ROWS+2][COLS+2] = {{0,},};

		if( cin.eof() ) break;
		for(int i = 0; i < ROWS; i++){
			char buf[32];
			string s;
			cin.getline(buf,sizeof(buf)/sizeof(buf[0]));
			s = buf;

			if( cin.eof() ) return 0;
			for(int j = 0; j < COLS; j++)
				if( s[j] == '1' ) map[i+1][j+1] = 1;	
		}
		cin.ignore();

		for(int i = 0; i < ROWS; i++)
			for(int j = 0; j < COLS; j++)
				if( map[i+1][j+1] == 1 ){
					dfs(map, i+1, j+1);
					cnt++;
				}

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int ans,s1,s2,n,a;
int solve(int tl);
string text;

int main(){

    while(1){
        cin >> n;
        if(n==0)break;
        cin >> a >> text;
        s1=text.size();
        ans=0;

        while(s1>=2*n+1){
            //cout <<" " << text.size()-s1 << endl;
            if(text[text.size()-s1]=='I')ans+=solve(text.size()-s1);
            s1--;
            }
        cout << ans << endl;
        ans=0;

    }

    return 0;
}

int solve(int tl){
    int i=1;
    int ccc=0;
    for(i=1;i<2*n+1;i+=2){
        if(text[tl+i]=='O'&&text[tl+i+1]=='I');
        else return 0;
    }
        ccc++;
        while(i<s1){
            if(text[tl+i]=='O'&&text[tl+i+1]=='I'){
            i+=2;
            s1-=2;
            ccc++;
            }else break;
        }
        return ccc;

}

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

int main(){
    string ss;
    while( cin >> ss ){
        int n[10];
        for( int i = 0; i < 10; i++){
            n[i] = ss[i] - '0';
        }
        for(int i = 9; i > 0; i--){
            for(int j = 0; j < i; j++){
                n[j] = (n[j] + n[j+1])%10;
            }
        }
        cout << n[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, k;
int val[256];
vector<char> e[N];
void init() {
	mt(val, 0);
	rep(i, 0, N) e[i].clear();
}
int main() {
	while(cin>>n>>k) {
		init();
		int s, p, r;
		cin>>s>>p>>r;
		val['s'] = s; val['p'] = p; val['r'] = r;
		string t; cin>>t;
		rep(i, 0, sz(t)) e[i%k].pb(t[i]);
		ll ret = 0;
		rep(i, 0, k) {
			if(!sz(e[i])) continue;
			e[i].pb('#');
			int cnt = 0;
			// rep(j, 0, sz(e[i])) dd(i), de(e[i][j]);
			rep(j, 0, sz(e[i])-1) {
				cnt++;
				char nc = e[i][j+1], c = e[i][j];
				// dd(c);de(nc);
				if(nc!=c) {
					ll add = 1ll * (cnt + 1ll) / 2 * val[c];
					// if(cnt == 1) add = val[c];
					// else add = 1ll * (cnt - 1) * val[c];
					// dd(nc);dd(c);de(add);
					ret += add;
					cnt = 0;
				}
			}
		}
		printf("%lld\n", ret);
	}
    return 0;
}


Measured memory_bytes: 7808