akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define rrp(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 1000010;
char str[N];
int n, val[N], mxp, mx[N];
int doit(int lim) {
  int cur = 0, mn = n;
  rep (i, 0, mxp) mn = min(mn, val[i]);
  rep (i, mxp + 1, n) {
    if (str[i] == '?') {
      if (mx[i] + 2 * (cur + 1) <= lim) {
	      ++ cur;
      }
    }
    mn = min(mn, val[i] + 2 * cur);
  }
  return lim - mn;
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  rep (i, 1, n) {
    val[i] = val[i-1];
    if (str[i] == '0' || str[i] == '?') -- val[i];
    else ++ val[i];
  }
  mxp = 0;
  rep (i, 1, n) if (val[i] > val[mxp]) mxp = i;
  rrp (i, n, 1) {
    mx[i] = val[i];
    if (i < n) mx[i] = max(mx[i], mx[i+1]);
  }
  int ans = min(doit(val[mxp]), doit(val[mxp] + 1));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12564
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

#define MAX 100000

struct TRAMP{
    char mark;
    int number,inputed_order;
};

TRAMP cards[MAX];

int n;

int Partition(int left,int right){
    int i = left-1,pivot = cards[right].number;
    for(int start = left; start < right; start++){
        if(cards[start].number <= pivot){
                i++;
                std::swap(cards[i],cards[start]);
        }
    }

    std::swap(cards[i+1],cards[right]);

    return i+1;
}

void quickSort(int left,int right){
    if(left < right){
        int q = Partition(left,right);
        quickSort(left,q-1);
        quickSort(q+1,right);
    }
}


int main(){

    bool stableFLG = true;
    scanf("%d",&n);

    for(int i = 0; i < n; i++){
        scanf("%s %d",&cards[i].mark,&cards[i].number);
        cards[i].inputed_order = i;
    }

    quickSort(0,n-1);

    for(int i = 1; i < n; i++){
        if(cards[i].number == cards[i-1].number && cards[i].inputed_order < cards[i-1].inputed_order){
        	stableFLG = false;
        	break;
        }
    }

    if(stableFLG){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    for(int i = 0; i < n; i++)   printf("%c %d\n",cards[i].mark,cards[i].number);
}



Measured memory_bytes: 4356
fun main(args: Array<String>) {
    keyence2020a()
}

fun keyence2020a() {
    val h = readLine()!!.toInt()
    val w = readLine()!!.toInt()
    val n = readLine()!!.toInt()

    val answer = Math.ceil(n.toDouble() / Math.max(h, w)).toLong()

    println(answer)
}


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

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

        int[] time = new int[n];
        int[] dueDate = new int[n];
        Work[] works = new Work[n];

        for (int i = 0; i < n; i++) {
            time[i] = sc.nextInt();
            dueDate[i] = sc.nextInt();
            works[i] = new Work(time[i], dueDate[i]);
        }

        Arrays.sort(works);
        int now = 0;
        for (Work work : works) {
            if (now + work.time <= work.dueDate) {
                now += work.time;
            } else {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

class Work implements Comparable<Work> {
    int time;
    int dueDate;

    public Work(int time, int dueDate) {
        this.time = time;
        this.dueDate = dueDate;
    }

    @Override
    public int compareTo(Work o) {
        return dueDate - o.dueDate;
    }
}


Measured memory_bytes: 108768
#include <stdio.h>

int main(){
	double a,b,c,d,e,f, x,y,dd;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)>0){
		dd = (a*e-b*d);
		x=(c*e-(c*b*d)/a-b*f+c*d*b/a)/dd;
		y=(a*f-c*d)/dd;
		if(x==0)x=0;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    L,R,d = map(int, input().split())
    
    count = 0
    for i in range(L, R+1):
        if i%d == 0:
            count += 1
            
    print(count)

main()


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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  int ans = 0;
  for(int i=0; i<L-1; i++){
    if(S.at(i)!=S.at(i+1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int D = 0, T = 0, S = 0;
	scanf("%d %d %d", &D, &T, &S);

	int ans = 0;
	if (D > T*S) {
		ans = 0;
	} else {
		ans = 1;
	}
	yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
/*void set_levels(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur] = dont;
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) set_levels(vec[cur][i], cur);
	}
}*/
/*ll fact[2000005];
ll komb(ll a, ll b){
	a++;
	ll payda = (fact[a]*fact[b]) % mod;
	return (fact[a+b] * (exp(payda, mod - 2))) % mod;
}*/

bool ans[100005] = {};
void dfs(vector<vector<pair<int, int>>>& vec, int cur, int dont, int dist){
	if(dist % 2 == 0){
		ans[cur] = ans[1];
	}else{
		ans[cur] = !ans[1];
	}
	for(auto& x: vec[cur]){
		if(x.first != dont){
			dfs(vec, x.first, cur, dist + x.second);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<vector<pair<int, int>>> vec(n+1);
	for(int i = 0; i < n-1; i++){
		int a, b, c; cin>>a>>b>>c;
		vec[a].push_back({b, c});
		vec[b].push_back({a, c});
	}
	dfs(vec, 1, -1, 0);
	for(int i = 1; i <= n; i++) cout<<ans[i]<<'\n';
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fir first
#define sec second
using namespace std;
const int N=200010;
char s[N];
int sum[N];
int read()
{
	int x=0,flag=1;char c=getchar();
	while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
int main()
{
	int n=read(),ans=1e9; scanf("%s",s+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+(s[i]=='#');
	for(int i=0;i<=n;i++) ans=min(ans,sum[i]+n-i-(sum[n]-sum[i]));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>

int res = 0;
//least_n: 選べる最小のn
void rec(int n, int s, int least_n){
	if(n == 1 && least_n <= s && s < 10){
		res++;
	}
	for(int i=least_n;i<10;i++){
		rec(n-1, s-i, i+1);
	}
}

int main(){
	int n, s;
	while(std::cin >> n >> s, n){
		res = 0;
		rec(n, s, 0);
		std::cout << res << std::endl;
	}
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> x(3);
    x.at(0) = A;
    x.at(1) = B;
    x.at(2) = C;
    sort(x.begin(), x.end());
    if(x.at(0) == 5 && x.at(1) == 5 & x.at(2) == 7 ){
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
}


Measured memory_bytes: 256
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int mod=1e9+7;
int Add(int a,int b){
	return a+b>=mod?a+b-mod:a+b;
}

const int maxn=4005;
int n,m,k,ans;
int dp[maxn][maxn],cur[maxn];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d%d",&n,&m,&k);
	int len=(n+m-1)/(k-1);
	dp[0][0]=1;
	rep(i,len)rep(j,m+1){
		int cur=dp[i][j];
		if(!cur)continue;
		rep(p,k)if(j+p<=m)dp[i+1][j+p]=Add(dp[i+1][j+p],cur);
	}
	rep(i,len){
		rep(j,m+1)cur[j]=0;
		rep(j,m+1)REP(p,k-1)if(j+p<=m)cur[j+p]=Add(cur[j+p],dp[i][j]);
		rep(j,m+1){
			int b=k*(i+1)-j-i;
			if(j%(k-1)!=m%(k-1)||b>n||b%(k-1)!=n%(k-1))continue;
			ans=Add(ans,cur[j]); 
		}
	}
	printf("%d\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 61056
# パスカルの三角形
N, K = map(int, input().split())

n = max(K, N - K + 1)
c = [[0] * (n + 1) for _ in range(n + 1)]
c[0][0] = 1
for i in range(1, n + 1):
    c[i][0] = 1
    for j in range(1, i + 1):
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007

result = []
for i in range(1, K + 1):
    result.append(c[K - 1][i - 1] * c[N - K + 1][i] % 1000000007)
print('\n'.join(str(i) for i in result))


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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;


int n;
char s[100005];
ll dp[100005][13];

int main(){
	int n;
	cin >> n;
	
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(n==i*j){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int n,x,y;
const int INF = 1001001001;
vector<int> ans,visited,dist,graph[2200];
void dfs(int now){
    visited[now] = 1;
    for(int next:graph[now]){
        if(visited[next])continue;
        dist[next] = min(dist[next],dist[now]+1);
        dfs(next);
        visited[next] = 0;
    }
}

int main()
{
    
    cin >> n >> x >> y;
    x--;y--;
    ans.resize(n);
    visited.resize(n);
    dist.resize(n,INF);
    rep(i,n){
        graph[i].push_back(i+1);
        graph[i+1].push_back(i);

    }
    graph[x].push_back(y);
    graph[y].push_back(x);
    rep(i,n){
        dist[i] = 0;
        dfs(i);
        rep(j,n)ans[dist[j]]++;
        dist = vector<int>(n,INF);
        visited = vector<int>(n,0);
    }
    rep(i,n)ans[i]/=2;
    rep(i,n-1)cout << ans[i+1] << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std; 

int main()
{
  int N ;
  cin>>N ;
  vector<int>L(N) ;
  for(int i=0;i<N;i++) cin>>L.at(i) ;
  
  sort(L.begin(),L.end()) ;
  int sum=0 ;
  for(int i=0;i<N-1;i++) sum+=L.at(i) ;
  if(L.at(N-1)>=sum) cout<<"No"<<endl ;
  else cout<<"Yes"<<endl ;
  
  return 0 ;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
        cout << 1 << '\n';
    else
        cout << ll(ceil(h / 2.0) * ceil(w / 2.0) + h / 2 * (w / 2)) << endl;
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    unsigned int s[100000]={},n;
    int p=0;
    cin>>n;
    for (int i=0;i<=n-1;i++){
       cin>>s[i];
    }
    
    for (int l=0;l<n-1;l++){
        if (s[l]==l+1 ){
            int m=s[l+1];
            s[l+1]=s[l];
            s[l]=m;
            p++;
        }
        
       
    }
    if (s[n-1]==n){
        int m=s[n-1];
        s[n-2]=s[n-1];
        s[n-1]=m;
        p++;
    }
        
    cout<<p;
    
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,z[100010],b[100010];
int main()
{
    cin>>n>>m;
    b[1]=1;
    for(int i=1;i<=n;++i)z[i]=1;
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        b[y]|=b[x];
        z[x]--;z[y]++;
        if (z[x]==0)b[x]=0;
	}
	int ans=0;
	for(int i=1;i<=n;++i){
	    if(b[i]&&z[i])ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
using namespace std;
const int N = 2e5 + 5;
int arr[N];
 
int main() {
    //  freopen("test.in", "r", stdin);
    //  freopen("ac.txt", "w", stdout);
    int n, k;
    scanf("%d %d", &n, &k);
    int s = 1, e = 1;
    for (int i = 0; i < n; ++i) {
        scanf("%d", arr + i);
        e = max(e, arr[i]);
    }
    while (s < e) {
        int mid = s + (e - s) / 2;
        int c = 0;
        for (int i = 0; i < n; ++i) {
            c += ((arr[i]-1) / mid);
        }
        if (c <= k) e = mid;
        else s = mid + 1;
    }
    printf("%d", s);
}

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

int gcd(int i, int j, int k);
int main()
{
  int times;
  cin >> times;

  int ans = 0;

  for (int i = 1; i <= times; i++)
  {
    for (int j = 1; j <= times; j++)
    {
      for (int k = 1; k <= times; k++)
      {
        ans += __gcd(__gcd(i, j), k);  
      }
    }  
    
  }
  cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

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

	int x; cin >> x;
	cout << (1 - x) << '\n';

	return 0;
}

Measured memory_bytes: 3648
package main

import "fmt"

func main() {

	var N int
	var S string

	fmt.Scanf("%d", &N)
	fmt.Scanf("%v", &S)

	num := 0
	l := len(S)

	// iよりも右にあるRGBの数
	numRs := make([]int, l)
	numGs := make([]int, l)
	numBs := make([]int, l)
	var numR int
	var numG int
	var numB int
	for i := l-1; i >= 0; i-- {
		numRs[i] = numR
		numGs[i] = numG
		numBs[i] = numB
		switch S[i] {
		case 'R':
			numR++
		case 'G':
			numG++
		case 'B':
			numB++
		}
	}

	for a := 0; a < l - 2; a++ {
		A := S[a]
		for b := a+1; b < l - 1; b++ {
			B := S[b]
			if A == B {
				continue
			}
			var C byte
			if A != 'R' && B != 'R' {
				C = 'R'
			}
			if A != 'G' && B != 'G' {
				C = 'G'
			}
			if A != 'B' && B != 'B' {
				C = 'B'
			}
			switch C {
			case 'R':
				num += numRs[b]
			case 'G':
				num += numGs[b]
			case 'B':
				num += numBs[b]
			}
			i2 := b + (b-a)
			if i2 < l && S[i2] == C {
				num--
			}
		}
	}
	fmt.Printf("%v\n", num)
}

Measured memory_bytes: 1992
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


int N;
double X[101], Y[101];
double dist(double x, double y) {
	return sqrt(x*x + y * y);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	REP(i, N) {
		cin >> X[i] >> Y[i];
	}
	double theta = 0;
	double ans = 0;
	while (theta <= 2 * pi) {
		double x = 0, y = 0;
		REP(i, N) {
			if (cos(theta)*X[i] + sin(theta)*Y[i] > 0) {
				x += X[i];
				y += Y[i];
			}
		}
		ans = max(ans, dist(x, y));
		theta += pi / 100.0;
	}
	cout << setprecision(12) << ans << endl;
}



Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Maybe
main=do
    (d:g:_)<-map read.words<$>getLine::IO[Int]
    pcs<-liftM (zip [1..]) $ replicateM d $ (\(p:c:_)->(p,c)).map read.words<$>getLine::IO[(Int,(Int,Int))]
    --
    print.minimum.mapMaybe (s g pcs) $ t [1..d]
--
s g pcs ns
    | cs >= g = Just cp
    | null res = Nothing
    | rn > rp = Nothing
    | True = Just (cp + rn)
    where
        (sel, res) = sp ns pcs
        (cs,cp) = f sel
        (ri,(rp,_)) = mx res
        rn = (((g-cs)`div`100)+ri-1) `div` ri

f = foldl' (\(a,s) (i,(p,c))->(a+100*i*p+c, s+p)) (0,0)

t [] = [[]]
t (x:xs) = concatMap (\u->[x:u,u]) $ t xs

sp ns = partition (\(i,_)->elem i ns)

mx :: [(Int,a)] -> (Int,a) 
mx = maximumBy (\(ai,_) (bi,_)->compare ai bi)

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef pair <long long, long long> pll;
 
ll mod = 1000000000;
 
int main(){
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  double d;
  cin >> d;
  ll co = 0;
  for (int i = 0; i < n; i++){
    double u, v;
    cin >> u >> v;
    double s = sqrt(u*u + v*v);
    if (s <= d)
     co++;
  }
  cout << co;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string o, e;
  cin >> o >> e;
  for(int i = 0; i < min(o.size(), e.size()); i++){
    cout << o[i] << e[i];
  }
  if(o.size() < e.size())cout << e[e.size() - 1];
  else if(o.size() > e.size())cout << o[o.size() - 1];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3644
#include <stdio.h>

#define MAX 2000001

int A[MAX],C[10001],B[MAX];
int n;


void CountingSort(){
	
	int i,j;
	for(i=0;i<10001;i++){ C[i] = 0; }
	for(j=1;j<=n;j++){ C[A[j]]++; }
	for(i=1;i<10001;i++){ C[i] = C[i] + C[i-1]; }
	for(j=1;j<=n;j++){ 
		B[C[A[j]]] = A[j]; 
		C[A[j]]--;
	 }

}

int main(void){

	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++){ scanf("%d",&A[i]); }
	CountingSort();
	for(i=1;i<=n;i++){ 
		if(i > 1) printf(" ");	
		printf("%d",B[i]); 
	}
	printf("\n");

return 0;

}



Measured memory_bytes: 17448
#include <stdio.h>

int main(void)
{
	int A, B, C, D, P;
	int x;
	int y;
	
	scanf("%d %d %d %d %d", &A, &B, &C, &D, &P);
	
	x = P * A;
	
	if (P > C){
		y = B + (P - C) * D;
	}
	else if (P <= C){
		y = B;
	}
	
	if (x < y){
		printf("%d", x);
	}
	else {
		printf("%d", y);
	}
	printf("\n");
	
	return (0);
}

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

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

    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            ans += d[i]*d[j];
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main(){
  int n,m,c,i,j,a,sum,ans;
  cin >> n >> m >> c;ans = 0;
  int b[m];
  for(i=0;i<m;i++) cin >> b[i];
  for(i=0;i<n;i++){
    sum = 0;
    for(j=0;j<m;j++){
      cin >> a;
      sum += b[j]*a;
    }
    if (sum+c>0) ans += 1;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();    
        String S = stdIn.next();
        stdIn.close();
        int[] a = new int[N];
        int[] cnt = {0, 0, 0};
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R') {
                a[i] = 0;
                cnt[0]++;
            }
            if (S.charAt(i) == 'G') {
                a[i] = 1;
                cnt[1]++;
            }
            if (S.charAt(i) == 'B') {
                a[i] = 2;
                cnt[2]++;
            }
        }
        long ans = 1;
        for (int i = 0; i < 3; i++) {
            ans *= (long)cnt[i];
        }
        for (int j = 0; j < N; j++) {
            for (int i = 0; i < j; i++) {
                int k = j + (j - i);
                if (k < N) {
                    if (a[i] == a[j]) continue;
                    if (a[i] == a[k]) continue;
                    if (a[k] == a[j]) continue;
                    ans--;
                }
            }
        }
        System.out.println(ans);        
    }
}

Measured memory_bytes: 28524
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int main(){
	fio;
	int a,b;
	cin>>a>>b;
	if((a*3+b)%2==0)
	cout<<(a*3+b)/2;
	else
	cout<<(a*3+b-1)/2;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C[] = new int[A];
        int D[] = new int[A-1];
        long ans =0;
        for(int i=0;i<A;i++){
	     C[i]=scan.nextInt();
        }
        for(int i=0;i<A-1;i++){
        	D[i]=C[i+1]-C[i];
        	if(D[i]<B){
        		ans += D[i];
        	}else {
        		ans += B;
        	}
        }
        System.out.println(ans+B);
	}
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		if(i % 2 == 0) continue;
		int c = 0;
		for(int j = 1; j <= i; j++)
		{
			if(i % j == 0) c++;
		}
		if(c == 8) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())

if N == 0:
    print(X)
else:
    p = set(map(int, input().split()))

    num = set(range(-102, 102))

    l = list(num.difference(p))
    l.sort()

    ans = 0
    absol = 110

    for i in l:
        a = abs(X - i)
        if a < absol:
            absol = a
            ans = i
        else:
            pass

    print(ans) 

Measured memory_bytes: 9140
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recursion<T>(int n, T v, Func<int, T, T> f) { var a = new T[n]; a[0] = v; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], X = I[1];
		var S = G;
		Array.Sort(S, (p, q) => q.CompareTo(p));
		var dp = new long[N + 1, X + 1];
		dp[0, X] = 1;
		for (var i = 0; i < N; i++)
		{
			var inv = Inverse(N - i);
			for (var x = 0; x <= X; x++)
				if (dp[i, x] != 0)
					for (var j = i + 1; j <= N; j++)
					{
						var y = x % S[j - 1];
						dp[j, y] = (dp[j, y] + dp[i, x] * inv % MOD) % MOD;
					}
		}
		var s = 0L;
		for (var x = 0; x <= X; x++) s = (s + x * dp[N, x] % MOD) % MOD;
		for (var i = 1; i <= N; i++) s = s * i % MOD;
		WriteLine(s);
	}
	public static long Inverse(long a, long mod = MOD)
	{
		if (a < 0) { a %= mod; if (a < 0) a += mod; }
		var t = SolveLinear(a, mod);
		return t.Item1 > 0 ? t.Item1 : t.Item1 + mod;
	}
	public static Tuple<long, long> SolveLinear(long n, long m)
	{
		if (n < 0) { var p = SolveLinear(-n, m); return p == null ? p : new Tuple<long, long>(-p.Item1, p.Item2); }
		if (m < 0) { var p = SolveLinear(n, -m); return p == null ? p : new Tuple<long, long>(p.Item1, -p.Item2); }
		if (n < m) { var p = SolveLinear(m, n); return p == null ? p : new Tuple<long, long>(p.Item2, p.Item1); }
		long a = 1, b = 0, c = 0, d = 1;
		while (m > 0)
		{
			var r = n % m;
			var q = n / m;
			n = m;
			m = r;
			var tmp = a;
			a = -a * q + b;
			b = tmp;
			tmp = c;
			c = -c * q + d;
			d = tmp;
		}
		return n != 1 ? null : new Tuple<long, long>(d, b);
	}
}

Measured memory_bytes: 168800
n_people, full_p, n_ques = map(int, input().split())

count = [0]*n_people

for i in range(n_ques):
  people = int(input())
  count[people-1] += 1

     
for i in range(n_people):
  if count[i] > n_ques-full_p:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4680
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int n=s.size();
  int mn = 1000;
  REP(i,n-2) {
    int val = stoi(s.substr(i,3));
    mn = min(mn, abs(val - 753));
  }
  cout<<mn<<endl;
  return 0;
}


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

int combination(int n,int k);
int fact(int l);
int main()
{
  int n,k;
  cin>>n>>k;
  int pro=k;
  int t=k;

  while(n-1!=0)
  {
      pro*=k-1;
      //k--;
      n--;
  }
  //int w=combination(n,k);

  cout<<pro;

  return 0;
}

int combination(int n,int k)
{
  int t=(fact(n)/(fact(n-k)*fact(k)));
  return t;
}

int fact(int l)
{
  if(l==1 || l==0)
    return 1;
    return l*fact(l-1);
}






Measured memory_bytes: 256
s = input()
count = 0
flag = True
for i in range(len(s)):
    if i==0:
        if s[0]!="A":
            flag = False
    else:
        if 2<=i<=len(s)-2:
            if s[i]=='C':
                if count>0:
                    flag = False
                else:
                    count += 1
            else:
                if 97>ord(s[i]) or ord(s[i])>122:
                    flag = False
        else:
            if 97>ord(s[i]) or ord(s[i])>122:
                flag = False
if count==0:
    flag = False
print('AC' if flag==True else 'WA')

Measured memory_bytes: 38384
#include<stdio.h>

int main(void) {
   int H, W, i, j, k;

   for(i=1;;i++){
     scanf("%d %d", &H, &W);
     if(H ==0 && W ==0) break;
     for(j=0;j<H;j++){
       for(k=0;k<W;k++){
         printf("#");
       }
       printf("\n");
     }
     printf("\n"); 
    }
   return 0;
}



Measured memory_bytes: 2604
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String,Integer> map = createMap(sc,n);
        int free = 0;
        int min = 1;
        int max = 0;
        if(map.get("free") != null){
            free = map.get("free");
            if(map.size() > 1){
                min = map.size()-1;
                max = min + free;
            }
            else{
                max = free;
            }
        }
        else{
            min = map.size();
            max = map.size();
        }
        System.out.println(min);
        System.out.println(max);
    }
    public static Map<String,Integer> createMap(Scanner sc,int n){
        Map<String,Integer> map = new HashMap<>();
        for(int i = 0;i < n;i++){
            int a = sc.nextInt();
            if(a >= 1 && a <= 399){
                if(map.get("gray") != null){
                    map.put("gray",map.get("gray"));
                }
                map.put("gray",1);
            }
            if(a >= 400 && a <= 799){
                if(map.get("brown") != null){
                    map.put("brown",map.get("brown"));
                }
                map.put("brown",1);
            }
            if(a >= 800 && a <= 1199){
                if(map.get("green") != null){
                    map.put("green",map.get("green"));
                }
                map.put("green",1);
            }
            if(a >= 1200 && a <= 1599){
                if(map.get("lightblue") != null){
                    map.put("lightblue",map.get("lightblue"));
                }
                map.put("lightblue",1);
            }
            if(a >= 1600 && a <= 1999){
                if(map.get("blue") != null){
                    map.put("blue",map.get("blue"));
                }
                map.put("blue",1);
            }
            if(a >= 2000 && a <= 2399){
                if(map.get("yellow") != null){
                    map.put("yellow",map.get("yellow"));
                }
                map.put("yellow",1);
            }
            if(a >= 2400 && a <= 2799){
                if(map.get("orange") != null){
                    map.put("orange",map.get("orange"));
                }
                map.put("orange",1);
            }
            if(a >= 2800 && a <= 3199){
                if(map.get("red") != null){
                    map.put("red",map.get("red"));
                }
                map.put("red",1);
            }
            if(a >= 3200 && a <= 4800){
                if(map.get("free") != null){
                    map.put("free",map.get("free")+1);
                    continue;
                }
                map.put("free",1);
            }
        }
        return map;
    }
}


Measured memory_bytes: 21076
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while (true){
            int n=sc.nextInt();
            int r=sc.nextInt();
            if (n==0&&r==0) break;
            int yama[]=new int[n+1];
            for (int i=1;i<n+1;i++) yama[i]=i;
            for (int i=0;i<r;i++){
                int p=sc.nextInt();
                int c=sc.nextInt();
                int cpy[]=new int[p-1];
                for (int j=0;j<p-1;j++) cpy[j]=yama[n-j];
                for (int j=0;j<c;j++){
                    yama[n-j]=yama[n-p-j+1];
                }
                for (int j=0;j<p-1;j++){
                    yama[n-c-j]=cpy[j];
                }
            }
            System.out.println(yama[n]);
        }
    }
}

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

//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 SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,k;

    cin >> a >> b >> c;
    cin >> k;

    int maxab = max( a, b);

    int maxi = max ( maxab, c);

    if( maxi == a){
        cout <<  pow( 2, k)* a + b + c << endl;
    }else if( maxi == b){

        cout << a + pow( 2, k) * b + c << endl;
    }
    else if( maxi == c){

        cout << a + b +  pow( 2, k) * c << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int Q = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		int[][] sum = new int[n][n];
		for (int i = 0; i < m; i++) {
			l[i] = sc.nextInt() - 1;
			r[i] = sc.nextInt() - 1;
			sum[l[i]][r[i]]++;
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				sum[i][j] += sum[i][j - 1];
			}
		}

		for (int i = 0; i < Q; i++) {
			int p = sc.nextInt() - 1;
			int q = sc.nextInt() - 1;
			int ans = 0;
			for (int j = p; j <= q; j++) {
				ans += sum[j][q];
			}
			System.out.println(ans);
		}
		sc.close();
	}
}


Measured memory_bytes: 156536
#include <iostream>
#include <fstream>
#include <list>
//#define LOCAL
using namespace std;
typedef long long ll;

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL

list<ll>number;
ll q;
cin>>q;
list<ll>::iterator cursor=number.begin();

for(ll i=1;i<=q;i++){
    int t;
    cin>>t;
    if(0==t){
        ll x;
        cin>>x;
        cursor=number.insert(cursor, x);
    }else if(1==t){
        int d;
        cin>>d;
        if(d>=0) while(d--) cursor++;
        else{
            d=-d;
            while(d--) cursor--;
        }

    }else if(2==t){
        cursor=number.erase(cursor);
    }
}
for(list<ll>::iterator it=number.begin();it!=number.end();it++){
    cout<<*it<<endl;
}
return 0;


#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 18536
import sys
readline = sys.stdin.readline

INF = 10**9+7
class Segtree:
    def __init__(self, A, intv, initialize = True, segf = max):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)
        
    def update(self, k, x):
        k += self.N0
        self.data[k] = x
        while k > 0 :
            k = k >> 1
            self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def binsearch(self, l, r, check, reverse = False):
        L, R = l+self.N0, r+self.N0
        SL, SR = [], []
        while L < R:
            if R & 1:
                R -= 1
                SR.append(R)
            if L & 1:
                SL.append(L)
                L += 1
            L >>= 1
            R >>= 1
        
        if reverse:
            for idx in (SR + SL[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx+1]):
                    idx = 2*idx + 1
                else:
                    idx = 2*idx
            return idx - self.N0
        else:
            pre = self.data[l+self.N0]
            for idx in (SL + SR[::-1]):
                if not check(self.segf(pre, self.data[idx])):
                    pre = self.segf(pre, self.data[idx])
                else:
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.segf(pre, self.data[2*idx])):
                    idx = 2*idx
                else:
                    pre = self.segf(pre, self.data[2*idx])
                    idx = 2*idx + 1
            return idx - self.N0

N = int(readline())
S = [0]+list(map(int, readline().strip()))

leftone = [None]*(N+1)
left = None
for i in range(N+1):
    if S[i] == 1:
        if left is None:
            left = i
        leftone[i] = left
    else:
        left = None

T = Segtree([None]*(N+1), -INF, initialize = False)
dp = [0]*(N+1)
T.update(0, 0)
T.update(1, -1)
T.update(2, -2)
for i in range(3, N+1):
    res = dp[i-1]
    if S[i] == 1:
        if S[i-1] == 0 and S[i-2] == 1:
            left = leftone[i-2]
            res = max(res, T.query(left-1, i-2)+i-2)
        if leftone[i] > 2 and S[leftone[i]-1] == 0 and S[leftone[i]-2] == 1:
            res = max(res, dp[leftone[i]-3] + i-leftone[i]+2-1)
    dp[i] = res
    T.update(i, dp[i]-i)
print(dp[-1])

Measured memory_bytes: 106828
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    S = input()

    # 10文字までしかないので、一個ずつ見ていっても良いのでは
    result = 10**10
    for i in range(0, len(S) - 2):
        r = min(abs(753 - int(S[i:i+3])), abs(int(S[i:i+3]) - 753))
        if r < result:
            result = r

    print(result)

main()


Measured memory_bytes: 5952
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        for (int i = 0; i < S.length; i++) {
            if (S[i] != T[i]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        return;
    }

}

Measured memory_bytes: 35644
#include<stdio.h>
int main(void){
    int H, W, i, j;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                    if(i == 0 || i == H - 1 || j == 0 || j == W - 1){
                    printf("#");
                    }else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
    }
    return 0;
}


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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846

    void solve(){
        int n;
        cin>>n;
        vector<int>a(n+1,0);
        for(int i=1;i<=n;i++){
            for(int j=0;j<=n;j+=i)
                a[j]++;
        }
        ll total=0;
        for(ll i=1;i<=n;i++)
            total+=(i*(ll)a[i]);
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 42260
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> map(h+1, vector<char>(w+1));
    vector<vector<int>> yoko(h, vector<int>(w));
    vector<vector<int>> tate(h, vector<int>(w));
    rep(i,h)rep(j,w) cin >> map[i][j];

        
    rep(i,h){
        int cnt = 0;
        int begin = 0;
        rep(j,w+1){
            if(map[i][j]=='#'||j==w){
                for(int k=begin; k<=begin+cnt-1; k++) yoko[i][k] = cnt;
                cnt = 0;
                begin = j+1;
            }else{
                cnt++;
            }
        }
    }

    rep(j,w){
        int cnt = 0;
        int begin = 0;
        rep(i,h+1){
            if(map[i][j]=='#'||i==h){
                for(int k=begin; k<=begin+cnt-1; k++) tate[k][j] = cnt;
                cnt = 0;
                begin = i+1;
            }else{
                cnt++;
            }
        }
    }

    int ans = 0;
    rep(i,h)rep(j,w) ans = max(ans, yoko[i][j] + tate[i][j] - 1);

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

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define int long long int
typedef long double ld;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mxe max_element
#define mne min_element
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int,int>
#define size(a)  (int)(a.size())
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define mod 1e9+7
#define inf 1e9+5
void solve(){
   string s,t;
   cin>>s>>t;
   int n=size(s), m=size(t);
   vector<vector<pair<int,pair<int,int>>>> dp(n+1,vector<pair<int,pair<int,int>>>(m+1));
   rep(i,1,n+1){
   	rep(j,1,m+1){
   		if(s[i-1]!=t[j-1]){
   			if(dp[i-1][j].ff>dp[i][j-1].ff){
   				dp[i][j].ff=dp[i-1][j].ff;
   				dp[i][j].ss={i-1,j};
   			}
   			else{
   				dp[i][j].ff=dp[i][j-1].ff;
   				dp[i][j].ss={i,j-1};
   			}
   		}
   		else{
   			dp[i][j].ff = dp[i-1][j-1].ff+1;
   			dp[i][j].ss = {i-1,j-1};
   		}
   	}
   }
   pi curr = dp[n][m].ss;
   string ans;
   if(curr.ff==n-1 && curr.ss == m-1) ans+=s[curr.ff];
   while(curr.ff>0 && curr.ss>0){
      pi prev = dp[curr.ff][curr.ss].ss; 
      if(prev.ss == curr.ss-1 && prev.ff == curr.ff-1){
      	ans+=s[prev.ff];
      }
      curr=prev;
   }
    reverse(all(ans));
   cout<<ans;
 }
 

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif
    */
	int test;
	//cin>>test;
	test=1;
	while(test--){
         solve();
         cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 211456
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long int solve(int l, int r, vector<long long int>&v, vector<vector<long long int>>&dp){
    if(l==r)
        return v[l];
    else{
        if(dp[l][r]!=-1)
            return dp[l][r];

        return dp[l][r]=max((v[l]-solve(l+1, r, v, dp)), (v[r]-solve(l, r-1, v, dp)));
    }
}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<long long int>v(n);
    vector<vector<long long int>>dp(n, vector<long long int>(n, -1));
    for(int i=0;i<n;i++)
        cin>>v[i];
    
    cout<<solve(0, n-1, v, dp);
    return 0;
}


Measured memory_bytes: 70912