akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        s: Chars
    }

    for (i, (a, b)) in s.windows(2).map(|x| (x[0], x[1])).enumerate() {
        if a == b {
            println!("{} {}", i + 1, i + 2);
            return;
        }
    }

    for (i, (a, b, c)) in s.windows(3).map(|x| (x[0], x[1], x[2])).enumerate() {
        if a == b || a == c || b == c {
            println!("{} {}", i + 1, i + 3);
            return;
        }
    }

    println!("-1 -1");
}


Measured memory_bytes: 2460
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	string P, Q;
	char c;
	for (int i = 0; i < N; i++){
		cin >> c;
		P.pb(c);
	}
	for (int i = 0; i < N; i++) {
		cin >> c;
		Q.pb(c);
	}

	vector<int>perm;
	for (int i = 1; i <= N; i++)perm.pb(i);

	vector<string>po;
	do {
		string temp;
		for (int i = 0; i < N; i++)temp.pb('0' + perm[i]);
		po.pb(temp);
	} while (next_permutation(all(perm)));
	sort(all(po));

	int a = 0;
	int b = 0;
	for (int i = 0; i < po.size(); i++) {
		if (P == po[i])a = i;
		if (Q == po[i])b = i;
	}
	puts(abs(a - b));
	return 0;
}

Measured memory_bytes: 2424
#include <iostream>
using namespace std;
int main() {
    string S;
    cin >> S;
    string Weather[3]= {"Sunny","Cloudy","Rainy"};
    for(int i=0;i<3;i++){
        if(S.compare(Weather[i]) == 0){
            cout << Weather[(i+1)%3] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 760
#include <cstdio>
#include <queue>
#include <iostream>
using namespace std;

const int MAX_N = 100000;

int N, Q;
int parent[MAX_N+1];
char op[MAX_N+1];
int node[MAX_N+1];
bool marked[MAX_N+1];

void init()
{
  marked[1] = true;
  for (int i = 2; i <= N; i++)
  {
    marked[i] = false;
  }
}

int find(int x)
{
  if (marked[x]) return x;
  else return find(parent[x]);
}

int main()
{
  parent[1] = 1;

  while(1)
  {
    cin >> N >> Q;
    if (N == 0 && Q == 0)
    {
      return 0;
    }

    init();

    for(int i=2; i<=N; i++)
    {
      scanf("%d", &parent[i]);
    }

    for(int i = 0; i < Q; i++){
      cin >> op[i] >> node[i];
    }

    long long ans = 0;
    for(int i = 0; i < Q; i++)
    {
      switch (op[i]) {
      case 'Q':
        ans += find(node[i]);
        break;
      case 'M':
        marked[node[i]] = true;
        break;
      default:
        break;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;

#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--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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 main(){
	int n,m;cin>>n>>m;
	graph g(n);
	rep(i,m){
		int a,b;cin>>a>>b;
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans=0;
	vector<int> v(n);
	rep(i,n)v[i]=i;
	rep(i,n-1){
		if(find(all(g[v[i]]),v[i+1])==g[v[i]].end()&&find(all(g[v[i+1]]),v[i])==g[v[i+1]].end())break;
		if(i==n-2)ans++;
	}
	while(next_permutation(all(v))){
		if(v[0]!=0)continue;
		rep(i,n-1){
			if(find(all(g[v[i]]),v[i+1])==g[v[i]].end()&&find(all(g[v[i+1]]),v[i])==g[v[i+1]].end())break;
			if(i==n-2)ans++;
		}
	}
	cout<<ans<<endl;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  if (A < 6) {
    cout << "0" << endl;
  }
  else if (12 < A) {
    cout << B << endl;
  }
  else{
    cout << B / 2 << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int flag=0,pd;
int main(){
    int k,t;
    int a[1001];
    cin>>k>>t;
    for(int i=0;i<t;i++) cin>>a[i],flag+=a[i];//flag=a[0]+...+a[t-1]
    for(int i=0;i<t;i++){
        pd=a[i]*2-flag-1;//pd=a[i]*2-(a[0]+...+a[t-1])-1
                         //  =a[i]-a[0]-a[1]-...-a[i-1]-a[i+1]-...-a[t-1]-1
        if(pd>=0){//若max(pd,0)=pd
            cout<<pd<<endl;//直接输出并跳出程序，因为这是最大的数了
            return 0;
        }
    }
    cout<<"0"<<endl;//说明max(pd,0)=0,输出0
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
 	str s, t;
 	cin >> s >> t;
 	int ans = 0;
 	fi(0, siz(s)) {
 		ans += s[i] != t[i];
 	}
 	cout << ans << '\n';
   	
}

Measured memory_bytes: 3808
n = int(input())
map = {}
for i in range(n):
  str = ''.join(sorted(input()))
  if str in map:
    map[str] += 1
  else:
    map[str] = 1

ans = 0
for value in map.values():
  ans += value * (value - 1) // 2

print(ans)

Measured memory_bytes: 17852
let () = Scanf.scanf "%d\n" @@ fun n ->
  let abs = Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  Array.fold_left max (0, 0) abs
  |> (fun (a, b) -> a + b)
  |> Printf.printf "%d\n"


Measured memory_bytes: 6784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	prev := sc.NextInt()
	mx := 0
	cur := 0
	for i := 1; i < n; i++ {
		tmp := sc.NextInt()
		if prev >= tmp {
			cur++
			if cur > mx {
				mx = cur
			}
			prev = tmp
		} else {
			prev = tmp
			cur = 0
		}
	}
	fmt.Printf("%v\n", mx)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    set<ll> s;
    rep(i, n) {
        cin >> a.at(i);
        s.insert(a.at(i));
    }
    
    if(s.count(0)) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;

    rep(i, n) {
        if(a.at(i) <= LLONG_MAX / ans && (ans * a.at(i))/a.at(i) == ans) ans *= a.at(i);
        else {
            cout << -1 << endl;
            return 0;
        }
        if(1000000000000000000LL < ans) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string ans = "CODEFESTIVAL2016";

li a[100100];

int main() {
    li k, n;
    cin >> k >> n;
    li maa = -1;
    li sum = 0;
    rin{
        cin >> a[i];
        maa = max(a[i], maa);
        sum += a[i];
    }
    if (maa <= (k + 1) / 2) {
        puts("0");
        return 0;
    }
    li rest = sum - maa;
    cout << (maa - (rest + 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in();
    ll sum=0,mi=1000000;
    int cnt_n=0;
    rep(i,n){
        int a=in();
        sum+=abs(a);
        if(abs(mi)>abs(a))mi=abs(a);
        if(a<0)cnt_n++;
    }
    if(cnt_n%2==1)sum-=2*mi;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
while 0 < n = gets.chomp.to_i
  a_total=0
  b_total=0
  n.times do 
    a, b = gets.chomp.split(' ').map(&:to_i)
    if a < b
      b_total += a + b
    elsif a > b
      a_total += a + b
    else
      a_total += a
      b_total += b
    end
  end
  puts "#{a_total} #{b_total}"
end

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

int main(){
    ll N, K;  cin >> N >> K;
    vector<ll> A(N+1, 0);
    vector<ll> S(N+1, 0);
    for(int i=1; i<=N; i++){
        cin >> A[i];
        A[i]--;
        S[i] = (S[i-1] + A[i])%K;
    }

    map<ll, ll> mp;
    ll ans = 0;
    for(int i=0; i<=N; i++){
        if(i - K >= 0){
            mp[S[i-K]]--;
        }
        ans += mp[S[i]];
        mp[S[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
if __name__ == '__main__':
	l=list(map(int,input().split(" ")))
	print(l.index(0)+1)
	





Measured memory_bytes: 10620
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    d = dict(zip("abc",[0]*3))
    for i in s:
        d[i] += 1
    d = list(d.values())
    if min(d)+1 < max(d):
        print("NO")
    else:
        print("YES")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 40072
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;

ll INF = 1e18;
ll N;
ll A[300][300];
ll B[300][300];
vector<pair<ll,pair<ll,ll>>> v;

int main(){
    ll L = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> A[i][j];
            B[i][j] = A[i][j];
            if(i > j) v.push_back(make_pair(A[i][j],make_pair(i,j)));
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                B[j][k] = min(B[j][k],B[j][i]+B[i][k]);
            }
        }
    }

    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        ll l = v[i].first;
        ll x = v[i].second.first;
        ll y = v[i].second.second;
        for(int j=0;j<N;j++){
            if(j == x || j == y) continue;
            if(B[x][y] < A[x][y]){
                cout << -1 << endl;
                return 0;
            }
            if(B[x][y] == A[x][j] + A[j][y]){
                B[x][y] = B[y][x] = INF;
            }
        }
        if(B[x][y] != INF) L += B[x][y];
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
int a,b,c1=0,c2=0,p,q;
scanf("%d",&a);
scanf("%d",&b);
p=a;
q=b;
while(a!=0)
{
  a=a/10;
  c1++;
}
while(b!=0)
{
  b=b/10;
  c2++;
}
if((c1==1)&&(c2==1))
{
printf("%d",p*q);
}
else 
printf("-1");
return 0;
}    



Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple {
    private int H, W;
    private string[] a;
    void Solve() {
        //input
        H = io.Int;
        W = io.Int;
        //cal
        var ans = long.MaxValue;
        //type A1 横横横
        if(H >= 3) ans = Min(ans, A(H, W));
        //type A2 縦縦縦
        if(W >= 3) ans = Min(ans, A(W, H));
        //type B1 縦横横
        ans = Min(ans, B(H, W));
        //rtpe B2 横縦縦
        ans = Min(ans, B(W, H));
        //ret
        WriteLine(ans);
    }
    long A(long a, long b) => a % 3 == 0 ? 0 : b;
    long B(long a, long b) {
        var ret = long.MaxValue;
        for(int i = 1; i < b; ++i) {
            var v1 = a * i;
            var v2 = (b - i) * (a / 2);
            var v3 = (b - i) * (a - (a / 2));
            ret = Min(ret, myMax(v1, v2, v3) - myMin(v1, v2, v3));
        }
        return ret;
    }
    long myMin(params long[] a) => a.Min();
    long myMax(params long[] a) => a.Max();
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = true
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 17476
n = int(input())
s1 = input()
s2 = input()
ans = 1
ch1 = 1
N = 1000000007
s1+='?'

if s1[0]==s1[1]:
    ch2=2
    ans=6
    s=3
else:
    ch2=1
    ans=3
    s=2

for i in range(s,n+1):
        if s1[i]==s1[i-1]:
            ch1+=1
        else:
            if ch1 ==1:
                if ch2==2:
                    ans*=1
                else:
                    ans=ans*2%N
            else:
                if ch2==2:
                    ans=ans*3%N
                else:
                    ans=ans*2%N
            ch2=ch1
            ch1=1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[55];
signed main(){
	cin>>n;
	cout<<50<<endl;
	rep(i,50){
		if(i<n%50)a[i]=50;
		else a[i]=49-n%50;
		cout<<a[i]+n/50<<(i==49?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int A[112345];
int sum[112345];
int cnt[112345];
string S;
int ans = 0;

int main(){
	
	cin>>N;
	
	fill( cnt, cnt+112345, 0 );
	
	REP( i, N ){
		scanf("%d", A+i);
		cnt[A[i]]++;
		cnt[A[i]-1]++;
		cnt[A[i]+1]++;
	}
	
	REP( i, 112345 ) ans = max( cnt[i], ans );
	
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


N = int(input())
if (N//10) % 10 == 9 or (N % 10) % 10 == 9:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;
  int p = 0, q = s.length() - 1;
  int lastp = p, lastq = q;
  while (p <= q) {
    while (s[p] == 'x') p++;
    while (s[q] == 'x') q--;
    if (p > q) break;
    if (s[p] != s[q]) {
      std::cout << -1 << std::endl;
      return 0;
    }
    lastp = p;
    lastq = q;
    p++;
    q--;
  }
  uint64_t count = 0;
  p = lastp;
  q = lastq;
  while (1) {
    lastp--;
    lastq++;
    if (lastp < 0 && lastq >= s.length()) break;
    int pcnt = 0, qcnt = 0;
    while (lastp >= 0 && s[lastp] == 'x') {
      lastp--;
      pcnt++;
    }
    while (lastq < s.length() && s[lastq] == 'x') {
      lastq++;
      qcnt++;
    }
    count += abs(pcnt - qcnt);
  }
  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int N, K;
int A[100001];

int GCD(int a, int b){
    if(b == 0){
        return a;
    }
    return GCD(b, a % b);
}

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

    cin >> N >> K;

    int m = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        m = max(m, A[i]);
    }
    
    int G = A[0];
    for(int i = 1; i < N; ++i)
        G = GCD(G, A[i]);
    
    if(K <= m && K % G == 0){
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
//    freopen ("input", "r", stdin);
//    freopen ("output", "w", stdout);
    int n, k;
    cin >> n >> k;
    n -= 1;
    k -= 1;
    cout << n / k + (n % k != 0);
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: u32,
        b: u32,
    }

    println!("{}", a * b);
}


Measured memory_bytes: 2088
n, m, k = [0] * 3
mod = 998244353

def format_input(filename = None):
	global n, m, k
	if filename == None:
		n, m, k = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 2 * 10**5)
		m = rng(1, 2 * 10**5)
		k = rng(0, n - 1)
		print(n, m, k)

inv_mod = [0, 1]
fact_mod = [1, 1]
inv_fact_mod = [1, 1]
def init_fact_table(n):
	global inv_mod, fact_mod, inv_fact_mod
	for i in range(1, n):
		inv_mod.append((-inv_mod[mod % (i + 1)] * (mod // (i + 1))) % mod)
		fact_mod.append((fact_mod[-1] * (i + 1)) % mod)
		inv_fact_mod.append((inv_fact_mod[-1] * inv_mod[-1]) % mod)

def combin_mod(n, r):
	return (fact_mod[n] * inv_fact_mod[r] * inv_fact_mod[n-r]) % mod

def get_answer():
	init_fact_table(n-1)
	answer = 0
	for i in range(k+1):
		answer += ((m % mod) * pow(m-1, n-i-1, mod)) * combin_mod(n-1, i)
		answer %= mod
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 32872
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]

# from math import ceil

res = [1, 1]
for i in range(n):
    t, a = TA[i]
    # mx = max(ceil(res[0] / t), ceil(res[1] / a))
    mx = max(-(-res[0] // t), -(-res[1] // a))
    res = [t * mx, a * mx]

print(sum(res))

Measured memory_bytes: 39280
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<long long> end_pos;

bool comp(int i, int j) {
  return end_pos[i] < end_pos[j];
}

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  long long x[N];
  long long l[N];
  for (int i = 0; i < N; ++i)
    cin >> x[i] >> l[i];

  vector<long long> start_pos(N);
  end_pos.resize(N);
  vector<int> indices(N);
  for (int i = 0; i < N; ++i) {
    start_pos[i] = x[i] - l[i];
    end_pos[i] = x[i] + l[i];
    indices[i] = i;
  }

  sort(indices.begin(), indices.end(), comp);

  long long ret = 0;
  long long cur = -1000000000000;
  for (int i = 0; i < N; ++i) {
    int index = indices[i];
    if (cur <= start_pos[index]) {
      ++ret;
      cur = end_pos[index];
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a<b)
    {
        if (b<c)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int h,w,n; cin>>h>>w>>n;
	if(h<w) swap(h,w);
	int i;
	for(i=1; h*i<n; i++) {}
	cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
string s;
in pd;
in n;
VI ssz;
VI cnt;
in aps(char c, in r){
  if(n%pd==0){
    in cr=0;
    forn(i,pd)
      cr+=(s[i]==c);
    in to=0;
    forn(i,r%pd)
      to+=(s[i]==c);
    return (r/pd)*cr+to;
  }
  ssz.clear();
  cnt.clear();
  ssz.PB(pd);
  ssz.PB(n);
  in cr=0;
  forn(i,pd)
    cr+=(s[i]==c);
  cnt.PB(cr);
  for(in i=pd;i<n;++i)
    cr+=(s[i]==c);
  cnt.PB(cr);
  while(ssz.back()<=r){
    ssz.PB(ssz[sz(ssz)-1]+ssz[sz(ssz)-2]);
    cnt.PB(cnt[sz(cnt)-1]+cnt[sz(cnt)-2]);
  }
  in sm=0;
  in nxt=sz(ssz)-1;
  while(nxt>=0){
    if(r>=ssz[nxt]){
      sm+=cnt[nxt];
      r-=ssz[nxt];
    }
    --nxt;
  }
  forn(i,r)
    sm+=(s[i]==c);
  return sm;
}
VI genpref(string& p){
  if(sz(p)==0){
    return {};
  }
  if(sz(p)==1){
    return {1};
  }
  VI mmc;
  in rms=1;
  in rsz=0;
  while(rsz<sz(p)-rms && p[rsz+rms]==p[rsz])
    ++rsz;
  mmc.resize(sz(p));
  mmc[0]=sz(p);
  mmc[1]=rsz;
  for(in i=2;i<sz(p);i++){
    mmc[i]=0;
    if(i<rms+rsz){
      mmc[i]=mmc[i-rms];
      if(mmc[i]+i>=rms+rsz)
	mmc[i]=rms+rsz-i;
    }
    if(i+mmc[i]>=rms+rsz){
      rms=i;
      rsz=mmc[i];
      while(rsz<sz(p)-rms && p[rsz+rms]==p[rsz])
	++rsz;
      mmc[i]=rsz;
    }
  }
  return mmc;
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>s;
  s.resize(sz(s)/2);
  n=sz(s);
  VI v=genpref(s);
  pd=n;
  for(in i=1;i<n;++i){
    if(v[i]==n-i){
      pd=i;
      break;
    }
  }
  in l,r;
  cin>>l>>r;
  for(char c='a';c<='z';++c){
    cout<<aps(c,r)-aps(c,l-1)<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1428
func main() {
    let n = Int(readLine()!)!
    
    var streak = 0
    for _ in 0..<n {
        let inputs = readLine()!
            .split(separator: " ")
            .compactMap { Int($0)! }
        if inputs[0] == inputs[1] {
            streak += 1
        } else {
            streak = 0
        }
        if streak >= 3 {
            print("Yes")
            return
        }
    }
    print("No")
}

main()


Measured memory_bytes: 8260
#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=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOREACH(itr,a,b) for(const auto itr=a;itr!=b;itr++)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N;
	ll result=0;
	string S;
	cin>>S;
	REPD(i,SIZE(S)){
		S=S.erase(i);
		if(SIZE(S)%2==1) continue;
		ll len=SIZE(S)/2;
		string T=S.substr(0,len);
		string hT=S.substr(len,len);
		if(T==hT){
			result=i;
			break;
		}
	}
	cout << result << "\n";
	return;
}

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


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

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

  int a,b,c,k;
  cin >> a >> b >> c >> k;

  ll ans = 0;
  ll cnt = min(a,k);
  ans += cnt;
  k -= cnt;
  cnt = min(b,k);
  k -= cnt;
  cnt = min(c,k);
  ans -= cnt;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void A_task();

int main()
{
	A_task();

	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N, A, B;
	get3int(N, A, B);

	printf("%d\n", tp_min(N * A, B));
}


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

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

    bool isDancable = true;
    for (int i = 0; i < S.length(); ++i){
        char s = S[i];
        if ( (i % 2 == 0 && s == 'L') || (i % 2 == 1 && s == 'R')) isDancable = false;
    }

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

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

char buf[1002];


set<char> s;

int main(){
	scanf("%s", buf);
	int siz = strlen(buf);
	for (int i = 0; i < siz; i++){
		s.insert(buf[i]);
	}
	for (auto it = s.begin(); it != s.end(); it++){
		if ((*it) == 'E'&&s.count('W') == 0){
			puts("No");
			return 0;
		}
		if ((*it) == 'W'&&s.count('E') == 0){
			puts("No");
			return 0;
		}
		if ((*it) == 'S'&&s.count('N') == 0){
			puts("No");
			return 0;
		}
		if ((*it) == 'N'&&s.count('S') == 0){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct edge{
    int to, cap, rev;
};

struct Dinic{
    const int INF = 1e9;
    int n;
    vector<vector<edge> > g;
    VI level, iter;

    void init(int x){
        n = x;
        g.resize(n);
        level.resize(n);
        iter.resize(n);
    }

    void add_edge(int from, int to, int cap){
        g[from].push_back((edge){to, cap, (int)g[to].size()});
        g[to].push_back((edge){from, 0, (int)g[from].size() - 1});
    }

    void bfs(int s){
        fill(ALL(level), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()){
            int v = que.front();
            que.pop();
            for (edge &e : g[v]){
                if (e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f){
        if (v == t) return f;
        for (int &i = iter[v]; i < g[v].size(); i++){
            edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.to]){
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0){
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t){
        int flow = 0;
        while (1){
            bfs(s);
            if (level[t] < 0) return flow;
            fill(ALL(iter), 0);
            int f;
            while ((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }

};

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

    Dinic di;
    di.init(n);

    while (m--){
        int u, v, c;
        cin >> u >> v >> c;
        di.add_edge(u, v, c);
    }

    cout << di.max_flow(0, n-1) << endl;

    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  int h, w;
  cin >> h >> w;
  char c[h][w];
  rep (i, h) {
    rep (j, w) {
      cin >> c[i][j];
    }
  }
  rep (i, h) {
    rep (j, w) {
      cout << c[i][j];
    }
    cout << endl;
    rep (j, w) {
      cout << c[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>//cout << fixed からの cout << setprecision(n) << 小数　によって小数を整数部分含めてn桁表示できるようにする
#include <cctype>
#include <unordered_map>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
  int n,ans;
  cin >> n;
  ans = -1;
  vector<vector<int> > satis(n,vector<int>(3));
  vector<vector<int> > dp(n+1,vector<int>(3));
  /*
  dp[day][yesterday]
  day:何日目終了時？(n+1個)
  yesterday:その日何やった？(0~2)
  */
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 3;j++) cin >> satis[i][j];
  }
  for (int j = 0; j < 3;j++) dp[0][j] = 0;
  for (int j = 0; j < 3;j++) dp[1][j] = satis[0][j];
  for(int day = 2;day <= n;day++){
    for(int yesterday = 0; yesterday < 3;yesterday++){
      for(int today = 0;today < 3;today++){
        if(yesterday != today){
          dp[day][today] = max(dp[day][today],dp[day-1][yesterday] + satis[day-1][today]);
        }
      }
    }
  }
  for (int j = 0; j < 3;j++) ans = max(ans,dp[n][j]);
  cout << ans << endl;

  /*
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 3;j++)
      cout << satis[i][j] << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto &x: s) cin >> x;

  vector<vector<bool> > visited(h, vector<bool>(w));
  vector<vector<int> > flip(h, vector<int>(w));
  priority_queue<vector<int>, vector<vector<int> >, greater<vector<int> > > que;
  if (s[0][0] == '.') que.emplace(vector<int>({0, 0, 0}));
  else que.emplace(vector<int>({1, 0, 0}));
  while (!que.empty()) {
    auto now = que.top();
    que.pop();
    if (visited[now[1]][now[2]]) continue;
    visited[now[1]][now[2]] = true;
    flip[now[1]][now[2]] = now[0];
    if (now[1] < h-1) {
      if (!visited[now[1]+1][now[2]]) {
        if (s[now[1]][now[2]] == '.' && s[now[1]+1][now[2]] == '#') que.emplace(vector<int>({now[0]+1, now[1]+1, now[2]}));
        else que.emplace(vector<int>({now[0], now[1]+1, now[2]}));
      }
    }
    if (now[2] < w-1) {
      if (!visited[now[1]][now[2]+1]) {
        if (s[now[1]][now[2]] == '.' && s[now[1]][now[2]+1] == '#') que.emplace(vector<int>({now[0]+1, now[1], now[2]+1}));
        else que.emplace(vector<int>({now[0], now[1], now[2]+1}));
      }
    }
  }

  cout << flip[h-1][w-1] << endl;

  return 0;
}


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

int main()
{
	string number;
	int sum;
	
	while(1)
	{
		cin >> number;
		
		if(number == "0"){
			break;
		}
		
		sum = 0;
		for(int i = 0; i < number . size(); i++){
			sum += number[i] - '0';
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#define N 1005
#define ll long long
using namespace std;
int i, j, k;
ll t1, t2, t3;
struct cake{
	ll b, t, p;
}a[N];

bool cmp(cake x, cake y) {
	return x.b*i + x.t*j + x.p*k > y.b*i + y.t*j + y.p*k;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, m, ans = -(ll)1e10;
	cin >> n >> m;
	for(int s = 1; s <= n; s++)
		cin >> a[s].b >> a[s].t >> a[s].p;
	for(i = -1; i <= 1; i += 2) {
		for(j = -1; j <= 1; j += 2) {
			for(k = -1; k <= 1; k += 2) {
				sort(a+1, a+1+n, cmp);
				t1 = 0, t2 = 0, t3 = 0;
				for(int s = 1; s <= m; s++)
					t1 += a[s].b, t2 += a[s].t, t3 += a[s].p;
				ans = max(ans, t1*i + t2*j + t3*k);
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

char map[3010][3010];
ll dp[3010][3010];
ll MOD = 1e9 + 7;

int mx[] = {0, 1};
int my[] = {1, 0};

void dfs(int x, int y)
{

    for (int mv = 0; mv < 2; mv++)
    {
        if (map[x + mx[mv]][y + my[mv]] == '.')
        {
            dp[x + mx[mv]][y + my[mv]]++;
            dfs(x + mx[mv], y + my[mv]);
        }
    }
}

int main()
{

    int h, w;
    cin >> h;
    cin >> w;

    REP(i, h)
    {
        cin >> map[i];
    }

    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            dp[i][j] = 0;

    dp[0][0] = 1;

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (i == 0 && j == 0 || map[i][j] == '#')
                continue;
            if (i - 1 >= 0)
            {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= MOD;
            }
            if (j - 1 >= 0)
            {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 27904
N=int(input())
S=[]
for _ in range(N):
    S.append(input())
def cnt(c):
    temp=0
    for val in S:
        if val[0]==c:
            temp+=1
    return temp

lst=['M','A','R','C','H']
march=list(map(cnt, lst))

#print(march)

answer=0
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            answer+=march[i]*march[j]*march[k]
print(answer)


Measured memory_bytes: 9800
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll n;
    cin >> n;
    if(n==23){
 cout << "Christmas Eve Eve" << endl;
    }else if(n==24){
 cout << "Christmas Eve" << endl;
    }else if(n==25){
cout << "Christmas" << endl;
    }else if(n==22){
cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256