akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n + 1, 1);
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
    }
    for(int i = 2; i <= n; i ++){
        if(a[i] <= a[i - 1]){
            b[i] += b[i - 1];
        }
    }
    cout << *max_element(b.begin(), b.end()) - 1 << "\n";
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let a: Vec<Vec<i32>> = read_vec2(3);
    let n: i32 = read();
    let b: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut table = [[false; 3]; 3];
    let mut yes = false;

    for (i, row) in a.iter().enumerate() {
        for (j, col) in row.iter().enumerate() {
            for v in &b {
                if v == col {
                    table[i][j] = true;
                }
            }
        }
    }

    // yoko
    for i in table.iter() {
        if i.iter().all(|&x| x) {
            yes = true;
            break;
        }
    }

    // tate
    if yes != true {
        if table[0][0] && table[1][0] && table[2][0] ||
        table[0][1] && table[1][1] && table[2][1] ||
        table[0][2] && table[1][2] && table[2][2] {
            yes = true;
        }
    }

    // naname
    if yes != true {
        if table[0][0] && table[1][1] && table[2][2] || 
        table[0][2] && table[1][1] && table[2][0] {
            yes = true;
        }
    }

    println!("{}", if yes {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import operator

N,M = map(int,readline().split())
X = list(map(int,readline().split()))
m = map(int,read().split())
ABY = list(zip(m,m,m))

# 併合を表す木を作成
# 作成可能な頂点がある
# 作成可能な頂点から降りていく -> 完成図における連結成分が分かる

def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    path = [x]
    while True:
        z = root[y]
        if y == z:
            break
        path.append(y)
        y = z
    for x in path:
        root[x] = z
    return z

V = N+M+1
root = list(range(V+1))
parent = [0] * (V+1)
cost = [0] + X + [0]*M
is_adm = [True] * (N+1) + [False] * (M+1) # 連結成分として成立している集合

for T,(a,b,y) in enumerate(sorted(ABY,key=operator.itemgetter(2)),1):
    ra = find_root(root,a)
    rb = find_root(root,b)
    # rx と ry を時刻 T （node N+T）にマージする
    v = N+T
    root[ra] = v; parent[ra] = v
    root[rb] = v; parent[rb] = v
    if ra == rb:
        cost[v] = cost[ra]
    else:
        cost[v] = cost[ra] + cost[rb]
    is_adm[v] = (cost[v] >= y)
# 時刻 M+1 に、全部の根をマージ
for x in range(1,V):
    if not parent[x]:
        parent[x] = V

# 親が成立していたら、自分も成立
for v in range(V-1,-1,-1):
    if is_adm[parent[v]]:
        is_adm[v] = True

answer = M - sum(is_adm[N+1:N+M+1])
print(answer)

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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] L = Console.ReadLine().Split(' ');
		int A = int.Parse(L[0]);
		int B = int.Parse(L[1]);
		int C = int.Parse(L[2]);
		int D = int.Parse(L[3]);

		//必要な攻撃回数
		int attack1 = C / B;
		if(C % B != 0){
				attack1 ++;
		}
		int attack2 = A / D;
		if(A % D != 0){
				attack2 ++;
		}

		//攻撃回数を比較
		//高橋の攻撃回数が多い場合
		if(attack1 > attack2){
				Console.WriteLine("No");
		}
		//同じ場合、先攻の高橋が有利
		//高橋の攻撃回数が少ない場合も同様
		else{
				Console.WriteLine("Yes");
		}

	}
}



Measured memory_bytes: 17856
# frozen_string_literal: true

n = gets.to_i
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
t = 0

a.zip(b).sort_by { |_, b| b }.each do |a, b|
  t += a
  if t > b
    puts :No
    exit
  end
end

puts :Yes

Measured memory_bytes: 31608
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char a[10][10];
int main() {
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
      cin>>A[i];
    }
    int count=0;
    for(int i=0;i<N;i++){
      while(i+1<N&&A[i]==A[i+1]){i++;}
      if(i+1<N&&A[i+1]>A[i]){while(i+1<N&&A[i]<=A[i+1]){i++;}}
      else if(i+1<N&&A[i+1]<A[i]){while(i+1<N&&A[i]>=A[i+1]){i++;}}
      count++;
    }
    cout<<count<<endl;
return 0;}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

bool Solve() {
  int H, W, N;
  cin >> H >> W >> N;

  using P = pair<int, int>;
  P s;
  cin >> s.first >> s.second;

  string S, T;
  cin >> S >> T;

  P h(1, W), v(1, H);
  for (int i = N - 1; 0 <= i; --i) {
    if (T[i] == 'U')
      v.second = min(H, v.second + 1);
    else if (T[i] == 'D')
      v.first = max(1LL, v.first - 1);
    else if (T[i] == 'L')
      h.second = min(W, h.second + 1);
    else if (T[i] == 'R')
      h.first = max(1LL, h.first - 1);

    if (S[i] == 'U')
      ++v.first;
    else if (S[i] == 'D')
      --v.second;
    else if (S[i] == 'L')
      ++h.first;
    else if (S[i] == 'R')
      --h.second;

    if (h.second < h.first || v.second < v.first) return false;
  }

  bool can_stay = (v.first <= s.first && s.first <= v.second) && (h.first <= s.second && s.second <= h.second);

  return can_stay;
}

signed main() {
  if (Solve())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    vector<ll> a(3);
    rep(i, 3) cin >> a[i];
    ll k = 0;
    while(true)
    {
        rep(i, 3){
            if(a[i]%2) ANS(k);
        }
        vector<ll> t(3);
        rep(i, 3)
        {
            rep(j, 3){
                if(i != j) t[j] += a[i]/2;
            }
        } //printv(t);
        if(a == t) ANS(-1);
        k++;
        a = t;
    }
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> graph(n);
    vector<ll> iri(n,0);
    for(i = 0;i < n+m-1;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        graph.at(a).push_back(b);
        ++iri.at(b);
    }
    queue<ll> que;
    vector<ll> vdis(n,-1);
    ll top;
    for(i = 0;i < n;++i){
        if(iri.at(i) == 0){
            top = i;
            break;
        }
    }
    vdis.at(top) = 0;
    que.emplace(top);
    while(!que.empty()){
        ll now = que.front();
        que.pop();
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i);
            if(iri.at(next) > 1){
                --iri.at(next);
            }else{
                vdis.at(next) = now+1;
                que.emplace(next);
            }
        }
    }
    for(i = 0;i < n;++i){
        cout << vdis.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
package main
 
import (
	"fmt"
)
 
func main() {
  var n int
  var x int
  var l []int
  fmt.Scan(&n)
  fmt.Scan(&x)
  for i := 0; i < n; i ++ {
    var tmpL int
    fmt.Scan(&tmpL)
    l = append(l, tmpL)
  }
  
  var tmpSum int
  var rs int
  for i, v := range l {
    tmpSum += v
    if i >= n {
      rs = n
      break
    }
    if tmpSum <= x {
      rs = i + 2
    } else if tmpSum > x {
    	break
    }
  }
	fmt.Println(rs)
}

Measured memory_bytes: 512
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())

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

    work.sort(key=lambda x: x[1])
    now = 0
    for a, b in work:
        now += a
        if now > b:
            print("No")
            return

    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 32664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
void testCase() {
    int n, k;
    cin >> n >> k;
    vector <int> price;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;
        price.push_back (p);
    }
    sort (price.begin(), price.end());
    ll ans = 0;
    for (int i=0; i<k; i++)
        ans += price[i];
    cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N ;

        if (N > 999)
        {
                cout << "ABD" << endl;
        }
        else 
        {
                cout << "ABC" << endl;
        }


        return 0;
}


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

int main() {
	
	long int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k < a) {
    cout << k << endl;
  }else if(k <= a + b) {
    cout << a << endl;
  } else {
    cout << 2 * a + b - k << endl;
  }



}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t;
    scanf("%lld",&t);
    long long ans=0;
    ans=100000;
    while(t)
    {
        long long p=t%1000;
        if(abs(p-753)<ans) ans=abs(p-753);
        t/=10;
    }
    printf("%lld\n",ans);
}


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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 1) {
        cout << "No"<<endl;
    } else {
        string s1 = s.substr(0, n / 2);
        string s2 = s.substr(n / 2, n / 2);
        if (s1 == s2) {
            cout << "Yes"<<endl;
        } else {
            cout << "No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

cnt = 0
flag = True
while flag:
    flag = False
    for i in reversed(range(1, N)):
        if A[i] < A[i - 1]:
            A[i], A[i - 1] = A[i - 1], A[i]
            cnt += 1
            flag = True

print(*A)
print(cnt)


Measured memory_bytes: 5616
#include <iostream>

constexpr int MAXN = 100;
int V[MAXN][MAXN];
int D[MAXN];
int F[MAXN];

template<int STACK_SIZE, typename T = int>
class Stack {

public:
    Stack() {};

    void Push(T val) {
        if (top_ < STACK_SIZE) {
            stack_[top_++] = val;
        }else{
            std::cerr << "Stack over flow..." << std::endl;
            exit(-11);
        }
    };
    bool Pop() {
        if (top_ > 0) {
            stack_[--top_];
            return true;
        }
        return false;
    };

    T Top() {
        return stack_[top_ - 1];
    }

    int Size() {return top_;}


private:
    int max_size_ = STACK_SIZE;
    int top_ = 0;
    T stack_[STACK_SIZE];
};

Stack<MAXN, int> S;

int main() {

    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }
    int cnt = 0;
    for (int t = 0; t < n; t++) {
        if (D[t] == 0) {
            D[t] = ++cnt;
            S.Push(t);
            while (S.Size()) {
                for (int i = 0; i < n; i++) {
                    if ((V[S.Top()][i] == 1) && (D[i] == 0)) {
                        S.Push(i);
                        D[i] = ++cnt;
                        break;
                    }
                    if (i == n - 1) {
                        F[S.Top()] = ++cnt;
                        S.Pop();
                    }
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        std::cout << i + 1 << " " << D[i] << " " << F[i] << std::endl;
    }

}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T";
  }
  if(b=="T"){
    cout<<"A";
  }
  if(b=="C"){
    cout<<"G";
  }
  if(b=="G"){
    cout<<"C";
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int T; cin >> T;
	for (int t = 1; t <= T;t++) {
		vector<ll> C(9);
		for (int i = 0; i < 9;i++) cin >> hex >> C[i];
		ll key = 0LL;
		for (int i = 0; i < 32;i++) {
			ll sum = 0LL;
			for (int j = 0; j < 8;j++) {
				sum += (C[j] ^ key);
			}
			ll C_sum = (sum& ((1LL << (i + 1)) - 1));
			ll C9 = ((C[8] ^ key) & ((1LL << (i + 1)) - 1));
			if (C_sum != C9) key = (key | (1LL << i));
		}
		cout << hex << key << endl;
	}
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		double r = sc.nextDouble();

		System.out.print(String.format("%.6f", r * r * Math.PI) + " ");
		System.out.println(String.format("%.6f", 2 * r * Math.PI));

	}

}



Measured memory_bytes: 28344
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  int N, M;
  cin >> N >> M;
  
  int L[M+1], R[M+1];
  for (int i = 1; i <= M; i++) {
    int l, r;
    cin >> l >> r;
    
    L[i] = l;
    R[i] = r;
  }

  int maxL = 0, minR = INT_MAX;
  for (int i = 1; i <= M; i++) {
    maxL = max(maxL, L[i]);
    minR = min(minR, R[i]);
  }

  cout << max(minR-maxL+1,0) << endl;  

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] v = new int[30];

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			rec(N, 0, N);
		}
	}

	static void rec(int rest, int pos, int prev) {
		if (rest == 0) {
			for (int i = 0; i < pos; ++i) {
				System.out.print(v[i]);
				if (i != pos - 1) System.out.print(' ');
			}
			System.out.println();
			return;
		}
		for (int i = Math.min(rest, prev); i > 0; --i) {
			v[pos] = i;
			rec(rest - i, pos + 1, i);
		}
	}

}

Measured memory_bytes: 12000
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	int m,n; scanf("%d%d",&m,&n);
	int cnt[20]={};
	rep(i,m) rep(j,n) {
		int a; scanf("%d",&a);
		cnt[i]+=a;
	}

	printf("%d\n",*max_element(cnt,cnt+m));

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    bool flag=true;
    for (int i = 0; i < s.size() -1 ; i++)    
        if (s[i] == s[i + 1])
            flag = false;

    if (flag)
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;cin>>N;
  ll A[N],ans=0;
  FOR(i,0,N)cin>>A[i];
  // check
  if(A[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  FOR(i,0,N-1){
    if(A[i+1]>=A[i]+2){
      cout<<-1<<endl;
      return 0;
    }
    if(A[i+1]==A[i]+1) ans++;
    else if(A[i+1] <= A[i]) ans += A[i+1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int f(int x) {
    return x*x;
}
 
int main(int argc, char** argv) {
    int d;
    while(cin >> d) {
        int s = 0;
        for(int i=d; i<600; i+=d) {
            s += f(i)*d;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3016
import java.util.*;

class Main {
	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> map = new TreeMap<>();
		
		int N = sc.nextInt();
		int max = 0;
		
		for (int i=0; i<N; i++) {
			String S = sc.next();
			if (map.containsKey(S)) {
				int tmp = map.get(S) + 1;
				map.put(S, tmp);
				max = Math.max(max, tmp);
			} else {
				map.put(S, 1);
				max = Math.max(max, 1);
			}
		}
		for (String key : map.keySet()) {
			if (max == map.get(key)) {
				System.out.println(key);
			}
		}
	}
}

Measured memory_bytes: 83636
#include <bits/stdc++.h>
#define ll long long
#define INF (ll) 1e9+7
#define maxn 200009
#define MOD 1000000007
#define inp freeopen("input.txt","r",stdin);
#define out freeopne("output.txt","w",stdout);
using namespace std; 
int main(){
    ios::sync_with_stdio(false);
    double a,b,t;
    cin>>a>>b>>t;
    t+=0.5;
    ll ans =0;
    ll tact=1;
    int cont=1;
    while(a*cont<t){
        ans+=b;
        cont++;
    }
    cout<<ans<<endl;
    return 0;
}   

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

typedef long long ll;

int main() {
    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    rep(i, D) N *= 100;
    cout << N << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;


int main() {
    ll n;
    cin >> n;
    cout << n*n << endl;
    


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<utility>
#include<string>

using namespace std;

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

int main(void) {
	int h, w;
	int total = 0;
	int x, y;
	int deep[50][50] = {};
	string s[51];
	queue< pair<int, int> > que;

	cin >> h >> w;

	total = h * w;

	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				total--;
			}
		}
	}

	que.push(make_pair(0, 0));
	deep[0][0] = 1;

	while (!que.empty()) {
		y = que.front().first;
		x = que.front().second;
		que.pop();

		for (int i = 0; i <= 3; i++) {
			if ((x + dx[i] >= 0) && (x + dx[i] < w) && (y + dy[i] >= 0) && (y + dy[i] < h)) {
				if (s[y + dy[i]][x + dx[i]] == '.') {
					if (deep[y + dy[i]][x + dx[i]] == 0) {
						que.push(make_pair(y + dy[i], x + dx[i]));
						deep[y + dy[i]][x + dx[i]] = deep[y][x] + 1;
					}
				}
			}
		}
	}

	if (deep[h - 1][w - 1] == 0) {
		cout << -1 << endl;
	}
	else {
		cout << total - deep[h - 1][w - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long a = scanner.nextLong();
        final long b = scanner.nextLong();
        final long c = scanner.nextLong();
        final long d = scanner.nextLong();
        final long lcd = getLCD(c, d);

        if (a == b) {
            System.out.println(0);
            return;
        }

        final long divideAC = (a - 1) / c;
        final long divideBC = b / c;
        final long divideAD = (a - 1) / d;
        final long divideBD = b / d;
        final long divideACD = (a - 1) / lcd;
        final long divideBCD = b / lcd;

        final long dDivivable = divideBD - divideAD;
        final long cDivivable = divideBC - divideAC;
        final long cdDivaivable = divideBCD - divideACD;

        System.out.println(b - a + 1 - (dDivivable + cDivivable - cdDivaivable));
    }

    private static long getLCD(final long a, final long b) {
        return a * b / gcd(a, b);
    }

    private static long gcd(final long m, final long n) {
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	auto cnt = [](string s, int n) {
		int a[26] = {}, b[26] = {}, cnt = 0;
		for (int i = 0; i < n; ++i)
			++a[s[i] - 'a'];
		for (int i = n; i < s.size(); ++i)
			++b[s[i] - 'a'];
		for (int i = 0; i < 26; ++i)
			if (a[i] && b[i])
				++cnt;
		return cnt;
	};
	int N; string S;
	cin >> N >> S;
	int m = 0;
	for (int i = 0; i < S.size(); ++i)
		m = max(m, cnt(S, i));
	out(m);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> B(N);
  REP(i, N) cin >> B[i];


  // dp[i][j]: 集合iを使ったとき, 最後がjの時の最小移動
  const int MAX = 55;
  vector<vector<int>> dp((1<<N), vector<int>(MAX, INF));
  dp[0][0] = 0;

  REP(i, (1<<N)){
    int c = __builtin_popcount(i);

    vector<pair<int, int>> ords;
    int iter = c;
    REP(k, N){
      if((i >> k)&1) continue;
      ords.emplace_back(k, iter++);
    }

    REP(j, MAX){
      if(dp[i][j] >= INF) continue;

      for(auto p : ords){
        int nextj;
        if(abs(p.first-c)%2 == 0) nextj = A[p.first];
        else nextj = B[p.first];

        if(j > nextj) continue;
        chmin(dp[i | (1 << p.first)][nextj], dp[i][j]+abs(p.second-c));
      }
    }
  }

  int ans = INF;
  REP(j, MAX){
    chmin(ans, dp[(1<<N)-1][j]);
  }

  if(ans == INF) ans = -1;
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 121216
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main() {
    int n;
    cin >> n;
    
    map<int, bool> dic;
    vector<int> a(n);
    int tmp;
    rep(i, n) {
        cin >> tmp;
        a[i] = tmp;
        dic[tmp] = false;
    }

    rep(i, n) {
        tmp = a[i];
        if (!dic[tmp]) {
            dic[tmp] = true;
        } else {
            dic[tmp] = false;
        }
    }

    int cnt = 0;
    repv(v, dic) {
        if (v.second) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(){
  long long n,min=1000001,max=-1000001,sum=0,i;
  scanf("%lld",&n);
  long long data[n];
  for(i=0;i<n;i++){
    scanf("%lld",&data[i]);
  }
  
  i = 0;
  max = data[0];
  for(i=1;i<n;i++){
    if(max<data[i]){
      max = data[i];
    }
  }
  i = 0;
  min = data[0];
  for(i=1;i<n;i++){
    if(min>data[i]){
      min = data[i];
    }
  }
  for(i=0;i<n;i++) sum = sum + data[i];

  printf("%lld %lld %lld\n",min,max,sum);

  return 0;
}

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

int main(){
    int n,k;
    string s;
    cin>>n>>s>>k;

    char check = s[k-1];

    for(int i=0;i<s.size();i++){
        if(s[i]!=check){
            s[i] = '*';
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import collections

N, M = map(int,input().split())

A = list(map(int,input().split()))
A.sort()
op = [0]*M

for i in range(M):
    b,c = map(int,input().split())
    op[i] = (c, b)

op.sort(reverse=True)

now = 0
flag = False
for i in range(M):
    if flag:
        break
    val, maisu = op[i]
    if now >= N:
        break
    if A[now] < val:
        for j in range(maisu):
            if now+j < N:
                if A[now+j] < val:
                    A[now+j] = val
                else:
                    flag = True
                    break
        now += maisu 
    else:
        break
    
print(sum(A))

Measured memory_bytes: 27044
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,s=1;
    cin>>a>>b>>c>>d;
    if(b>a)
    {
        cout<<a*c;return 0;
    }
    else
    {
        cout<<((b*c)+((a-b)*d));return 0;
    }
    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;

const int MAX = 510000;
const int MOD = 1000000007;

long long 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 mulmod(ll a, ll b){
    return (a*b) % MOD;
}

int main(void){
    COMinit();
    int N, K; cin >> N >> K;
    for(int i = 1; i <= K; i++){
        if(N-K < i-1){
            cout << 0 << endl;
            continue;
        }
        ll ans;
        ans = mulmod(fac[K-1], fac[N-K+1]);
        ans = mulmod(ans, finv[K-i]);
        ans = mulmod(ans, finv[i-1]);
        ans = mulmod(ans, finv[N-K-i+1]);
        ans = mulmod(ans, finv[i]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int c;
typedef long long ll;
ll a[100005];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    ll A;
    cin >> A;
    if(A < 0ll) c++;
    a[i] = abs(A);
  }
  sort(a,a+n);
  ll s = 0;
  if(c % 2) {
    for(int i = 0; i < n; i++) s += a[i];
    cout << s - a[0] * 2 << endl;
  }
  else {
    for(int i = 0; i < n; i++) s += a[i];
    cout << s << endl;
  }
}
    
  
  


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC137
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            for(int i = s[1]-s[0]+1;i<=s[1]+s[0]-1;i++){
                if(i!=s[1]+s[0]-1){
                    Write("{0} ",i);
                }else{
                    WriteLine(i);
                }

            }


        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
   int r; cin >> r;
   cout <<3*r*r<<endl;
        
    return 0;
}


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n;
ll k;
ll a[252521];
ll b[252521]; // for za-atu
ll bit[252521]; // for fenwick-tree

// fenwick tree max size is n
ll sum(int x){
  ll ret = 0;
  while(x>0){
    ret += bit[x];
    x -= x&-x;
  }
  return ret;
}
void add(int x,ll v){
  while(x<=n){
    bit[x] += v;
    x += x&-x;
  }
}

int main(){
  scanf("%d%lld",&n,&k);
  REP(i,n)scanf("%lld",a+i+1);
  REP(i,n)a[i+1] += a[i] - k;
  n++;

  // za-atu
  REP(i,n)b[i] = a[i];
  sort(b,b+n);
  int m = unique(b,b+n) - b;
  REP(i,n)a[i] = lower_bound(b,b+m,a[i])-b+1;

  // fenwick tree
  ll ans = 0;
  REP(i,n){
    ans += sum(a[i]);
    add(a[i], 1);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < s.length; i++) {
            if(s[i] == '1') {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35724
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

void dfs(vvi& g,vl &ans, vl &cnt, int v, int p, ll sum) {
	sum += cnt[v];
	ans[v] = sum;
	REP(i, g[v].size()) {
		if (g[v][i] != p) {
			dfs(g, ans, cnt, g[v][i], v, sum);
		}
	}

}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vvi g(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		
	}
	vl cnt(n);
	REP(i, q) {
		int p,x;
		cin >>p>> x;
		p--;
		cnt[p] += x;
	}
	vl ans(n);
	dfs(g, ans, cnt, 0, -1, 0);
	REP(i, n) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 32128
INF = float('inf')

V, E = map(int, input().split())
A = [[INF] * V for _ in range(V)]

for i in range(V):
    A[i][i] = 0

for _ in range(E):
    s, t, d = map(int, input().split())
    A[s][t] = d

for k in range(V):
    for i in range(V):
        if A[i][k] == INF:
            continue
        for j in range(V):
            if A[k][j] == INF:
                continue
            A[i][j] = min(A[i][j], A[i][k] + A[k][j])

negative = False
for i in range(V):
    if A[i][i] < 0:
        negative = True

if negative:
    print('NEGATIVE CYCLE')
else:
    for i in range(V):
        ans_row = []
        for j in range(V):
            if A[i][j] == INF:
                ans_row.append('INF')
            else:
                ans_row.append(A[i][j])
        print(*ans_row)



Measured memory_bytes: 6284
n = int(input())
dp =[[0]*3 for _ in range(n)]
dp[0] = list(map(int,input().split()))
for i in range(1,n):
  a,b,c=map(int,input().split())
  dp[i][0] = a + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = b + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = c + max(dp[i-1][0],dp[i-1][1])
print(max(dp[n-1]))

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

using namespace std;

const int N = 1e2+7;

long long a, b, k;

int main()
{
    cin >> a >> b >> k;
    long long c = min(a, k);
    a -= c;
    k -= c;
    c = min(b, k);
    b -= c;
    cout << a << " " << b << endl;
    return 0;
}



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

#define ll long long int
#define LD long double

const int N = 100010;

int inf = 1e9;
int mod = 1e9 + 7;

signed main()
{
    //freopen("IN.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    pair<int,int> p[n + 1];
    for(int i = 1; i <= n; i++) {
        int x; cin >> x;
        p[i].first = x; p[i].second = i;
    }

    sort(p + 1, p + n + 1);

    for(int i = 1; i <= n; i++) {
        cout << p[i].second << " ";
    }


    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> m){
        int ans = 0;
        if (n <= 3) ans += 100000 * (4 - n);
        if (m <= 3) ans += 100000 * (4 - m);
        if (n == 1 && m == 1) ans += 400000;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int mx=max(a, max(b,c));
    int mn=min(a, min(b,c));
    int md=a+b+c-mx-mn;
    int x=mx-md,y=mx-mn;
    cout << ((y-x+1)/2+(y-x)%2+x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    string s;
    cin >> s;
    bool isEasy = true;
    for(int i=0; i < s.size(); i += 2){
        if(s.at(i) == 'L') isEasy = false;
    }
    for(int i=1; i < s.size(); i += 2){
        if(s.at(i) == 'R') isEasy = false;
    }
    cout << (isEasy ? "Yes" : "No" ) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int w, h, x, y;

  cin >> w >> h >> x >> y;


  printf("%.8lf %d\n", 1.0  * w * h /2, 2*x == w && 2*y == h ? 1 : 0);



  return 0;
}


Measured memory_bytes: 256
def main():
    ans_list = list(map(int, input().split()))
    # print(ans_list)
    if (ans_list[0] % 2) != 0 and (ans_list[1] % 2) != 0:
        print("Odd")
    else:
        print("Even")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#Nはノード数、Mはエッジ数
N, M = map(int, input().split())

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


#再帰関数、ここが難しいかもしれない。
def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1

    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)

    visited[now] = False

    return total_paths

print(dfs(0, 0))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            solve(writer, reader);
        }
    }

    private static void solve(PrintWriter writer, InputReader reader) throws IOException {
        int[] ints = reader.readIntsSplitByDelimiter(" ");
        writer.println(ints[0] - ints[1] + 1);
        writer.flush();
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 20692