akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
 
#define Max 500000
 
void insert(int); 
void find(int, int);
void Preorder(int);    
void Inorder(int);     
 

typedef struct{    
  int key;
  int p;
  int l[2];
} Node;
 
Node T[Max];
 
int main(){
  int i, n, k;
  char s[7];
 
  scanf("%d", &n);
 
  T[0].key = -1;
 
  
  for(i = 0; i < n; i++){
    T[i].l[0] = -1;
    T[i].l[1] = -1;
 
    scanf("%s", s);
 
    if(strcmp(s, "insert") == 0){
      scanf("%d", &T[i].key);
      insert(i);
    }
    else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }
    else if(strcmp(s, "find") == 0){
      scanf("%d", &k);
      find(0, k);
    }
  }
   
  return 0;
}
 
 
void insert(z){
  int x, y;
 
  y = -1;
  x = 0;
 
  if(z != 0){
    while(x != -1){
      y = x;
      if(T[z].key < T[x].key) x = T[x].l[0];
      else x = T[x].l[1];
    }
  }
 
  T[z].p = y;
 
  if(y != -1){
    if(T[z].key < T[y].key) T[y].l[0] = z;
    else T[y].l[1] = z;
  }
}
 
void find(x, k){
 
  if(x == -1) printf("no\n");
  else if(T[x].key == k) printf("yes\n");
  else if(k < T[x].key) find(T[x].l[0], k);
  else find(T[x].l[1], k);
}
 
 
void Preorder(int a){
  printf(" %d", T[a].key);
 
  if(T[a].l[0] != -1) Preorder(T[a].l[0]);
  if(T[a].l[1] != -1) Preorder(T[a].l[1]);
}
 
 
void Inorder(int a){
  if(T[a].l[0] == -1){
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
  else{
    Inorder(T[a].l[0]);
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
}

Measured memory_bytes: 8428
// 2019-12-17 20:33:07 CST
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#define N 105
#define M 200005
using namespace std;
const int INF = 1e9;

int n, m, jsq, wid[N], hid[N];
char s[N][N];
int tot = 1, fir[40004], nxt[M], to[M], val[M];
int S, T, dep[40004];

inline void addE(int u, int v, int w1, int w2) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v, val[tot] = w1;
    nxt[++tot] = fir[v], fir[v] = tot, to[tot] = u, val[tot] = w2;
}

// {{{
inline bool bfs() {
    memset(dep, -1, sizeof dep);
    queue<int> q; while (!q.empty()) q.pop();
    q.push(S), dep[S] = 0;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = fir[u], v; i; i = nxt[i]) {
            v = to[i];
            if (!val[i] || dep[v] != -1) continue;
            dep[v] = dep[u] + 1, q.push(v);
        }
    }
    return dep[T] != -1;
}

int dfs(int u, int now) {
    if (u == T || !now) return now;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        if (!val[i] || dep[v] != dep[u] + 1) continue;
        int tmp = dfs(v, min(now, val[i]));
        if (!tmp) continue;
        val[i] -= tmp, val[i ^ 1] += tmp;
        return tmp;
    }
    return 0;
}

inline int dinic() {
    int res = 0, tmp;
    while (bfs()) {
        while ((tmp = dfs(S, INF)))
            res += tmp;
    }
    return res;
}
// }}}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        scanf("%s", s[i] + 1);

    int cnt = 0;
    for (int i = 1; i <= n; ++i)
        hid[i] = ++cnt;
    for (int i = 1; i <= m; ++i)
        wid[i] = ++cnt;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            if (s[i][j] == '.') continue;
            if (s[i][j] == 'S')
                S = ++cnt, addE(S, hid[i], INF, INF), addE(S, wid[j], INF, INF);
            if (s[i][j] == 'T')
                T = ++cnt, addE(hid[i], T, INF, INF), addE(wid[j], T, INF, INF);
            if (s[i][j] == 'o') {
                int a = ++cnt, b = ++cnt;
                addE(a, hid[i], INF, INF), addE(b, wid[j], INF, INF), addE(a, b, 1, 1);
            }
        }
    
 //   cout << S << " " << T << endl;
 //   for (int i = 1; i <= cnt; ++i) {
 //       cout << i << " :  ";
 //       for (int j = fir[i]; j; j = nxt[j])
 //           cout << " ("<< to[j] << ", " << val[j] << ")  ";
 //       cout << endl;
 //   }

    int ans = dinic();

    if (ans > n * m * 10) ans = -1;

    cout << ans <<endl;

    return 0;
}

/*
    春江花月夜     张若虚

    春江潮水连海平,海上明月共潮生.
    滟滟随波千万里,何处春江无月明!
    江流宛转绕芳甸,月照花林皆似霰.
    空里流霜不觉飞,汀上白沙看不见.
    江天一色无纤尘,皎皎空中孤月轮.
    江畔何人初见月,江月何年初照人?
    人生代代无穷已,江月年年望相似.
    不知江月照何人,但见长江送流水.
    白云一片去悠悠,青枫浦上不胜愁.
    谁家今夜扁舟子,何处相思月明楼?
    可怜楼上月徘徊,应照离人妆镜台.
    玉户帘中卷不去,捣衣砧上拂还来.
    此时相望不相闻,愿逐月华流照君.
    鸿雁长飞光不度,鱼龙潜跃水成文.
    昨夜闲潭梦落花,可怜春半不还家.
    江水流春去欲尽,江潭落月复西斜.
    斜月沉沉藏海雾,碣石潇湘无限路.
    不知乘月几人归,落月摇情满江树.
 */


Measured memory_bytes: 1280
import java.util.ArrayDeque;
import java.util.Scanner;

class Area {
    int startIdx;
    int value;

    public Area(int startIdx, int value) {
        this.startIdx = startIdx;
        this.value = value;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        ArrayDeque<Area> areaStack = new ArrayDeque<>();

        int sum = 0;
        char[] input = sc.next().toCharArray();
        for (int i = 0; i < input.length; i++) {
            if (input[i] == '\\') {
                stack.push(i);
            } else if (!stack.isEmpty() && input[i] == '/') {
                int oppositeIdx = stack.pop();
                sum += i - oppositeIdx;

                int a = i - oppositeIdx;
                while (!areaStack.isEmpty() && areaStack.peek().startIdx > oppositeIdx) {
                    a += areaStack.pop().value;
                }
                areaStack.push(new Area(oppositeIdx, a));
            }
        }

        System.out.println(sum);

        StringBuffer sb = new StringBuffer();
        int areaStackSize = areaStack.size();
        sb.append(areaStackSize);

        for (int i = 0; i < areaStackSize; i++) {
            sb.append(" ");
            sb.append(areaStack.removeLast().value);
        }
        System.out.println(sb);
    }
}



Measured memory_bytes: 28340
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define repk(a) for(int k=0;k<int(a);k++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num == 0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n;
}

int a, b;
signed main() {
	cin >> a >> b;
	if (a > 8 || b > 8)cout << ":(" << endl;
	else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      	int count=0;
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
      	if(!isPalindrome(str)){
          System.out.println("No");
          System.exit(0);
        }
      
      	String strFirst=str.substring(0,str.length()/2);
      	if(!isPalindrome(strFirst)){
          System.out.println("No");
          System.exit(0);
        }
      
      	String strLast=str.substring((str.length()+3)/2-1,str.length());
      	if(!isPalindrome(strLast)){
          System.out.println("No");
          System.exit(0);
        }
      	System.out.println("Yes");
    }
  	public static boolean isPalindrome(String str){
		StringBuffer sb = new StringBuffer(str);
		String reverseStr = sb.reverse().toString();
      	return str.equals(reverseStr);
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
#define pb push_back

int main(int argc, char** argv) {
	string s;
	string t;
	cin>>s;
	cin>>t;
	int fg=0;
	rep(i,0,s.length()-1)
	{
		if(s[i]!=t[i])fg=1;
	}
	if(s.length()+1!=t.length())fg=1;
	if(!fg)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3624
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val o, e = sc.next()
  val sb = new StringBuilder
  for (i <- 0 until o.length + e.length) {
    if (i % 2 == 0) {
      sb += o(i / 2)
    } else {
      sb += e(i / 2)
    }
  }
  println(sb.toString())
}


Measured memory_bytes: 55244
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
string C;
void input(){
    fast_io();
    cin >> N >> C;
}

int solve(){
    vector<int> cntW(N+1),cntR(N+1);
    for (int i = 0; i < N; i++)
    {
        if(C[i]=='W') cntW[i+1]++;
        cntW[i+1] += cntW[i];
    }

    for (int i = N-1; i >= 0; i--)
    {
        if(C[i]=='R') cntR[i]++;
        cntR[i] += cntR[i+1];
    }
    int ans = N;
    for (int i = 0; i < N; i++)
    {
        ans = min(ans,max(cntW[i],cntR[i+1]));
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 5176
package main

import (
	"fmt"
)

func main() {
	var a, b, n int64

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&n)

	if n < b {
		fmt.Println(a * n / b)
	} else {
		fmt.Println(a * (b - 1) / b)
	}
}


Measured memory_bytes: 1752
// *** creator : cfmasterr *** //
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,X,Y;
  cin>>N>>X>>Y;
  X--;Y--;
  vector<int> v(N);
  REP(i,N)FOR(j,i+1,N){
    int d=j-i;
    d=min(d,abs(j-Y)+1+abs(i-X));
    v[d]++;
  }
  FOR(i,1,N)cout<<v[i]<<endl;
  return 0;
}


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


int main () {
    int A[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j< 3; j++) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;

    bool sheet[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            sheet[i][j] = false;
        }
    }

    for (int k = 0; k < N; k++) {
        int b;
                cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (A[i][j] == b) sheet[i][j] = true;
            }
        }
    }


    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (sheet[i][j] == false) break;
            if (j == 2) bingo = true;
        }
    }    
     
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < 3; i++) {
            if (sheet[i][j] == false) break;
            if (i == 2) bingo = true;
        }
    }

    for (int hoge = 0; hoge < 3; hoge++) {
        if (sheet[hoge][hoge] == false) break;
        if (hoge == 2) bingo = true;
    }

    for (int hoge = 0; hoge < 3; hoge++) {
        if (sheet[hoge][2 - hoge] == false) break;
        if (hoge == 2) bingo = true;
    }


    cout << (bingo ? "Yes" : "No") << endl;
    return 0;
}



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

int main(){
    ll n, a, b;
    cin >> n;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            a = i;
            b = n/i;
        }
    }
	cout << a+b-2 << endl;
    return 0;
}


Measured memory_bytes: 384
sx,sy,tx,ty = map(int,input().split())
(tx,ty) = (tx-sx,ty-sy)
route1 = "U"*ty + "R"*tx
route2 = "D"*ty + "L"*tx
route3 = "L" + "U"*(ty+1) + "R"*(tx+1) + "D"
route4 = "R" + "D"*(ty+1) + "L"*(tx+1) + "U"
ans = route1 + route2 + route3 + route4
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = (res*x)%md;
        x = (x*x)%md;
        y = y/2;
    }
    return res;
}


void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+c == 2*b)
		cout<<"YES";
	else 
		cout<<"NO";
}

int main()
{
    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


Measured memory_bytes: 256
"""abc088_b"""
N = int(input())
A = list(map(int, input().split()))

alice = 0
bob = 0

a_desc = sorted(A, reverse=True)

for i, a in enumerate(a_desc):
    if i % 2 == 0:
        alice += a
    else:
        bob += a

print(alice - bob)


Measured memory_bytes: 9048
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

void re_curse()
{
    ll n,k;
    cin>>n>>k;
    ll front=0,back=0, ans=0;
    for(int i=0;i<k;i++)
    {
        front+=i;
        back+=(n-i);
    }
    for(int i=k;i<=n+1;i++)
    {
        ans+=(back-front+1);
        ans%=1000000007;
        front+=i;
        back+=(n-i);
    }
    cout<<ans<<endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    re_curse();
    return 0;
}

Measured memory_bytes: 3652
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[] a = new int[(int) n];
		for (int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[n/2] - a[n/2-1]);
		sc.close();
	}

}

Measured memory_bytes: 50620
import java.util.*;

public class Main {
  
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
        String[] lines = line.split(" ", 0);
    	int red = Integer.parseInt(lines[0]);
    	int green = Integer.parseInt(lines[1]);
    	int blue = Integer.parseInt(lines[2]);
      	line = sc.nextLine();
      	int max = Integer.parseInt(line);
		int count = 0;
      	
     	while (red >= green) {
          green *= 2;
          count++;
        }
     	while (green >= blue) {
          blue *= 2;
          count++;
        }
      
      	if (count > max) {
          	System.out.println("No");
        } else {
          	System.out.println("Yes");
        }
	}
}

Measured memory_bytes: 35608
#pragma region
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
#pragma endregion



int A[100005];
int n,m,ans=0,t;

bool ord(int a, int b){
	return a>b;
}


int main()
{
    int N[4],k;
    scanf("%d%d%d%d",&N[0],&N[1],&N[2],&k);
    sort(N,N+3,ord);
   
    for (int i = 0; i < k; ++i)
    {
    	N[0]*=2;
    	ans+=N[0];
    }

    ans = N[0]+N[1]+N[2];

    return !printf("%d\n", ans);
    /*
    for (int i = 0; i < n; ++i)
    {
    	scanf("%d",&A[i]);
    }*/
    
    

    
       
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define INFF 100000000000000000 //1e17

#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
const int Nmax=1e5+5;
int dp[102][Nmax]={};
void initialise()
{
	for(int i=0;i<102;i++)
		{for(int j=0;j<Nmax;j++)
			{if(j==0 )
				dp[i][j]=0;
				else
				dp[i][j]=INF;
		}}
}
int32_t main()
{
	IOS;
	int N,W; cin>>N>>W;
	initialise();
	int val[N+1]={},wt[N+1]={};
	int SS=0;
	for(int i=1;i<=N;i++)
		{cin>>wt[i]>>val[i]; SS+=val[i];}
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=SS;j++)
		{
			if(dp[i-1][j]<INFF)
				{dp[i][j]=min(dp[i-1][j],dp[i][j]);
				dp[i][j+val[i]]=min( dp[i-1][j]+wt[i] , dp[i][j+val[i]] ); }
		}
	}
	//deb(dp[1][1]);
	int mn=INF;
	//for(int i=0;i<=SS;i++)
	//	deb(dp[N][i]);
	for(int i=SS;i>=0;i--)
	{
		if(dp[N][i]<=W)
			{mn=i; break;}
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 80000
import sys
n = int(sys.stdin.readline().strip())
a = [int(sys.stdin.readline().strip()) for x in range(n)]

total = 0

pre_i = 0
for i in a:
    if pre_i == 1 and i >= 1:
        total += 1
        i -= 1
    total += i / 2
    pre_i = i % 2

print total


Measured memory_bytes: 8964
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>

using namespace std;

int main(){
	int n,a;
	string str;
	list<int> l;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		if(str == "insert"){
			cin >> a;
			l.push_front(a);
		}else if(str == "delete"){
			cin >> a;
			auto itr = l.begin();
			for(;itr!=l.end();++itr)if(*itr==a){l.erase(itr);break;}
		}else if(str == "deleteFirst"){
			l.pop_front();
		}else if(str == "deleteLast"){
			l.pop_back();
		}
	}
	auto itr = l.begin();
	cout << *itr;++itr;
	for(;itr!=l.end();++itr){
		cout << " " << *itr;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 34424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= Math.sqrt(X); i++) {
				int j = 1;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[] prize = {300000, 200000, 100000};
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int ans = (x == 1 && y == 1) ? 400000 : 0;
        --x;
        --y;
        if(x < 3) ans += prize[x];
        if(y < 3) ans += prize[y];
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-09 21:49:59
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 + 7;

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

  int n; cin >> n;
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  bool dp[n][61];
  // dp[i][j] : a_i の j 桁目に bit が立っているか

  for (int i = 0; i < n; ++i) {
    bitset<61> bs(a[i]);
    for (int j = 0; j < 61; ++j) {
      dp[i][j] = bs.test(j);
    }
  }

  int64 dp2[n][61];
  // dp2[i][j] : a_0 から a_i まで見たときに、j 桁目の bit が立っているものの個数

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 61; ++j) {
      if (i == 0) {
        dp2[i][j] = dp[i][j];
      } else {
        dp2[i][j] = dp[i][j] + dp2[i - 1][j];
      }
    }
  }

  int64 ans = 0;

  for (int i = 1; i < n; ++i) {
    bitset<61> bs(a[i]);
    for (int j = 0; j < 61; ++j) {
      if (bs.test(j)) {
        ans += (1LL << j) % MOD * (i - dp2[i - 1][j]) % MOD;
      } else {
        ans += (1LL << j) % MOD * dp2[i - 1][j] % MOD;
      }
    }
  }

  cout << ans % MOD << endl;

  return 0;
}

Measured memory_bytes: 163456
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    double a, b, x;
    cin >> a >> b >> x;
    std::cout<<std::fixed<<std::setprecision(10);
    if(x > a * a * b / 2){
        cout<<180 * atan(2 * (b * a * a - x) / (a * a * a)) / M_PI<<endl;
    }else{
        cout<<180 * atan(a * b * b / (2 * x)) / M_PI <<endl;
    }
}


Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
for k in range(min(50, K)):
    B = [0]*N
    for i in range(N):
        B[max(0, i-A[i])] += 1
        r = i+A[i]+1
        if r < N:
            B[r] -= 1
    A = list(accumulate(B))
print(*A)


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

int main()
{
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> c[i][j];
    }
  }

  vector<int> a(3), b(3);


  for (int i = 0; i < 3; ++i) b[i] = c[0][i];
  for (int i = 0; i < 3; ++i) a[i] = c[i][0] - b[0];

  for (int i = 1; i < 3; ++i) {
    for (int j = 1; j < 3; ++j) {
      if (a[i]+b[j] != c[i][j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}

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

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();


        if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)) {
            System.out.println("Yes");
        }
        else{ System.out.println("No");}





    }
}





Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,D; cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int z=0;z<D;z++){
            cin >> X[i][z];
        }
    }
    int ans =0;
      for(int i=0;i<N;i++){
        for(int z=i+1;z<N;z++){
            int norm=0;
            for(int k=0;k<D;k++){
                int diff = abs(X[i][k] - X[z][k]);
                norm += diff * diff;     
            }
            bool fiag = false;
            for(int k=0;k<=norm;k++){
                if(k*k==norm)
                ans++;
            } 
        }

    }
    cout << ans;
}

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

#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   /*
   int A,B,C;
   cin>>A>>B>>C;

   int m = A%B;
   if(m == 0){
      if(C == 0){
         cout<<"YES"<<endl;
         return 0;
      }
      else{
         cout<<"NO"<<endl;
         return 0;
      }
   }
   cout<<m<<endl;
   */

   ll N,W;
   cin>>N>>W;
   vector<ll>w(N),v(N);
   for(int i=0;i<N;i++)cin>>w[i]>>v[i];
   ll w1 = w[0]-1;
   for(int i=0;i<N;i++)w[i]-=w1;
   vector<vector<vector<ll>> >dp(N+1,vector<vector<ll> >(401,vector<ll>(N+1)));
   for(ll i=0;i<=N;i++){
      for(ll j=1;j<=400;j++){
         for(int k=1;k<=N;k++){
            if(i==0)dp[i][j][k] = 0;
            else if(j-w[i-1]>=0)dp[i][j][k] = max(dp[i-1][j-w[i-1]][k-1]+v[i-1],dp[i-1][j][k]);
            else dp[i][j][k] = dp[i-1][j][k];
         }
      }
   }
   ll Max = 0;
   for(int i=0;i<=400;i++){
      for(int j=0;j<=N;j++){
         if(i+j*w1>W)continue;
         Max = max(dp[N][i][j],Max);
      }
   }
   cout<<Max<<endl;
   return 0;
}


Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes":"No") << endl;
}


Measured memory_bytes: 256
line = input().split()
N = int(line[0])
x = int(line[1])
ans = 0

a = input().split()
a = [int(i) for i in a]
a.sort()

for i in range(N):
    if a[i] > x:
        print(ans)
        break
    else:
        x -= a[i]
        if i != (N - 1):
            ans += 1
        else:
            if x == 0:
                ans += 1
            print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	int a, b, x = 0;
	scanf("%d %d %d", &a, &b, &x);

	if (a > x) {
		printf("NO\n");
	} else if (a + b < x) {
		printf("NO\n");
	} else {
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> c(N);
    REP(i, Q) {
        int temp;
        cin >> temp;
        c[temp - 1]++;
    }
    REP(i, N) {
        if(Q - c[i] < K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
def Divisor(n):
    res = []
    for i in range(1, int(n**0.5)+1):
      if n % i != 0: continue
      res.append(i)
      if i*i != n: res.append(n//i)
    return res

n = int(input())

#K is a divisor of N
ans = 0
for x in Divisor(n):
    if x == 1: continue
    tmp = n
    while (tmp % x == 0):
        tmp /= x
    tmp %= x    
    if tmp == 1: 
      ans += 1
      
#K is not a divisor of N (except 1)
ans += len(Divisor(n-1))-1
print(ans)

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    int x, y;
    if(n % 2 == 1){
        x = a[(n + 1) / 2 - 1];
        y = b[(n + 1) / 2 - 1];
    }else{
        x = a[n / 2] + a[n / 2 - 1];
        y = b[n / 2] + b[n / 2 - 1];
    }
    cout << y - x + 1 << endl;  
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 6340
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = scan.nextInt();
		
		List<Integer> hpList = new ArrayList<Integer>();
		for (int i=0; i<n; i++) {
			hpList.add(scan.nextInt());
		}
		Collections.sort(hpList);
		
		long minAttackCount = 0;
		for (int i=0; i<hpList.size()-count; i++) {
			minAttackCount += hpList.get(i);
		}
		
		System.out.println(minAttackCount);
	}
	
}

Measured memory_bytes: 93092
const Main = input => {
    input = input.trim();
    const ascii = input.charCodeAt(0);

    if(0x41 <= ascii && ascii <= 0x5A) {
        console.log('A');
    } else if(0x61 <= ascii && ascii <= 0x7A) {
        console.log('a');
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29684
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
using namespace std;
const int N=1e5+5;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,head[N],sg[N],cnt;
struct edge{
	int to,nxt;
}e[N<<1];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int f){
	edge(u){
		int v=e[i].to;
		if(v==f) continue;
		dfs(v,u);
		sg[u]^=(sg[v]+1);
	}
}
int main(){
	n=read();
	inc(i,2,n){
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	dfs(1,0);
	if(sg[1]) puts("Alice");
	else puts("Bob");
}

Measured memory_bytes: 7296
#include <stdio.h>

void solve(int a){
	int ans = 0;
	while (a > 0){
		ans ++;
		a /= 10;
	}
	printf("%d\n", ans);
}

int main (){
	int a, b;
	while (~scanf("%d%d", &a, &b)){
		solve(a+b);
	}
	return 0;
}

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

using namespace std;
 
int main()
{
    string str;
    int n;
     
    cin >> n;
    cin.ignore();
    while (n--) {
        getline(cin, str);
        for (int j = 0; j < (int)str.size(); j++) {
            string key = str.substr(j, 7), repl;
            if (key == "Hoshino") {
                repl = "Hoshina";
                for (int k = 0; k < 7; k++) {
                    str[j+k] = repl[k];
                }
            }
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j,k;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  k=-1;
  for(i=0; i<n; i++){
      scanf("%d",&A[i]);
      if(A[i]>k){
          k=A[i];
      }
  }
  for(i=0; i<=k; i++){
      C[i]=0;
  }
  for(i=0; i<=n; i++){
      C[A[i]]++;
  }
  for(i=1; i<=k; i++){
      C[i]+=C[i-1];
  }
  for(i=n; i>=0; i--){
      B[C[A[i]]]=A[i];
      C[A[i]]--;
  }

  printf("%d",B[2]);
  for(i=3; i<n+2; i++){
      if(i)printf(" ");
      printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 9596
// while( !(succeed == try()) );

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 


// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{    
    int n;
    cin>>n;

    int arr[n];
    loop(i,0,n) cin>>arr[i];



    int ans = 0;
    loop(i,0,n)
    {
        loop(j,i+1,n)
        {
            loop(k,j+1,n)
            {
                // bug(i, j, k, ans);
                int a = arr[i];
                int b = arr[j];
                int c = arr[k];
                if(a!=b and b!=c and a!=c and a+b>c and a+c>b and b+c>a)
                {

                    ans++;
                }
            }
        }
    }

    cout<<ans<<endl;
}

int32_t main(){

    ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // INP();
    int t=1;
    //cin>>t;
    
    while(t--) alpha();

    return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

bool in(int target, int max) { return 0 <= target && target < max - 1; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int win = std::count(S.cbegin(), S.cend(), 'o');
  int k = S.length();
  if (win >= 8) {
    cout << "YES" << endl;
    return 0;
  }
  if (8 - win <= 15 - k) {
    cout << "YES" << endl;
    return 0;
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include"stdio.h"
int main(){
    char s[201];
    scanf("%s",s);
    int f[26];
    for(int i=0;i<26;i++) f[i]=0;
    int cnt=0;
    while(s[cnt]!='\0'){
        f[s[cnt]-'a']++;
        cnt++;
    }
    s[cnt-1]='\0';
    cnt--;
    int clear=1;
    while(1){
        if(cnt%2)  cnt--;
        else{
            for(int i=0;i<cnt/2;i++){
                if(s[i]!=s[i+cnt/2])  clear=0;
            }
            if(clear){
                printf("%d\n",cnt);
                break;
            }
            clear=1;
            cnt--;
        }
    }
}


Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int w = fs.nextInt();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		if((a <= b && b <= a+w) || (b <= a && a <= b+w)) {
			System.out.println(0);
		}else {
			System.out.println(Math.min(Math.abs(b+w-a), Math.abs(a+w-b)));
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 22996
import math
def ip():return int(input())
def inp():return map(int,input().split())
def linp():return list(map(int,input().split()))

n,l=inp()
ans=l*n+(1+n)*n//2-n
if l>=0:k=1+l-1
elif l<-(n-1):
    k=l+n-1
else:k=0
print(ans-k)



Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(){
	long long int x,y;
	long long int i,j;
	while(scanf("%lld%lld",&i,&j),i){
		x=i,y=j;
		while((i!=0)&&(j!=0)){
			if(i>j){
				i=i%j;
			}else{
				j=j%i;
			}
		}
		if(i==0){
			y=x*y/j;
			x=j;
		}else{
			y=x*y/i;
			x=i;
		}
		printf("%lld %lld\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    x = (c*e - b*f) / (a*e - b*d)
    y = (a*f - c*d) / (a*e - b*d)
    if x == -0.0:
        x = 0
    if y == -0.0:
        y = 0
    print('{:.3f} {:.3f}'.format(x, y))

Measured memory_bytes: 7352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

bool f;
ll n, x, y;
P start;
vector<P> vp;
P Move[12] = { P(-2, 1), P(-2, 0), P(-2, -1), P(-1, 2), P(-1, -2),
P(0, 2), P(0, -2), P(1, 2), P(1, -2), P(2, 1), P(2, 0), P(2, -1) };

void solve(ll num, ll x, ll y){
	if (num == n){
		f = 1;
		return;
	}
	REP(i, 12){
		ll nx = x + Move[i].first, ny = y + Move[i].second;
		if (nx >= 0 && nx <= 9 && ny >= 0 && ny <= 9){
			int posx = vp[num].first, posy = vp[num].second;
			if (posx - 1 <= nx&&nx <= posx + 1 && posy - 1 <= ny&&ny <= posy + 1){
				solve(num + 1, nx, ny);
			}
		}
	}
}

int main(){
	while (cin >> x >> y&&x + y){
		f = 0;
		start = P(x, y);
		vp.clear();
		cin >> n;
		REP(i, n){
			cin >> x >> y;
			vp.push_back(P(x, y));
		}
		solve(0, start.first, start.second);
		if (f)cout << "OK" << endl;
		else cout << "NA" << endl;
	}
}

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

class Dmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var ans = 0L;
        var minusCount = 0;
        var absMinNum=long.MaxValue;
        for (int i=0;i<N;++i)
        {
            if (A[i] < 0) minusCount++;
            var absNum = Math.Abs(A[i]);
            ans +=absNum;
            if (absNum < absMinNum) absMinNum = absNum;
        }
        if (minusCount % 2 == 1) ans -= (absMinNum * 2);
        Console.WriteLine(ans);
    }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double dd;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(), (c).end()
#define MOD 1000000007
#define MAX 1e5 + 10

int main() {
#ifdef HOME
    freopen("kek.in", "r", stdin);
    freopen("kek.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vll arr(3 * n);
    for (int i = 0; i < 3 * n; i++)
        cin >> arr[i];
    vll first(3 * n, 0);
    multiset<ll> s;
    s.insert(arr[0]);
    first[0] = arr[0];
    for(int i = 1; i < n; i++){
        s.insert(arr[i]);
        first[i] = first[i - 1] + arr[i];
    }
    for(int i = n; i < 2 * n; i++) {
        if (arr[i] > *s.begin()) {
            first[i] = first[i - 1] - *s.begin() + arr[i];
            s.erase(s.find(*s.begin()));
            s.insert(arr[i]);
        }
        else
            first[i] = first[i - 1];
    }
    vll sec(3 * n, 0);
    s.clear();
    s.insert(arr[3 * n - 1]);
    sec[3 * n - 1] = arr[3 * n - 1];
    for(int i = 2; i <= n; i++) {
        s.insert(arr[3 * n - i]);
        sec[3 * n - i] = sec[3 * n - i + 1] + arr[3 * n - i];
    }
   /* for(auto a : s)
        cout << a << " ";
    cout << endl;*/
    for(int i = 2 * n - 1; i >= n; i--) {
     //   cout << " i " << i << " max " << *s.rbegin() << " arr[i] " << arr[i] << endl;
        if (arr[i] < *s.rbegin()) {
            sec[i] = sec[i + 1] - *s.rbegin() + arr[i];
            s.erase(s.find(*s.rbegin()));
            s.insert(arr[i]);
        }
        else
            sec[i] = sec[i + 1];
    }
    ll ans = -9223372036854775807;
    for(int i = n; i <= 2 * n; i++)
        ans = max(ans, first[i - 1] - sec[i]);
   /* for(auto a : first)
        cout << a << " ";
    cout << endl;
    for(auto a : sec)
        cout << a << " ";
    cout << endl;*/
    cout << ans;
    return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n,m;
    cin>>n>>m;

    priority_queue<int> q;
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        q.push(a);
    }

    for(int i=0; i<m; i++){
        int am = q.top()/2;
        q.push(am);
        q.pop();
    }

    LL total=0;
    for(int i=0; i<n; i++){
        total+=q.top();
        q.pop();
    }

    cout<<total<<endl;

    return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
double f(double a, double b, double c) {
    double A = acos((a*a + b*b - c*c) / (2*a*b))/2,
        B = acos((b*b + c*c - a*a) / (2*b*c))/2;
    return b / (2 + 1 / tan(A) + 1 / tan(B));
}

int main() {
    int x1, y1, x2, y2, x3, y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)),
        b = sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1)),
        c = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
    printf("%.10f\n", max(max(f(a, b, c), f(b, c, a)), f(c, a, b)));
}


Measured memory_bytes: 384