akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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 solve(n: usize, p: Vec<u32>) -> usize {
  // indexes[num] is index of num in p
  let mut indexes = vec![0; n + 1];
  // prevs[i] is the previous non-calculated index of i
  let mut prevs: Vec<_> = (0..n + 2).map(|n| if n == 0 { 0 } else {n - 1}).collect();
  // nexts[i] is the next non-calculated index of i
  let mut nexts: Vec<_> = (0..n + 2).map(|n| n + 1).collect();

  prevs[n + 1] = n;
  nexts[0] = 1;

  for i in 0..n {
    indexes[p[i] as usize] = i + 1;
  }

  let mut ans = 0;
  for num in 1..n {
    let index = indexes[num];
    // prev is the previous index
    let prev = prevs[index];
    // next is the next index
    let next = nexts[index];

    // count with some conditions
    if 0 < prev { // number bigger than num is in nexts
      ans += num * (prev - prevs[prev]) * (next - index);
    }
    // number bigger than num is in prevs
    if next != n + 1 {
      ans += num * (index - prev) * (nexts[next] - next);
    }

    // concat prev and next to mark as calculated
    nexts[prev] = next;
    prevs[next] = prev;
  }
  ans
}

fn main() {
  input! {
    n: usize,
    p: [u32; n]
  };

  println!("{}", solve(n, p));
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    string s,t;cin>>s>>t;
    if(s+t[t.size()-1]==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  int ans = 0;
  for(int i = 0; i < n; i++) cin >> v.at(i);
  for(int i = 0; i < n; i++) cin >> c.at(i);
  for(int i = 0; i < n; i++) ans = max(ans, ans+(v.at(i)-c.at(i)));
  cout << ans;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair

vector<pll> uft; //where weight

pll search(ll w){
    if(uft[w].F==w){return {w,0};}
    pll k=search(uft[w].F);
    uft[w].F=k.F; uft[w].S+=k.S;
    return uft[w];
}


int main(){
    ll n,m;
    cin>>n>>m;
    uft.resize(n);
    for(int i=0;i<n;i++){
        uft[i].F=i;
    }
    bool j=true;
    for(int i=0;i<m;i++){
        ll l,r,d;
        cin>>l>>r>>d;
        pll a=search(l),b=search(r);
        if(a.F==b.F && a.S-b.S!=d){j=false; break;}
        uft[a.F]={b.F,d-a.S+b.S};
    }
    cout<<(j?"Yes":"No")<<endl;
    
    
    return 0;
}

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

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 100010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/

int H[MAX];
vector <int> adj[MAX];

int main()
{
    // in;
    int n, m, a, b;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> H[i];
    while(m--){
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int good = 0;
    for(int i = 1; i <= n; i++){
        bool ok = true;
        for(auto x: adj[i]){
            if(H[x] >= H[i])
            {
                ok = false;
                break;
            }
        }
        good += ok;
    }
    cout << good;
    return 0;
}


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

using namespace std;

int main(void){
  int A, B;
  string S;
  cin >> A >> B >> S;
  for(int i = 0; i < A; i++){
    if(S[i] < '0' || '9' < S[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(S[A] != '-'){
    cout << "No" << endl;
    return 0;
  }
  for(int i = A + 1; i < A + B + 1; i++){
    if(S[i] < '0' || '9' < S[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskT {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int count = 0;
            
        	int num_friends = in.nextInt();
        	int min_height = in.nextInt();
        	
        	for(int i = 0; i< num_friends; i++){
        		int curr_height = in.nextInt();
        		if(curr_height >= min_height)
        			count ++;
        	}
        	
        	System.out.print(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if((a+b == c)||(a+c == b)||(b+c == a)){
    printf("Yes\n");
  }
  else printf("No\n");
  
  return 0;
}

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

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


// 素因数分解 pair
vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

//  二項係数の計算nCk セット
//  https://drken1215.hatenablog.com/entry/2018/06/08/210000
//  使い方としては、最初に一度前処理として COMinit() をしておけば、あとは COM(n, k) 関数を呼べばよい
//  前処理 COMinit(): O(n)
//　クエリ処理 COM(n, k): O(1)
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*

 *
 * */

int main() {

    ll A,B,N;
    cin >> A >> B >> N;

    ll x = B-1;

    if(x > N){
        x = N;
    }

    ll ans = (ll)(A*x)/B - (ll)A * (x/B);
    cout << ans  << endl;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#define fastio ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define ict int t; cin >> t
#define lct ll t; cin >> t;
#define in(a) int a; cin >> a
#define ln(a) ll a; cin >> a
#define loop(i,n) for (ll i = 0; i < n; ++i) 
#define looprev(i,n) for (ll i=n-1; i>=0 ; --i)
#define LOOP(i,k,n) for (ll i = k; i <= n; ++i) 
#define LOOPREV(i,k,n) for (ll i = k; i >= n; --i) 
#define mp make_pair 
#define pa pair <ll,ll>
#define vec vector<ll>
#define vecpa vector<pa>
#define vec2D vector <ll<ll>>
#define que queue<ll>
#define deq deque<ll> 
#define stk stack<ll>
#define iterate vector<ll>::iterator
#define pub push_back
#define pob pop_back
#define pof pop_front
#define puf push_front
#define emp emplace_back
#define all(a) a.begin(),a.end();

using namespace std;

void solve(){
    string s;
    cin >> s;
    ll sum = 0;
    for(int i = 0; i<s.length(); i++){
        sum+= s[i] - '0';
    }
    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    fastio;
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e7;

int main() {
    int n; cin >> n;
    map<int,int> ct;
    rep(i,n-1) {
        int x; cin >> x;
        ct[x]++;
    }
    rep(i,n) cout << ct[i+1] << endl;
}

Measured memory_bytes: 12972
a = list(input())
n = len(a)
count = 0
for i in range(0,n,2):
    if a[i] == 'R' or a[i] == 'U' or a[i] == 'D':
        count += 1
for j in range(1,n,2):
    if a[j] == 'L' or a[j] == 'U' or a[j] == 'D':
        count += 1
if count == n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define DEBUG

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define ALL(v) v.begin(), v.end()

int main(){
    string X;
    cin>>X;
    
    int Y=stoi(X.substr(0,4));
    int M=stoi(X.substr(5,7));
    int D=stoi(X.substr(8,10));
    if(Y<2019){
        cout<<"Heisei";return 0;
    }else if(Y>2019){
        cout<<"TBD";return 0;
    }else{
        if(M<=4){
            cout<<"Heisei";return 0;
        }else if(M>4){
            cout<<"TBD";return 0;
        }
    }
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


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

int n;
ll ecut(int from, int to)
{
    if (to - from <= 1)
        return -1;

    int s = from + 1, t = to, mid;
    ll target = (a[to] + a[from]) / 2;
    while (s != t)
    {
        mid = (s + t) / 2;
        if (a[mid] == target)
            s = t = mid;
        else if(a[mid] > target)
            t = mid;
        else
            s = mid + 1;
    }

    ll ans = a[to];
    rep(i, 3)
    {
        int p = s - 1 + i;
        if (p <= from or p > to) continue;
        ll cand = max(a[p] - a[from], a[to] - a[p]);
        ans = min(ans, cand);
    }
    return ans;
}

int main()
{
    cin >> n;
    rep(i,n)
    {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }

    ll ans = a[n];
    rep(i, n + 1)
    {
        ll c1 = ecut(0, i);
        ll c2 = ecut(i, n);
        if (c1 == -1 or c2 == -1) continue;

        ll cand = max(c1, c2) - min(a[i] - c1, a[n] - a[i] - c2);
        ans = min(ans, cand);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll sum = 0;
    for(ll i=n-1;i>=0;i--)
    {
        if(i%2==0)
        {
            sum+=a[i];
        }
        else
            sum-=a[i];
    }
    
    cout<<sum<<" ";
    for(ll i=1;i<n;i++)
    {
        sum = 2*a[i-1] - sum;
        cout<<sum<<" ";
    }
	return 0;
}

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

c_ac = 0
c_wa = 0
c_tle = 0
c_re = 0

for i in range(n):
    s = input()
    if s == "AC":
        c_ac += 1
    elif s == "WA":
        c_wa += 1
    elif s == "TLE":
        c_tle += 1
    else:
        c_re += 1

print("AC x", c_ac)
print("WA x", c_wa)
print("TLE x", c_tle)
print("RE x", c_re)



Measured memory_bytes: 69924
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  Vi a(n),l(n-1),r(n-1);
  rep(i,0,n) cin >> a[i];
  int sum0=0,sumn=0;
  rep(i,0,n-1){
    sum0 += a[i];
    l[i] = sum0;
    sumn += a[n-1-i];
    r[n-2-i] = sumn;
  }
  int ans = INF;
  rep(i,0,n-1){
    ans = min(ans,abs(l[i]-r[i]));
    //cout<<l[i]<<' '<<r[i]<<endl;
  }
  cout << ans << endl;
  return 0;
}


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

l = list(map(int, input().split())
         )

if 1 not in l:
    print(-1)
else:
    ans = 0
    now = 1
    for i in range(n):
        if l[i] != now:
            ans += 1
        else:
            now += 1
    print(ans)


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int a,b;cin>>a>>b;
	cout<<max(0,a-2*b)<<endl;
}

Measured memory_bytes: 256
import java.io.*;
 
public class Main {
 
public static void main(String[] args) throws IOException {
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 String line;
 
while ((line = br.readLine()) != null) {
 
String[] data = line.split(" ");
 double[] d = new double[data.length];
 
for (int i = 0; i < d.length; i++) {
 d[i] = Double.parseDouble(data[i]);
 }
 
double x = (d[2] * d[4] - d[5] * d[1]) / (d[0] * d[4] - d[3] * d[1]),
 y = (d[0] * d[5] - d[3] * d[2]) / (d[0] * d[4] - d[3] * d[1]);
 
x = Math.round(x * 1000) / (double) 1000;
 y = Math.round(y * 1000) / (double) 1000;
 
System.out.printf("%.3f %.3f\n", x, y);
 }
 }
 }

Measured memory_bytes: 17040
def solve(a,n,mn,mx):
	ans=0
	V=[False]*n
	b=sorted(a)
	T=[0]*(mx+1)
	for i in range(n): T[b[i]]=i
	for i in range(n):
		if V[i]: continue
		cur=i
		sum=0
		cnt=0
		m=1<<30
		while True:
			V[cur]=True
			v=a[cur]
			cnt+=1
			sum+=v
			m=min(m,v)
			cur=T[v]
			if V[cur]: break
		ans+=min(sum+(cnt-2)*m,sum+m+(cnt+1)*mn)
	return ans

n=int(input())
a=list(map(int,input().split()))
mn=1<<30
mx=mn*-1
for i in range(n):
	mn=min(mn,a[i])
	mx=max(mx,a[i])
print(solve(a,n,mn,mx))



Measured memory_bytes: 5776
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k=0,ans=0;
    cin >> n;
    string a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    string x;
    cin >> x;
    for(int i=0;i<n;i++){
        if(a[i]==x) k = i;
    } 
    for(int i=k+1;i<n;i++) ans += b[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
x1, y1, x2, y2 = map(float, input().split())
if x1 > x2:
    if y1 > y2:
        print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))
    else:
        print(math.sqrt((x1 - x2) ** 2 + (y2 - y1) ** 2))
else:
    if y1 > y2:
        print(math.sqrt((x2 - x1) ** 2 + (y1 - y2) ** 2))
    else:
        print(math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))


Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecveci seen(10,veci(10));
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int H,W;
bool ok = true;

void dfs(vector<string> &G, int y, int x) {
    seen[y][x] = 1;
    bool go = false;
    REP(dir,4) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
        if(seen[ny][nx] || G[ny][nx] == '.') continue;
        if(dir == 0 || dir == 1) ok = false;
        go = true;
        //cout << y << "->" << ny << " " << x << "->" << nx << endl;
        dfs(G,ny,nx);
    }
    //cout << y << " " << x << " " << go << endl;
    if(!go) {
        if(y < H-1 || x < W-1) ok = false;
    }
}

int main() {
    cin >> H >> W;
    vector<string> G(H);
    REP(i,H) cin >> G[i];
    dfs(G,0,0);
    cout << (ok ? "Possible" : "Impossible") << endl; 
}

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

int main(){
    int N;
    std::string S;

    std::cin >> N;
    std::cin >> S;

    std::string tmp;
    std::string tmp2;

    bool iteration_flag = false;

    if (N % 2 != 1){
        tmp = S.substr(0,N/2);
        tmp2 = S.substr(N/2);
        if (tmp == tmp2){
            iteration_flag = true;
        }
    }   

    if (iteration_flag == true){
        std::cout << "Yes";
    }else{
        std::cout << "No";

    }
    return 0;
}

Measured memory_bytes: 256
n = input()
p = list(map(int,input().split()))

cnt = 0

for i in range(1,int(n)-1):
  if (p[i-1] < p[i]) and (p[i] < p[i+1]):
    cnt += 1
  elif (p[i-1] > p[i]) and (p[i] > p[i+1]):
    cnt += 1
    
print(cnt)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, x, t; cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << '\n';
  return 0;
}


Measured memory_bytes: 3604
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIR1(n): return [LI1() 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)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    AB = LIR1(N-1)

    g = [[] for _ in range(N)]
    visited = [False] * N
    ins = [-1] * N

    for a, b in AB:
        g[a].append(b)
        g[b].append(a)

    q = deque()
    visited[0] = True
    q.append(0)

    while q:
        u = q.popleft()
        outs_num = 0
        visited[u] = True

        for v in g[u]:
            if not visited[v]:
                if outs_num == ins[u]:
                    outs_num += 1

                ins[v] = outs_num

                outs_num += 1
                q.append(v)

    print(max(ins) + 1)
    for a, b in AB:
        print(ins[b] + 1)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 108392
# coding: utf-8
import sys


def main(argv=sys.argv):

    a, b, c, d = map(int, input().split(' '))

    if (a + b) == (c + d):
        print('Balanced')
    elif (a + b) > (c + d):
        print('Left')
    elif (a + b) < (c + d):
        print('Right')

    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim().Split(' ').Select(n => int.Parse(n)).ToArray();
            int H = line[0];
            int A = line[1];
            int count = 0;
            while (H > 0)
            {
                H = H - A;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11348
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
 
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  ll n,m,ans;  cin >> n >> m;
  vll x(m);
  rep0(i,m){
    cin >> x[i];
  }
  
  if(n >= m){
    ans = 0;
  }else{
    sort(all(x));
    vll distance(m);
    rep1(i,m-1){
      distance[i-1] = x[i] - x[i-1];
    }
    sort(all(distance),greater<ll>());
    ans = x[m-1]-x[0];
    rep0(i,n-1){
      ans -= distance[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ch = sc.nextInt()-1;
		int cw = sc.nextInt()-1;
		int dh = sc.nextInt()-1;
		int dw = sc.nextInt()-1;
		char[][] grid = new char[h][w];
		for(int i = 0; i < h; i++){
			grid[i] = sc.next().toCharArray();
		}
		/*
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				System.out.print(grid[i][j]);
			}
			System.out.println();
		}
		*/
		
		// 計算
		long result = 0;
		int INF = 1001001001;
		int[][] dist = new int[h][w];
		for(int i = 0; i < h; i++){
		    Arrays.fill(dist[i], INF);
		}
		dist[ch][cw] = 0;
		ArrayDeque<int[]> q = new ArrayDeque<int[]>();
		q.addFirst(new int[]{ch, cw});
		int[] dx = {-1, 0, 1, -1, 1, -1, 0, 1, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; 
		int[] dy = {-1, -1, -1, 0, 0, 1, 1, 1, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2};
		while(!q.isEmpty()){
		    int[] p = q.pollFirst();
    		int i = p[0];
    		int j = p[1];
		    int now = dist[i][j];
    		for(int k = 0; k < dx.length; k++){
    		    int ni = i + dx[k];
    		    int nj = j + dy[k];
    		    int c = 1;
    		    if(abs(dx[k]) + abs(dy[k]) == 1) c = 0;
    		    if(0 <= ni && ni < h && 0 <= nj && nj < w){
    		        if(grid[ni][nj] == '.'){
    		            if(now + c < dist[ni][nj]){
    		                dist[ni][nj] = now + c;
    		                if(c == 0){
    		                    q.addFirst(new int[]{ni, nj});
    		                }else{
    		                    q.addLast(new int[]{ni, nj});
    		                }
    		            }
    		        }
    			}
    		}
		}
		
		if(dist[dh][dw] == INF){
		    result = -1;
		}else{
		    result = dist[dh][dw];
		}
		//System.out.println(Arrays.toString(dist));
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 50716
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B,C,X,Y = map(int,input().split())

ans = 0

Z = min(X,Y)
if A+B >= C*2:
    ans = min(C*Z*2 + A*(X-Z) + B*(Y-Z), C*max(X,Y)*2)
else:
    ans = A*X + B*Y

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
//const int MOD = 1000000007;
const int MOD = 998244353;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll modinv(ll x, ll n){
    return modpow(x, n - 2);
}

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

    ll ans = 0;

    COMinit();
    rep(i, k+1){
        ans += COM(n-1, n-i-1) * ((m * modpow(m-1, n-i-1))%MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15496
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int n=read(),m=read();
	if(n>m) swap(n,m);
	if(n==1){
		if(m==1) printf("1\n");
		else printf("%d\n",m-2);
	}
	else{
		printf("%lld\n",1ll*(n-2)*(m-2));
	}
	return 0;
}


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

int main()
{
	char s[11];
	scanf("%s", s);
	if (s[0] != 'A')
	{
		printf("WA");
		return 0;
	}
	int len = strlen(s);
	// printf("%d", len);
	int count = 0;
	int i = 1;
	while (s[i])
	{
		if (i >= 2 && i <= len - 2)
		{
			if (s[i] == 'C')
				count++;
			if (s[i] != 'C' && s[i] >= 'A' && s[i] <= 'Z')
			{
				printf("WA");
				return 0;
			}
		}
		else if (s[i] >= 'A' && s[i] <= 'Z')
		{
			printf("WA");
			return 0;
		}
		i++;
	}
	if (count == 1)
		printf("AC");
	else
		printf("WA");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
        #define ll  long long
        #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define rep(i,a,b)  for(ll i=a;i<b;i++)
        #define pb push_back
        #define Max(x,y,z) max(x,max(y,z))
        #define f first
        #define s second
        #define lbd lower_bound
        #define sz(x)       (ll)x.size()
        #define pi 3.1415926536
        #define mod 1000000007
        #define MOD 998244353
        #define val 1.00000000
        #define INF INT_MAX
        using namespace std;
        /*const int N=2e5+5;
        bool vis[N];*/
        void solve()
        {
            ll n,m,l=0,r=0,z,sum1=0,cnt1=0,ha,a,b,c,d,x,y;
            cin>>n;
            ll ans=0;
            rep(i,1,n+1)
            {   ll cnt=0;
                x=i;
                //cout<<"hello";
                while(x)
                {
                    cnt++;
                    x=x/10;
                    //cout<<"h";
                }
                //cout<<cnt<<" ";
                if(cnt%2==1) ans++;
            }
            cout<<ans;
            
        }        
    int main()
        {   
            /*#ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif*/
     
            ll t=1;
            //cin>>t;
            while(t--)
                solve();
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {

    ll n;
    cin>>n;
    ll c=0,max=0;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        if(a==b)
        {
            c++;
        }
        else if(a!=b && c<3)
        c=0;
    }
    if(c>=3)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

}


Measured memory_bytes: 3632
# ABC062b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

h, w = map(int, input().split())
a = [input().replace('\n', '') for _ in range(h)]

print('#' * (w + 2))
for line in a:
    print('#', end='')
    print(line, end='')
    print('#')
print('#' * (w + 2))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, A[100010];
map<int, int> m;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        m[A[i]-1]++;
        m[A[i]]++;
        m[A[i]+1]++;
    }

    int ans = 0;
    auto itr = m.begin();
    while(itr != m.end()){
        ans = max(ans, (*itr).second);
        itr++;
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 5120
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //all_shop_num
        int f[][] = new int[n][10]; //shop_num 0or1
        int p[][] = new int[n][11]; //profits

        for(int i=0; i<n; i++){
            for(int j=0; j<10; j++){
                f[i][j] = sc.nextInt();
            }
        }
        for(int i=0; i<n; i++){
            for(int j=0; j<11; j++){
                p[i][j] = sc.nextInt();
            }
        }
        long ans =-1_000_000_000;
        for(int i=1; i<(1 << 10); i++){
            long benefits = 0;
            for(int j = 0; j<n; j++){
                int cnt = 0;
                for(int k = 0; k< 10; k++){
                    if((i >> k & 1)==1 && f[j][k]==1)
                        cnt++;
                }
                benefits += p[j][cnt];
            }
            ans = Math.max(ans, benefits);
        }
        System.out.println(ans);

    }
    
}

Measured memory_bytes: 26124
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pii pair<int, int>
int main()
{
    char ch;
    stack<int> si;
    stack<pii> spii;
    int sum = 0;
    for (int i = 0; cin >> ch; i++)
    {
        if (ch == '\\')
        {
            si.push(i);
        }
        else if (ch == '/' && si.size() > 0)
        {
            int j = si.top();
            si.pop();
            sum += i - j;
            int a = i - j;
            while (spii.size() > 0 && spii.top().first > j)
            {
                a += spii.top().second;
                spii.pop();
            }
            spii.push(make_pair(j, a));
        }
    }
    vector<int> vi;
    while (spii.size() > 0)
    {
        vi.push_back(spii.top().second);
        spii.pop();
    }
    reverse(vi.begin(), vi.end());
    cout << sum << endl;
    cout << vi.size();
    for (int i = 0; i < vi.size(); i++)
    {
        cout << " ";
        cout << vi[i];
    }
    cout << endl;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define maxn 3050

using namespace std;
typedef double db;
db dp[maxn][maxn],p[maxn];
int n;
int main(){
    cin >> n;
    for (int i=0;i<n;i++) cin >> p[i];
    dp[0][0]=1;
    for (int i=0;i<n;i++)
    for (int j=0;j<=i;j++){
        dp[i+1][j]+=dp[i][j]*(1-p[i]);
        dp[i+1][j+1]+=dp[i][j]*p[i];
    }
    db ans=0;
    for (int i=n/2+1;i<=n;i++) ans+=dp[n][i];
    printf("%.14f\n",ans);
}


Measured memory_bytes: 70272
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", max({a + b, a - b, a * b}));
        return 0;
}



Measured memory_bytes: 256
W,H,N=gets.chomp.split(" ").map(&:to_i)

count = 0
now_pos = gets.chomp.split(" ").map(&:to_i)
(N-1).times do
    next_pos = gets.chomp.split(" ").map(&:to_i)
    x_diff = now_pos[0] - next_pos[0]
    y_diff = now_pos[1] - next_pos[1]
    x_diff_abs = x_diff.abs
    y_diff_abs = y_diff.abs
    count = count + x_diff_abs + y_diff_abs
    if x_diff * y_diff > 0
        count = count - (x_diff_abs < y_diff_abs ? x_diff_abs : y_diff_abs)
    end
    now_pos = next_pos
end
puts count



Measured memory_bytes: 6872
#include <stdio.h>
//箱の番号は―１
//赤ボール１個の時：１
//赤ボール２個の時:２
struct Box_t
{
	int sum;
	bool  WB;
	bool  RB;
};
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	Box_t Box[100000];
	for (int i = 1; i < N; i++){
		Box[i].RB = false;
		Box[i].WB = 1;
		Box[i].sum = 1;

	}
	Box[0].RB = 1;
	Box[0].sum = 1;
	Box[0].WB = false;
	for (int i = 0; i < M; i++){
		int before, after;
		scanf("%d %d",&before,&after);
		before -= 1;
		after -= 1;
		if (Box[before].RB){
			Box[after].RB = true;
			if (Box[before].sum == 1){
				Box[before].RB = false;
			}
		}
		Box[after].sum++;
		Box[before].sum--;
	}
	int answer = 0;
	for (int i = 0; i < N; i++){
		if (Box[i].RB){
			answer++;
		}
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a=0,b=0,c=0,d=0;
  while(n--)
  {
    string s;
    cin>>s;
    if(s.compare("AC")==0)
    {
      a++;
    }
    else  if(s.compare("WA")==0)
    {
      b++;
    }
    else
       if(s.compare("TLE")==0)
    {
      c++;
    }else
          if(s.compare("RE")==0)
    {
      d++;
    }
  }
  cout<<"AC "<<"x "<<a<<"\n";
  cout<<"WA "<<"x "<<b<<"\n";
  cout<<"TLE "<<"x "<<c<<"\n";
  cout<<"RE "<<"x "<<d<<"\n";
  return 0;
}
  

Measured memory_bytes: 3636
// B - Christmas Eve Eve
// https://atcoder.jp/contests/abc115/tasks/abc115_b
// +build ignore

package main

import (
	"fmt"
)

func main() {
	var n, tmp, ans int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
		ans += p[i]
		if p[i] > tmp {
			tmp = p[i]
		}
	}
	ans = ans - (tmp / 2)
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}

int main(void){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = b-a+1;
	//cで割り切れる1以上の個数
	ans -= b/c - (a-1)/c;
	ans -= b/d - (a-1)/d;
	ans += b/(c*d/gcd(c,d)) - (a-1)/(c*d/gcd(c,d));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int cnt[4] = {};
    rep(i, 6) {
        int a;
        cin >> a;
        cnt[a - 1]++;
    }
    sort(cnt, cnt + 4, greater<int>());
    //rep(i, 4) cout << i << " " << cnt[i] << endl;
    if (cnt[0] == 2 && cnt[1] == 2 && cnt[2] == 1) {
        cout << "YES" << endl; 
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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))
//-------------------------------------------------------


string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int ma=0;
	for(i=1;i*2<S.size();i++) {
		if(S.substr(0,i)==S.substr(i,i)) ma=i*2;
	}
	cout<<ma<<endl;
}


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: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int MOD = (int)1e9 + 7;
int add(int x, int y)
{
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y)
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y)
{
	return ((ll)x * y) % MOD;
}
int bin_pow(int x, int p)
{
	if (p == 0) return 1;
	if (p == 2 || (p & 1)) return mult(x, bin_pow(x, p - 1));
	return bin_pow(bin_pow(x, p / 2), 2);
}
int rev(int x)
{
	return bin_pow(x, MOD - 2);
}

const int N = 200100;
const int K = 4010;
const int Z = 2002;
int n;
int a[N][2];
int C[K][K];
ll b[K];
int f[2 * K], rf[2 * K];
int ans = 0;

void init()
{
	f[0] = 1;
	for (int i = 1; i < 2 * K; i++)
		f[i] = mult(f[i - 1], i);
	rf[2 * K - 1] = rev(f[2 * K - 1]);
	for (int i = 2 * K - 1; i > 0; i--)
		rf[i - 1] = mult(rf[i], i);

	
	for (int i = 0; i < K; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < K; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);

	return;
}

void read()
{
/*	
	n = 200000;
	for (int i = 0; i < n; i++)
		a[i][0] = a[i][1] = 2000;
	*/
	
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 2; j++)
			scanf("%d", &a[i][j]);
	

	return;
}

void solve(int x, int y)
{
	/*
	for (int i = -x; i <= y; i++)
		b[Z - i] = add(b[Z - i], C[x + y][x + i]);
	*/
	
	for (int i = -x; i <= y; i++)
		b[Z - i] += C[x + y][x + i];
	
	return;
}

int getC(int n, int k)
{
	return mult(f[n], mult(rf[k], rf[n - k]));
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	init();

	read();

	for (int i = 0; i < n; i++)
		solve(a[i][0], a[i][1]);

	for (int i = -Z; i <= Z; i++)
		b[Z + i] %= MOD;

	for (int i = -Z; i <= Z; i++)
		ans = add(ans, mult(b[Z + i], b[Z - i]));

	for (int i = 0; i < n; i++)
		ans = sub(ans, getC(2 * (a[i][0] + a[i][1]), 2 * a[i][0]));

	if (ans & 1) ans += MOD;
	ans /= 2;

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 47360
import numpy as np
import sys

input = sys.stdin.readline

H,W = map(int,input().split())

a = []
for _ in range(H):
    x = input()
    a.append(x)

for _ in range(W+2):
    print('#',end="")
print("")

for i in range(H):
    print('#',end="")
    print('{}'.format(a[i][:len(a[i])-1]),end="")
    print('#')

for _ in range(W+2):
    print('#',end="")
print("")

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
int N;
int d[13]={};
int ans=0;

int min_judge(vector<int> v){
  int mn=99999;
  for(int i=0;i<v.size();i++){
    //cout<<v[i]<<" ";
    for(int j=i+1;j<v.size();j++){
      int val=min(abs(v[i]-v[j]),abs(24-abs(v[i]-v[j])));
      mn=min(val,mn);
    }
  }//cout<<endl;
  //cout<<mn<<endl;
  return mn;
}

void dfs(int i,vector<int> v){
  if(i==13){
    int val= min_judge(v);
    ans=max(val,ans);
    return ;
  }

  if(i==0){
    if(d[i]==1)v.push_back(i);
    dfs(i+1,v);
  }else if(i==12){
    if(d[i]==1)v.push_back(i);
    dfs(i+1,v);
  }else if(d[i]==2){
    v.push_back(i);
    v.push_back(24-i);
    dfs(i+1,v);
  }else if(d[i]==1){
    vector<int> v2=v;
    v.push_back(i);
    v2.push_back(24-i);
    dfs(i+1,v);
    dfs(i+1,v2);
  }else{
    dfs(i+1,v);
  }
  return;
}

int main(){
  cin>>N;
  d[0]++;
  for(int i=0;i<N;i++){
    int val;
    cin>>val;
    d[val]++;
  }

  for(int i=1;i<=12;i++){
    if(d[0]>=2||d[12]>=2||d[i]>=3){
      cout<<0<<endl;
      return 0;
    }
  }
  vector<int> v;
  dfs(0,v);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define MOD 998244353

void solve()
{
double n,m,sum=0,maxi=-1;
cin>>n>>m;
std::vector<double> v;
rep(i,n)
{
	double x;
	cin>>x;
	v.pb(x);
	sum+=x;
}
double c=0;
double val=sum/(4*m);

rep(i,n)
{
	if(v[i]>=val)
		c++;
}
if(c<m)
	cout<<"No\n";
else
	cout<<"Yes\n";
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int T;
	// cin >> T;
	T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3788