akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>

using namespace std;

const double eps = 1e-12;
typedef complex<double> Point;

ostream& operator<<(ostream& os, const Point& p){
    return os <<  p.real() << " " << p.imag();
}

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps) return  1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)     return  2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

int main(){
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    Point p0(x0, y0), p1(x1, y1);
    auto state = [](int x){switch(x){
        case  1: return "COUNTER_CLOCKWISE";
        case -1: return "CLOCKWISE";
        case  2: return "ONLINE_BACK";
        case -2: return "ONLINE_FRONT";
        case  0: return "ON_SEGMENT";
    }};
    int q;
    cin >> q;
    while(q--){
        int x2, y2;
        cin >> x2 >> y2;
        cout << state(ccw(p0, p1, Point(x2, y2))) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1132
#include<stdio.h>
int main()
{
	int h, w, k;
	scanf("%d %d %d", &h, &w, &k);
	char s[10][10];
	int i, j;
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	int mh, mw;
	mh = 1;
	for (i = 0; i < h; i++)
		mh *= 2;
	mw = 1;
	for (i = 0; i < w; i++)
		mw *= 2;
	int ans = 0;
	int p[10], q[10];
	int a, b, c;
	for (a = 0; a < mh; a++)
	{
		c = a;
		for (i = 0; i < h; i++)
		{
			p[i] = c % 2;
			c /= 2;
		}
		for (b = 0; b < mw; b++)
		{
			c = b;
			for (j = 0; j < w; j++)
			{
				q[j] = c % 2;
				c /= 2;
			}
			c = 0;
			for (i = 0; i < h; i++)
				for (j = 0; j < w; j++)
					if (s[i][j] == '#' && p[i] == 0 && q[j] == 0)
						c++;
			if (c == k)
				ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

namespace Contest
{
	class Program
	{
		static void Main()
		{
			int[] nums =  { -1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
			var xy = Console.ReadLine().Split().Select(int.Parse);
			int x = xy.First(), y = xy.Last();
			Console.WriteLine(nums[x] == nums[y] ? "Yes" : "No");
#if DEBUG
			Console.ReadKey();
#endif
		}
	}

	public class Operation
	{
		public int Num { get; set; }
		public int Repeats { get; set; }
	}
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, i, j, tmp, cnt = 0;
  int num[100];
  
	cin >> N;
  
	for( i = 0 ; i < N ; i++){
    cin >> num[i];
  	}
	
  for(i = 0 ; i < N ; i++){
    for(j = N - 1 ; j >= i+1 ; j--){
      if(num[j] < num[j-1]){
    tmp = num[j];
    num[j] = num[j-1];
    num[j-1] = tmp;
    cnt++;
      }
    }
  }
  for(i = 0 ; i < N-1 ; i++){
  	cout << num[i] << " ";
  	}
	cout << num[N-1] << endl;
	cout << cnt << endl;
	
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	
	int N, tmp;
	vector<int> A, in;
	int first, second;
	
	cin >> N;
	for(int i=0; i<N; i++) {
		cin >> tmp;
		A.push_back(tmp);
	}
	
	in = A;
	sort(A.begin(), A.end(), greater<int>());
	first = A[0];
	second = A[1];
	for(int i=0; i<N; i++) {
		cout << ((in[i] == first) ? second : first) << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3316
fun main(args: Array<String>) {
	val x: Long = readLine()!!.toLong()
  	
  	var dep: Long = 100
  	var i = 0
  	
    while(true) {
    	val plus = dep * 0.01
      	dep = dep + plus.toLong()
        i++
      	
      	if (dep >= x) {
          	break
        }
    }
  
    print("$i")
}

Measured memory_bytes: 34400
#include <stdio.h>;
//#include "Main.h"

int main(void)
{
	int a;
	char s[11];
	scanf("%d", &a);
	scanf("%s", s);
	if (a >= 3200)
	{
		printf("%s",s);
	}
	else
	{
		printf("red");
	}
	return 0;
}

Measured memory_bytes: 128
fun main(args:Array<String>) {
  val (n, k) = readLine()!!.split(" ").map(String::toInt)

  val bs = mutableMapOf<Int,Int>()
  readLine()!!.split(" ").map(String::toInt).map {
    if( bs.get(it) == null ) bs[it] = 0
    
    bs[it] = bs[it]!! + 1
  }
  val cs = bs.toList().sortedBy { it.second }.slice( 0..(bs.size - k - 1) )
  println(cs.map { it.second }.sum() )
}


Measured memory_bytes: 103392
#include<stdio.h>

int main(void)
{
	int i=0,n1=1,n2=1,a[10000],b[10000];
	
	for(i=0;n1!=10001;i++){
		scanf("%d %d",&n1,&n2);
		a[i]=n1;
		b[i]=n2;
		if(n1==0&&n2==0){n1=10001;
		}
	}
	for(n1=0;n1+1<i;n1++){
		if(a[n1]<b[n1]) printf("%d %d\n",a[n1],b[n1]);
		else printf("%d %d\n",b[n1],a[n1]);
	}
	return 0;
}

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

int main() {
    int n;
    string str;
    cin >> n >> str;

    int count = 0;
    int status = 0;

    for (int i = 0; i < n; i++){
        if (str.at(i) == 'A'){
            status = 1;
        }
        else if (str.at(i) == 'B' && status == 1){
            status = 2;
        }
        else if (str.at(i) == 'C' && status == 2){
            count++;
            status = 0;
        }
        else{
            status = 0;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
import collections as cl

n,m0,m1 = map(int,input().split())

c0 = list(range(n+1))
c1 = c0[:]
a0 = []
a1 = []
for i in range(n+1):
  a0.append([i])
  a1.append([i])

for i in range(m0):
  p,q = map(int,input().split())
  s = c0[p]
  t = c0[q]
  if s == t:
    continue
  if len(a0[s]) < len(a0[t]):
    p,q = q,p
    s,t = t,s
  for x in a0[t]:
    c0[x] = s
  a0[s] += a0[t]
  a0[t] = []
  
for i in range(m1):
  p,q = map(int,input().split())
  s = c1[p]
  t = c1[q]
  if s == t:
    continue
  if len(a1[s]) < len(a1[t]):
    p,q = q,p
    s,t = t,s
  for x in a1[t]:
    c1[x] = s
  a1[s] += a1[t]
  a1[t] = []
  
c = [c0[i]*n+c1[i] for i in range(n+1)]
p = cl.Counter(c)
#print(c)
#print(p)
#quit()
ans = [str(p[c[i]]) for i in range(1,n+1)]
print(" ".join(ans))

Measured memory_bytes: 92368
/*
 * FileName:     B
 * CreatedDate:  2020-03-01 21:13:57 +0900
 * LastModified: 2020-03-01 21:27:26 +0900
 */

#include <stdio.h>

int main(void){
    int a[3][3],b,ura_a[3][3];
    int i,j,k;
    for(i=0;i<3;i++){
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
        ura_a[i][0]=0;
        ura_a[i][1]=0;
        ura_a[i][2]=0;
    }
    int N;
    scanf("%d",&N);
    for(k=0;k<N;k++){
        scanf("%d",&b);
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
                if(a[i][j]==b){
                    ura_a[i][j]=1;
                }
            }
        }
    }
    for(i=0;i<3;i++){
        if(ura_a[i][0]==1 && ura_a[i][1]==1 && ura_a[i][2]==1){
            printf("Yes\n");
            return 0;
        }
        if(ura_a[0][i]==1 && ura_a[1][i]==1 && ura_a[2][i]==1){
            printf("Yes\n");
            return 0;
        }
    }
    if(ura_a[0][0]==1 && ura_a[1][1]==1 && ura_a[2][2]==1){
        printf("Yes\n");
        return 0;
    }
    if(ura_a[2][0]==1 && ura_a[1][1]==1 && ura_a[0][2]==1){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;

}


Measured memory_bytes: 128
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int a,b;
signed main(){
    I(a); I(b);
    auto g = __gcd(a,b);
    int n = g;
    int ans = 1;
    int i = 2;
    while (i*i <= g){
        if(n%i == 0){
            ans++;
            while(n % i == 0) n /= i;
        }
        i++;
    }
    if (n>1) ans++;
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int sum_num(int a)
{
    int s = 0;
    while (a)
    {
        s += a % 10;
        a /= 10;
    }
    return s;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    rep2(i, 1, n + 1)
    {
        int num = sum_num(i);
        if (a <= num && num <= b)
        {
            ans += i;
        }
    }

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


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n;
    char a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"="<<endl;

    else if(a>b)
        cout<<">"<<endl;

    else
        cout<<"<"<<endl;



    return 0;
}





Measured memory_bytes: 3636
#include<stdio.h>
const int m = 1000000007;

long long dp[1001][1001];
char a[1001][1001];

int main() {
	dp[0][1] = 1;
	int h, w;
	scanf("%d%d", &h, &w );
	for( int i=1; i<=h; ++i ) { 
		scanf("%s",&a[i][1]);
		for( int j=1; j<=w; ++j )
			if( a[i][j] == '.' )
				dp[i][j] = (dp[i][j-1]+dp[i-1][j])%m;
			else
				dp[i][j] = 0;
	}
	printf("%lld\n", dp[h][w] );
}


Measured memory_bytes: 8960
#include<stdio.h>

void func(int a, int *sum, int *msum, int *max){
  *sum = *sum + a;
  a = a % 10;
  a = 10 - a;
  a = a % 10;
  *msum = *msum + a;
  if(*max < a){
    *max = a;
  }
}

int main(void){
  int a, b, c, d, e;
  int sum=0, msum=0, max=0;
  scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);

  func(a, &sum, &msum, &max);
  func(b, &sum, &msum, &max);
  func(c, &sum, &msum, &max);
  func(d, &sum, &msum, &max);
  func(e, &sum, &msum, &max);

  printf("%d\n", sum + msum - max);

  return 0;
}


Measured memory_bytes: 128
n, k, q = map(int, input().split())

A = list(map(int, [input() for _ in range(q)]))

sc = [k]*n
for a in A:
    sc[a-1] += 1

for i in range(len(sc)):
    if sc[i] > q:
        print("Yes")
    else:
        print("No")


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

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	// bet[a][b]: a以上b以下ということ
	vector<vector<int>> bet(N+1, vector<int>(N+1, 0));
	for(int i=0;i<M;i++) {
		int l, r;
		cin >> l >> r;
		bet[l][r]++;
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=N;j++) {
			// bet[i][j]は左i, 右jの以下の全て
			bet[i][j] = bet[i][j] + bet[i-1][j] + bet[i][j-1] - bet[i-1][j-1];
		}
	}

	for(int i=0;i<Q;i++) {
		int p, q;
		cin >> p >> q;
		cout << bet[q][q] - bet[p-1][q] - bet[q][p-1] + bet[p-1][p-1] << endl;
	}
}

Measured memory_bytes: 1920
import java.util.Scanner;

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

        int K = sc.nextInt();
        int X = sc.nextInt();

        int rslt = K * 2 - 1;

        for (long i = 0; i < rslt; i++) {
            System.out.print(X - K + i + 1);
            if (i != rslt - 1) {
                System.out.print(" ");
            }
        }
        System.out.println();
    }
}

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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>> S(H,vector<int>(W));
  vector<int> X(N),Y(N),A(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i) >> Y.at(i) >> A.at(i);
  }
  for(int i=0;i<N;i++){
    if(A.at(i)==1){
      for(int j=0;j<H;j++){
        for(int k=0;k<X.at(i);k++){
          S.at(j).at(k)=1;
        }
      }
    }
    else if(A.at(i)==2){
      for(int j=0;j<H;j++){
        for(int k=X.at(i);k<W;k++){
          S.at(j).at(k)=1;
        }
      }
    }
    else if(A.at(i)==3){
      for(int j=0;j<Y.at(i);j++){
        for(int k=0;k<W;k++){
          S.at(j).at(k)=1;
        }
      }
    }
    else{
      for(int j=Y.at(i);j<H;j++){
        for(int k=0;k<W;k++){
          S.at(j).at(k)=1;
        }
      }
    }
  }
  int sum=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)==0){
        sum++;
      }
    }
  }
  cout << sum << endl;
}

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

int main(){

  int x,y;
  int tmp;

  cin >> x >> y;

  if(y>x){
    tmp=x;
    x=y;
    y=tmp;
  }

  while(y>0){
    tmp = x%y;
    x=y;
    y=tmp;
  }

  cout << x << endl;

  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main() {
	int n;
	cin >> n;
	hei(ll) a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 1;
	rep(i,0, n) {
		if (ans == 0) {
			cout << 0 << endl;
			return 0;
		}
		if (1000000000000000000 / ans < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    bool ok = true;
    rep(i,N) {
        cin>>A;
        if(A%2 == 0){
            if(A%3 != 0 && A%5 != 0) ok = false;
        }
    }
    cout<<(ok ? "APPROVED" : "DENIED")<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

template <typename T>
void inputList(vector<T>* list, int n, int sortType = 0)
{
  repl(i, n)
  {
    T tmp;
    cin >> tmp;
    list->push_back(tmp);
  }
  if(sortType == 0)
  {
    sort(list->begin(), list->end());
  }
  else if(sortType == 1)
  {
    sort(list->begin(), list->end(), greater<T>());
  }
}


int main()
{
  ll n;
  cin >> n;
  vector<ll> list;
  inputList<ll>(&list, n, 2);
  map<ll, ll> tmp;
  tmp[0] = 1;
  
  ll ans = 0;
  ll baseh = list[0];
  repl(i, n)
  {
    if(i == 0)
    {
      continue;
    }
    
    ll v = list[i] + list[0] - i; 
    ans += tmp[v];
    
    ll v2 = -list[i] + list[0] - i;
    if(tmp.find(v2) == tmp.end())
    {
      tmp[v2] = 1;
    }
    else
    {
      tmp[v2] = tmp[v2] + 1;
    }
    
  }
  
  cout << fixed << ans << endl;
  
  return 0;
}

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

void solve(void) {
	int n, i;
	cin >> n;
	vector<int> v(n, 0), dp(n, 0);
	for(auto&t: v) cin >> t;
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for(i = 2; i < n; ++i) dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
	cout << dp[n-1] << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
int a[3][100005],n;
int dp[3][100005];
int main (){
	int i,j,k;
	n=read();
	for (i=1;i<=n;i++)
	{a[1][i]=read();}
	for (i=1;i<=n;i++)
	{a[2][i]=read();}
	for (i=1;i<=2;i++)
	{for (j=1;j<=n;j++)
	{if (i==1) {dp[i][j]=dp[i][j-1]+a[i][j];}
	else {dp[i][j]=max(dp[i][j-1]+a[i][j],dp[i-1][j]+a[i][j]);}
	}
	}
	printf ("%d",dp[2][n]);
	return 0;
}
	

Measured memory_bytes: 256
N=int(input())

shisu26=[]

def shinhou26(M):
    #26進法の一番下の数を出力して、更新する関数
    #これに26進法の答えをいれていく
    amari=M%26
    shisu26.append(amari)
    if M>26:
        if M%26==0:
            M=(M-26)//26
            return M
        else:
            M=(M-M%26)//26
            return M
    elif M==26:
        M=0
        return M
    else:
        M=0
        return M
    #0をストップシグナルとする

for i in range(15):
    #十分な回す回数
    N=shinhou26(N)
    if N==0:
        break

shisu26=list(reversed(shisu26))
alp="zabcdefghijklmnopqrstuvwxy"

ans=""
for i in shisu26:
    s=alp[i]
    ans+=str(s)
print(ans)


Measured memory_bytes: 61688
#include<iostream>
using namespace std;
int main() {
	int n, d, x;
	cin >> n;
	cin >> d >> x;
	int *a = new int[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int result = x;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j * a[i] + 1 <= d; ++j) {
			result++;
		}
	}
	cout << result;
	delete[]a;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(10**12)

ans = 0
now = T[0]
i = 0

while i < N:
    ans += 1
    num = 0
    while i < N and T[i] <= now+K and num < C:
        num += 1
        i += 1
    now = T[i]
print(ans)
    

Measured memory_bytes: 81068
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    ll k; cin >> k;
    bool flag = true;
    char cc = s[0];
    REP(i, s.size()){
        if(s[i] != cc) flag = false;
    }
    if(flag) cout << (s.size()*k)/2 << endl;
    else{
        ll fr=0, bk=0;
        char c1 = s[0];
        REP(i, s.size()){
            if(s[i] != c1){
                break;
            }
            else{
                fr++;
            }
        }
        char c2 = s[s.size()-1];
        for(int i=s.size()-1; i>=0; i--){
            if(s[i] != c2){
                break;
            }
            else{
                bk++;
            }
        }
        ll res = 0;
        ll cnt = 0;
        char c3 = 'A';
        REP(i, s.size()){
            //cout << cnt << endl;
            if(s[i] != c3){
                c3 = s[i];
                res += k*(cnt/2);
                cnt = 1;
            }
            else{
                cnt++;
                if(i == s.size()-1) res += k*(cnt/2);
            }
        }
        //cout << res << endl;
        if(s[0] == s[s.size()-1]) res -= (k-1)*(fr/2 + bk/2 - (fr+bk)/2);
        cout << res << endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <chrono>
// #include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846
 
ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}
 
int pow(int a,int b){
	if(b == 0)return 1;
	int res = pow(a,b/2);
	res = res*res;
	if(b&1)res *= a;
	return res;
}

int ceil(int a,int b){
	if(a%b == 0)return a/b;
	return a/b+1;
}


bool compare(char c,char c1){
	if(c == '1')return true;
	else if(c == '2' && c1 == '0')return true;
	return false;
}



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
    // int t;
    //  cin >> t;
 
 //     while(t--){

 // }

int n;
cin >> n;

int pos[n];
int neg[n];
fo(i,0,n){
	int x,y;
	cin >> x >> y;
	pos[i] = x+y;
	neg[i] = x-y;
}

int max_pos = -mod;
int min_pos = mod;
int max_neg = -mod; 
int min_neg = mod;

fo(i,0,n){
	max_pos = max(pos[i],max_pos);
	min_pos = min(pos[i],min_pos);
	max_neg = max(neg[i],max_neg);
	min_neg = min(neg[i],min_neg);
}
cout << max(max_pos-min_pos,max_neg-min_neg) << endl;





return 0;
	
	}


Measured memory_bytes: 6760
n, h, w= [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(n)] 
#print(n,h,w)
#print(e)
cnt=0
for j in range(n):
  if e[j][0]>=h and e[j][1]>=w:
    cnt+=1
print(cnt)

Measured memory_bytes: 3188
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        (h,w):(usize,usize),
        m:usize,
        objects:[(usize,usize);m],
    }
    let objects = objects
        .iter()
        .map(|&(x, y)| (x - 1, y - 1))
        .collect::<Vec<_>>();
    let mut row_objects = vec![0; h];
    let mut column_objects = vec![0; w];
    for &(x, y) in objects.iter() {
        row_objects[x] += 1;
        column_objects[y] += 1;
    }
    let &row_max = row_objects.iter().max().unwrap();
    let row_max_num = row_objects.iter().filter(|&&val| val == row_max).count();
    let &column_max = column_objects.iter().max().unwrap();
    let column_max_num = column_objects
        .iter()
        .filter(|&&val| val == column_max)
        .count();
    let max_pattern = row_max_num * column_max_num;
    let bomb_pattern = objects
        .iter()
        .filter(|&&(x, y)| row_objects[x] == row_max && column_objects[y] == column_max)
        .count();
    let ans = if max_pattern > bomb_pattern {
        row_max + column_max
    } else {
        row_max + column_max - 1
    };
    println!("{}", ans);
}

Measured memory_bytes: 17756
import java.util.Arrays;
import java.util.Scanner;

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

    int[] n = new int[3];
    for (int i = 0; i < 3; i++) n[i] = scanner.nextInt();
    Arrays.sort(n);

    int r = n[2] - n[0] + n[2] - n[1];
    if (r % 2 == 0) {
      System.out.println(r / 2);
    } else {
      System.out.println((r + 3) / 2);
    }
  }
}


Measured memory_bytes: 21844
#include "iostream"
#include "algorithm"
#include "cmath"
#include "cstdlib"

using namespace std;

int main()
{	
	int a, b, c, d;

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

	int a_b = abs(a - b);
	int a_c = abs(a - c);
	int b_c = abs(b - c);

	if (a_c <= d || (a_b <= d) && (b_c <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;

   cin>>n;
   m=n;
   for (ll i=1;i*i<=n;i++){

     m= ((n%i)? m: min(m,i+n/i-2) );
   }
   cout<<m<<endl;
   return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	int j = 0, i = n - 1;
	for (; i > j; i--)
	{
		if (s[i] == 'R' && s[j] == 'W')
		{
			j++; ans++;
		}
		else if (s[i] == 'R' && s[j] != 'W')
		{
			j++; i++;
		}
	}
	cout << ans;
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    double n,x;
    string u;
    cin >>n;
    
    double ans = 0.0;
    for(int i=0;i<n;i++){
        cin >>x >>u;
        if(u == "BTC"){
            x*= 380000.0;
        }else if(u == "JPY"){
            x*=1.0;
        }
        ans+=x;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int T[N],Tsum=0;
    for(int i=0;i<N;i++){
        cin>>T[i];
        Tsum+=T[i];
    }
    int M;
    cin>>M;
    int P[M],X[M];
    for(int i=0;i<M;i++){
        cin>>P[i]>>X[i];
    }
    for(int i=0;i<M;i++){
        cout<<Tsum-T[P[i]-1]+X[i]<<endl;
    }
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()))
# n, k, q = 6, 3, 4
# a = [3, 1, 3, 2]
ans = []
s = []
for i in range(n):
    # ans.append('Yes')
    s.append(k - q)
# print(s, ans)
for i in range(q):
    s[a[i] - 1] += 1
ans = []
for i in s:
    if i > 0:
        ans.append('Yes')
    else:
        ans.append('No')
# print(s)
print('\n'.join(ans))


Measured memory_bytes: 12852
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 1100000
#define Nmax 17
typedef struct {
	int digit_val;
	int a;
	int b;
	bool fix[Nmax];
} num_bit;
using namespace std;
int Diff_bit(int a, int b, int digit)
{
	if (!((a >> digit) % 2) && (b >> digit) % 2)
		return 1;
	else if ((a >> digit) % 2 && !((b >> digit) % 2))
		return -1;
	else return 0;
}

int Pm_bit(int num, int digit)
{
	if ((num >> digit) % 2)
		return 1;
	else return -1;
}

void num_write(num_bit num)
{
	if (num.digit_val == 1)
	{
		cout << num.a << " " << num.b << " ";
	}
	else
	{
		int i = 0, j = 0;
		while (1)
		{
			if (Diff_bit(num.a, num.b, i) != 0 && !(num.fix[i]))
				break;
			i++;
		}
		num.fix[i] = true;
		while (1)
		{
			if (!(num.fix[j]))
				break;
			j++;
		}

		num_bit a, b;
		a.a = num.a;
		a.b = num.a - pow(2, j) * Pm_bit(num.a, j);
		b.a = a.b + pow(2, i) * Diff_bit(num.a, num.b, i);
		b.b = num.b;
		a.digit_val = num.digit_val - 1;
		b.digit_val = num.digit_val - 1;
		for (i = 0; i < Nmax; i++)
		{
			a.fix[i] = num.fix[i];
			b.fix[i] = num.fix[i];
		}
		num_write(a);
		num_write(b);
	}
}
int main() {
	bool can;
	int N, A, B, i, diff_num = 0, diff_bit[Nmax];
	num_bit N_ini;

	cin >> N >> A >> B;
	N_ini.a = A;
	N_ini.b = B;
	N_ini.digit_val = N;
	for (i = 0; i < Nmax; i++)
	{
		N_ini.fix[i] = false;
	}
	for (i = 0; i < N; i++)
	{
		if (!((A >> i) % 2) && (B >> i) % 2)
		{
			diff_bit[i] = 1;
			diff_num++;
		}
		else if ((A >> i) % 2 && !((B >> i) % 2))
		{
			diff_bit[i] = -1;
			diff_num++;
		}
		else diff_bit[i] = 0;
	}
	if (diff_num % 2)
		can = true;
	else can = false;
	if (can)
	{
		cout << "YES" << endl;
		num_write(N_ini);
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 1024
from collections import deque,defaultdict
n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    edges[a-1].append([b-1,i])
    edges[b-1].append([a-1,i])
c = 1
col = [0]*(n-1)
visited = [0]*(n-1)
que=deque()
for v in edges[0]:
    que.append(v)
    col[v[1]]=c
    visited[v[1]]=1
    c+=1
while que:
    v=que.popleft()
    c = 1
    used = set()
    for i in edges[v[0]]:
        if(visited[i[1]]):
            used.add(col[i[1]])
    for next_v in edges[v[0]]:
        if(not visited[next_v[1]]):
            if(c in used):
                c+=1
            col[next_v[1]] = c
            used.add(c)
            c+=1
            visited[next_v[1]] = 1
            que.append(next_v)
print(max(col))
for i in col:
    print(i)


Measured memory_bytes: 106920
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	int ans = 0;
	rep(i, 0, N) {
		if ((i+1) % 2 == 1) {
			if (a[i] % 2 == 1)++ans;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    long long int n,a,b;
    cin>>n>>a>>b;
    if((a-b)%2==0){
        cout<<abs(a-b)/2<<endl;
    }else{
       cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    int friendNum;
    int blockNum;

    read(N, friendNum, blockNum);

    UnionFind uf(N);
    vector<int> outdeg(N);
    rep(i, friendNum) {
        int a, b;
        read(a, b);
        --a, --b;
        uf.unite(a, b);
        ++outdeg[a];
        ++outdeg[b];
    }

    map<int, bool> block[100010];
    vector<int> minus(N);
    rep(i, blockNum) {
        int a, b;
        read(a, b);
        --a, --b;
        block[a][b] = block[b][a] = true;
        if (uf.same(a, b)) {
            ++minus[a];
            ++minus[b];
        }
    }

    rep(u, N) {
        int ans = uf.size(u) - 1;
        ans -= outdeg[u];
        ans -= minus[u];
        cout << ans << (u < N-1 ? ' ' : '\n');
    }

    return 0;
}


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

bool check(int *arr, int n) {
  for(int i=0; i<n; i++) {
	if(arr[i] != i+1) return false;
  }
  return true;
}

int main() {
  int n;
  int arr[10000];
  
  while(cin >> n, n) {
	for(int i=0; i<n; i++) {
	  cin >> arr[i];
	}
	int turn;
	bool good = true;
	for(turn=0; turn<10000; turn++) {
	  if(n == 0) {
		good = false;
		break;
	  }
	  if(check(arr, n)) break;
	  
	  for(int i=0; i<n; i++) {
		arr[i] --;
	  }
	  
	  arr[n] = n; n++;
	  
	  int cnt = 0;
	  for(int i=0; i<n; i++) {
		if(arr[i]) {
		  arr[cnt++] = arr[i];
		}
	  }
	  n = cnt;
	}
	if(turn == 10000 || !good) cout << -1 << endl;
	else cout << turn << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1172
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int A;
    int B;
    
    cin >> A;
    cin >> B;

    int K;
    K = (A+B)/2;
    if( (A+B)%2 == 0 ){
        cout << K << endl;    
    }else{
        cout << "IMPOSSIBLE" << endl;
    }


}

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

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				/* input */
				String line = br.readLine();
				if(line.equals("END")) break;


				int n = Integer.parseInt(br.readLine());

				int[] l = new int[n+1];

				for(int i=1;i<=n;i++){
					String line2 = br.readLine().replaceAll(" ","");
					l[i] = Integer.parseInt(line2,2);
				}


				Node t = makeTree(line,l);
				//t.output();

				int ans = 0;
				t = check(t,l);
				for(int c : t.cand){
					if(c==15) ans++;
				}

				System.out.println(ans);
			}
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}

	static class Node{
		int v;
		Node left,right;
		ArrayList<Integer> cand;

		public Node(){
			this.v = 0;
			this.left = null;
			this.right = null;
			this.cand = new ArrayList<Integer>();
		}

		public void output(){
			if(this.v!=0){
				System.out.print(this.v);
			} else {
				System.out.print("(");
				this.left.output();
				System.out.print(" ");
				this.right.output();
				System.out.print(")");
			}
		}
	}

	public static Node makeTree(String s, int[] l){
		Node t = new Node();
		if(s.length()==1){
			t.v = Integer.parseInt(s);
			t.cand.add(l[t.v]);
		} else {
			int level = 0;
			int index = 0;

			while(true){
				if(s.charAt(index)=='('){
					level++;
				} else if(s.charAt(index)==')'){
					level--;
				} else if(s.charAt(index)==' '&&level==1){
					break;
				}
				index++;
			}
			t.left = makeTree(s.substring(1,index),l);
			t.right = makeTree(s.substring(index+1, s.length()-1),l);
		}
		return t;
	}

	public static Node check(Node r, int[] l){
		if(r.left==null&&r.right==null){
			return r;
		}

		r.left = check(r.left,l);
		r.right = check(r.right,l);
		for(int c1 : r.left.cand){
			for(int c2 : r.right.cand){
				r.cand.add(c1&c2);
				r.cand.add(c1|c2);
				r.cand.add(c1^c2);
			}
		}
		return r;
	}
}

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

int main() {
    int N;
    string c;
    cin >> N >> c;
    auto wpos = c.find('W');
    auto rpos = c.rfind('R');
    int ans = 0;
    if (wpos == string::npos or rpos == string::npos) {
        cout << ans << endl;
        return 0;
    }
    while (wpos < rpos) {
        c.at(wpos) = 'R';
        c.at(rpos) = 'W';
        ans++;
        wpos = c.find('W');
        rpos = c.rfind('R');
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,m,ss[25],ans,sum;
int a[25][25];
bool check()
{
	for(int i=1;i<=n;i++)
	{
		if(ss[i]==1)
		{
			for(int j=1;j<=n;j++)
			{
				if(a[i][j]==0&&ss[j]==1)return 0;
				if(a[i][j]==1&&ss[j]==0)return 0;
			}			
		}
	}
//	cout<<"sum="<<sum<<endl;
	return 1;
}
void dfs(int now)
{
	if(now==n+1)
	{
		if(check())ans=max(sum,ans);
		return;
	}
	for(int i=0;i<2;i++)
	{
		ss[now]=i;
		if(i==1)sum++;
		dfs(now+1);
		if(i==1)sum--;
	}
}
int main()
{
	scanf("%d",&n);
	memset(a,-1,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&m);
		for(int j=1,x,y;j<=m;j++)
		{
			scanf("%d%d",&x,&y);
			a[i][x]=y;
		}
	}
	dfs(1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
@in=split(" ",<>);
$s=<>;
$_=substr($s,$in[1],(sort ($in[3],$in[4]))[1]-$in[1]+1);
$r= m/##/;
$_=substr($s,$in[2]-2,(sort ($in[3],$in[4]))[0]-$in[2]+3);
$r=$r || $in[3]>$in[4] && !m/\.\.\./;
print "". ["Yes","No"]->[$r]."\n";


Measured memory_bytes: 1100
from math import acos, atan2, cos, hypot, isclose, pi, sin
from typing import List, Tuple


def tangent_points(c1x: float, c1y: float, c1r: float,
                   c2x: float, c2y: float, c2r: float) -> List[Tuple[float, float]]:
    c1c2 = hypot(c2x - c1x, c2y - c1y)
    t0 = atan2(c2y - c1y, c2x - c1x)
    ps: List[Tuple[float, float]] = []

    r1r2 = c1r + c2r
    if isclose(c1c2, r1r2):
        ps.append((c1x + c1r * cos(t0), c1y + c1r * sin(t0)))
    elif c1c2 > r1r2:
        t1 = acos(r1r2 / c1c2)
        ps.append((c1x + c1r * cos(t0 + t1), c1y + c1r * sin(t0 + t1)))
        ps.append((c1x + c1r * cos(t0 - t1), c1y + c1r * sin(t0 - t1)))

    r1r2 = c1r - c2r
    if isclose(c1c2, abs(r1r2)):
        if r1r2 > 0.0:
            t1 = 0.0
        else:
            t1 = pi
        ps.append((c1x + c1r * cos(t0 + t1), c1y + c1r * sin(t0 + t1)))
    elif c1c2 > abs(r1r2):
        if r1r2 > 0.0:
            t1 = acos(r1r2 / c1c2)
        else:
            t1 = pi - acos(-r1r2 / c1c2)
        ps.append((c1x + c1r * cos(t0 + t1), c1y + c1r * sin(t0 + t1)))
        ps.append((c1x + c1r * cos(t0 - t1), c1y + c1r * sin(t0 - t1)))

    return ps


if __name__ == "__main__":
    c1x, c1y, c1r = map(lambda x: float(x), input().split())
    c2x, c2y, c2r = map(lambda x: float(x), input().split())

    ps = tangent_points(c1x, c1y, c1r, c2x, c2y, c2r)

    for p in sorted(ps):
        print("{:.6f} {:.6f}".format(*p))



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

int patty[55];
int total[55];

int dfs(int n, int x) {
  if(n == 0) {
    if(x <= 0) return 0;
    else return 1;
  }

  int res = 0;
  if(x <= total[n - 1] + 1LL) {
    res += dfs(n - 1,x - 1);
  } else {
    res += patty[n - 1] + 1LL + dfs(n - 1, x - total[n - 1] - 2);
  }
  return res;
}

signed main() {
  int n,x;
  cin >> n >> x;

  patty[0] = total[0] = 1LL;
  for (int i = 1; i <= n + 1; i++) {
    patty[i] = patty[i - 1] * 2LL + 1LL;
    total[i] = total[i - 1] * 2LL + 2LL + 1LL;
  }

  int answer = dfs(n, x);
  cout << answer << endl;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        long count = 0;
        for (char c : S.toCharArray()) {
            count += c-48;
            if (count%9 == 0) {
                count = 0;
            }
        }
        System.out.println(count == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 40672
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<iostream>
#define _PI acos(-1.0)
#define INF 0x3f3f3f3f
#define esp 1e-9
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define FRE freopen("abc.in", "r", stdin)
#define MEM(X,Y) memset(X,Y,sizeof(X))
typedef long long LL;
typedef unsigned long long ULL;
long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
/*===========================================*/

int result[2005];

int main(void)
{
	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);
	for(int i=1;i<=n;++i)
		for (int j = i + 1; j <= n; ++j)
		{
			if (abs(i - x) + abs(y - j) + 1 <= j - i)
				++result[abs(i - x) + abs(y - j) + 1];
			else
				++result[j - i];
		}
	for (int i = 1; i < n - 1; ++i)
		printf("%d\n", result[i]);
	printf("%d", result[n - 1]);

}

Measured memory_bytes: 256
import itertools
N = int(input())
LX, LY = [], []
RX, RY = [], []
DX, DY = [], []
UX, UY = [], []

for _ in range(N):
  x,y,d = input().split()
  x,y = int(x), int(y)
  if d == 'L':
    LX.append(x)
    LY.append(y)
  elif d == 'R':
    RX.append(x)
    RY.append(y)
  elif d == 'U':
    UX.append(x)
    UY.append(y)
  else:
    DX.append(x)
    DY.append(y)

INF = 10**18
fixed_x = [min(UX + DX + [INF]), max(UX + DX + [-INF])]
fixed_y = [min(LY + RY + [INF]), max(LY + RY + [-INF])]

R_x = [min(RX + [INF]), max(RX + [-INF])]
L_x = [min(LX + [INF]), max(LX + [-INF])]
U_y = [min(UY + [INF]), max(UY + [-INF])]
D_y = [min(DY + [INF]), max(DY + [-INF])]

def calc_x(t):
  # t秒後の横幅
  right = fixed_x[1]
  left = fixed_x[0]
  for x in [R_x[1]+t, L_x[1]-t]:
    if right < x:
      right = x
  for x in [R_x[0]+t, L_x[0]-t]:
    if left > x:
      left = x
  return right - left

def calc_y(t):
  # t秒後の横幅
  right = fixed_y[1]
  left = fixed_y[0]
  for y in [U_y[1]+t, D_y[1]-t]:
    if right < y:
      right = y
  for y in [U_y[0]+t, D_y[0]-t]:
    if left > y:
      left = y
  return right - left

def area(t):
  if t < 0:
    return INF
  return calc_x(t) * calc_y(t)

from scipy.optimize import fmin
xopt = fmin(area, x0 = 10**8, ftol = 10**-9, disp = False)
answer = area(xopt[0])
print(answer)

Measured memory_bytes: 25952
n = int(input())
numbers = list(map(int, [input() for _ in range(n)]))
numbers.sort()
score = sum(numbers)

if score % 10 == 0:
	for i in numbers:
		if i % 10 == 0:
			pass
		else:
			score -= i
			break

if score % 10 == 0:
	print(0)
else:
	print(score)

Measured memory_bytes: 3060
import itertools
import numpy as np
import copy

def main():
	N, K = map(int,input().split())

	Vs = list(map(int,input().split()))

	allCandidates = []
	for i in range(K + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		vs = copy.deepcopy(Vs)
		exceptFlag = False
		for k in candidate:
			if k == 0:
				try:
					have.append(vs[0])
					del vs[0]
				except:
					exceptFlag = True
					break
			if k == 1:
				try:
					have.append(vs[-1])
					del vs[-1]
				except:
					exceptFlag = True
					break
			if k == -1:
				try:
					if have[np.argmin(have)] < 0:
						del have[np.argmin(have)]
				except:
					exceptFlag = True
					break
		if not exceptFlag:
			score = sum(have)
			if score > maxScore:
				maxScore = score

	print(maxScore)

if __name__ == '__main__':
	main()


Measured memory_bytes: 16608
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		System.out.println(sc.next().replace(',', ' '));		
	}
}

Measured memory_bytes: 21844