akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    if(s[n-1]=='s')
        s+='e';
    s+='s';
    cout<<s;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3652
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
mii m;
void solve()
{
   int n; cin>>n;
   int h[n],cnt=0;
   rep(i,0,n) cin>>h[i];
   cnt+=h[0];
   rep(i,1,n)
   {
      if(h[i]>h[i-1]) cnt+=h[i]-h[i-1];
   }
   cout<<cnt;
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    string s;
    cin >> s;
    if(atoi(s.substr(0,4).c_str()) < 2019){
        cout << "Heisei" << endl;
        return 0;
    }
    if(s.substr(0,4)=="2019"){
        if(s.substr(5,2) == "03"
        || s.substr(5,2) == "02"
        || s.substr(5,2)== "01"){
            cout << "Heisei" << endl;
            return 0;
        }
        if(s.substr(5,2) == "04"){
            if(atoi(s.substr(8,2).c_str()) <= 30){
                cout << "Heisei" << endl;
                return 0;
            }
        }
    }
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

class union_find_tree{
private:
    static constexpr int uft_N=100005;
    int uft_n;
    queue<int> uft_q1;
    vector<int> uft_parent;
    vector<int> uft_num;
public:
    void init(){
        uft_parent.assign(uft_n,-1);
        uft_num.assign(uft_n,1);
    }
    union_find_tree(int uft_n_init){
        assert(uft_n_init>=0);
        uft_n=uft_n_init;
        init();
    }
    union_find_tree(){
        uft_n=uft_N;
        init();
    }

    int check_parent(int uft_x){
        assert(uft_x>=0 && uft_x<uft_n);
        if(uft_parent[uft_x]!=-1){
            uft_q1.push(uft_x);
            return check_parent(uft_parent[uft_x]);
        }
        int uft_a;
        while(!uft_q1.empty()){
            uft_a=uft_q1.front(),uft_q1.pop();
            uft_parent[uft_a]=uft_x;
        }
        return uft_x;
    }

    bool connect(int uft_x,int uft_y){
        assert(uft_x>=0 && uft_x<uft_n);
        assert(uft_y>=0 && uft_y<uft_n);
        uft_x=check_parent(uft_x),uft_y=check_parent(uft_y);
        if(uft_x==uft_y)return true;
        if(uft_num[uft_x]>uft_num[uft_y])swap(uft_x,uft_y);
        uft_parent[uft_x]=uft_y;
        uft_num[uft_y]+=uft_num[uft_x];
        return false;
    }

    int size(int pos){
        pos=check_parent(pos);
        return uft_num[pos];
    }
};

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n>>m;
    union_find_tree ua(n);
    for(i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        ua.connect(a,b);
    }
    a=0;
    for(i=0;i<n;i++){
        a=max(a,ua.size(i));
    }
    cout<<a<<endl;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    B = [0] * N
    for a in A:
        B[a-1] += 1
    for i in range(N):
        if B[i] <= (Q-K):
            print(NO)
        else:
            print(YES)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8632
N = int(input())
A = list(map(int, input().split()))
a = 0
s = sum(A)
sn = s/N
A.sort()
m = A[0]
M = A[0]
if len(A) > 1:
  M = A[-1]
c = 1000000
for i in range(m, M+1):
  if abs(i - sn) < c:
    a = i
    c = abs(i-sn)
ans = 0
for i in range(N):
  ans += (a-A[i])**2
print(ans)

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

int main(){
  ll R, C, k;
  cin >> R >> C >> k;
  ll r[k], c[k], v[k];
  vector<vector<ll>> m(R+2,vector<ll>(C+2));
  rep(i,k) {
    cin >> r[i] >> c[i] >> v[i];
    m[r[i]][c[i]] = v[i];
  }
  vector<vector<vector<ll>>> dp(R+2,vector<vector<ll>>(C+2,vector<ll>(4)));
  for(int j = 1; j <= C+1; j++) {
    for(int i = 1; i <= R+1; i++) {
      rep(id,4) {
        if(m[i][j] > 0) {
          if(id < 3) {
            if(i+1 <= R+1) dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][id]+m[i][j]);
            if(j+1 <= C+1) dp[i][j+1][id+1] = max(dp[i][j+1][id+1],dp[i][j][id]+m[i][j]);
          }
        }
        if(i+1 <= R+1) dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][id]);
        if(j+1 <= C+1) dp[i][j+1][id] = max(dp[i][j+1][id],dp[i][j][id]); 
      }
    }
  }
  ll ans = 0;
  rep(i,4) ans = max(ans,dp[R+1][C+1][i]);
  cout << ans << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;

    char check_odd[3] = {'R', 'U', 'D'};
    char check_even[3] = {'L', 'U', 'D'};

    int flag = 0;
    for(int i = 0; i < s.length(); i++){
        flag = 0;
        if(i % 2 == 0){
            for(int j = 0; j < 3; j++){
                if(check_odd[j] == s[i]){
                    flag = 1;
                    break;
                }
            }
        }else{
            for(int j = 0; j < 3; j++){
                if(check_even[j] == s[i]){
                    flag = 1;
                    break;
                }
            }
        }

        if(flag == 0){
            break;
        }
    }

    if(flag == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
def main():
  N = int(input())
  cuisine =  []
  for i in range(N):
    a,b = map(int, input().split())
    cuisine.append([a+b, a, b])
  cuisine.sort(key = lambda x:x[0], reverse = True)
  happy_t = 0
  happy_a = 0
  for i in range(N):
    if i % 2 == 0:
      happy_t += cuisine[i][1]
    else:
      happy_a += cuisine[i][2]
  print(happy_t-happy_a)
  
if __name__ == "__main__":
  main()

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

int main() {
    int64_t N,K;
    cin >> N >> K;
    
    vector<int64_t> A(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    for ( int64_t i = K; i < N; ++i){
        if ( A[i-K] < A[i] ){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 4840
A, B = map(int, input().split())
cake = [0]*16
for i in range(A):
  try:
    cake[i*2] = 1
  except:
    print(':(')
    exit()
for i in range(B):
  try:
    cake[(i*2)+1] = 1
  except:
    print(':(')
    exit()
print('Yay!')

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n, m) = get!(usize, usize);
    
    let res = (1..(m/n+1)).rev().filter(|a| m % a == 0 ).filter(|a| m/(n*a) >= 1).take(1).last().unwrap();
    println!("{}", res);
}


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

namespace AtCoderProject
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadLine();
            var input = ReadLineSplitInt32();
            input.Sort();
            var max = input[input.Count - 1];
            var sum = input.Take(input.Count - 1).Sum();
            Console.WriteLine(max < sum ? "Yes" : "No");
        }

#if DEBUG
        static string input = @"
4
3 8 4 1
";
        static string _ReadLineImpl() => queue.Dequeue();
        static Queue<string> queue;
        static Program()
        {
            queue = new Queue<string>();
            foreach (var line in input.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                queue.Enqueue(line);
        }
#else
        private static string _ReadLineImpl() => Console.ReadLine();
#endif
        static string ReadLine() => _ReadLineImpl();
        static int ReadLineInt32() => int.Parse(ReadLine());
        static double ReadLineDouble() => double.Parse(ReadLine());
        static List<string> ReadLineSplit() => ReadLine().Split().ToList();
        static List<int> ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        static List<double> ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToList();

        static IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        static IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        static IEnumerable<List<string>> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
}


Measured memory_bytes: 13396
/**
*    author:  yuya1234
*    created: 14.07.2020 11:58:33
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  ll x,y;
  cin>>x>>y;

  ll ans=LONG_LONG_MAX;

  if(x<=y)ans=min(ans,y-x);
  if(-x<=y)ans=min(ans,y+x+1);
  if(x<=-y)ans=min(ans,-y-x+1);
  if(-x<=-y)ans=min(ans,-y+x+2);

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a[3][3], ok[3][3];
    rep(i, 3)rep(j, 3){
        cin >> a[i][j];
        ok[i][j] = 0;
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n){
        cin >> b.at(i);
        rep(j, 3)rep(k, 3){
            if(a[j][k] == b[i])ok[j][k] = 1;
        }
    }
    bool ans = false;
    rep(i, 3){
        if(ok[i][0] == 1 && ok[i][1] == 1 && ok[i][2] == 1)ans = true;
        if(ok[0][i] == 1 && ok[1][i] == 1 && ok[2][i] == 1)ans = true;
    }
    if(ok[0][0] == 1 && ok[1][1] == 1 && ok[2][2] == 1)ans = true;
    if(ok[0][2] == 1 && ok[1][1] == 1 && ok[2][0] == 1)ans = true;
    if(ans)cout << "Yes";
    else cout << "No";
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;
double T[202020];

double AA(int x,int y) {
	return T[x]+T[y-x]+T[N-y];
}

ll num(double A) {
	ll ret=0;
	for(int x=1;x<N;x++) {
		int y=x+(N-x)/2;
		int tx=x;
		if(AA(x,y)<=A) {
			ret += (N-(x+1));
			continue;
		}
		while(y-tx>1) {
			int m=(y+tx)/2;
			if(AA(x,m)<=A) tx=m;
			else y=m;
		}
		ret += (y-1-x)*2;
	}
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	double PI=atan(1)*4;
	
	cin>>N>>K;
	vector<double> D;
	FOR(i,N) T[i]=sin(i*2*PI/N)/2.0;
	
	
	double L=0,R=2;
	FOR(i,100) {
		double M=(L+R)/2;
		if(num(M)*N>=K*3) R=M;
		else L=M;
	}
	/*
	for(x=1;x<N;x++) for(y=x+1;y<N;y++) {
		double dx = 2*PI*x/N;
		double dy = 2*PI*y/N;
		double a = (sin(dx)+sin(dy-dx)+sin(-dy))/2.0;
		D.push_back(a);
	}
	sort(ALL(D));
	*/
	_P("%.12lf\n",L);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
#include<cstring>
#include<cmath>
#include<cstdio>
#include<string>
#include<string.h>
#include<stdio.h>



int main() {

    long long int a,b,x;
    cin >> a >> b;
    x = (a+b);

    if(x%2==0)
    {
        cout << x/2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }





  return 0;

}







Measured memory_bytes: 256
s = input()
l = list(s)
c1 = s.count(l[0])
c2 = s.count(l[1])
c3 = s.count(l[2])
c4 = s.count(l[3])
if c1 == 2 and c2 == 2 and c3 == 2 and c4 == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
H, W = 12, 12
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]


def dfs(i, j):
    field[i][j] = 0
    for k in xrange(4):
        ny = i + dy[k]
        nx = j + dx[k]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        if field[ny][nx] == 1:
            dfs(ny, nx)

while 1:
    field = []
    for i in xrange(H):
        field.append(map(int, raw_input()))

    ret = 0
    for i in xrange(H):
        for j in xrange(W):
            if field[i][j] == 1:
                dfs(i, j)
                ret += 1
    print ret
    try:
        raw_input()
    except EOFError:
        break

Measured memory_bytes: 4304
# 各桁の数値の総和を計算する.
def calc_digit_sum(num):
    sums = 0
    while num > 0:
        sums += num % 10
        num //= 10
    return sums


n = int(input())
s = input()

cnt = 0
for index in range(n-2):
    if s[index:index+3] == "ABC":
        cnt += 1
print(cnt)

Measured memory_bytes: 61916
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 200003;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	bool flag = false;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){
		flag = true;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	if(flag) x = -x;
}
pii a[N];
int n;
LL sum;
int main(){
	read(n);
	for(Rint i = 1;i <= n;i ++) read(a[i].second), read(a[i].first);
	sort(a + 1, a + n + 1);
	for(Rint i = 1;i <= n;i ++){
		sum += a[i].second;
		if(sum > a[i].first){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  int mx = max({a + b, a - b , a * b});
  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N, K, Q;    cin >> N >> K >> Q;
    vector<int> v(N,0);
    for(int i=0; i<Q; i++){
        int A;  cin >> A;
        v[A-1]++;
    }
    for(int i=0; i<N;i++){
        if(K-Q+v[i] > 0)    cout << "Yes" << '\n';
        else    cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	const int n = 4, m = 3;
	vector<pii> edges(m);
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		if(a > b){ swap(a, b); }
		edges[i] = pii(a - 1, b - 1);
	}
	sort(edges.begin(), edges.end());
	vector<int> order(n);
	for(int i = 0; i < n; ++i){ order[i] = i; }
	bool answer = false;
	do { 
		bool accept = true;
		for(int i = 0; i + 1 < n; ++i){
			int a = order[i], b = order[i + 1];
			if(a > b){ swap(a, b); }
			if(!binary_search(edges.begin(), edges.end(), pii(a, b))){
				accept = false;
			}
		}
		if(accept){
			answer = true;
			break;
		}
	} while(next_permutation(order.begin(), order.end()));
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}



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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
struct UF {
		vi e;
			UF(int n) : e(n, -1) {}
				bool same_set(int a, int b) { return find(a) == find(b); }
					int size(int x) { return -e[find(x)]; }
						int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
							void join(int a, int b) {
										a = find(a), b = find(b);
												if (a == b) return;
														if (e[a] > e[b]) swap(a, b);
																e[a] += e[b]; e[b] = a;
																	}
};
int p[100009];
int ax[100009],bx[100009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	UF dsu(n);
	vector<pii> a,b;
	rep(i,n) {
		int x;cin>>x;
		a.pb({x,i});
	}
	rep(i,n) {
		int x;cin>>x;
		b.pb({x,i});
	}
	sort(all(a));
	sort(all(b));
	bool fg=0;
	rep(i,n){
		if(a[i].fst>b[i].fst){
			fg=1;
		}
		ax[a[i].snd] = i;
		bx[b[i].snd] = i;
		dsu.join(a[i].snd,b[i].snd);
		if(i){
			if(a[i].fst<=b[i-1].fst) p[i]=1;
			p[i]+=p[i-1];
		}
	}
	if(fg) cout<<"No";
	else {
		int cnt = 0;
		rep(i,n) if(dsu.find(i)==i) cnt++;
		if(cnt>1) cout<<"Yes";
		else{
			bool gg=0;
			rep(i,n){
				if(a[ax[i]].fst<=b[bx[i]].fst){
					if(ax[i]>=bx[i]||p[bx[i]]-p[ax[i]]>=bx[i]-ax[i]){
						gg=1;
						break;
					}
				}
			}
			if(gg) cout<<"Yes";
			else cout<<"No";
		}
	}
	return 0;
}



Measured memory_bytes: 3572
import java.util.Scanner;

class Main {
    public static void main(String[] args){
    	
    	//
        Scanner sc = new Scanner(System.in);
        //??????????????????
        String s = sc.nextLine();
        String p = sc.nextLine();
        
        s=s+s;
        //
        if(s.indexOf(p)!=-1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;

typedef long long LL;

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

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

    LL ss = 0;
    LL d = 10000000000000000;
    for (int i = 0; i < n - 1; i++) {
        ss += a[i];
        sum -= a[i];
        d = min(d, llabs(sum - ss));
    }

    cout << d << endl;

    return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val ans = solve(H, W)
    println(ans)
}

fun solve(H: Int, W: Int): Long {
    return when {
        W == 1 -> {
            1L
        }
        H == 1 -> {
            1L
        }
        W % 2 == 0 -> {
            (W.toLong() / 2) * H.toLong()
        }
        H % 2 == 0 -> {
            ((W.toLong() / 2) + 1L) * (H.toLong() / 2L) + ((W.toLong() / 2L)) * (H.toLong() / 2L)
        }
        else -> {
            ((W.toLong() / 2) + 1L) * (H.toLong() / 2L) + (W.toLong() / 2L) * (H.toLong() / 2L) + (W.toLong() / 2L) + 1L
        }
    }
}


/**
 * ファクション
 */
fun floor(target: Double): Double {
    return Math.floor(target)
}

fun ceil(target: Double): Double {
    return Math.ceil(target)
}


Measured memory_bytes: 37820
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;

int main() {
        int n;
        cin>>n;
  		int d[n + 1][n + 1];
        //vector<vector<int>> need(n, vector<int> (n));
        for (int i = 0; i < n; i ++) {
                for (int j = 0; j < n; j ++) {
                        cin>>d[i][j];
                }
        }
  		  //e = [[0 for i in range(n)] for i in range(n)]
  int e[n + 1][n + 1];
  int p = 0;
    //d[i][j]: iからjへの最短距離
	for (int k = 0; k < n; k ++) {
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < n; j ++) {
                if(d[i][j] > d[i][k] + d[k][j]){
                  	p = -1;
                    //cout<<-1<<endl;
                    //exit(1);
                }
                else if(d[i][j] == d[i][k] + d[k][j] && i != j && i != k && j != k){
                    e[i][j] = INF;
                }
            }
        }
    }
    if(p == 0){
        int long long ans = 0;
        for (int i = 0; i < n; i ++) {
                for (int j = 0; j < n; j ++) {
        			if(e[i][j] != INF){
            			ans += d[i][j];
                    }
                }
        }
		ans = ans / 2;
		cout<<ans<<endl;     
    }
  	else{
      cout<<p<<endl;  
    }
}

Measured memory_bytes: 896
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using ml = boost::multiprecision::cpp_int;
using md = boost::multiprecision::cpp_dec_float_100;
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    md a, b, c;
    cin >> a >> b >> c;
    cout << (sqrt(a) + sqrt(b) < sqrt(c) ? "Yes" : "No") << endl;

    return 0;
}


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

ll N;

int main(){
	cin>>N;
	string s;
	set<string> S;
	for(int i=0;i<N;i++){
		cin>>s;
		S.insert(s);
	}
	cout<<S.size()<<endl;


}

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

int main(){
    int n,m;
    int A[100][100];
    int b[100];
    int x =0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(int i=0;i<n;i++){
        x = 0;
        for(int j =0;j<m;j++){
            x +=A[i][j]*b[j];
        }
        printf("%d\n",x);
    }
    return 0;
}




Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod=1e9+7;
ll fact[2009],inv[2009];
ll f(ll b,ll p){
    ll power=b,ret=1;
    while (p>0){
        if (p&1)
            ret=ret*power%mod;
        power=power*power%mod;
        p=p>>1;
    }
    return ret%mod;
}
int main()
{
    FASTINOUT;
    ll x,k;
    cin>>x>>k;
    fact[0]=1;
    inv[0]=f(1,mod-2);
    for (int i=1;i<=x;i++){
        fact[i]=i*fact[i-1]%mod;
        inv[i]=f(fact[i],mod-2)%mod;
    }
    for (int i=1;i<=k;i++){
        ll ans=0;
        if (i<=x-k+1){
            ll kl=fact[k-1]*inv[i-1]%mod*inv[k-i]%mod;
            ll op=fact[x-k+1]*inv[i]%mod*inv[x-k+1-i]%mod;
            ans=kl*op%mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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


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

  double mid = sqrt(N);
  ll a = 1;
  if (N % 2 == 0) {
    for (ll i = 1; i <= mid; i++) {
      if (N % i == 0) a = i;
    }
  }
  else {
    for (ll i = 1; i <= mid; i++) {
      if (N % i == 0) a = i;
    }
  }
  ll b = N / a;

  ll res = a + b - 2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    string n; cin>>n;
    for(int i=0;i<3;i++){
        if(n[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
int c[maxn];
vector<int> g[maxn];
int siz[maxn];


ll ans[maxn];


// mp_to[c]: # of nodes trapped under to's subtree, where the root is color=c.
// size[to] - mp_to[c] is the # of nodes in the air gap between the to and a node with color=c.

void dfs(int at, int p, map<ll,ll>& mp) {
    siz[at]=1;
    int C = c[at];
    for (int to: g[at]) {
	if (to == p) continue;
	map<ll,ll> mp_to;
	dfs(to, at, mp_to);
	siz[at]+=siz[to];
	ll middle = siz[to]-mp_to[C];
	ans[C] -= (middle*(middle+1)/2);

	// Smaller to larger
	// Each item (call it x) in the smaller subset moves to the larger one
	// x's subset at least doubles in size
	// So x will move at most logn times. So overall, time complexity of dfs is nlogn.
	if (mp.size() < mp_to.size()) {
	    swap(mp, mp_to);
	}
	for (auto pr: mp_to) {
	    mp[pr.first] += pr.second;
	}
    }
    
    mp[C] = siz[at];
}

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

    
    cin>>n;
    for (int i=1; i<=n; i++) {
	cin>>c[i];
    }

    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    for (int i=1; i<=n; i++) {
	ans[i]=1ll*n*(n+1)/2;
    }

    map<ll,ll> mp;
    dfs(1,0,mp);

    for (int i=1; i<=n; i++) {
	ll top = n-mp[i];
	ans[i] -= (top*(top+1)/2);
    }

    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<"\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 92636
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 0;

int main()
{
	FIO;
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	for(int i=1; i<=n; i++) {
		int x;
		cin >> x;
		v.pb({x, i});
	}
	sort(all(v));;
	for(auto i : v) {
		cout << i.second << " ";
	}
	return 0;	
}	

Measured memory_bytes: 1780
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << s[0][0] << s[1][0] << s[2][0] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N, K;
	cin >> N >> K;

	int R, S, P;
	cin >> R >> S >> P;

	string T;
	cin >> T;

	int scr = 0;
	for (int i = 0; i < K; i++) {
		if (T[i] == 'r') {
			scr += P;
		}
		else if (T[i] == 'p') {
			scr += S;
		}
		else {
			scr += R;
		}
	}

	for (int i = K; i < N; i++) {
		if (T[i] == T[i - K]) {
			T[i] = 'x';
		}
		else {
			if (T[i] == 'r') {
				scr += P;
			}
			else if (T[i] == 'p') {
				scr += S;
			}
			else {
				scr += R;
			}
		}
	}

	cout << scr << endl;

	return 0;

}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll a,b,c,k; cin>>a>>b>>c>>k;
  a-=b;
  if(k%2) a*=-1;
  if(abs(a)>1e18) cout << "Unfair" << endl;
  else cout << a << endl;
}


Measured memory_bytes: 256
class dice init =
  let rot_n (x1,x2,x3,x4,x5,x6):int*int*int*int*int*int = (x2,x6,x3,x4,x1,x5) and
      rot_e (x1,x2,x3,x4,x5,x6):int*int*int*int*int*int = (x4,x2,x1,x6,x5,x3) in
  let rot_s l = rot_n l |> rot_n |> rot_n and
      rot_w l = rot_e l |> rot_e |> rot_e in
  let all_init =
    let rec rotate d list = function
        0 -> list
      | i -> rotate (rot_e d) (d::list) (i-1) in
    let rotate2 n l = rotate n l 4 in
    rotate2 init []
    |> rotate2 (rot_e init |> rot_s)
    |> rotate2 (rot_w init |> rot_s)
    |> rotate2 (rot_n init)
    |> rotate2 (rot_s init)
    |> rotate2 (rot_n init |> rot_n) in
object (self: 'self)
  val mutable faces:int*int*int*int*int*int = init
  val all:'a list = all_init

  method get_face = faces
  method get_all = all
  method equals (other:'self) = self#contains other#get_face
  method contains fc =
    let rec find l = match l with
        [] -> false
      | (x1,x2,x3,x4,x5,x6)::tl -> if (x1,x2,x3,x4,x5,x6) = fc then true
                                   else find tl
    in find all
end;;

let split_int s = Str.split (Str.regexp_string " ") s |> List.map int_of_string;;
let () =
  let f n = (n 0,n 1,n 2,n 3,n 4,n 5) in
  let nth s = split_int s |> List.nth in
  let d1 = new dice (read_line () |> nth |> f) and
      d2 = new dice (read_line () |> nth |> f) in
  if d1#equals(d2) then print_endline "Yes"
  else print_endline "No"
;;

Measured memory_bytes: 2104
# tokiomarine2020_b.py
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V<=W:
    print('NO')
    exit()

if A<B:
    A = A+T*V
    B = B+T*W
    if A>=B:
        print('YES')
        exit()
else:
    A = A-T*V
    B = B-T*W
    if A<=B:
        print('YES')
        exit()
print("NO")


Measured memory_bytes: 9196
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    while(1){
        int N;
        cin >> N;
        if(N == 0) break;
        string L;
        int P, A, B, C, D, E, F, S, M;
        vector<pair<double, string>> v;
        vector<pair<string, double>> ans;

        for(int i = 0; i < N; i++){
            cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            int T = A+B+C+D+E+(D+E)*(M-1);
            v.push_back(make_pair( (double)(M*F*S-P)/T, L) );
        }
        sort(all(v), greater<pair<double, string>>());

        ans.push_back(make_pair(v[0].second, v[0].first));
        for(int i = 1; i < v.size(); i++){
            if(v[i].first != v[i-1].first){
                sort(all(ans));
                for(auto x : ans){
                    cout << x.first << "\n";
                }
                ans.clear();
            }
            ans.push_back(make_pair(v[i].second, v[i].first));
        }
        sort(all(ans));
        for(auto x : ans){
            cout << x.first << "\n";
        }
        cout << "#" << "\n";
    }

    return 0;
}


Measured memory_bytes: 3164
import math
import decimal
N, D = map(int,input().split())
x = []
for i in range(N):
    a,b=input().split()
    x.append([int(a), int(b)])

count = 0


for i in range(N):
    a = math.sqrt(x[i][0]**2 + x[i][1]**2)
    # ans = math.sqrt((x[i][0])^2 + (x[i][1])^2)
    if a <= D:
        count += 1

print(count)

Measured memory_bytes: 40028
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, W; cin >> N >> W;
	VP A(N);
	REP(i, N) cin >> A[i].first >> A[i].second;
	rSORT(A);
	int w;
	VI a, b, c, d;
	a.push_back(0);
	b.push_back(0);
	c.push_back(0);
	d.push_back(0);
	REP(i, N) {
		if (A.back().first + 3 == A[i].first)d.push_back(A[i].second);
		if (A.back().first + 2 == A[i].first)c.push_back(A[i].second);
		if (A.back().first + 1 == A[i].first)b.push_back(A[i].second);
		if (A.back().first + 0 == A[i].first)a.push_back(A[i].second);
	}
	w = A.back().first;
	int ans = 0;
	int cnt1 = 0;
	REP(i, a.size()) {
		cnt1 += a[i];

		int cnt2 = 0;
		REP(j, b.size()) {
			cnt2 += b[j];

			int cnt3 = 0;
			REP(k, c.size()) {
				cnt3 += c[k];

				int cnt4 = 0;
				REP(l, d.size()) {
					cnt4 += d[l];

					//cout << i << " " << j << " " << k << " " << l << " "<< cnt1 + cnt2 + cnt3 + cnt4 <<endl;
					if (w*(i + j + k + l) + j * 1 + k * 2 + l * 3 <= W)chmax(ans, cnt1 + cnt2 + cnt3 + cnt4);



				}
			}


		}
	}
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
w, h, n = map(int, input().split())

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x_min = max(x, x_min)
    elif a == 2:
        x_max = min(x, x_max)
    elif a == 3:
        y_min = max(y, y_min)
    else:
        y_max = min(y, y_max)
print(max(y_max - y_min, 0) * max(x_max - x_min, 0))


Measured memory_bytes: 3064
import sys
from typing import List


def main():
    def readline() -> str:
        s = sys.stdin.readline()
        return s.rstrip()

    n: int = int(readline())
    c: List[str] = list(readline())

    if "W" not in c or "R" not in c:
        print(0)
        return

    l_p: int = c.index("W")
    r_p: int = -1
    operations: int = 0

    while n > l_p - r_p:
        if c[l_p] == "W":
            if c[r_p] == "R":
                c[l_p] = "R"
                c[r_p] = "W"
                operations += 1
                l_p += 1
            r_p -= 1
        else:
            if c[r_p] == "W":
                r_p -= 1
            l_p += 1

    print(operations)
    # print("".join(c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 73932
#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 <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  int n;

  cin >> n;

  long a[n];

  fillLong(a, n);

  int kcnt = 0;
  rep(i, n) {
    if (a[i] % 2) kcnt++;
  }
  
  cout << (kcnt % 2 ? "NO" : "YES") << endl;

  return 0;
}


Measured memory_bytes: 1272
from operator import itemgetter

n,m= map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab)
money = 0
drink = 0
for i in range(n):
         drink += ab[i][1]
         if drink > m:
                  drink -= ab[i][1]
                  break
         else:
                  money += ab[i][1] * ab[i][0]
                  continue
         break
money += (m - drink)*ab[i][0]
print(money)




Measured memory_bytes: 28592
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

const int M = 1e9 +7;

int tab[100001];

bool odd(int n)
{
	if(tab[0]!=1) return 0;
	for(int i=2;i<n;i+=2) if(tab[i] != 2) return 0;
	return 1;
}

bool even(int n)
{
	if(tab[0]!=0) return 0;
	for(int i=1;i<n;i+=2) if(tab[i] != 2) return 0;
	return 1;
}

int power(int n)
{
	if(n==0) return 1;
	else if(n%2) return 2*(power(n/2)%M)*power(n/2)%M;
	else return power(n/2)%M * power(n/2)%M;
}

void solve()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		tab[x]++;
	}
	if((n%2==0 && even(n)) || (n%2==1 && odd(n)))
	{
		cout << power(n/2);
	}
	else cout << "0";
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 4456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] nm = br.readLine().split(" ");
		int N = Integer.parseInt(nm[0]);
		int M = Integer.parseInt(nm[1]);

		System.out.println(((N-M)*100 + (M*1900)) * (int)Math.pow(2, M));
	}

}


Measured memory_bytes: 23636
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int min=642;
		int[] a=new int[s.length()-2];
		for(int i=0; i<s.length()-2; i++) {
			a[i]=Integer.parseInt(s.substring(i, i+3));
			min=Math.min(Math.abs(a[i]-753), min);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21204