akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, y;
    cin >> x >> y;
    vector<int> group(13);
    group[1] = 1, group[3] = 1, group[5] = 1, group[7] = 1, group[8] = 1, group[10] = 1, group[12] = 1;
    group[4] = 2, group[6] = 2, group[9] = 2, group[11] = 2;
    group[2] = 3;
    if (group[x] == group[y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scan(&input)
	inputRune := []rune(input)
	var outputRune []rune
	for ip := range inputRune {
		switch inputRune[ip] {
		case 'B':
			l := len(outputRune)
			if l > 0 {
				outputRune = outputRune[:l-1]
			}
		default:
			outputRune = append(outputRune, inputRune[ip])
		}
	}
	fmt.Println(string(outputRune))
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    char s[19];
    int i;
    scanf("%s", s);
    for (i=0; i<19; i++)
    {
        if (s[i] == ',') {
            s[i] =  ' ';
        }
    }
    printf("%s\n", s);
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.rbegin(),a.rend());
    int ans = 0;
    rep(i,k){
        ans += a[i];
    }
    cout<< ans << endl;
    
    return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> A(N);
  rep(i, 0, N) A[i] = L + i;
  int ans = 0;
  rep(i, 0, N) ans += A[i];
  int mn = 1e9;
  rep(i, 0, N) if(abs(A[i] < abs(mn))) mn = A[i];
  cout << ans - mn << endl;
  return 0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(ll (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;
bool m[114514];
string s;

void p(bool x, bool y) {
	bool h[114514] = {};
	h[0] = x, h[1] = y;
	reps(i,1,n) h[i+1] = (h[i]==m[i]) ? h[i-1] : 1-h[i-1];
	reps(i,1,n-1) if ((h[i]&&((m[i]&&h[i-1]!=h[i+1])||(!m[i]&&h[i-1]==h[i+1])))
			|| !h[i]&&((m[i]&&h[i-1]==h[i+1])||(!m[i]&&h[i-1]!=h[i+1]))) return;
	if ((h[0]&&((m[0]&&h[n-1]!=h[1])||(!m[0]&&h[n-1]==h[1])))
		|| !h[0]&&((m[0]&&h[n-1]==h[1])||(!m[0]&&h[n-1]!=h[1]))) return;
	if ((h[n-1]&&((m[n-1]&&h[n-2]!=h[0])||(!m[n-1]&&h[n-2]==h[0])))
		|| !h[n-1]&&((m[n-1]&&h[n-2]==h[0])||(!m[n-1]&&h[n-2]!=h[0]))) return;
	rep(i,n) cout << (h[i] ? 'S' : 'W');
	cout << ln;
	exit(0);
}

signed main() {
	cin >> n >> s;
	rep(i,n) m[i] = s[i]=='o';
	rep(i,2) rep(j,2) p(i,j);
	cout << -1 << ln;
}

Measured memory_bytes: 848
N, M = map(int, input().split())

AB = []

for _ in range(N):
    AB.append(list(map(int, input().split())))

CD = []

for _ in range(M):
    CD.append(list(map(int, input().split())))

for i in range(N):
    distance = 10**9+7
    for j in range(M)[::-1]:
        temp = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
        # print(AB[i][0] - CD[j][0],AB[i][1] - CD[j][1])
        # print('temp=',temp,'j=',j)
        if temp <= distance:
            distance = temp
            ans = j+1
            # print('ans=',ans)
    print(ans)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
module Main where

import Data.Functor
import Data.Bool

main :: IO ()
main = do
  { [n] <- getInts
  ; print =<< loop (maxBound, minBound) n
  }

loop :: (Int, Int) -> Int -> IO Int
loop (_,maxv) 0 = return maxv
loop (!minv, !maxv) !n = do
  { [r] <- getInts
  ; loop (min minv r, max maxv (r - minv)) (n - 1)
  }
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4328
import sys
 
cnt = {}
 
for line in sys.stdin:
  for l in line:
    if l.isalpha():
      c = l.lower()
      cnt[c] = cnt.get(c,0)+1
 
for i in range(26):
  c = chr(ord('a')+i)
  print( c, " : ", cnt.get(c,0), sep = '' )


Measured memory_bytes: 5568
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll a, b;
    cin >> a >> b;

    rep(i, b * 100) {
        double temp = i;
        ll temp_a = temp * 0.08, temp_b = temp * 0.10;
        if (temp_a == a && temp_b == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}



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

int n;

int num[4];

const int maxn = 3e4 + 5;
bool vis[maxn];


int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    if(n >= 6){
        num[0] = 2, num[1] = 3, num[2] = 4, num[3] = 6;
        long long sum = 0;
        for(int i = 0;i < n;i++){
            sum += num[i % 4]; 
            vis[num[i % 4]] = 1;
            num[i % 4] += 6;
        }
        if(sum % 6 == 0){

        }else if(sum % 6 == 2){
            vis[8] = false;
            vis[num[3]] = true;
        }else if(sum % 6 == 3){
            vis[9] = false;
            vis[num[3]] = true;
        }else if(sum % 6 == 5){
            vis[9] = false;
            vis[num[2]] = true;
        }
        vector<int> ans;
        for(int i = 1;i <= 30000;i++){
            if(vis[i]){
                ans.push_back(i);
            }
        }
        for(int i = 0;i < n;i++){
            cout << ans[i];
            if(i == n - 1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }else if(n == 3){
        cout << 2 << " " << 5 << " " << 63 << endl;
    }else if(n == 4){
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
    }else if(n == 5){
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << " " << 90 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> A;
  multiset<int> se;
  for(int i=0;i<n;i++){int a;cin >> a;A.push_back(a);se.insert(a);}
  for(int i=0;i<n;i++){
    se.erase(se.find(A[i]));
    cout << *(--se.end()) << "\n";
    se.insert(A[i]);
  }
}

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s[0]==s[1])
            {
                Console.WriteLine("1 2");
                return;
            }
            for (int i = 0; i < s.Length-2; i++)
            {
                string t = s.Substring(i, 3);
                if(t[0] ==t[1] || t[1]==t[2] || t[2]==t[0])
                {
                    Console.WriteLine("{0} {1}", i + 1, i + 3);
                    return;
                }
            }
            Console.WriteLine("-1 -1");
        }
    }
}


Measured memory_bytes: 6232
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>

using namespace std;
using ll = long long;

int main(){
    int k,n;
    cin >> k >> n;
    vector<int> hs(n,0);
    for(int i = 0;i < n;++i)cin >> hs[i];
    int max = 0;
    for(int i = 0;i < n - 1;++i){
        int tmp = hs[i + 1] - hs[i];
        if(tmp > max)max = tmp;
    }
    if(k + hs[0] - hs[n - 1] > max)max = k + hs[0] - hs[n - 1];
    cout << (k - max) << endl;
}


Measured memory_bytes: 1656
n = int(input())
a = [9, 8, 7, 6, 5, 4, 3, 2, 1]
cnt = 0
if 1 <= n <= 81:
    for i in a:
        if n % i == 0:
            if 1 <= (n / i) <= 9:
                cnt += 1
                print("Yes")
                break

if cnt == 0:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll A,B,X; cin>>A>>B>>X;
    if(2*X>=(A*A*B)){
        long double tmp = A*B - X/(long double)A;
        tmp /= (long double)A;
        tmp /= (long double)A;
        tmp *= 2.0;
        printf("%.9Lf",(180.0*atan(tmp))/M_PI);
    }else{
        long double tmp = (long double)(A*B*B) / ((long double)(2.0*X));
        printf("%.9Lf",(180.0*atan(tmp))/M_PI);
    }
}



Measured memory_bytes: 3728
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  if (13 <= A) {
    cout << B << endl;
  } else if (6 <= A && A <= 12) {
    cout << B / 2 << endl;
  } else if (A <= 5) {
    cout << 0 << endl;
  }
  return 0;
}


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

int main(){

  string s, left="qwertasdfgzxcvb";

  while(cin>>s){
    if(s=="#") break;
    bool right;
    if(left.find(s[0])!=string::npos) right=false;
    else right=true;
    int cnt=0;
    for(int i=1;i<s.size();i++){
      if(right){
	if(left.find(s[i])!=string::npos){
	  right=false;
	  cnt++;
	}
      }else{
	if(left.find(s[i])==string::npos){
	  right=true;
	  cnt++;
	}
      }
    }
    cout<<cnt<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3148
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b;cin>>a>>b;
  if(a>=b*2-1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//AtCoder AGC025 A - Digits Sum
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    ll ans=0;
    while(N>0){
        if(N==10){
            ans += N;
            break;
        }
        ll keta=N%10;
        N/=10;
        ans+=keta;
    }
    cout<<ans<<endl;
    return 0;
}

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

int func(int,int);

int main(){
  int N,flag=0;
  cin >> N;
  vector <int> A(N),B((N+1)/2,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
    if((N%2)==1){
      if((A[i]%2)==1){
        flag=1;
      }
    }else{
      if((A[i]%2)==0){
        flag=1;
      }
    }
    B[A[i]/2]++;
    if(B[A[i]/2]>2){flag=1;}
    if(A[i]==0 && B[A[i]/2]>1){flag=1;}
  }

  if(N==1){
    cout << 1 << endl;
  }else if(flag==1){
    cout << 0 << endl;
  }else{
    cout << func(2,N/2) << endl;
  }
  return 0;
}
int func(int x,int a){
  if(a>1){
    return x*func(x,a-1)%Q;
  }else{
    return x;
  }
}


Measured memory_bytes: 1664
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define UNIQ(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

bool is_trianglable(ll a, ll b, ll c) {
    return a + b > c && a != b && b != c && a != c;
}

void func(long long N, std::vector<long long> L){
    VSORT(L);
    // UNIQ(L);

    ll sum = 0;
    for (ll i = 0; i < sz(L); i++) {
        for (ll j = i+1; j < sz(L); j++) {
            for (ll k = j+1; k < sz(L); k++) {
                if (is_trianglable(L[i], L[j], L[k])) {
                    // cout << L[i] << ", " << L[j] << ", " << L[k] << endl;
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    func(N, std::move(L));
    return 0;
}


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

int main() {
	int n;
	std::cin >> n;
	int a[n+1];
	for (int i = 0; i < n+1; i++) {
	    std::cin >> a[i];
	}
	int b[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> b[i];
	}
	
	int kill_i = 0;
	long long ans = 0;
	
	for (int i = 0; i < n; i++) {
	    kill_i = min(b[i], a[i] + a[i+1]);
	    
	    if(a[i] - kill_i < 0) {
	        a[i+1] -= (kill_i - a[i]);
	        a[i] = 0;
	    }else{
	        a[i] -= kill_i;
	    }
	    
	    ans += kill_i;
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define mod 1000000007
#define P pair<int,int>//l x
using namespace std;

int dp[302][302][302];
vector<P>a[301];
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, x; cin >> l >> r >> x;
		a[r].push_back({ l, x });
	}
	for (P i : a[1]) {
		if (i.second >= 2) {
			puts("0");
			return 0;
		}
	}
	int ans = 0;
	dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= j; k++) {
				bool OK = true;
				for (P S : a[i]) {
					int c = 1;
					if (S.first <= j)c++;
					if (S.first <= k)c++;
					if (c != S.second) { OK = false; }
				}
				int b[3] = { k,j,i };
				do {
					int x = b[0], y = b[1], z = b[2];
					if (!OK)dp[x][y][z] = 0;
					dp[i + 1][y][z] += dp[x][y][z];
					dp[i + 1][y][z] %= mod;
					dp[x][i + 1][z] += dp[x][y][z];
					dp[x][i + 1][z] %= mod;
					dp[x][y][i + 1] += dp[x][y][z];
					dp[x][y][i + 1] %= mod;
					if (i == n){
						ans += dp[x][y][z];
						ans %= mod;
					}
				} while (next_permutation(b, b + 3));
			}
		}
	}
	cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) {
        int i = 1;
        int oldRank = -1;
        Scanner sc = new Scanner(System.in);
        List<Team> team = new ArrayList<Team>();
        while (true) {
            String[] in = sc.nextLine().split(",");
            int num = Integer.parseInt(in[0]);
            int ac = Integer.parseInt(in[1]);
            if (num == 0 && ac == 0) {
                break;
            }
            team.add(new Team(num, ac));
        }
        Collections.sort(team, new Team());
        for (Team t : team) {
            if (oldRank == -1) {
                oldRank = t.teamAccept;
            }
            if (oldRank != t.teamAccept) {
                i++;
            }
            t.teamRank = i;
            oldRank = t.teamAccept;
        }
        while (sc.hasNext()) {
            int teamNumber = sc.nextInt();
            for (Team t : team) {
                if (teamNumber == t.teamNumber) {
                    System.out.println(t.teamRank);
                }
            }
        }
    }
}
class Team implements Comparator<Team> {
    public int teamNumber;
    public int teamAccept;
    public int teamRank;

    public Team(int num, int ac) {
        this.teamNumber = num;
        this.teamAccept = ac;
    }

    public Team() {
    }

    public String getTeamString() {
        return "(" + teamNumber + "," + teamAccept + ")" + teamRank;
    }

    public int compare(Team o1, Team o2) {
        int team1 = o1.teamAccept;
        int team2 = o2.teamAccept;
        if (team1 > team2) {
            return -1;
        } else if (team1 == team2) {
            return 0;
        } else {
            return 1;
        }
    }
}

Measured memory_bytes: 17228
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n=pI(readline())
  a=sort!(pM(split(readline())),rev=true)
  println(sum(a[1:2:end])-sum(a[2:2:end]))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


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

int main() {
    long h, w, ans;
    cin >> h >> w;
    if(h % 2 && w % 2) ans = h * w / 2 + 1;
    else ans = h * w / 2;
    if(h == 1 || w == 1) ans = 1;
    cout << ans << endl;
}

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

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

const int N = 111;

int n, m, ans, Ex, Ey;
int sr[N][N], sc[N][N], dp[N][N][N][N];
char ch[N][N];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
        cin >> ch[i][j];
        sr[i][j] = sr[i][j-1] + (ch[i][j] == 'o');
        sc[i][j] = sc[i-1][j] + (ch[i][j] == 'o');
        if (ch[i][j] == 'E') Ex = i, Ey = j;
    }

    for (int u = 0; u < Ex; u++) {
        for (int d = 0; d <= n - Ex; d++) {
            for (int l = 0; l < Ey; l++) {
                for (int r = 0; r <= m - Ey; r++) {
                    int ret = 0;

                    int top = max(Ex - u, d + 1);
                    int bot = min(Ex + d, n - u);
                    int lft = max(Ey - l, r + 1);
                    int rgt = min(Ey + r, m - l);

                    if (u > 0 && Ex - u - d > 0)  ret = max(ret, dp[u-1][d][l][r] + (sr[Ex-u][rgt] - sr[Ex-u][lft-1]));
                    if (d > 0 && Ex + d + u <= n) ret = max(ret, dp[u][d-1][l][r] + (sr[Ex+d][rgt] - sr[Ex+d][lft-1]));
                    if (l > 0 && Ey - l - r > 0)  ret = max(ret, dp[u][d][l-1][r] + (sc[bot][Ey-l] - sc[top-1][Ey-l]));
                    if (r > 0 && Ey + l + r <= m) ret = max(ret, dp[u][d][l][r-1] + (sc[bot][Ey+r] - sc[top-1][Ey+r]));

                    dp[u][d][l][r] = ret;
                    ans = max(ans,ret);
                }
            }
        }
    }

    cout << ans;
}


Measured memory_bytes: 236288
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

char n[2];
int main(){
    cin>>n;
    if(n[0]=='9'||n[1]=='9') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    S=input()
    ans=[S[0]]    
    t=S[0]
    for i in range(1,len(S)):
        if S[i]!=t:
            t=S[i]
            ans.append(t)
    print(len(ans))
if __name__ == "__main__":
    main()

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

using namespace std;

int main(int argc, char const *argv[])
{
    string s, s2;
    cin >> s;

    for(bool flg=true;flg;) {
        flg=false;
        if(s.length()==0) {
            cout << "YES" << endl;
            return 0;
        } else {
            if(s.length() >= 5) {
                s2 = s.substr(s.length()-5, 5);
                if (s2=="dream" || s2 == "erase") {
                    flg=true;
                    s = s.substr(0,s.length()-5);
                    continue;
                }
            }
            if(s.length() >= 6) {
                s2 = s.substr(s.length()-6, 6);
                if (s2 == "eraser") {
                    flg=true;
                    s = s.substr(0,s.length()-6);
                    continue;
                }
            }
            if(s.length() >= 7) {
                s2 = s.substr(s.length()-7, 7);
                if (s2=="dreamer") {
                    flg=true;
                    s = s.substr(0,s.length()-7);
                    continue;
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
int main(void){
    char s[1000], t[1000];
    int n, m, i, j, p, q;
    
    scanf("%s%s",s,t);
    n=strlen(s);
    m=strlen(t);
    
    for(i=0;i<n;i++){
        p=s[i];
        for(j=i;j<n;j++){
            if(s[j]<p){
                p=s[j];
                s[j]=s[i];
                s[i]=p;
            }
        }
    }
    for(i=0;i<m;i++){
        p=t[i];
        for(j=i;j<m;j++){
            if(t[j]>p){
                p=t[j];
                t[j]=t[i];
                t[i]=p;
            }
        }
    }
    
    if(n<m) q=n;
    else    q=m;
    for(i=0;i<q;i++){
        if(s[i]<t[i]){
            printf("Yes\n");
            return 0;
        }
        else if(s[i]>t[i]){
            printf("No\n");
            return 0;
        }
    }
    if(n<m) printf("Yes\n");
    else    printf("No\n");
    return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 100000;
constexpr int mod = 1000000007;
LL S[maxn + 1], A, B;
int DPA[maxn + 1], DPB[maxn + 1];
int TA[maxn + 1], TB[maxn + 1];
void add(int& x, int y){
    x += y;
    if(x >= mod) x -= mod;
}
int sub(int x){
    return x ? mod - x : 0;
}
void add(int* T, int N, int p, int x){
    for(p += 1; p <= N + 1; p += p & -p) add(T[p - 1], x);
}
int sum(int* T, int p){
    int res = 0;
    for(p += 1; p; p -= p & -p) add(res, T[p - 1]);
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N >> A >> B;
    for(int i = 1; i <= N; i += 1) cin >> S[i];
    DPA[0] = 1;
    add(TA, N, 0, 1);
    S[0] = -1E18;
    int QA = 0, QB = 0;
    for(int i = 1; i <= N; i += 1){
        int DPY = sum(TA, upper_bound(S, S + i, S[i] - B) - S - 1);
        int DPX = sum(TB, upper_bound(S, S + i, S[i] - A) - S - 1);
        add(DPA[i - 1], DPX);
        add(TA, N, i - 1, DPX);
        add(DPB[i - 1], DPY);
        add(TB, N, i - 1, DPY);
        if(S[i] - S[i - 1] < A)
            for(; QA + 1 < i; DPA[QA ++] = 0)
                add(TA, N, QA, sub(DPA[QA]));
        if(S[i] - S[i - 1] < B)
            for(; QB + 1 < i; DPB[QB ++] = 0)
                add(TB, N, QB, sub(DPB[QB]));
        //for(int j = 0; j < i; j += 1) cout << DPA[j] << " "; cout << "\n";
        //for(int j = 0; j < i; j += 1) cout << DPB[j] << " "; cout << "\n";
    }
    int ans = sum(TA, N);
    add(ans, sum(TB, N));
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int n, q; std::cin >> n >> q;
	std::vector<std::vector<int>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int a, b; std::cin >> a >> b;
		nodes[a - 1].push_back(b - 1);
		nodes[b - 1].push_back(a - 1);
	}
	std::vector<int> additional(n, 0);
	for (auto i = 0; i < q; ++i) {
		int p, x; std::cin >> p >> x;
		additional[p - 1] += x;
	}
	std::queue<int> queue; queue.push(0);
	std::vector<bool> is_visited(n, false);
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		is_visited[top] = true;
		for (const auto next : nodes[top]) if (!is_visited[next]) {
			additional[next] += additional[top];
			queue.push(next);
		}
	}
	for (auto i = 0; i < n; ++i) {
		if (i != 0) std::cout << ' ';
		std::cout << additional[i];
	}
	std::cout << std::endl;
}

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

int main(){
 
  long long Y,ans;
  ans=0;
 cin>>Y;
  vector<int>a(Y);

for(int i=0;i<Y;i++){
cin>>a[i];
  if(i!=0){
  if(a[i]==a[i-1]){
    a[i]=0;
    ans++;
  }
  }
}
  cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ans = -1
    for i in range(1, 1000000):
        tax_A = int(i * 108 / 100 - i)
        tax_B = int(i * 110 / 100 - i)
        if tax_A == A and tax_B == B:
            ans = i
            break
        else:
            continue
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int hina;
		int han = 0;
		while(han == 0){
			if(x == 0 && y == 0){
				han = 1;
				break;
			} else if(x > y){
				hina = x;
				x  =   y;
				y = hina;
			}
		    System.out.println(x + " " + y);
			x = scan.nextInt();
			y = scan.nextInt();
		}
	}
}



Measured memory_bytes: 35428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
//		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);

		int[][] matrix = new int[n][m];
		int[] vector = new int[m];

		//String[] tmpArray = br.readLine().split(" ");
		//int[] input = new int[n];
		for(int i = 0; i < n; i++){
			tmpArray = br.readLine().split(" ");
//			int b = Integer.parseInt(tmpArray[0])-1;
//			int f = Integer.parseInt(tmpArray[1])-1;
//			int r = Integer.parseInt(tmpArray[2])-1;
//			int v = Integer.parseInt(tmpArray[3]);

			for(int j = 0; j < m; j++){
				matrix[i][j] = Integer.parseInt(tmpArray[j]);
			}
		}
		for(int i = 0; i < m; i++){
			vector[i] = Integer.parseInt(br.readLine());
		}
		
		for(int i = 0; i < n ; i++){
			int sum = 0;
			for(int j = 0; j < m; j++){
				//System.out.printf("%d %d\n", matrix[i][j] , vector[j]);
				sum += matrix[i][j]*vector[j];
			}
			
			System.out.println(sum);
		}
			
//		System.out.print(input[0]);
//		for(int i = 1 ; i < n; i++){
//			System.out.print(" "+ input[i]);
//		}
//		System.out.println();
////		
//		Arrays.sort(input);
//		System.out.printf("%d %d %d\n", input[0], input[input.length - 1], sum);
//		
//		while(true){
//			String[] tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[1]);
//			if(a == 0 && b == 0){
//				break;
//			}
//			
//			for(int i = 0; i < a; i++){
//				for(int j = 0; j < b; j++){
//					if((i + j)%2 == 1){
//						System.out.print(".");
//					}
//					else{
//						System.out.print("#");
//					}
//				}
//				System.out.println();
//			}
//			System.out.println();
//		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 27396
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan=new Scanner(System.in);
		int num=scan.nextInt();
		int[] r=new int[num];


		for (int i=0;i<=num-1;i++ ) {
			r[i]=scan.nextInt();
		}

		int min=r[0];
		int temp=r[1]-r[0];

		for(int i=1;i<=num-1;i++){
				if(temp<(r[i]-min))temp=r[i]-min;
				if(min>r[i])min=r[i];
		}

		System.out.println(temp);
		
	}
}



Measured memory_bytes: 102064
def gcd(a, b)
  a, b = b, a if a > b
  while b % a != 0
    d = a
    a = b % a
    b = d
  end
  a
end

def lcm(a, b)
  a * b / gcd(a, b)
end

_n = gets.chomp.to_i
ns = gets.chomp.split.map(&:to_i)

m = ns.inject do |a, b|
  lcm(a, b)
end
m -= 1

sum = ns.inject(0) do |sum, n|
  sum + m % n  
end

p sum

Measured memory_bytes: 11644
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;

const int N = 1e5 + 123;
const ll mod = 1e9 + 7;             

int n;
vector<int> g[N];
ll dp[2][N];    

void dfs(int v, int pr=-1){
	dp[1][v] = 1, dp[0][v] = 1;
	for(int u: g[v]){
		if(pr != u){
			dfs(u, v);
		}
	}

	for(int u: g[v]){
		if(u == pr)
			continue;
		dp[1][v] = (dp[1][v] * dp[0][u]) % mod;
		dp[0][v] = (dp[0][v] * ((dp[0][u] + dp[1][u]) % mod)) % mod;
	}
}

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

	cin >> n;
	for(int i = 1;i < n;i++){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);	
	}
	dfs(1);
	cout << (dp[1][1] + dp[0][1]) % mod;
}

Measured memory_bytes: 14208
using System;

namespace _0008 {

	public static class Program {

		public static void Main() {
			string input;
			while (!string.IsNullOrEmpty(input = Console.ReadLine())) {
				var x = int.Parse(input);
				var count = 0;

				for (int i = 0; i < 10; i++) {
					for (int j = 0; j < 10; j++) {
						for (int k = 0; k < 10; k++) {
							for (int l = 0; l < 10; l++) {
								if (i + j + k + l == x) {
									count++;
								}
							}
						}
					}
				}

				Console.WriteLine(count);
			}
		}

	}

}

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[i-1]) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 512
S=input()
a=0
if S[0]==S[1]:
    if S[2]==S[3]:
        if S[0]!=S[2]:
            print("Yes")
            a=1
if S[0]==S[2]:
    if S[1]==S[3]:
        if S[0]!=S[1]:
            print("Yes")
            a=1
if S[0]==S[3]:
    if S[1]==S[2]:
        if S[0]!=S[1]:
            print("Yes")
            a=1
if a==0:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b,c;
    cin>>k>>n>>m;
    rep(i,n,m+1)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define GRAYCODE(i) (i ^ (i >> 1))

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    int a, b; cin >> a >> b;
    string ans;
    if(0 < a) ans = "Positive";
    else if(b < 0){
        if((b-a) % 2) ans = "Positive";
        else ans = "Negative";
    }
    else ans = "Zero";
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n, d, x, a, cnt = 0;
    cin >> n >> d >> x;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        for (int j = 1; j <= d; j += a)
            cnt++;
    }

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import deque

################ DANGER ################
test = ""
#test = \
"""
9 6 1
1 2
2 3
3 4
4 5
5 6
4 7
7 8
8 9
ans 5
"""

"""
5 4 1
1 2
2 3
3 4
3 5
ans 2
"""

"""
5 4 5
1 2
1 3
1 4
1 5
ans 1
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
        
n, taka, aoki = map(int, input2().split())

edges = [0] * (n-1)
for i in range(n-1):
    edges[i] = tuple(map(int, input2().split()))

adjacencyL = [[] for i in range(n+1)]
for edge in edges:
    adjacencyL[edge[0]].append(edge[1])
    adjacencyL[edge[1]].append(edge[0])    

################ DANGER ################
#print("taka", taka, "aoki", aoki)
#import matplotlib.pyplot as plt
#import networkx as nx
#G = nx.DiGraph()
#G.add_edges_from(edges)
#nx.draw_networkx(G)
#plt.show()
########################################

takaL = [None] * (n+1)
aokiL = [None] * (n+1)
takaL[taka] = 0
aokiL[aoki] = 0
takaQ = deque([taka])
aokiQ = deque([aoki])

for L, Q in ((takaL, takaQ), (aokiL, aokiQ)):
    while Q:
        popN = Q.popleft()
        for a in adjacencyL[popN]:
            if L[a] == None:
                Q.append(a)
                L[a] = L[popN] + 1
                
    #print(L)
    
print(max(aokiL[i] for i in range(1, n+1) if takaL[i] < aokiL[i]) - 1)


Measured memory_bytes: 36504
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(1024, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 1023; count = 0;
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (~map[temp].first) {
			if (map[temp].first == suf) {
				return map[temp].second;
			}
			temp = mask&(temp + 1);
		}
		std::cerr << "?????¨????????????????????§????????????\n";
		std::abort();
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map;
	uint32 n;
	std::cin >> n;
	int64 a,sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans,i+1-map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15296
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int



int main()
{
   int N ;
   scanf("%d",&N);
   int array[N];

   int count = 0;


   for (int j = 0;j<N;j++)
   {
       scanf("%d",&array[j]);
   }
     int max = 0;
   int i = 0;
   while (i<N-1)
   {
       if (array[i]>=array[i+1])
       {
         count++;
         if (max<count)max=count;
         i++;
       }
       else if (array[i]<=array[i+1])
       {
          count = 0;
          i++;
       }
   }

   printf("%d",max);

   return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
int lcm(int a, int b) {
	return gcd(a, b) * a * b;
}

//degree → radian
int chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
int chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int a, b, n;



int main() {
	
	cin >> a >> b;
	n = a + b;
	if (n == 3)  cout << 3 << endl;
	else if (n == 4) cout << 2 << endl;
	else cout << 1 << endl;
		


	return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;
const LL MOD = 1e9 + 7;


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    LL ans = 1;
    LL cnt = 0;
    rep(i, 2 * n) {
        if (s[i] == 'B') {
            if (cnt % 2 == 1) {
                ans = ans * (cnt--) % MOD;
            } else {
                cnt++;
                ans *= cnt <= n;
            }
        } else {
            if (cnt % 2 == 1) {
                cnt++;
                ans *= cnt <= n;
            } else {
                ans = ans * (cnt--) % MOD;
            }
        }
    }
    if (cnt != 0) {
        ans = 0;
    }
    loop(i, 1, n + 1) {
        ans = ans * i % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 832
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

from collections import deque

def bfs(graph, queue, dist, prev):
    while queue:
        current = queue.popleft()

        for n in graph[current]:
            if dist[n] != -1:
                continue
            else:
                dist[n] = dist[current] + 1
                prev[n] = current
                queue.append(n)

queue = deque([1])
dist = [0] + [-1] * n
prev = [0] + [-1] * n
dist[1] = 0
prev[1] = 0
bfs(graph, queue, dist, prev)
if -1 in prev:
    print('No')
else:
    print('Yes')
    for n in prev[2:]:
        print(n)


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

double t_root(double q){
	double x = q / 2;
	while(max(x * x * x  - q,-(x * x * x - q)) >= 0.000001 * q){
		x = x - (x * x * x - q) / (3 * x * x);
	}
	return x;
}

int main(){
	double q;
	while(cin >> q){
		if(q == -1) break;
		cout << fixed << setprecision(6) <<  t_root(q) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def r(a, b, c, d, e, f):
    return a * (d-f) + c * (f-b) + e * (b-d) > 0
 
while True:
    try: line = list(map(float, input().split()))
    except: break
     
    x1, y1, x2, y2, x3, y3, xp, yp = line
    abc = r(x1, y1, x2, y2, x3, y3)
    pab = r(xp, yp, x1, y1, x2, y2)
    pbc = r(xp, yp, x2, y2, x3, y3)
    pca = r(xp, yp, x3, y3, x1, y1)
 
    print('YES' if abc == pab == pbc == pca else 'NO')


Measured memory_bytes: 5588
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0], 10);
  input.shift();
  var sum = 0;
  for (var i = 0; i < n; i++){
  	var x1 = Number(input[i].split(' ')[0]);
    var y1 = Number(input[i].split(' ')[1]);
    for (var j = 0; j < n; j++){
        if (i === j) {
        	continue;
        }
		var x2 = Number(input[j].split(' ')[0]);
      var y2 = Number(input[j].split(' ')[1]);
  		sum += Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    }
  }
  console.log(sum / n);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064