akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
#define lnt(s) (ll)s.length()
#define mt(cnt) cnt.empty()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;
using pl = pair<ll, pll>;
using tll = tuple<ll, ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b, k;
	cin >> a >> b >> k;
	cout << (a-k <= 0 ? 0 : a-k) << " " << (a-k < 0 ? (b-abs(a-k) < 0 ? 0 : b-abs(a-k)) : b);
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MOD = 1000000007;

int main() {
    long long N, K;
    cin >> N >> K;
    long long M = N+1, L = K-1;
    long long res = M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6;
    cout << res%MOD << endl;
}





// N-k+1, N











Measured memory_bytes: 3596
import sys
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし


L = LI2()
N = len(L)
mod = 10**9+7

a = 1
b = 0

for i in range(N):
    if L[i] == 1:
        b += pow(3,N-i-1,mod)*a
        b %= mod
        a *= 2
        a %= mod

print((a+b) % mod)


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

int main() {
	int n, i;
	long long a, max = -10000000, min = 10000000;
	long long sum=0;
	
	cin >> n ;
	
	for (i = 0; i < n; i++){
		cin >> a;
		if (a < min) min = a;
		if (a > max) max = a;
		sum = sum + a;
		
	}
	cout << min << " " << max << " " << sum << endl;

	
	
	return 0;
}

Measured memory_bytes: 3100
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace nik20102
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_nik20102A();
        }

        public static void solve_nik20102B()
        {

        }

        public static void solve_nik20102A()
        {
            int n = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(n % 2 == 0 ? n / 2 - 1 : n / 2);
        }
    }
}


Measured memory_bytes: 13268
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    string s,t,u; int a,b; cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;  

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main () {
	char ans[5];
	
	scanf ("%s",ans);
	
		if (!strcmp ("ARC", ans)) {
			printf ("ABC\n");
		}
		if (!strcmp ("ABC", ans)) {
			printf ("ARC\n");
		}
	
	return 0;
}

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

int main(void) {
    const string vowel = "aeiou";
    char c;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> c;
    cout << (vowel.find(c) != string::npos? "vowel" : "consonant") << "\n"; 
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    long long ans = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            ans += (long long) A[i] * A[j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

ll gcd(ll a, ll b)
{
    ll r;
    if (b>a) swap(a,b);
        if (a%b==0) return b;
        else
        {
            while (a%b!=0)
            {
                r=a%b;
                a=b;
                b=r;
            }
            return b;
        }
}

ll lcm(ll a,ll b)
{
    if (a>b) return a/gcd(a,b)*b;
    else return b/gcd(a,b)*a;
}

int main()
{
    int N,M; cin >> N >> M;
    vector<ll> a(N),two(N,0);
    ll l;
    for (int i=0;i<N;i++)
    {
        cin>>a[i];
        a[i]/=2;
    }
    l=a[0];
    ll ans=0;
    for (int i=1;i<N;i++) l=lcm(l,a[i]);
    for (int i=1;i*l<=M;i+=2) ans++;
    for (int i=0;i<N;i++)
    {
        while(a[i]%2==0)
        {
            a[i]/=2;
            two[i]++;
        }
    }

    for (int i=0;i<N-1;i++)
    {
        if (two[i]!=two[i+1]) ans=0;
    }

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

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int64_t Q=998244353;
  vector<vector<int64_t>> dp(C+1,vector<int64_t>(D+1));
  dp[A][B]=1;
  for(int i=A;i<C;i++){
    dp[i+1][B]=(dp[i][B]*B)%Q;
  }
  for(int i=B;i<D;i++){
    dp[A][i+1]=(dp[A][i]*A)%Q;
  }
  for(int i=A;i<C;i++){
    for(int j=B;j<D;j++){
      dp[i+1][j+1]=(dp[i][j+1]*(j+1)+dp[i+1][j]*(i+1)-dp[i][j]*i*j+Q*i*j)%Q;
    }
  }
  cout<<dp[C][D]<<endl;    
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,sum=0;
    cin >> n;
    vll l(n),r(n);
    rep(i,n){
        cin >> l[i] >> r[i];
        sum += (r[i]-l[i]+1);
    }
    cout << sum << endl; 
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type dice struct {
	sur [6]int8
}

func (d *dice) Scan() {
	for i := 0; i < 6; i++ {
		fmt.Scan(&d.sur[i])
	}
	return
}

func (d *dice) Move(dir rune) {
	nd := *d
	switch dir {
	case 'E':
		d.sur[0] = nd.sur[3]
		d.sur[2] = nd.sur[0]
		d.sur[3] = nd.sur[5]
		d.sur[5] = nd.sur[2]
	case 'N':
		d.sur[0] = nd.sur[1]
		d.sur[1] = nd.sur[5]
		d.sur[4] = nd.sur[0]
		d.sur[5] = nd.sur[4]
	case 'S':
		d.sur[0] = nd.sur[4]
		d.sur[1] = nd.sur[0]
		d.sur[4] = nd.sur[5]
		d.sur[5] = nd.sur[1]
	case 'W':
		d.sur[0] = nd.sur[2]
		d.sur[2] = nd.sur[5]
		d.sur[3] = nd.sur[0]
		d.sur[5] = nd.sur[3]
	}
	return
}

func (d *dice) Search(up, front, depth int8) *dice {
	if depth >= 4 {
		return nil
	}
	for i := 0; i < 4; i++ {
		nd := *d
		switch i {
		case 0:
			nd.Move('E')
		case 1:
			nd.Move('N')
		case 2:
			nd.Move('S')
		case 3:
			nd.Move('W')
		}
		if nd.sur[0] == up && nd.sur[1] == front {
			return &nd
		}
		if resd := nd.Search(up, front, depth+1); resd != nil {
			return resd
		}
	}
	return nil
}

func main() {
	var q, u, f int8
	d := &dice{[6]int8{1, 2, 3, 4, 5, 6}}
	d.Scan()
	fmt.Scan(&q)
	for i := int8(0); i < q; i++ {
		fmt.Scan(&u, &f)
		resd := d.Search(u, f, 0)
		fmt.Println(resd.sur[2])
	}
	return
}



Measured memory_bytes: 1120
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(0); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int stoi ( char c ) {return c-'0';}

int main()
{
	optimize();

	ll a;
	cin >> a;

	string s;
	cin >> s;

	ll b = stoi ( s[0] ) * 10;
	b += stoi ( s[2] );
	b *= 10;
	b += ( stoi ( s[3] ) );

	a *= b;
	a /= 100;
	cout << a << endl;


	return 0;
}

















Measured memory_bytes: 3660
#![allow(unused)]

use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};
use std::{cmp, collections, fmt, io, iter, ops, str};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt:expr) => {};
    ($fmt:expr, $($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let x = parse_line::<i32>();

    const MAX: i32 = 1000;

    let mut is_pow = vec![false; MAX as usize + 1];
    is_pow[1] = true;

    for b in 2..(MAX + 1) {
        for p in (2..).take_while(|p| b.pow(*p) <= MAX) {
            is_pow[b.pow(p) as usize] = true;
        }
    }

    let mut i = x as usize;
    while !is_pow[i] {
        i -= 1;
    }

    println!("{}", i);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = (x as f64).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<map>

#define ll long long

using namespace std;

int main(void) {
	int N;
	cin >> N;
	map<int, int> m;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		m[d]++;
	}
	int ans = 0;
	for (auto itr = m.begin(); itr != m.end(); itr++) ans++;
	cout << ans << endl;
	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	ll k;
	cin >> n >> k;
	vi a(n), f(n);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> f[i];
	sort(all(a));
	sort(all(f), greater<int>());

	ll l = -1, r = 1e12;

	while (r - l > 1) {
		ll c = (l + r) / 2;
		ll train = 0;
		rep(i, n)train += (max((ll)a[i] * f[i] - c, 0LL) + f[i] - 1) / f[i];
		if (train <= k)r = c;
		else l = c;
	}

	cout << r << endl;

}

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

int main() {
  string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  char c;
  cin >> c;
  bool upper = false;
  for (int i = 0; i < (int)ABC.size(); i++) {
    if(c==ABC[i]) upper = true;
  }

  if (upper) cout << "A";
  else cout << "a";
  return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		
		// 計算
		int result = 0;
		if(m1 != m2) result = 1;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

int H, W, K;
string c[10];

int main() {
  //
  cin >> H >> W >> K;
  rep(i, 0, H) { cin >> c[i]; }

  ll ans = 0;
  for (int i = 0; i < (1 << H); ++i) {
    for (int j = 0; j < (1 << W); ++j) {
      int cnt = 0;
      rep(h, 0, H) {
        rep(w, 0, W) {
          if (i & (1 << h)) {
            continue;
          }
          if (j & (1 << w)) {
            continue;
          }

          if (c[h][w] == '#') {
            cnt++;
          }
        }
      }

      if (cnt == K) {
        ++ans;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 3632
#14:42
n,k = map(int,input().split())
s = input()

rec = []
for i in range(n):
  if i == 0:
    last = s[0]
    combo = 1
  elif s[i] == last:
    combo += 1
  else:
    last = s[i]
    rec.append(combo)
    combo = 1
rec.append(combo)
if s[0] == '0':
  rec = [0] + rec
if s[-1] == '0':
  rec = rec + [0]
#print(rec)
rec = [0] * (2*n) + rec + [0] * (2*n)

for j in range(len(rec)):
  if j == 0:
    cum = [rec[0]]
  else:
    cum.append(cum[-1] + rec[j])
#print(cum)

can = []
st = 1
while True:
  try:
    can.append(cum[st+2*k+1]-cum[st])
    st += 2
  except:
    break
#print(can)
print(max(can))

Measured memory_bytes: 82852
n, k = map(int, input().split())
s = input()

L = 0
r = 0
# k + 1 回目の 0 エリアの直前まで r を進める
for _ in range(k):
    while r < len(s) and s[r] == '1':
        r += 1
    while r < len(s) and s[r] == '0':
        r += 1
while r < len(s) and s[r] == '1':
    r += 1

ans = r - L
# 1つずつエリアずらす
while True:
    while L < len(s) and s[L] == '1':
        L += 1
    while L < len(s) and s[L] == '0':
        L += 1
    while r < len(s) and s[r] == '0':
        r += 1
    while r < len(s) and s[r] == '1':
        r += 1
    ans = max(ans, r - L)
    if r >= len(s):
        break

print(ans)


Measured memory_bytes: 3316
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j;
	int N;
	int res = 0;
	string S;
	cin >> N;
	cin >> S;
	for (i = 0; i < N - 2; ++i) {
		if (S[i] == 'A'&&S[i + 1] == 'B'&&S[i + 2] == 'C') {
			++res;
		}
	}
	cout << res << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	ll n;
	cin >> n;
	ll ans = 0;
	ans += 1000 * (n / 500);
	n %= 500;
	ans += 5 * (n / 5);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    t = input()
    cnt1 = 0
    a = t.replace("?","D")
    cnt1 = a.count("D") + a.count("PD")
    b = t.replace("?","P")
    cnt2 = b.count("D") + b.count("PD")
    if cnt1>cnt2:
        print(a)
    else:
        print(b)

Measured memory_bytes: 9900
import java.io.*;
public class Main{
  public static void main(String[] args){
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	  int[] a = new int[4];
      String s = bf.readLine();
	  for(int i = 0; i < 4; i++)
        a[i] = charToInt(s, i);
      for(int i = 0; i < 8; i++){
        int ans = a[0];
      	for(int j = 0; j < 3; j++){
          int k = i>>j;
          if(k%2 == 1)
            ans += a[j+1];
          else
            ans -= a[j+1];
        }
        if(ans == 7){
          for(int j = 0; j < 3; j++){
            System.out.print(a[j]);
            System.out.print((i>>j)%2 == 1 ? "+" : "-");
          }
          System.out.println(a[3]+"=7");
          return;
        }
      }
    } catch(IOException e){}
  }
  public static int charToInt(String s, int k){
  	return Character.getNumericValue(s.charAt(k));
  }
}
    

Measured memory_bytes: 22612
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N, D = [int(x) for x in input().split()]
X = []
for _ in range(N):
    x = [int(x) for x in input().split()]
    X.append(x)

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        r = [(a - b) ** 2 for a, b in zip(X[i], X[j])]
        # print("i:{},j:{}, sqrt(r):{}".format(i, j, math.sqrt(sum(r))))
        r = math.sqrt(sum(r))
        if float.is_integer(r):
            cnt += 1

print(cnt)

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>
#include <numeric>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

  for(int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = a[i];
  }

  sort(b.begin(), b.end(), greater<int>());

  for(int i=0; i<n; ++i){
        if(a[i] != b[0]){
          cout << b[0] << endl;
        }
        else{
          cout << b[1] << endl; 
        }
  }
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void update(int n, int x,int y,int dp[], int map[]);

int main() {
    int n;
    cin >> n;
    int p[n*n];
    REP(i,n*n){
        cin >> p[i];
        p[i]--;
    }
    int dp[n*n];
    int map[n*n];
    REP(i,n*n){
        dp[i]= min(min((int)i/n,i%n ),min(n-(int)(i/n) -1,n-(i%n)-1));
        map[i]=1;
    }
    ll ans=0;
    REP(i,n*n){
        int x = p[i]/n;
        int y = p[i]%n;
        ans+=dp[p[i]];
        map[p[i]]=0;
        update(n,x,y,dp,map);
        //cout << dp[8]<< endl;
    }
    cout << ans << endl;
    return 0;
}

void update(int n, int x, int y, int dp[], int map[]){
    int mincost;
    if(x!=0&&x!=n-1&&y!=0&&y!=n-1){
        mincost = min(min(dp[x*n+y+n]+map[x*n+y+n], dp[x*n+y+1]+map[x*n+y+1]), min(dp[x*n+y-n]+map[x*n+y-n], dp[x*n+y-1]+map[x*n+y-1]));
    } else {
        mincost = 0;
    }
    dp[x*n+y]=mincost;

    if(x!=0&&dp[x*n+y-n]>dp[x*n+y]+map[x*n+y]){
        dp[x*n+y-n]=dp[x*n+y];
        update(n,x-1,y,dp,map);
    }
    if(x!=n-1&&dp[x*n+y+n]>dp[x*n+y]+map[x*n+y]){
        dp[x*n+y+n]=dp[x*n+y];
        update(n,x+1,y,dp,map);
    }
    if(y!=0&&dp[x*n+y-1]>dp[x*n+y]+map[x*n+y]){
        dp[x*n+y-1]=dp[x*n+y];
        update(n,x,y-1,dp,map);
    }
    if(x!=n-1&&dp[x*n+y+1]>dp[x*n+y]+map[x*n+y]){
        dp[x*n+y+1]=dp[x*n+y];
        update(n,x,y+1,dp,map);
    }
}

Measured memory_bytes: 40568
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut xs = vec![0; n];
    for i in 0..n {
        let sign = if i % 2 == 0 { 1 } else { -1 };
        xs[0] += a[i] * sign;
    }
    for i in 1..n {
        xs[i] = 2 * a[i - 1] - xs[i - 1];
    }
    println!(
        "{}",
        xs.iter()
            .map(|x| format!("{}", x))
            .collect::<Vec<_>>()
            .join(" ")
    );
    // x0 + x1 = 2*a0;
    // x1 + x2 = 2*a1;
    // x2 + x3 = 2*a2;
    // x3 + x4 = 2*a3;
    // x4 + x0 = 2*a4;
    //
    // x0 = 2*a0 - x1;
    // x1 = 2*a1 - x2;
    // x2 = 2*a2 - x3;
    // x3 = 2*a3 - x4;
    // x4 = 2*a4 - x0;
    //
    // x0 = 2*a0 - (2*a1 - x2);
    // x0 = 2*a0 - 2*a1 + x2;
    // x0 = 2*a0 - 2*a1 + 2*a2 - x3;
    // x0 = 2*a0 - 2*a1 + 2*a2 - 2*a3 + x4;
    // x0 = 2*a0 - 2*a1 + 2*a2 - 2*a3 + 2*a4 - x0;
    // x0 = a0 - a1 + a2 - a3 + a4;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, c, x, count = 0;
  cin >> a >> b >> c >> x;
  rep(i, a + 1) {
    rep(j, b + 1) {
      rep(k, c + 1) {
        if (500 * i + 100 * j + 50 * k == x) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	double a,b,c,d,e,f,x,y,s,t;
	int i;
	
	while(scanf(" %lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		s=b*d-a*e;
		t=c*d-a*f;
		y=t/s;
		x=(c-b*y)/a;
		
		s=x;
		i=s;
		s=s-(double)i;
		s*=1000;
		i=s;
		s=s-(double)i;
		if(s>=0.5)x+=0.001;
		
		s=y;
		i=s;
		s=s-(double)i;
		s*=1000;
		i=s;
		s=s-(double)i;
		if(s>=0.5)y+=0.001;
		
		printf("%.3lf %.3lf\n",x,y);
		
		
		
		
		
		
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
//#define ll long long
#define ll int
static const ll MOD = 1000000007;

using namespace std;



int main(){
    int N;
    cin >> N;

    int res = MOD;

    for(int i = 1; i <= N / 2 + 1; ++i)
    {
        int a = i;
        int b = N - i;

        int tmp = 0;
        while(a > 0)
        {
            tmp += a % 10;
            a /= 10;
        }
        while(b > 0)
        {
            tmp += b % 10;
            b /= 10;
        }

        res = min(res,tmp);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
def calc(i):
    sum_problems = 0
    for j in range(D):
        if i & (1 << j):
            sum_problems += p[j]
    num_problems[i] = sum_problems

nums=list(map(int,input().split()))
D = nums[0]
G = nums[1]
p = []
c = []

num_problems = [1000] * (1 << D)

for i in range(D):
    nums=list(map(int,input().split()))
    p.append(nums[0])
    c.append(nums[1])


for i in range(1 << D):
    sum_tmp = 0
    
    for j in range(D):
        if i & (1 << j):
            sum_tmp += p[j] * (j + 1) * 100 + c[j]
    
    if sum_tmp >= G:
        calc(i)
        
    else:
        j = D-1
        sum_res = 0
        while j > -1:
            if not (i & (1 << j)):
                for k in range(p[j]):
                    sum_tmp += 100 * (j + 1)
                    sum_res += 1
                    if sum_tmp >= G:
                        break
            j -= 1
            if sum_tmp >= G:
                calc(i)
                num_problems[i] += sum_res
                break
            
print(min(num_problems))






Measured memory_bytes: 43500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    rep(i, n) cin >> x[i] >> y[i] >> a[i];
    vector<vector<bool>> flag(h, vector<bool>(w, true));
    rep(i, n)
    {
        if (a[i] == 1)
            rep(j, h) rep(k, x[i]) flag[j][k] = false;
        if (a[i] == 2)
        {
            rep(j, h)
            {
                for (int k = x[i]; k < w; ++k)
                    flag[j][k] = false;
            }
        }
        if (a[i] == 3)
            rep(j, w) rep(k, y[i]) flag[k][j] = false;
        if (a[i] == 4)
        {
            rep(j, w)
            {
                for (int k = y[i]; k < h; ++k)
                    flag[k][j] = false;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) if (flag[h - 1 - i][j]) ans++;
    cout << ans << endl;
}
int main(void)
{
    solve();
}


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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long A,B;
    cin >> A >> B;
    
    long long C = GCD(A,B);
    
    const auto &res = prime_factorize(C);
    
    map<int,int> ans;
    //cout << C << ":";
    for (auto p : res) {
        for (int i = 0; i < p.second; ++i) {
            //cout << " " << p.first;
            ans[p.first] = 1;
        }
    }
    
    int num = 1;
    num = num + ans.size();
    cout << num << endl;

    return 0;
}


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

using namespace std;

int main(){
  string n[1000];
  int i = 0;
  string m;

  map<string, int> M;

  while(cin >> n[i]){
    M[n[i]] += 1;
    i++;
  }


  int max = M[n[0]];
  m = n[0];

  for(int j = 1; j < i; j++){
    if(max < M[n[j]]){
      max = M[n[j]];
      m = n[j];
    }
  }
  cout << m;
  
  max = 0;
  
  for(int j = 0; j < i; j++){
    if(n[j].length() > max){
      max = n[j].length();
      m = n[j];
    }
  }
  
  cout << " " << m << endl;
  return 0;

}
    

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	string s;
	cin>>s;
	int len=s.length();
	int ans=0;
	int so_far=0;

	for(int i=0;i<len;i++){
		if(s[i]=='R')so_far++;
		else so_far=0;
		ans=max(so_far,ans);
	}

	cout<<ans<<endl;

	return 0;
}
 

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

int main()
{
  ll N, C;
  cin >> N >> C;
  vector<vector<ll>> D(C, vector<ll>(C));
  for (ll i = 0; i < C; i++)
  {
    for (ll j = 0; j < C; j++)
    {
      cin >> D.at(i).at(j);
    }
  }

  vector<vector<ll>> X(C, vector<ll>(3, 0));
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < N; j++)
    {
      ll c;
      cin >> c;
      c--;
      X.at(c).at((i + j) % 3)++;
    }
  }

  ll ans = INF;
  for (ll i = 0; i < C; i++)
  {
    for (ll j = 0; j < C; j++)
    {
      if (i == j)
        continue;
      
      for (ll k = 0; k < C; k++)
      {
        if (i == k || j == k)
          continue;

        ll tmp = 0;
        for (ll l = 0; l < C; l++)
        {
          tmp += D.at(l).at(i) * X.at(l).at(0);
          tmp += D.at(l).at(j) * X.at(l).at(1);
          tmp += D.at(l).at(k) * X.at(l).at(2);
        }

        chmin(ans, tmp);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

while a >= b and k > 0:
    b *= 2
    k -= 1
    

while b >= c and k > 0:
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9168
#!/usr/bin/env ruby
info = gets.chomp.split(" ").map(&:to_i)
result = 0

info[0].times do
  nums = gets.chomp.split(" ").map(&:to_i)
  dst =Math.sqrt(nums[0]**2 + nums[1]**2)
  if dst <= info[1]
    result += 1
  end
end

puts result


Measured memory_bytes: 14372
module C
  sub Main(byval args() as string)
    dim n as integer = integer.parse(console.readline())
    dim arr() as string = split(console.readline())
    dim x() as integer = array.convertall(of string,integer)(arr,addressof integer.parse)
    array.sort(x)
    dim i,a,y,z as integer
    z=0
    for a=x(0) to x(n-1)
    	y=0
        for i=0 to n-1
          	y+=(x(i)-a)^2
        next
  		if a=x(0) then
    		z=y
  		else
    		if z>y then z=y
  		end if
    next
    console.writeline(z)
  end sub
end module

Measured memory_bytes: 13536
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PI;
const int MAX_N=100010;
struct Edge{
	int u,v,cost;
	bool operator<(const Edge& rhs) const{
		return cost<rhs.cost;
	}
} ed[MAX_N*4];
vector<int> xs,ys;
int x[MAX_N],y[MAX_N];
PI dicx[MAX_N],dicy[MAX_N];
int N,M;
int par[MAX_N],_rank[MAX_N];
void init(int N){
	for(int i=1;i<=N;i++){
		par[i]=i;
		_rank[i]=0;
	}
}
int find(int x){
	if(par[x]==x) return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(_rank[x]<_rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(_rank[x]==_rank[y]) _rank[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
void kruskal(){
	sort(ed,ed+M);
	init(N);
	long long ans=0;
	for(int i=0;i<M;i++){
		Edge& e=ed[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			ans+=e.cost;
		}
	}
	printf("%lld\n",ans);
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d%d",x+i,y+i);
		xs.push_back(x[i]);
		ys.push_back(y[i]);
	}
	memset(dicx,-1,sizeof dicx);
	memset(dicy,-1,sizeof dicy);
	sort(xs.begin(),xs.end());
	sort(ys.begin(),ys.end());
	for(int i=1;i<=N;i++){
		x[i]=lower_bound(xs.begin(),xs.end(),x[i])-xs.begin();
		y[i]=lower_bound(ys.begin(),ys.end(),y[i])-ys.begin();
		if(dicx[x[i]].first==-1)
			dicx[x[i]].first=i;
		else
			dicx[x[i]].second=i;
		if(dicy[y[i]].first==-1)
			dicy[y[i]].first=i;
		else
			dicy[y[i]].second=i;
	}
	for(size_t i=1;i<xs.size();i++){
		if(xs[i]==xs[i-1]) dicx[i]=dicx[i-1];
	}
	for(size_t i=1;i<ys.size();i++){
		if(ys[i]==ys[i-1]) dicy[i]=dicy[i-1];
	}
	for(int i=1;i<=N;i++){
		if(x[i]>0) ed[M++]=(Edge){i,((xs[x[i]-1]==xs[x[i]])?(dicx[x[i]].first==i?dicx[x[i]].second:dicx[x[i]].first):dicx[x[i]-1].first),xs[x[i]]-xs[x[i]-1]};
		if(x[i]+1<(int)xs.size()) ed[M++]=(Edge){i,((xs[x[i]+1]==xs[x[i]])?(dicx[x[i]].first==i?dicx[x[i]].second:dicx[x[i]].first):dicx[x[i]+1].first),xs[x[i]+1]-xs[x[i]]};
		if(y[i]>0) ed[M++]=(Edge){i,((ys[y[i]-1]==ys[y[i]])?(dicy[y[i]].first==i?dicy[y[i]].second:dicy[y[i]].first):dicy[y[i]-1].first),ys[y[i]]-ys[y[i]-1]};
		if(y[i]+1<(int)ys.size()) ed[M++]=(Edge){i,((ys[y[i]+1]==ys[y[i]])?(dicy[y[i]].first==i?dicy[y[i]].second:dicy[y[i]].first):dicy[y[i]+1].first),ys[y[i]+1]-ys[y[i]]};
	}
	kruskal();
	return 0;
}

Measured memory_bytes: 9076
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int m,f;
	m=n;
	f=0;
	while(m>0)
	{
		f+=m%10;
		m/=10;
	}
	if(n%f==0)
	  printf("Yes\n");
	else
	  printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
int n,L,T,x[N],w[N];
int main() {
    scanf("%d%d%d",&n,&L,&T);
    for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&w[i]);
    int mk=0;
    for(int i=1;i<=n;i++) {
        if(w[i]==1) {
            mk+=(x[i]+T)/L;
            mk%=n;
            x[i-1]=(x[i]+T)%L;
        }
        else{
            mk-=(L-x[i]-1+T)/L;
            mk%=n;
            x[i-1]=((x[i]-T)%L+L)%L;
        }
    }
    sort(x,x+n);
    for(int i=0;i<n;i++) {
        // cout<<(i+mk+n)%n<<endl;
        printf("%d\n",x[(i+mk+n)%n]);
    }
    
}

Measured memory_bytes: 4460
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	long long int N;
	cin>>N;
	std::vector<long long int>A(N);
	REP(i,N)cin>>A[i];
	std::sort(A.begin(),A.end());
	long long int ans=1,co=0;
	for(int i=N-1;i>0;i--){
		if(A[i]==A[i-1]){
			ans*=A[i];
			i--;
			co++;
		}
		if(co==2){
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 1024
import math
#def getTotal(now_depo, now_year, goal):
#  if(now_depo >= goal):
#    return now_year
#  else:
#    return getTotal(math.floor(now_depo * 1.01), now_year + 1, goal)

goal = int(input())
depo = 100
#print(getTotal(depo, 0, goal))
now_year = 0
while (True):
  depo = math.floor(depo * 1.01)
  now_year += 1
  if(depo >= goal):
    print(now_year)
    break

Measured memory_bytes: 9168
t = gets.to_i
tres = []
t.times do
  g = gets.split.map(&:to_i)
  p = gets.to_i
  m = Array.new(p).map{Array.new(4)}
  p.times do |j|
    m[j] = gets.split.map(&:to_i)
  end


  pm = Array.new(g[0] + 1).map{Array.new(g[1] + 1, 0)}
  p.times do |j|
    tx = [m[j][0], m[j][2]].max
    ty = [m[j][1], m[j][3]].max
    if m[j][0] == m[j][2]
      if pm[tx][ty] == 1 || pm[tx][ty] == 3
        pm[tx][ty] = 3
      else
        pm[tx][ty] = 2
      end
    elsif m[j][1] == m[j][3]
      if pm[tx][ty] == 2 || pm[tx][ty] == 3
        pm[tx][ty] = 3
      else
        pm[tx][ty] = 1
      end
    end
  end

  res = Array.new(g[0] + 1).map{Array.new(g[1] + 1, 0)}

  for i in (0..g[0]) do
    for j in (0..g[1]) do
      if i == 0 && j == 0
        res[i][j] = 1
      else
        if j != 0 && (pm[i][j] != 2 && pm[i][j] != 3)
          res[i][j] += res[i][j - 1]
        end
        if i != 0 && (pm[i][j] != 1 && pm[i][j] != 3)
          res[i][j] += res[i - 1][j]
        end
      end
    end
  end

  res = res[g[0]][g[1]]
  puts (res.zero? ? "Miserable Hokusai!" : res)
  tres << res


end

#p tres

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

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

void solve()
{
        ll x, y;
        cin >> x >> y;
        if(abs(x - y) < 2){
                cout << "Brown" << "\n";
        }
        else{
                cout << "Alice" << "\n";
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


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

int n;
pair<int, pair<string, int>> lis[100];

bool custom(const pair<int, pair<string, int>> &a, const pair<int, pair<string, int>> &b){
	if(a.second.first != b.second.first) return a.second.first < b.second.first;
	else return a.second.second > b.second.second;
}

int main(){		
	cin >> n;
	for(int i = 0; i < n; i++)
		lis[i].first = i, cin >> lis[i].second.first >> lis[i].second.second;
       	sort(lis, lis + n, custom);
	for(int i = 0; i < n; i++) printf("%d\n", lis[i].first + 1);	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX = 111;

int A[333];

int main()
{
    string S;
    cin >> S;
    FOR(i, 0, SZ(S))
    A[S[i]] = 1;
    
    if (A['W'] ^ A['E'])
    {
        cout << "No" << endl;
        return 0;
    }
    
    if (A['N'] ^ A['S'])
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
N = int(input())
A = [0] + list(map(int, input().split()))
C = Counter(A)

value = sorted(set(A), reverse=True)
a_to_i = defaultdict(int)

for i, a in enumerate(A):
    if not a_to_i[a]:
        a_to_i[a] = i

ans = [0] * (N + 1)
cnt = 0
i = N
for x, y in zip(value[:-1], value[1:]):
    i = min(i, a_to_i[x])
    cnt += C[x]
    ans[i] += (x - y) * cnt

print(*ans[1:], sep="\n")

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


///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

string s;
int k;
vector<string> v;

int main(){
    cin>>s>>k;
    rep(j,k)rep(i,s.size()-j){
        if(find(all(v),s.substr(i,j+1)) == v.end()){
            //cout<<"a"<<endl;
            v.pb(s.substr(i,j+1));
        };
    }
    sort(all(v));
    cout<<v[k-1]<<endl;
    return 0;
}

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

string query(int n) {
	cout << n << '\n';
	fflush(stdout);
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (l < r) {
		int m = (l + r) / 2;
		R = query(m);
		if (m % 2) {
			if (L == R) r = m;
			else l = m;
		} else {
			if (L == R) l = m;
			else r = m;
		}
	}
	return 0;
}

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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n = 5;
    for (int i = 1; i <= 5; i++) {
        int x; cin >> x;
        if (x == 0)
            cout << i << endl;
    }

    return 0;
%>

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

using namespace std;

int N, K;

int main() {
	int h, m;
	double rest;

	h = 1;
	cin >> N >> K;
	rest = N;
	while (true) {
		m = rest / (K + 1) * K;
		if (m == 0) {
			break;
		}
		++h;
		rest = m;
	}	
	cout << h << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

void print_rec(int h, int w){
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << "#";
		}
		cout << endl;
	}
	cout << endl;
}

int main(void){

	int h,w;
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		print_rec(h, w);
	}
	return 0;
}

Measured memory_bytes: 1152