akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   string s,t;
   cin>>s>>t;
   int ans=10000;
   
   for(int i=0; i<=s.length()-t.length(); i++){
       int x=i;
       int c=0;
       for(int j=0; j<t.length(); j++){
           if(t[j]==s[x]){
               x++;
               continue;
           }else{
               c++;
           }
           x++;
       }
       ans = min(ans, c);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3680
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll ans = 1;
    rep(i,0,N){
        if(A[i] == 0){
            print(0);
            return;
        }
        if(ans > INF / A[i]){
            print(-1);
            return;
        }else{
            ans *= A[i];
        }
    }
    print(ans);


    

}

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

Measured memory_bytes: 4440
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
 
 

 
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        {
        	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)
	    cin>>a[i];
	ll cnt[64]={0},ans=0,p=1;
 
    
    for(ll i=0;i<n;i++)
    {
        ll c=0;
        while(a[i]>0)
        {
            cnt[c]+=a[i]%2;
            a[i]/=2;
            c++;
        }
    }
  
    for(ll i=0;i<64;i++)
    {
        p=pow(2,i);
        p%=MOD;
        ans+=((((n-cnt[i])*cnt[i])%MOD)*p%MOD);
        ans%=MOD;
  }
  cout<<ans;
        }
        return 0;
}

Measured memory_bytes: 5580
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n, k;
	cin >> n >> k;
	long long ans=pow(n/k,3);
	if(!(k%2))
		ans+=pow(n/(k/2)-n/k,3);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	
	static int[] w;
	
	public static int steps(int value, int goal) {
		System.out.println(value+" "+goal);
		if (value==goal) return 0;
		else {
			int min = 1<<30;
			if (value >= 2 && value > goal) min = Math.min(min, steps(value-1 , goal) + 1);
			if (value < goal) min = Math.min(min, steps(value+1 , goal) + 1);
			for (int i=0; i<w.length; i++) {
				min = Math.min(min, steps(value + w[i] , goal) + 10);
			}
			return min;
		}
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int a = sc.nextInt(), b = sc.nextInt(), q = sc.nextInt();
		
		TreeSet<Long> shrines = new TreeSet<Long>(),
				temples = new TreeSet<Long>();
		
		for (int i=0; i<a; i++) shrines.add(sc.nextLong());
		for (int i=0; i<b; i++) temples.add(sc.nextLong());
		
		for (int i=0; i<q; i++) {
			long s = sc.nextLong();
			Long leftS = shrines.floor(s), rightS = shrines.ceiling(s),
					leftT = temples.floor(s), rightT = temples.ceiling(s);
			if (leftS==null) leftS = -1L<<60; 
			if (leftT==null) leftT = -1L<<60; 
			if (rightS==null) rightS = 1L<<60; 
			if (rightT==null) rightT = 1L<<60; 
			//both left
			long min = Math.max(s-leftS, s-leftT);
			//both right
			min = Math.min(min, Math.max(rightS-s, rightT-s));
			//leftS, rightT
			min = Math.min(min, (s-leftS) + (rightT-s) + Math.min((s-leftS), (rightT-s)));
			//leftT, rightS
			min = Math.min(min, (s-leftT) + (rightS-s) + Math.min((s-leftT), (rightS-s)));
			System.out.println(min);
			
		}
		
		//topcoders, codeforces, aiio(australian judges), atcoders, codechef
		
		
//		int n = sc.nextInt(), mp = 0;
//		int[] goals = new int[3];
//		for (int i=0; i<3; i++) goals[i] = sc.nextInt();
//
//		w = new int[n];
//		
//		for (int i=0; i<n; i++) {
//			w[i] = sc.nextInt();
//			
//		}
//	
//		
//		
//		for (int l=0; l<3; l++) {
//			int r = 1<<30;
//			for (int i=0; i<n; i++) {
//				r = Math.min(r, steps(w[i],goals[l]));
//			}
//			mp += r;
//		}
//		
//		System.out.println(mp);
		
		




		//		int[] w = new int[n];
		//		for (int i=0; i<n; i++) {
		//			w[i] = sc.nextInt();
		//			for (int l=0; l<3; l++) {
		//				if (w[i]==goals[l]) {
		//					goals[l] = -1;
		//					w[i] = 1<<30;
		//				}
		//			}
		//		}
		//
		//		for (int i=0; i<n; i++) {
		//			for (int l=0; l<3; l++) {
		//				if (goals[l]>0 && Math.abs(goals[l]-w[i])<=10) {
		//					goals[l] = -1;
		//					w[i] = 1<<30;
		//					mp += Math.abs(goals[l]-w[i]);
		//				}
		//			}
		//		}
		//
		//		for (int l=0; l<3; l++) {
		//			if (goals[l]==-1) continue;
		//			int min = 1<<30;
		//			int get = goals[l];
		//			for (int i=0; i<n-1; i++) {
		//				for (int q=i+1; q<n; q++) {
		//					int first = w[i], second = w[q];
		//					if (min > Math.abs(get - (first+second))) {
		//						min = Math.abs(get - (first+second));
		//					}
		//
		//				}
		//
		//			}
		//			mp += min;
		//		}
		//		System.out.println(mp);





	}
}


Measured memory_bytes: 109408
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int k = nextInt();

    int[] p = new int[n];
    for(int i=0;i<n;i++){
      p[i] = nextInt();
    }

    Arrays.sort(p);

    long ans = 0;

    for(int i=0;i<k;i++){
      ans+=p[i];
    }



    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 38144
s = input()
t = s.replace('BC', 'D')
a_count = 0
ans = 0
for i in range(len(t)):
    if t[i] == 'A':
        a_count += 1
    elif t[i] == 'D':
        ans += a_count
    else:
        a_count = 0
print(ans)

Measured memory_bytes: 3500
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        System.out.println(a >= 13 ? b : (a <= 5 ? 0 : b/2));
   }
}


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

int main(){
	int x = 0, N, t = 0;
	cin >> N;
	string S;
	cin >> S;
	for(int i = 0; i < N; i++){
		if(S[i] == 'I'){
			x++;
		}else if(S[i] == 'D'){
			x--;
		}
		if(t < x){
			t = x;
		}
	}
	cout << t << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = input()
    K= int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    keta=100+1
    dp=[[0]*(keta+1) for _ in range(keta+1)]
    dp[0][0]=1

    for i in range(1,keta+1):
        for j in range(0,i+1):
            dp[i][j]+=dp[i-1][j]+dp[i-1][j-1]*9
    l=len(N)
    cur0=0
    tot=0
    for i,si in enumerate(N):
        n=int(si)
        if n!=0:
            tot+=(n-1)*dp[l-1-i][K-i-1+cur0]+dp[l-1-i][K-i+cur0]
        else:
            cur0+=1
    ic=0
    for s in N:
        if s!='0':ic+=1
    if ic==K:tot+=1
    print(tot)
    

        
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 63680
#pragma region header
#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
#define mp make_pair
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i > static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
using namespace std;

using vi = vector<int>;

template <class T>
void COUT(const T &x) { cout << x << endl; }

constexpr int lshift(const int &x) noexcept { return 1ll << x; }

#pragma endregion header

void solve(int N, vi a, vi b) {
  int ans = 0;
  vi t(30, 1);
  rep(i, 29) t[i + 1] = t[i] << 1;
  rrep(k, 29) {
    each(x, a) x %= t[k + 1];
    each(x, b) x %= t[k + 1];
    sort(all(b));
    bool odd = false;
    int t1 = t[k], t2 = t[k] * 2, t3 = t[k] * 3, t4 = t[k] * 4;
    each(x, a) odd ^= ((lower_bound(all(b), t4 - x) - lower_bound(all(b), t3 - x)) ^ (lower_bound(all(b), t2 - x) - lower_bound(all(b), t1 - x))) & 1;
    if(odd) ans += lshift(k);
  }
  COUT(ans);
}


#pragma region main
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);

  int N;
  cin >> N;
  vi a(N);
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  vi b(N);
  for(int i = 0 ; i < N ; i++){
    cin >> b[i];
  }
  solve(N, move(a), move(b));
}
#pragma endregion main


Measured memory_bytes: 6268
N, M = map(int, input().split())
a_b = []
for _ in range(M):
    a, b = map(int, input().split())
    a_b.append((a, b))
a_b.sort(key=lambda x: x[0])

r = a_b[0][1]
ans = 1
for a, b in a_b[1:]:
    if a >= r:
        r = b
        ans += 1
        continue
    if b < r:
        r = b
print(ans)

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

int main() {

	int n, m; cin >> n >> m;
	vector<int> num(n + 1, 0);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		num[a]++;
		num[b]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==1 && s[i]=='R'){
      cout<<"No"<<endl;
      break;
    }
    else if(i%2==0 && s[i]=='L'){
      cout<<"No"<<endl;
      break;
    }
    if(i==s.size()-1){
      cout<<"Yes"<<endl;
    }
  }
}


Measured memory_bytes: 256
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()}
 
      
n, q = list(map(lambda x: int(x), input().split()))
uf = UnionFind(n)
for _ in range(q):
    t, u, v = list(map(lambda x: int(x), input().split()))
#     print(uf.parent_indexes)
    if t == 0:
        uf.union(u, v)
        continue
    print('1') if uf.same(u, v) else print('0')

Measured memory_bytes: 11600
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    if(a+b<10) cout << a+b << endl;
    else cout << "error" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 2e5 + 10;
int n,a[maxn];
map<int,int> memo;
signed main() {
  IO;
  cin >> n;
  rep(i,2,n) cin >> a[i];
  rep(i,1,n){
  	memo[a[i]]++;
  }
  rep(i,1,n){
  	cout << memo[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
  ll n;
  cin>>n;
  vector<ll> w(n),s(n),ans(n);
  cin>>w[0];
  s[0]=w[0];
  rep(i,1,n) {
    cin>>w[i];
    s[i]+=s[i-1]+w[i];
  }
  rep(i,0,n){
    ans[i]=abs(s[n-1]-2*s[i]);
  }    
  cout<<*min_element(range(ans));
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.nextLine();
		
		StringBuffer sb = new StringBuffer(str).reverse();
		
		System.out.println(sb);

	}

}

Measured memory_bytes: 17116
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
struct UFS{
	int n;
	int par[200005];
	void init(int _n){
		n=_n;
		for(int i=0;i<n;i++)par[i]=i;
	}
	int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
	bool unite(int x,int y){
		int nx=find(x),ny=find(y);
		if(nx==ny)return false;
		par[nx]=ny;
		return true;
	}
}uf;
int n,q,best[400005];
vector<pair<int,pair<int,int> > >edge;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>q;uf.init(n);
	memset(best,inf,sizeof best);
	for(int i=1;i<=q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		edge.push_back(make_pair(c,make_pair(a,b)));
		best[a]=min(best[a],c+1);best[a+n]=min(best[a+n],c+1);best[b]=min(best[b],c+2);best[b+n]=min(best[b+n],c+2);
	}
	for(int i=1;i<2*n;i++){
		best[i]=min(best[i],best[i-1]+2);
	}
	for(int i=n;i<2*n;i++){
		edge.push_back(make_pair(best[i],make_pair(i%n,(i+1)%n)));
	}
	sort(edge.begin(),edge.end());
	int ans=0;
	for(auto e:edge){
//		cerr<<e.second.first<<" "<<e.second.second<<" "<<e.first<<endl;
		ans+=uf.unite(e.second.second,e.second.first)*e.first;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19308
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    long long int H;
    int u=1;
    cin>>H;
    while (H != 1)
    {
        H = H/2;
        u++;
    }
    long long int z = pow(2, u);
    z--;
    cout<<z;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  map<char,int> mp;
  for(int i = int('a');i<int('a')+26;i++){
    mp[char(i)] = 0;
  }
  string s;
  cin >>s;
  for(auto p : s){
    mp[p] ++;
  }
  for(auto p : mp){
    if(p.second == 0){
      cout << p.first << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head = (head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a<b?a:b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head =1;
  tail=n+1;


  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11864
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
//LLONG_MIN

//AC

int main(void){
	ll a[1000];
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	cout<<(a[2]-a[0])<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,s;
int rec(int sum,int dig,int cnt);
int main(){
  while(1){
    scanf("%d %d",&n,&s);
    if(n==0&&s==0)break;
    printf("%d\n",rec(0,0,0));
  }
  return 0;
}
int rec(int sum,int dig,int cnt){
  if(cnt>n||sum>s) return 0;
  if(cnt==n&&sum==s) return 1;
  if(dig>9) return 0;
  int ret=0;
  ret+=rec(sum+dig,dig+1,cnt+1);
  ret+=rec(sum,dig+1,cnt);
  return ret;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int main()
{
	bool vis[maxn]={0};
	int n;
	cin>>n;
	while(n%2==0) n/=2;
	while(n%5==0) n/=5;
	
	if(n==1){
	    cout<<1<<'\n';
	    return 0;
	}
	
	queue<int> q;
	q.push(1);
	vis[1]=1;
	int cnt=1;
	
	while(!q.empty()){
		int tmp=q.size();
		REP(i,tmp){
			int cur=q.front();
			//cout<<cur<<'\n';
			q.pop();
			if(cur==0){
				cout<<cnt<<'\n';
				return 0;
			}
			while(!vis[(cur+1)%n]){
				q.push((cur+1)%n);
				vis[(cur+1)%n]=1;
				cur=cur*10%n;
			}
		}
		cnt++;
	}
	
	return 0;
}












Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int X;

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

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

signed main(){
	cin>>X;
	int L=lcm(360,X);
	cout<<L/X<<endl;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> t(n+1);
	vector<int> x(n+1);
	vector<int> y(n+1);

	for(int i = 1; i <= n; i++){
		cin >> t.at(i) >> x.at(i) >> y.at(i);
	}

	bool can = true;
	for(int i = 0; i < n; i++){
		int dt = t.at(i+1)-t.at(i);
		int dist = abs(x.at(i+1)-x.at(i)) + abs(y.at(i+1)-y.at(i));
		if(dt < dist) can = false;
		if(dt%2 != dist%2) can = false; 
	}
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;

}

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

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

  int ans=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')s[i]='1';
    else s[i]='0';
  }

  for(int i=s.size(); i>0; i--){
    string t;
    for(int j=0; j<i; j++)t.push_back('1');

    if(s.find(t)!=-1){
      ans=i;
      break;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long

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

    vector<ll> p[26];

    string s , t;
    cin >> s >> t;
    ll n = s.size();
    for(int i = 0 ; i < n ; i++) p[s[i] - 'a'].push_back(i);

    ll cur = -1 , out = 0;
    for(auto i : t)
    {
        if(!p[i - 'a'].size()) return cout << -1 , 0;

        int nxt = upper_bound(p[i - 'a'].begin() , p[i - 'a'].end() , cur) - p[i - 'a'].begin();
        if(nxt == p[i - 'a'].size())
        {
            out++;
            cur = p[i - 'a'][0];
        }
        else
        {
            cur = p[i - 'a'][nxt];
        }
    }
    cout << out * n + cur + 1;

    return 0;
}


Measured memory_bytes: 1736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define REP(i,n)  for(int i=0;i<(n);i++)

void trace(int a[], int n){
    REP(i, n){
        if(i>0)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

void insertSort(int a[], int n){
    int j, i, v;
    for(i = 1;i<n;i++){
        v=a[i];
        j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        trace(a,n);
    }
}

int main(){
    int n;
    int a[100];
    
    scanf("%d", &n);
    REP(i, n)scanf("%d", &a[i]);
    
    trace(a,n);
    insertSort(a, n);
    
    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n;cin>>n;
        string s;cin>>s;
        int k;cin>>k;
        char d;
        for(int i=0;i<n;i++){
            if(i==k-1){
                d=s[i];
            }
        }
        for(int i=0;i<n;i++){
            if(d!=s[i]){
                s[i]='*';
            }
        }
        for(int i=0;i<n;i++)
        cout<<s[i];
        return 0;
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        char ch;
        cin>>ch;
        if(ch>='A' && ch<='Z')
            cout<<"A"<<'\n';
        else    cout<<"a\n";
    }
    return 0;
}

Measured memory_bytes: 3636
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = A[left:mid] + [float("inf")]
    R = A[mid:right] + [float("inf")]

    i = 0
    j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return right - left

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = mergeSort(A, left, mid)
        cnt2 = mergeSort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0

n = int(input())
S = [int(s) for s in input().split()]

ans = mergeSort(S, 0, n)

print(*S)
print(ans)

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

int main(){
	int a,b;
	char c;
	while(1){
	cin>>a>>c>>b;
    if(c=='+'){
	cout<<a+b<<endl;
}
	else if(c=='-'){
    cout<<a-b<<endl;
}
    else if(c=='*'){
	cout<<a*b<<endl;
}
	else if(c=='/'){
	cout<<a/b<<endl;
}
	else if(c=='?'){
	break;
}
}
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(void)
{
	int a = 0,b = 0,k = 0;
	scanf("%d %d %d",&a,&b,&k);
	int i;
	for(i = 1;i <= k; i++){
		if(i %2 == 1){
			if(a % 2 == 1)
				a--;
			a /= 2;
			b += a;
		}
		else{
			if(b % 2 == 1)
				b--;
			b /= 2;
			a += b;
		}
	}
	printf("%d %d",a,b);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;
int n,m,k;
int a[200010] = {};
int b[200010] = {};
int as[200010] = {};
int bs[200010] = {};
ll bsearch(int A){
    // 条件を満たす最大値を求める
    ll ok = 0;  //解が存在する値
    ll ng = m+1;//解が存在しない値 

    // 条件を満たす最小を求める
    // ll ok = 100;  //解が存在する値
    // ll ng = -1;  //解が存在しない値 

    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(A + bs[mid] <= k){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}
/*----------------------------------------------------------------*/
signed main(){

	
	cin >> n >> m >> k;
	rep(i,n)cin >> a[i];
	rep(i,m)cin >> b[i];

	rep(i,n)as[i+1] = as[i]+a[i];
	rep(i,m)bs[i+1] = bs[i]+b[i];

	int ans = 0;
	rep(i,n+1){
		int A = as[i];
		if(A > k)continue;
		int B = bsearch(A);
		chmax(ans,B+i);
		// cerr << i << " : " << A << "," << bs[B] << endl;
	}

	cout << ans << endl;

	



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc172.contest.atcoder.jp/tasks/abc172_c

Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int index = 0;
  cin >> index;
  
  cout << num.at(index - 1) << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int edge[199999][2];

int qmem[499996];

int *e[200000];
int el[200000];

int s[200000];
int rs[200000];
int is[200000];
int par[200000];

int d[200000][6];

int x[200000];

int main(void){
	int n=nextpint();
	int q=nextpint();
	for(int i=0; i<n-1; i++){
		int A=nextpint()-1;
		int B=nextpint()-1;
		edge[i][0]=A;
		edge[i][1]=B;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=0; i<n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<n-1; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
		e[B][el[B]++]=A;
	}
	s[0]=0;
	rs[0]=0;
	is[0]=1;
	int S=1;
	for(int i=0; i<n; i++){
		for(int j=0; j<el[s[i]]; j++){
			int p=e[s[i]][j];
			if(is[p]==0){
				s[S]=p;
				rs[p]=S;
				S++;
				par[p]=s[i];
				is[p]=1;
			}
		}
	}
	for(int i=0; i<q; i++){
		int p=nextpint()-1;
		int X=nextpint();
		x[p]+=X;
	}
	for(int i=0; i<n; i++){
		int p=s[i];
		int X=x[p];
		for(int j=0; j<el[p]; j++){
			int q=e[p][j];
			if(q!=par[p]){
				x[q]+=X;
			}
		}
	}
	for(int i=0; i<n-1; i++){
		printf("%d ", x[i]);
	}
	printf("%d\n", x[n-1]);
}


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

int dp[305][305][305];

int main(){
  
  string s;
  int K;
  
  cin>>s>>K;
  
  memset(dp,-1,sizeof(dp));
  
  dp[0][s.size()-1][0]=0;
  
  int ans=0;
  
  for(int l=0;l<s.size();l++)
    
    for(int r=s.size()-1;r>=l;r--){

      for(int k=0;k<=K;k++){
	
	if(dp[l][r][k]==-1) continue;
	
	if(s[l]==s[r]){
	  if(l==r) ans=max(ans, dp[l][r][k]+1);
	  else{
	    dp[l+1][r-1][k]=max(dp[l+1][r-1][k], dp[l][r][k]+2);
	    ans=max(ans, dp[l+1][r-1][k]);
	  }
	}
	
	if(l==r) continue;
	
	if(k<K){
	  dp[l+1][r-1][k+1]=max(dp[l+1][r-1][k+1], dp[l][r][k]+2);
	  ans=max(ans, dp[l+1][r-1][k+1]);
	}
	
	dp[l+1][r][k]=max(dp[l+1][r][k], dp[l][r][k]);
	dp[l][r-1][k]=max(dp[l][r-1][k], dp[l][r][k]);
	dp[l+1][r-1][k]=max(dp[l+1][r-1][k], dp[l][r][k]);
      }
    }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 111104
using System;

class DigitsInMultiplication {
    static void Main(string[] args)
    {
        long N = 0, A = 0, B = 0;
        string s;

        s = Console.ReadLine();

        N = Int64.Parse(s);

        for (A = 1; A <= N; A++) {
            if (A*A > N)
                break;
            if (N % A == 0)
                B = A;
        }
        Console.WriteLine(((N/B).ToString()).Length);
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
    
    IOS
    int a,b,c;
    cin>>a>>b>>c;
    int d=c-a-b;
    if(d>0&&4*a*b<(c-a-b)*(c-a-b)){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }


    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string s;
	cin>>s;

	REP(i,0,s.size()){
		cout<<"x";
	}
	cout<<endl;

	return 0;
}

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	string s;
	cin >> n >> s;
	LL low = 0;
	LL high = n;
	while (high-low > 1){
		LL mid = (high+low)/2;
		bool good = false;
		for (LL i = 0; i+mid <= n; i++){
			string needle = s.substr(i,mid);
			vector<LL> next(mid+1,-1);
			for (LL j = 0; j < mid; j++){
				LL back = next[j];
				while (back >= 0 && needle[back] != needle[j])
					back = next[back];
				next[j+1] = back+1;
			}
			LL pos = 0;
			for (LL j = i+mid; j < n; j++){
				while (pos >= 0 && needle[pos] != s[j])
					pos = next[pos];
				pos++;
				if (pos == mid){
					good = true;
					pos = next[pos];
				}
			}
		}
		if (good)
			low = mid;
		else
			high = mid;
	}
	cout << low << "\n";
}


Measured memory_bytes: 256
package main

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

var dp []int64

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}
func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	n, _ := strconv.Atoi(getNextLine(scanner))
	// var n int
	// fmt.Fscan(fp, &n)
	aList := make([]int, n)
	hList := make([]int, n)
	h := strings.Split(getNextLine(scanner), " ")
	a := strings.Split(getNextLine(scanner), " ")
	for i := 0; i < n; i++ {
		hList[i], _ = strconv.Atoi(h[i])
		// fmt.Fscan(fp, &h)
		// hList[i] = h
	}
	for i := 0; i < n; i++ {
		aList[i], _ = strconv.Atoi(a[i])
		// fmt.Fscan(fp, &a)
		// aList[i] = a
	}

	segSize := 1
	for segSize < n {
		segSize = segSize << 1
	}
	dp = make([]int64, segSize*2)
	for i := 0; i < n; i++ {
		dp[segSize-1+hList[i]-1] = int64(aList[i]) + query(0, hList[i]-1, 0, 0, segSize)
		update(segSize - 1 + hList[i] - 1)
	}
	fmt.Println(query(0, n, 0, 0, n))
}

func query(a int, b int, k int, l int, r int) int64 {
	if b <= l || r <= a {
		return int64(0)
	}
	if a <= l && r <= b {
		return dp[k]
	}
	vl := query(a, b, k*2+1, l, (l+r)/2)
	vr := query(a, b, k*2+2, (l+r)/2, r)
	if vl < vr {
		return vr
	}
	return vl
}

func update(i int) {
	for i > 0 {
		i = (i - 1) / 2
		dp[i] = dp[i*2+1]
		if dp[i] < dp[i*2+2] {
			dp[i] = dp[i*2+2]
		}
	}
}


Measured memory_bytes: 32792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int t = -1;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i] >>= 1;
        int foo = a[i];
        int cnt = 0;
        while(foo % 2 == 0){
            ++cnt;
            foo /= 2;
        }
        if(t == -1) t = cnt;
        else{
            if(t != cnt){
                cout << 0 << endl;
                return 0;
            }
        }
        a[i] >>= t;
    }
    m >>= t;
    ll lcm = 1;
    for(int i = 0; i < n; ++i){
        int g = __gcd(lcm, (ll)a[i]);
        lcm = lcm / g * a[i];
        if(lcm > m){
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = m / lcm;
    if(ans % 2 == 0)    ans >>= 1;
    else    ans = (ans >> 1) + 1;
    cout << ans << endl;
}

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

struct Node{
    int num, cost;
};

vector<int> tree[100005];
int d[2][100005];
int n;

void bfs(int p, int s){
    for(int i=1;i<=n;++i)d[p][i] = INT_MAX;
    d[p][s] = 0;
    queue<Node> que;
    que.push((Node){s, 0});
    while(!que.empty()){
        Node curr = que.front(); que.pop();
        for(int next : tree[curr.num]){
            int newcost = curr.cost + 1;
            if(newcost < d[p][next]){
                d[p][next] = newcost;
                que.push((Node){next, newcost});
            }
        }
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    bfs(0, 1);
    bfs(1, n);
    int fennec = 0, snuke = 0;
    for(int i=1;i<=n;++i){
        if(d[0][i] <= d[1][i])fennec++;
        else snuke++;
    }

    cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;

    return 0;
}


Measured memory_bytes: 6724