akhauriyash/Code-Regression huggingface dataset:
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String S = sc.next();
		int min = 1000;
		for(int i = 0; i + 2 <= S.length()-1; i++){
			int s = Integer.parseInt(S.substring(i, i+3));
			min = Math.min(min, Math.abs(s-753));
		}
		System.out.println(min);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if(A==1 || B==1) {
        if(A==1 && B!=1) {
            cout << "Alice" << endl;
        } else if(A!=1 && B==1) {
            cout << "Bob" << endl;
        } else {
            cout << "Draw" << endl;
        }
    } else {
        if(A>B) {
            cout << "Alice" << endl;
        } else if(A<B) {
            cout << "Bob" << endl;
        } else {
            cout << "Draw" << endl;
        }
    }



    return 0;
    
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn print_with_spaces(a: &Vec<usize>) {
    let n = a.len();
    for i in 0..n {
        if i >= 1 {
            print!(" ");
        }
        print!("{}", a[i]);
    }
    println!();
}

fn main() {
    let (n, m): (usize, usize) = read();
    let am: Vec<usize> = readnc();

    let mut odd: Vec<usize> = vec![];
    let mut even: Vec<usize> = vec![];
    for &ai in &am {
        if ai % 2 == 1 {
            odd.push(ai);
        } else {
            even.push(ai);
        }
    }

    if odd.len() >= 3 {
        println!("Impossible");
    } else {
        let mut a: Vec<usize> = vec![];
        let mut b: Vec<usize> = vec![];
        if odd.len() >= 1 {
            a.push(odd[0]);
        }
        for i in even {
            a.push(i);
        }
        if odd.len() == 2 {
            a.push(odd[1]);
        }

        if a.len() == 1 {
            if n == 1 {
                b.push(1);
            } else {
                b.push(a[0]-1);
                b.push(1);
            }
        } else {
            if a[0] >= 2 {
                b.push(a[0]-1);
            }
            for i in 1..a.len() {
                if i == a.len()-1 {
                    b.push(a[i]+1);
                } else {
                    b.push(a[i]);
                }
            }
        }

        print_with_spaces(&a);
        println!("{}", b.len());
        print_with_spaces(&b);
    }

}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
  int a=0,b=0,c=0,d=0;

 scanf("%d",&a);
 scanf("%d",&b);
 scanf("%d",&c);
 
 d=b/a;

 if(c < d) d=c;

 printf("%d",d);

return 0;
}


Measured memory_bytes: 128
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn prime_numbers(limit: u64) -> Vec<u64> {
    let mut is_candidate = vec![true; (limit + 1) as usize];
    let mut prime_numbers: Vec<u64> = Vec::new();
    for i in 2..(limit+1) {
        if is_candidate[i as usize] {
            prime_numbers.push(i);
            let mut j = 2;
            while i * j < limit + 1 {
                is_candidate[(i * j) as usize] = false;
                j += 1;
            }
        }
    }
    prime_numbers
}

fn main() {
    let n: usize = input();
    let prime_nums = prime_numbers(55555);
    let mut candidates: Vec<u64> = Vec::new();
    for i in prime_nums {
        if i % 5 == 1 {
            candidates.push(i);
        }
    }
    for i in 0..n {
        print!("{} ", candidates[i]);
    }

}


Measured memory_bytes: 2236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //dijkstra
  struct UndirectedGraph
{
    using Pint = pair<ll,ll>;
    using Plint = pair<ll,ll>;
    ll V;
    ll E;
    ll dDefault;
    vector<ll> weights;
    vector<vector<Pint>> to;
    vector<Pint> edges;
 
    UndirectedGraph(ll V, ll dDefault=-1) : V(V), E(0), dDefault(dDefault),
                             to(vector<vector<Pint>>(V)) {}
 
    void add_edge(ll v1,ll v2, ll w)
    {
        to[v1].push_back(Pint(v2, E));
        edges.push_back(Pint(v1, v2));
        weights.push_back(w);
        E++;
    }
 
    vector<ll> dist;
    void dijkstra(ll start)
    {
        dist = vector<ll>(V, dDefault);
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        pq.push(Plint(0, start));
 
        while (!pq.empty()) {
            Plint p = pq.top(); pq.pop();
            ll v = p.second;
            if (dist[v] >= 0 && dist[v] <= p.first) continue;
            dist[v] = p.first;
            for (auto vnxt : to[v]) {
                 ll dnxt = dist[v] + weights[vnxt.second];
                if (dnxt < dist[vnxt.first] || dist[vnxt.first] < 0) {
                    pq.push(Plint(dnxt, vnxt.first));
                }
            }
        }
    }
};

  ll i,n,q,k;cin>>n;ll a,b,c;
  UndirectedGraph graph(n);
  rep(i,n-1){cin>>a>>b>>c;a--;b--;graph.add_edge(a,b,c);graph.add_edge(b,a,c);}
  cin>>q>>k;ll x,y;k--;
  graph.dijkstra(k);
  rep(i,q){cin>>x>>y;x--;y--;cout<<graph.dist[x]+graph.dist[y]<<endl;}
  return 0;
}

Measured memory_bytes: 17884
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int seven = 0;
		int five = 0;
		int[] num = new int[3];
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < num.length; i++) {

			num[i] = scanner.nextInt();
		}
		for (int i = 0; i < 3; i++) {
			if (num[i] == 5) {
				five=five+1;
			}
			if (num[i] == 7) {
				seven=seven+1;
			}

		}

		if (five == 2 && seven == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

int main(){
    int D,G,p[11],c[11];
    cin>>D >>G;
    for(int i=0;i<D;i++)cin>>p[i] >>c[i];
    
    int ans = 1e9;
    for(int mask=0;mask<(1<<D);mask++){
        int sum=0,num=0,rest_max=-1;
        for(int i=0;i<D;i++){
            if(mask & (1<<i)){
                sum+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max = i;
            }
        }
        
        if(sum<G){
            int s1 = 100*(rest_max+1);
            int need = (G-sum+s1-1)/s1;
            if(need>=p[rest_max])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,ans=0;
vec A;
vec bubllesort(vec A){
    if(A.size()==1) return A;
    vec B(A.begin(),A.begin()+A.size()/2),C(A.begin()+A.size()/2,A.end()),res;
    B=bubllesort(B);
    C=bubllesort(C);
    int b=0,c=0;
    rep(i,A.size()){
        if(b<B.size()&&(c==C.size()||B[b]<C[c])) res.push_back(B[b]),b++;
        else res.push_back(C[c]),c++,ans+=B.size()-b;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    bubllesort(A);
    cout<<ans<<"\n";
}


Measured memory_bytes: 11004
// ABC141B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	bool ans = true;
	for (int i = 0; i < S.size(); i++)
	{
		if ((i % 2 == 0) && (S.at(i) == 'L'))
		{
			ans = false;
			break;
		}
		if ((i % 2 == 1) && (S.at(i) == 'R'))
		{
			ans = false;
			break;
		}
	}
	if (ans == true)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

using namespace std;

bool is_valid(const string &s, int l, int r){
  for(int i=l;i<r-1;i++){
    if(s[i] == '#' && s[i+1] == '#')
      return false;
  }
  return true;
}

bool is_otable(const string &s, int l, int r){
  for(int i=l;i<r-2;i++){
    bool ok = true;
    for(int j=0;j<3;j++){
      if(s[i+j] == '#')ok = false;
    }
    if(ok)return true;
  }
  return false;
}

int main(){
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  a--;b--;c--;d--;
  bool f = is_valid(s, a, max(c, d) + 1);
  bool g = c < d | is_otable(s, b - 1, min((int)s.length(), d + 2));
  if(f & g)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  cerr << f << " " << g << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for1l(n) for (ll i = 0 ; i < n ; i++)
#define for2l(n) for (ll j = 0 ; j < n ; j++)

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (n % k == 0) cout << 0;
    else cout << 1;
}

Measured memory_bytes: 3572
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define debug(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    File();
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0; i<3; i++)
        if(s[i] == 'R')
            cnt++;

    if(s[0] == 'R' and s[2] == 'R' and s[1] != 'R')
        cnt=1;
    cout<<cnt;
}


Measured memory_bytes: 3648
import queue
INF = float('inf')

def bfs():
    q = queue.Queue()
    [q.put([x, 0]) for x in graph[0]]
    while not q.empty():
        n = q.get()
        nex = n[0]; now = n[1]
        if visited[nex] == INF:
            visited[nex] = now
            [q.put([x, nex]) for x in graph[nex]]
    return

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    graph[A-1].append(B-1)
    graph[B-1].append(A-1)

visited = [INF for _ in range(N)]
bfs()

if INF in visited:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(visited[i]+1)

Measured memory_bytes: 150152
N = int(input())
S = input()

w, e = [0], [0]
for n in range(N):
	if "W" == S[n]:
		w += [w[-1] + 1]
	else:
		w += [w[-1]]
	if "E" == S[-n - 1]:
		e += [e[-1] + 1]
	else:
		e += [e[-1]]
w = w[:-1]
e = e[:-1][::-1]

#print(w)
#print(e)

min_dir = 10 ** 12
for n in range(N):
	min_dir = min(min_dir, abs(e[n] + w[n]))

print(min_dir)


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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> data = {a, b, c};
  
  sort (data.begin(), data.end());
  
  if (data[0] == data[1] && data[0] == data[2] && data[1] == data[2]) {
    if (data[0] % 2 == 0)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  }
  
  else {
    int count = 0;
    while (data[0] % 2 == 0 && data[1] % 2 == 0 && data[2] % 2 == 0) {
      int s = data[0]/2 + data[1]/2;
      int t = data[2]/2 + data[1]/2;
      int u = data[0]/2 + data[2]/2;
      data[0] = t;
      data[1] = u;
      data[2] = s;
      count++;
    }
    cout << count << endl;
  }
}

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

const int N = 2e5+5;
struct Job {int e,l;}J[N];
int n;

int main(){
	scanf("%d", &n);
	for(int i=0;i<n;++i){
		scanf("%d%d", &(J[i].l), &(J[i].e));
	}
	sort(J, J+n, [](const Job &a, const Job &b){return a.e!=b.e?a.e<b.e:a.l<b.l;});
	for(int i=0,t=0;i<n;++i){
		t += J[i].l;
		if(J[i].e < t){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
    return 0;
}


Measured memory_bytes: 1792
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
   ab <- getLine
   let c0 = words ab
   let c = read ((head c0) ++ (last c0)) :: Int
   
   let ans = [n |  n <- [1..317], n^2 == c]
   
   if ans == []
   then putStrLn "No"
   else putStrLn "Yes"
   

Measured memory_bytes: 508
#include <iostream>
#include <vector>

using namespace std;

int main () {
   int N,K,i,x=0;
   cin>>N>>K;
   vector<int> h(N);
   for(i=0;i<N;i++){
       cin>>h[i];
	   if(K<=h[i])
		   x++;
   }
   cout<<x;
   return 0;}


Measured memory_bytes: 640
from collections import deque

H, W = map(int, input().split())
S = [input() for i in range(H)]
g = 0
q = deque()
q.append((0, 0))
dist = [[0 for j in range(W)] for i in range(H)]
dr = [(1,0),(-1,0),(0,1),(0,-1)]

while len(q):
    r = q.popleft()
    x = r[1]
    y = r[0]
    now = dist[y][x]
    if y == H-1 and x == W-1:
        g = 1
        break
    for d in range(4):
        nx = x + dr[d][0]
        ny = y + dr[d][1]
        if 0 <= nx < W and 0 <= ny < H:
            if S[ny][nx] != "#" and dist[ny][nx] == 0:
                dist[ny][nx] = now+1
                q.append((ny,nx))

sharp = sum([i.count("#") for i in S])
if  g == 1:
  print(H * W - now - sharp - 1)
else:
  print(-1)

Measured memory_bytes: 40432
#include<iostream>
using namespace std;
int main(){
  int h,w;
  int dy[8]={-1,-1,-1,0,1,1,1,0};
  int dx[8]={-1,0,1,1,1,0,-1,-1};
  char maps[100][100];
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(maps[i][j]!='#'){
	int cnt=0;
	for(int k=0;k<8;k++){
	  int ny=i+dy[k];
	  int nx=j+dx[k];
	  if(ny>=0&&ny<h&&nx>=0&&nx<w&&maps[ny][nx]=='#'){
	    cnt++;
	  }
	}
	maps[i][j]='0'+cnt;
      }
      cout<<maps[i][j];
    }
    cout<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k, ans, i, j, m, x, id;
	string s;
	cin >> n >> k >> s;
	vector<int> v;
	if (s[0] == '0') v.push_back(0);
	for (i = 0; i < n; i++) {
		for (j = i; (j < n) && (s[j] == s[i]); j++);
		v.push_back(j - i);
		i = j - 1;
	}

	m = v.size();
	vector<int> sum(m + 1);
	sum[0] = 0;
	for (i = 1; i <= m; i++) sum[i] = sum[i - 1] + v[i - 1];

	ans = 0;
	for (i = 1; i <= m; i += 2) {
		id = min(m, i + k * 2);
		x = sum[id] - sum[i - 1];
		ans = max(ans, x);
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 1272
#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n;
  cin >>n ;
  ll sum=0;

  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5 !=0){
      sum+= i;
    }
  }

  cout <<sum ;
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

string ABCD;
string op;

bool dfs(int sum, string cop) {
    if (cop.length() == 3) {
        op = cop;
        return sum == 7;
    }

    if (dfs(sum+(ABCD[cop.length()+1] - '0'), cop+"+")) return true;
    if (dfs(sum-(ABCD[cop.length()+1] - '0'), cop+"-")) return true;

    return false;
}

int main() {
    cin >> ABCD;

    int j=0;
    int k=0;
    if (dfs(ABCD[0]-'0', "")) {
        REP(i, 7) {
            if (i%2==0) {
                cout << ABCD[j];
                j++;
            }
            else {
                cout << op[k];
                k++;
            }
        }
        cout << "=7" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool ok = false;
  for (int i = a; i <= b * a; i++) {
    if (i % a == 0 && i % b == c) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
        ll x,y;
        cin>>x>>y;
        ll z=x*x+y*y;
        if(z<=d*d)
            ++ans;
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  const long long mod = 1e9 + 7;
  int n;
  cin >> n;
  long long a[1001] = {};
  for (int i = 2; i <= n; i++) {
    int x = i;
    for (int j = 2; j * j <= x; j++) {
      int cnt = 0;
      while (x % j == 0) {
        cnt++;
        x /= j;
      }
      a[j] += cnt;
    }
    if (x > 1) a[x]++;
  }
  long long ans = 1;
  for (int i = 0; i < 1001; i++) {
    ans *= (a[i] + 1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main(){

    int n, a, b; cin >> n >> a >> b;
    cout << min(a, b) << " " << -min(0LL, n - (a + b)) << endl;
    return 0;
}

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

typedef struct{
  int n;
  int list[101];
}Data;

int N,cnt,criminal;
Data data[101],leak_data;

void search(){

  int cnt2;
  
  for(int i=1 ; i <= N ; i++){
    cnt2=0;
    for(int j=1 ; j <= leak_data.n ; j++){
      for(int k=1 ; k <= data[i].n ; k++){
	if(leak_data.list[j] == data[i].list[k])cnt2++;
      }
    }
    if(cnt2 == leak_data.n){
      criminal=i;
      cnt++;
    }
  }
  
}
int main(){
  
  while(1){
    
    cin >>N;
    if(N == 0)break;

    cnt=0;
    
    for(int i=1 ; i <= N ; i++){
      cin >>data[i].n;
      for(int j=1 ; j <= data[i].n ; j++){
	cin >>data[i].list[j];
      }
    }
    
    cin >>leak_data.n;
    for(int i=1 ; i <= leak_data.n ; i++){
      cin >>leak_data.list[i];
    }
    
    search();
    
    if(cnt != 1){
      cout <<"-1"<<endl;
    }else{
      cout <<criminal<<endl;
    }
    
  }
  
  return 0;
}

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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

const int N = 1e5;
PII C[N + 1];

int main()
{       
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; ++i)
        scanf("%d %d", &C[i].st, &C[i].nd);

    sort(C, C + m);

    priority_queue < int > Q;
    int result = 0;

    for (int i = 0; i < m; ++i)
    {
        int x = C[i].st;

        if (!Q.empty() && -Q.top() <= x)
        {
            ++result;
            while (!Q.empty())
                Q.pop();
        }

        Q.push(-C[i].nd);
    }

    if (!Q.empty())
        ++result;

    printf("%d", result);
    
    return 0;
}

Measured memory_bytes: 1408
INF = 10e9

def frog(arr, n):
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in (i+1, i+2):
            if j < n:
                dp[j] = min(dp[j], dp[i] + abs(arr[i]-arr[j]))
    return(dp[-1])


if __name__ == '__main__':

    n = int(input())
    arr = [int(x) for x in input().split()]
    print(frog(arr, n))


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int INF = 1e9 + 5;

void min_self(int& a, int b) {
	a = min(a, b);
}

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	for(int row = 0; row < H; ++row) {
		cin >> grid[row];
	}
	vector<vector<int>> dp(H, vector<int>(W, INF));
	// minimal number of operations
	dp[0][0] = (grid[0][0] == '#');
	for(int row = 0; row < H; ++row) {
		for(int col = 0; col < W; ++col) {
			if(row == 0 && col == 0) {
				continue;
			}
			if(row != 0) {
				min_self(dp[row][col], dp[row-1][col] + (grid[row][col] == '#' && grid[row-1][col] == '.'));
			}
			if(col != 0) {
				min_self(dp[row][col], dp[row][col-1] + (grid[row][col] == '#' && grid[row][col-1] == '.'));
			}
		}
	}
	int answer = dp[H-1][W-1];
	cout << answer << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  while(true)
  {
    cin >> a >> b;
    if(a==0&&b==0) return 0;
    while(a--)
    {
      int r = b;
      while(r--)
        cout << "#";
      cout << "\n";
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3028
#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() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e17;
ll mod = 1000000007;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  ll arr[n + 5], arr2[n + 5];
  for (ll i = 1; i <= n + 1; i++)
    cin >> arr[i];
  for (ll i = 1; i <= n; i++)
    cin >> arr2[i];

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    if (arr2[i] <= arr[i]) {
      res += arr2[i];
      arr[i] -= arr2[i];
    } else {
      res += arr[i];
      arr2[i] -= arr[i];
      res += min(arr2[i], arr[i + 1]);
      arr[i + 1] -= min(arr[i + 1], arr2[i]);
    }
  }

  cout << res << en;

  return 0;
}


Measured memory_bytes: 1792
// Last Change: 04/12/2020 21:40:12.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const size_t R = 0;
const size_t G = 1;
const size_t B = 2;

int main() {
  ll N;
  string S;
  cin >> N;
  cin >> S;

  // R, G, B
  vector<array<ll, 3>> imo(N);
  array<ll, 3> temp{0, 0, 0};
  for (ll i = N - 1; i >= 0; --i) {
    if (S[i] == 'R') {
      ++temp[R];
    } else if (S[i] == 'G') {
      ++temp[G];
    } else {
      ++temp[B];
    }
    imo.at(i) = temp;
  }

  /*
  for (auto &&e : imo) {
    for (auto &&f : e) {
      cout << f << " ";
    }
    cout << endl;
  }
  */

  ll res = 0;
  for (ll i = 0; i < N - 2; ++i) {
    for (ll j = i + 1; j < N - 1; ++j) {
      if (S[i] == S[j])
        continue;

      size_t c = 3;
      if (S[i] == 'R' or S[j] == 'R') {
        c -= R;
      }
      if (S[i] == 'G' or S[j] == 'G') {
        c -= G;
      }
      if (S[i] == 'B' or S[j] == 'B') {
        c -= B;
      }

      ll temp = imo[j + 1][c];
      ll kd = 2 * j - i;
      if (kd < N && !(S[kd] == S[i] or S[kd] == S[j])) {
        temp -= 1;
      }

      res += temp;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

ll N, U, V;
vector<vector<ll>> G;
vector<bool> visited;

vector<ll> TtoA;

void dfs1(ll v, ll l)
{
  if (visited.at(v))
    return;
  visited.at(v) = true;

  TtoA.at(v) = l;

  for (auto nv : G.at(v))
  {
    dfs1(nv, l + 1);
  }
}

/*
vector<bool> del;

void dfs1_5(ll v, ll fv)
{
  if (visited.at(v))
    return;
  visited.at(v) = true;

  if (fv != -1)
  {
    if (TtoA.at(v) > TtoA.at(fv))
      del.at(v) = true;
  }

  for (auto nv : G.at(v))
  {
    dfs1_5(nv, v);
  }
}
*/

ll ans = -INF;
void dfs2(ll v, ll l)
{
  if (TtoA.at(v) * 2 <= TtoA.at(U))
    return;
  
  if (visited.at(v))
    return;
  visited.at(v) = true;

  //cerr << v << " " << l << endl;

  chmax(ans, TtoA.at(v) - 1);

  for (auto nv : G.at(v))
  {
    dfs2(nv, l + 1);
  }
}

int main()
{
  cin >> N >> U >> V;
  U--, V--;
  G.resize(N);
  for (ll i = 0; i < N - 1; i++)
  {
    ll A, B;
    cin >> A >> B;
    A--, B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }

  visited = vector<bool>(N, false);
  TtoA = vector<ll>(N, 0);
  dfs1(V, 0);

  /*
  for (ll i = 0; i < N; i++)
  {
    cerr << TtoA.at(i) << endl;
  }
  */

  /*
  del = vector<bool>(N, false);
  visited = vector<bool>(N, false);
  dfs1_5(U, -1);
  */

  visited = vector<bool>(N, false);
  dfs2(U, 0);

  cout << ans << endl;
}

Measured memory_bytes: 9216
n=int(input())

dp=[[0 for _ in range(3)] for _ in range(n+1)]

for i in range(3):
  dp[0][i]=0
  
a=[]


  
for _ in range(n):
  d=list(map(int,input().split()))
  a.append(d)
  
for x in range(n):
  for y in range(3):
    for z in range(3):
      if y!=z:
        dp[x+1][z]=max(dp[x+1][z],dp[x][y]+a[x][z])
        
print(max(dp[n][0],dp[n][1],dp[n][2]))

Measured memory_bytes: 50096
# coding: utf-8
# Your code here!

while True:
   min = 1000
   max = 0
   sum = 0
   
   n = int(input())
   if n == 0:
      break
   for i in range(n):
      s = int(input())
      if s < min:
         min = s
      if s > max:
         max = s
      sum += s
   print((sum - min - max) // (n - 2) )
      



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+')
    cout << a+b << endl;
  else
    cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(map(int,input().split()))

i = bisect.bisect_left(A, 0)
j = bisect.bisect_right(A, 0)
if i == j:
    if i == 0:
        negatives = A[:1]
        positives = A[1:]
    elif i == N:
        negatives = A[:-1]
        positives = A[-1:]
    else:
        negatives = A[:i]
        positives = A[i:]

else:
    m = max((i+j)//2, 1)
    negatives = A[:m]
    positives = A[m:]


score = sum(positives) - sum(negatives)
print(score)

def it():

    def balanced(pos, neg):
        y = neg.pop()
        x = pos.pop()
        yield (x,y)
        y = x-y
        while pos and neg:
            x = neg.pop()
            yield (x,y)
            y = x-y
            x = pos.pop()
            yield (x,y)
            y = x-y

    if len(positives) < len(negatives):

        x = positives.pop()

        while len(positives)+1 < len(negatives):
            y = negatives.pop()
            yield (x,y)
            x -= y
        positives.append(x)
    elif len(positives) > len(negatives):
        x = negatives.pop()

        while len(negatives)+1 < len(positives):
            y = positives.pop()
            yield (x,y)
            x -= y
        negatives.append(x)

    for x,y in balanced(positives, negatives):
        yield x,y


for x,y in it():
    print(x,y)












Measured memory_bytes: 14484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    int n;
    std::string s;
    std::cin >> n;
    std::cin >> s;
    int ng0 = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'E') {
            ng0++;
        }
    }

    std::vector<int> ng;
    ng.push_back(ng0);
    for (int i = 1; i < n; i++) {
        ng.push_back(ng[i - 1] - (s[i] == 'E') + (s[i - 1] == 'W'));
    }
    std::cout << *std::min_element(ng.begin(), ng.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 3836
main = getContents >>= mapM_ (print . length . solve . read) . lines

-- pretty brainless
solve :: Int -> [(Int,Int,Int)]
solve n = [(i,j,k) | i <- [0..9], j <- [0..9], k <- [0..9],
                        let l = n - i - j - k, 0 <= l && l <= 9]

Measured memory_bytes: 4172
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define S_LENGTH (10 + 1)
#define ATOI '0'

int main(void)
{
    long N;
    int  SN;
    char str[S_LENGTH];
    char input[S_LENGTH];
    
    fgets(str, S_LENGTH, stdin);
    sscanf(str, "%s", input);
    
    N = atoi(input);
    for(int i=0; i < strlen(input); i++){
      SN += input[i] - ATOI;
    }
    
    if( (N % SN) == 0 ){
       printf("Yes");
    }else{
       printf("No");
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n;
    cin >> n;
    vector <ll> v;
    ll cntP = 0;
    ll cntN = 0;
    ll ans = 0;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        v.push_back(tmp);
        ans += abs(tmp);
        if(tmp > 0)cntP++;
        if(tmp < 0)cntN++;
    }
    sort(v.begin(), v.end());
    if(cntN == 0){
        ans -= 2*v[0];
    }else if(cntP == 0){
        ans += 2*v[n-1];
    }
    cout << ans << endl;
    ll t = v[0];
    for (ll i=n-2;i>0;i--){
        if(v[i] >= 0){
            cout << t << " " << v[i] << endl;
            t = t - v[i];
        }else{
            break;
        }
    }
    cout << v[n-1] << " " << t << endl;
    t = v[n-1] - t;
    for (ll i=1;i<n-1;i++){
        if(v[i] < 0) {
            cout << t << " " << v[i] << endl;
            t = t - v[i];
        }
    }
}

Measured memory_bytes: 2804
#include <iostream>
using namespace std;
int main(){
	
	int A,B,C,D;
	cin >> A >> B >> C >> D;

	int L=A+B;
	int R=C+D;
	if(L > R){
		cout<<"Left";
		}
		
	if(L == R){
		cout<<"Balanced";
		}
	if(L < R){

	cout<<"Right";	
		}	
			return 0;
			}		
	
	
 	
	


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
	int w, a, b; cin >> w >> a >> b;
	if (a>b)
		swap(a, b);
	if (b - (a + w)>0)
		cout << b - (a + w);
	else
		cout << "0\n";
	
}

Measured memory_bytes: 3164
#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 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; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int x;
    cin >> x;
    if (x >= 30) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string S;
  bool flag=false;
  for(int i=0;i<n;i++)
  {
    cin >> S;
    if(S=="Y") 
    {
      flag=true;
      break;
    }
  }
  if(flag==true) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long[] H = new long[N];
            for (int i = 0; i < N; i++) {
                H[i] = sc.nextLong();
            }

            int ans = 0;

            int count = 0;
            for (int i = 0; i < N - 1; i++) {
                if (H[i] >= H[i + 1]) {
                    count++;
                    if (ans < count) {
                        ans = count;
                    }
                } else {
                    count = 0;
                }
            }

            System.out.println(ans);
        }
    }

}


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

map<pair<string, string>, ll> m;

vector<pair<string, string>> f(const string& s) {
	vector<pair<string, string>> res;
	int N = s.size();
	for (int i = 0; i < (1 << N); i++) {
		string l, r;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) l += s[j];
			else r += s[j];
		}
		res.emplace_back(l, r);
	}
	return res;
}

int main() {
	int N; cin >> N;
	string s; cin >> s;
	string l = s.substr(0, N);
	string r = s.substr(N, N);
	reverse(r.begin(), r.end());
	for (auto& x : f(l)) {
		m[x]++;
	}
	ll res = 0;
	for (auto& x : f(r)) {
		res += m[x];
	}
	cout << res << endl;
}

Measured memory_bytes: 95976
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, d;
    cin >> n >> m >> d;
    double ans = (d == 0 ? 1. : 2.) * (n - d) / (n * n) * (m - 1);
    cout << fixed << setprecision(15) << ans << '\n';
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String line = "";
      List<String> list = new ArrayList<>();
      String[] lines;
      double a,b,c,d,e,f;
      double x,y;

      while( (line = br.readLine()) != null && !(line.isEmpty()) ) {
        list.add(line);
      }

      for(String l:list) {

        lines = l.split(" ");
        a = Integer.parseInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        c = Integer.parseInt(lines[2]);
        d = Integer.parseInt(lines[3]);
        e = Integer.parseInt(lines[4]);
        f = Integer.parseInt(lines[5]);

        y = (f-(d*c/a)) / (e-(d*b/a));
        if(y == -0) y = 0;
        x = (f-(e*c/b)) / (d-(a*e/b));
        if(x == -0) x = 0;

        System.out.printf("%.3f %.3f\n", x,y);

      }
    }
  }
}


Measured memory_bytes: 24496
def main():
    n=int(input())
    h=list(map(int,input().split()))
    count = 0
    while max(h) > 0:
        m = 101
        i = 0
        while h[i] == 0:
            i += 1
        j = i
        while i < n:
            if j == n or h[j] == 0:
                count += m
                for x in range(i,j):
                    h[x] -= m
                i = j
                break
            elif h[j] != 0:
                m = min(m, h[j])
            j += 1
    print(count)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9060
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <sys/time.h>
#include <iostream>
using namespace std;

// bool is_anagram4(string const & s1, string const & s2)
// {
//     // if (s1.length() != s2.length()) return false;

//     int count[26] = {0};
//     for (int i=0; i<s1.length(); ++i)
//     {
//         count[s1[i]-'a']++;
//         count[s2[i]-'a']--;
//     }
//     for (int i=0; i<26; ++i)
//     {
//         if (count[i] != 0) return false;
//     }
//     return true;
// }

int main(){
  long long count = 0;
  vector<string> hoge;
  vector<long long> result;
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++){
    cin >> s;
    sort(s.begin(), s.end());
    hoge.push_back(s);
  }

  // for (int i = 0; i < n - 1; i++){
  //   for (int v = i + 1; v < n; v++){
  //     if(is_anagram4(hoge[i], hoge[v]) == 1){
  //       count += 1;
  //     }
  //   }
  // }

  sort(hoge.begin(), hoge.end());
  
  // cout << count << endl;

  // for (int i = 0; i < n; i++){
  //   cout << hoge[i] << endl;
  // }
  int renzoku = 1;
  for (int i = 0; i < n - 1; i++){
    string a = hoge[i];
    string b = hoge[i + 1];
    if(i == n - 2){
      if(a == b){
        renzoku += 1;
      }
      result.push_back(renzoku);
    }else{
      if(a == b){
        renzoku += 1;
      }else{
        result.push_back(renzoku);
        renzoku = 1;
      }
    }
  }

  for (int i = 0; i < result.size(); i++){
    count += result[i]*(result[i] - 1)/2;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 7284
A, B, C = map(int, input().split())
M=max(A,B,C)
abc=sorted([M-A, M-B, M-C], reverse=True)[:2]
#print(abc)

if sum(abc)%2==0:
    print(sum(abc)//2)
else:
    print(sum(abc)//2+2)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> t(n),a(n);
	rep(i,n) cin >> t.at(i) >> a.at(i);
	ll T = 1, A = 1;
	rep(i,n){
		ll k = max((T + t.at(i) - 1) / t.at(i), (A + a.at(i) - 1) / a.at(i));
		T = k * t.at(i);
		A = k * a.at(i);
	}
	cout << A + T << endl;
}


Measured memory_bytes: 256
def dot(x, y):
  return sum([x[i]*y[i] for i in range(len(x))])

def Dot(A, b):
  return [dot(A[i], b) for i in range(len(A))]

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(n)]
print(len(list(filter(lambda x: x+c>0, Dot(A, b)))))

Measured memory_bytes: 3064