akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		
		Queue<String> que = new ArrayDeque<>();
		que.offer("3");
		que.offer("5");
		que.offer("7");
		int cnt = 0; 
		while (true) {
			String str = que.poll();
			if (Long.valueOf(str) > n) 
				break;
			if (str.indexOf("3") != -1 && str.indexOf("5") != -1 && str.indexOf("7") != -1) {
				cnt++;
			}
			que.offer(str + "3");  
			que.offer(str + "5");
			que.offer(str + "7");
			
		}
		out.println(cnt);

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for(a; a <= b; a++) {
    if(a % k == 0) {
      cout << "OK" << endl;
      break;
    }
    else if (a == b) {
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ios_base::sync_with_stdio(0);
    int n, x, i, vl = 0, ans = 0;
    cin >> n;
    map<ll, ll> a;
    while(n--) {
        cin >> x;
        ++a[x];
    }

    for (auto v : a) {
        if (v.x > v.y) {
            ans += v.y;
        } else {
            ans += v.y - v.x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6400
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int[] DN = new int[2];
        int cont = 0;
        for (String s:str.split(" ")){
            DN[cont] = Integer.parseInt(s);
            cont++;
        }
        if (DN[1]!=100){
            System.out.println((int)Math.pow(100,DN[0])*DN[1]);
        } else {
            System.out.println((int)Math.pow(100,DN[0])*(DN[1]+1));
        }
    }
}

Measured memory_bytes: 22612
import numpy as np

f = open(0)
N = int(f.readline())
xy = np.fromstring(f.read(), dtype=np.int64, sep=' ').reshape((-1, 2)).T.copy()
x = xy[0]
y = xy[1]
c1 = x + y
c2 = x - y
ans = max(c1.max() - c1.min(), c2.max() - c2.min())
print(ans)


Measured memory_bytes: 34444
s = raw_input()
l = 0
r = len(s)-1
c = 0
while l<r:
  if s[l]==s[r]:
    l += 1
    r -= 1
  elif s[l]=='x' and s[r]!='x':
    l += 1
    c += 1
  elif s[l]!='x' and s[r]=='x':
    r -= 1
    c += 1
  elif s[l]!='x' and s[r]!='x':
    print -1
    exit(0)
print c


Measured memory_bytes: 2820
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    
    let mut a : Vec<(i64, i64)> = Vec::new();
    
    for i in 0..n {
        let cnt : i64 = iter.next().unwrap().parse().unwrap();
        a.push((-cnt, i as i64));
    }
    
    a.sort();
    
    //println!("{:?}",a);
    
    for i in 0..n {
        if i as i64 == a[0].1 {
            println!("{}", -a[1].0);
        } else {
            println!("{}", -a[0].0);
        }
    }
    
}

Measured memory_bytes: 13040
x, y = map(int, input().split())
ans = 0

if x == 1:
    ans += 300000
if y == 1:
    ans += 300000
if x == 2:
    ans += 200000
if y == 2:
    ans += 200000
if x == 3:
    ans += 100000
if y == 3:
    ans += 100000
if x == 1 and y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// xor-sum2.rs --- Xor Sum 2
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Failed to parse token")
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let n = get!(usize);
    let xs = (0..n).map(|_| read()).collect::<Vec<u64>>();

    let mut xors = vec![0; n + 1];
    let mut sums = vec![0; n + 1];
    for i in 0..n {
        xors[i + 1] = xors[i] ^ xs[i];
        sums[i + 1] = sums[i] + xs[i];
    }

    let ans = (0..n)
        .map(|from| {
            let mut ok = from;
            let mut ng = n + 1;

            while ng - ok > 1 {
                let mid = (ok + ng) / 2;

                if xors[mid] ^ xors[from] == sums[mid] - sums[from] {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }

            (ok - from) as i64
        })
        .sum::<i64>();

    with_bufwriter(|mut out| writeln!(out, "{}", ans).unwrap());
}


Measured memory_bytes: 10492
#include <iostream>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	bool bad = false;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == S[i+1]) {
			bad = true;
		}
	}
	if (bad) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  ll A,B;
  cin>>A>>B;
  ll ans=A*B;
  while(B){
    A%=B;
    swap(A,B);
  }
  cout<<ans/A<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		System.out.println(a<b&&b<c?"Yes":"No");
	}
}


Measured memory_bytes: 26044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2])
  {
    cout<<"Yes"<<endl;
  }
  else if(s[1]==s[2]&&s[2]==s[3]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int a,result=0;
    cin>>a;

    FOR(i,1,a+1){
        if((int)log10(i)%2==0){
            result++;
        }
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
      cin>>n>>d;
      int a[n][d];
      for(int i=0; i < n; i++){
      for(int j=0; j < d; j++){
           cin>> a[i][j];
      }
      }
      int ans=0;
      for(int i=0;i<n;i++)
      {
        for(int j=i+1; j<n; j++)
        {  int sum = 0;
            for(int k=0; k<d; k++)
            {
                sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            int l=sqrt(sum);
            if(sum==l*l)
                ans++;
        }

      }
      cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int a, b;
	string op;
	cin >> a >> op >> b;
	if(op == "+"){
		printf("%d\n", a + b);
	}else{
		printf("%d\n", a - b);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;


int main() 
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vl A(X);
	vl B(Y);
	vl C(Z);
	rep(i, X)
		cin >> A[i];
	rep(i, Y)
		cin >> B[i];
	rep(i, Z)
		cin >> C[i];
	vl AB;
	rep(x, X) {
		rep(y, Y) {
			AB.push_back(A[x] + B[y]);
		}
	}
	sort(AB.begin(), AB.end(), greater<ll>());
	vl ABC;
	int T = min(K, X*Y);
	rep(xy, T) {
		rep(z, Z) {
			ABC.push_back(AB[xy] + C[z]);
		}
	}
	sort(ABC.begin(), ABC.end(), greater<ll>());
	rep(i, K) {
		cout << ABC[i] << endl;
	}
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	for(int i=2; i<=100; i++){
		if(A%i==0 and B%i==0 and C%i!=0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 3600
N,K = map(int,input().split())
XY = [tuple(map(int,input().split())) for i in range(N)]
xs = []
ys = []
for x,y in XY:
    xs.append(x)
    ys.append(y)
xs.sort()
ys.sort()

ans = float('inf')
for l in range(N-1):
    for r in range(l+1,N):
        w = xs[r] - xs[l]
        for d in range(N-1):
            for u in range(d+1,N):
                h = ys[u] - ys[d]
                if w*h >= ans: continue
                cnt = 0
                for x,y in XY:
                    if xs[l] <= x <= xs[r] and ys[d] <= y <= ys[u]:
                        cnt += 1
                        if cnt==K: break
                if cnt==K:
                    ans = w*h
print(ans)

Measured memory_bytes: 74784
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;




int main() {
  int N;
  cin >> N;
  vector<long long> An(N), Bn(N), Cn(N);
  REP(n,N) cin >> An.at(n);
  REP(n,N) cin >> Bn.at(n);
  REP(n,N) cin >> Cn.at(n);
  sort(An.begin(),An.end());
  sort(Bn.begin(),Bn.end());
  sort(Cn.begin(),Cn.end());

  long long ans = 0;
  long long a, b, c;
  vector<long long>::iterator position;
  long long idx_lower;

  long long k=0,l=0;
  REP(nb,N){
    b = Bn.at(nb);
    position = lower_bound(An.begin(), An.end(), b);
    idx_lower = distance(An.begin(), position);
    k = idx_lower;
    
    position = upper_bound(Cn.begin(), Cn.end(), b);
    idx_lower = distance(Cn.begin(), position);
    l = N-idx_lower;
    ans += k*l;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
import java.io.*;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			StringBuffer sb = new StringBuffer(buf);
			System.out.println(sb.reverse());
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}
}

Measured memory_bytes: 16852
# coding: utf-8

# In[5]:


import numpy as np


# In[6]:


N = int(input())
h = np.array([int(x) for x in input().split()])


# In[34]:


ans = h[0]
for i in range(1, N):
    d = h[i] - h[i-1]
    
    if d > 0:
        ans += d

print(ans)



Measured memory_bytes: 21784
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let [n,k] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n k as
  print ans

compute :: Int -> Int -> [Int] -> Int
compute n k as
  | k == 0 = amax
  | c1 <= k = 1
  | True = loop 1 amax
  where
    c1 = cutCount1 n as -- 長さ1に切り刻む回数
    amax = maximum as   -- 一度も切らないときの最大長
    loop a b
      | a+1 >= b = b
      | c > k = loop m b
      | True  = loop a m
      where
        m = div (a+b) 2
        c = cutCount m as

cutCount :: Int -> [Int] -> Int
cutCount x as = sum [div (a + x - 1) x - 1 | a <- as]

cutCount1 n as = sum as - n

-- 解説を忠実に実装

Measured memory_bytes: 19968
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int c = 0;
        for (int i = 0; i < b.length(); i++) {
            if (b.charAt(i) != a.charAt(i)) {
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 41472
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second


using namespace std;

void solve(){
    int n;
    cin >> n;
    vector<int> q(n);
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }
    vector<int> nxt(n);
    int l = n;
    for(int i = n - 1; i >= 0; i--){
        nxt[i] = l;
        if(q[i] != 0){
            l = i;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        int x = 0;
        for(int j = i; j <n;){
            sum += q[j];
            x = x^q[j];
            if(sum != x){
                ans += j - i;
                break;
            }
            j = nxt[j];
            if(j == n){
                ans += j - i;
            }
        }
    }
    cout << ans;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int test = 1;
    //freopen("output.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //cin >> test;
    while(test--){
        solve();
    }
}


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

int main(){
    int A, B; cin >> A >> B;
    bool cannot = true;
    for(int i=B*10; i<B*10+10; i++){
        int c = i*0.08;
        if(c == A){
            cout << i << endl;
            cannot = false;
            break;
        }
    }
    if(cannot) cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi p(n); rep(i, n) cin >> p[i];
	vector<vi> dp(n, vi(4, inf));
	rep(i, 4) dp[0][i] = i;
	
	rep(i, n - 1) rep(j, 4) if(dp[i][j] < inf){
		rep(k, 4){
			if(j + k < p[i]) continue;
			dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + 2 * k);
		}
	}
	int ans = inf;
	rep(i, 4) rep(j, 4){
		if(i + j < p[n - 1]) continue;
		ans = min(ans, dp[n - 1][i] + j);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3264
# coding: utf-8
# Your code here!

N, M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(M)]
L = [li[j][0] for j in range(M)]
R = [li[k][1] for k in range(M)]
ctr = 0

if min(R) - max(L) >= 0:
    print(min(R) - max(L) + 1)
else:
    print(0)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

struct data{
	llong from;
	llong to;
	llong cost;

	data(){};
	data(llong from, llong to, llong cost) :
		from(from),
		to(to),
		cost(cost)
	{}
};

llong N, M, P;
vector<data> edges;

llong BellmanFord(int start, int goal) {
	vector<llong> dis(N+1, inf);
	dis[start] = 0;

	for (int i = 0; i < 2*N; ++i) {
		for (int j = 0; j < edges.size(); ++j) {
			data edge = edges[j];
			if (dis[edge.to] > dis[edge.from] + edge.cost) {
				dis[edge.to] = dis[edge.from] + edge.cost;
				if (i >= N && edge.to == goal) return -1;
			}
		}
	}

	return -min(0ll, dis[goal]);
}

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

	llong to, from, money;
	for (int i = 0; i < M; ++i) {
		cin >> from >> to >> money;
		edges.push_back(data(from, to, -money + P));
	}

	cout << BellmanFord(1, N) << endl;

	return 0;
}

Measured memory_bytes: 576
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::abs;
int main() {
	int N;
	long long K;
	scanf("%d %lld", &N, &K);
	auto A = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", A + i);
		A[i]--;
	}
	auto vis = new int[N];
	auto pos = new int[N];
	for (int i = 0; i < N; i++)vis[i] = -1;
	int now = 0;
	vis[0] = 0;
	pos[0] = 0;
	int l = -1, s = -1;
	for (int i = 1; i <= K; i++) {
		now = A[now];
		pos[i] = now;
		if (vis[now] != -1) {
			s = vis[now];
			l = i - vis[now];
			break;
		}
		vis[now] = i;
	}
	if (l == -1) {
		printf("%d", now + 1);
	}
	else {
		int n = (K - s) % l + s;
		printf("%d", pos[n] + 1);
	}
	return 0;
}

Measured memory_bytes: 5396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        aoj solver = new aoj();
        solver.solve(1, in, out);
        out.close();
    }

    static class aoj {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long[] len = new long[3];
            while (true) {
                len[0] = in.nextLong();
                len[1] = in.nextLong();
                len[2] = in.nextLong();
                if (len[0] == 0 && len[1] == 0 && len[2] == 0) break;

                Arrays.sort(len);
                double min1 = len[0], min2 = len[1];


                int loops = in.nextInt();
                for (int i = 0; i < loops; i++) {
                    long r = in.nextLong() * 2;

                    // x^2 + y^2 < r^2
                    if (min1 * min1 + min2 * min2 < r * r) {
                        out.println("OK");
                    } else {
                        out.println("NA");
                    }
                }
            }
        }

    }
}




Measured memory_bytes: 26060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
 
int main() {
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        uint num = n, sum = 0, p;
        for (int i=0; i<n; ++i) {
            cin >> p;
            sum += p;
        }
        vector<uint> J(n-1);
        for (int i=0; i<n-1; ++i) {
            cin >> J[i];
        }
        sort(J.rbegin(), J.rend());
        uint res = sum * n;
        for (int i=0; i<n-1; ++i) {
            sum += J[i];
            -- num;
            res = max(res, sum * num);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1464
import collections
import sys

N = int(input())
*D, = map(int, input().split())
M = int(input())
*T, = map(int, input().split())

d = collections.Counter(D)
t = collections.Counter(T)

for k,v in t.items():
    if d[k] >= v:
        pass
    else:
        print('NO')
        sys.exit()
print('YES')

Measured memory_bytes: 153676
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'W') {
            cnt++;
        }
    }
    long long cnt2 = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            cnt2 += cnt;
        } else {
            cnt--;
        }
    }
    cout << cnt2 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#define nil -1
#define N 100001

typedef struct{
  int parent;
  int R_sibling;
  int L_child;
}BT;

BT bt[N];

int C_depth(int a){
  int deep = 0;
  while(bt[a].parent != nil){
    deep++;
    a = bt[a].parent;
  }
  return deep;
}

void WRU(int b){
  if(bt[b].parent == nil)printf(" root,");
  else if(bt[b].L_child == nil) printf(" leaf,");
  else printf(" internal node,");
}

void C_child(int c){
  int i;
  printf(" [");

  for(i=bt[c].L_child;i != nil;i=bt[i].R_sibling){
    if(bt[i].R_sibling == nil) printf("%d",i);
    else printf("%d, ",i);
  }

  printf("]\n");
}

int main(){
  int n,mem,ins,hol[N],num;
  int i,j;

  scanf("%d",&n);

  //必要数初期化
  for(i=0;i<n;++i){
    bt[i].parent = nil;
    bt[i].R_sibling = nil;
    bt[i].L_child = nil;
  }

  //データ入力

  for(i=0;i<n;++i){
    scanf("%d%d",&num,&mem);

    for(j=0;j<mem;++j){
      scanf("%d",&hol[j]);

      if(j==0){
	bt[num].L_child = hol[j];
	bt[bt[num].L_child].parent = num;
      }
      else {
	bt[hol[j-1]].R_sibling = hol[j];
	bt[hol[j]].parent = num;
      }
    }
  }
  for(i=0;i<n;++i){
    printf("node %d: ",i);
    printf("parent = %d, ",bt[i].parent);
    printf("depth = %d,",C_depth(i));
    WRU(i);
    C_child(i);
  }
  
 
  return 0;
}



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

int main() {

	long long int s, c;
	long long int ans;
	cin >> s >> c;

	if (s >= c / 2) {
		ans = c / 2;
	}
	else {
		c -= s * 2;
		c /= 4;
		ans = s + c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i < (int)(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;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a,b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double A = a;
  double B = b;
  double f = A / B;
  printf("%d %d %f", d, r, f);
}






Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;

int dp[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[100005];
    for(int i = 0; i < n; ++i) { cin >> a[i]; dp[i] = INF; }
    dp[0] = 0;
    for(int i = 0; i < n - 1; ++i) {
        if(i + 1 < n - 1) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
        }
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
    }

    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll N, K, A;
  cin >> N >> K;
  vector<ll> vP;
  vector<ll> vM;
  ll nZ = 0;
  for (int i=0; i<N; i++) {
    cin >> A;
    if (A < 0) {
      vM.push_back(-A);
    } else if (A == 0) {
      nZ++;
    } else {
      vP.push_back(A);
    }
  }
  sort(vM.begin(), vM.end());
  sort(vP.begin(), vP.end());
  ll nM = vM.size();
  ll nP = vP.size();
  ll num = nM * nP;
  if (K <= num) {
    ll lo = -(1LL << 61);
    ll hi = 0;
    while (lo <= hi) {
      ll mid = (lo + hi) / 2;
      ll n = 0;
      ll m = nM - 1;
      for (int i=0; i<nP; i++) {
        while (m >= 0 && - vP[i] * vM[m] <= mid) m--;
        n += nM - 1 - m;
      }
      if (n < K) lo = mid + 1;
      else hi = mid - 1;
    }
    cout << lo << endl;
    return 0;
  }
  num += nZ * (nP + nM) + nZ * (nZ - 1) / 2;
  if (K <= num) {
    cout << 0 << endl;
    return 0;
  }
  ll lo = 0;
  ll hi = 1LL << 61;
  while (lo <= hi) {
    ll mid = (lo + hi) / 2;
    ll n = 0;
    {
      ll m = nM - 1;
      for (int i=0; i<nM; i++) {
        while (m >= 0 && vM[i] * vM[m] > mid) m--;
        n += m + 1 - (m >= i);
      }
    }
    {
      ll m = nP - 1;
      for (int i=0; i<nP; i++) {
        while (m >= 0 && vP[i] * vP[m] > mid) m--;
        n += m + 1 - (m >= i);
      }
    }
    if (n / 2 < K - num) lo = mid + 1;
    else hi = mid - 1;
  }
  cout << lo << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}
/*
  RRLRL
  11111

    1
   1
    1
     1
      1
  01211
 */
int main()
{
    string s = get<string>();
    int n = s.size();
    vector<int> cnt(n);

    int nlr = -1; // index of the nearest L to the right
    int nrl = n;
    for (int i = 0; i < n; i++) {
        // cout << "i: " << i  << endl;
        // cout << "nlr: " << nlr  << endl;
        // cout << "nrl: " << nrl  << endl;
        // for (int i = 0; i < n; i++) {
        //     if (i != 0) cout << " ";
        //     cout << cnt[i];
        // }
        // cout << endl;
        if (s[i] == 'R') {
            if (nlr < i) {
                nlr = i+1;
                while (s[nlr] != 'L')
                    nlr++;
                // cout << "nlr <= " << nlr << endl;
            }
            if ((nlr - i) % 2 == 1)
                cnt[nlr-1]++;
            else
                cnt[nlr]++;
            nrl = i;
        } else if (s[i] == 'L') {
            if ((i - nrl) % 2 == 1)
                cnt[nrl+1]++;
            else
                cnt[nrl]++;
        }
    }
    for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << cnt[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
N,D=map(int,input().split())
F=[tuple(map(int,input().split())) for i in range(N)]

EDGE=[[] for i in range(2*N)]
EDGE_INV=[[] for i in range(2*N)]

# 0～N : X_i
# N+1～2N: Y_i = ￢X_i

for i in range(N):
    x1,y1=F[i]

    for j in range(i,N):
        x2,y2=F[j]

        if abs(x1-x2)<D and i!=j:
            EDGE[i].append(N+j)
            EDGE[j].append(N+i)

            EDGE_INV[N+j].append(i)
            EDGE_INV[N+i].append(j)

        if abs(x1-y2)<D:
            EDGE[i].append(j)
            EDGE[N+j].append(N+i)

            EDGE_INV[j].append(i)
            EDGE_INV[N+i].append(N+j)

        if abs(y1-x2)<D:
            EDGE[N+i].append(N+j)
            EDGE[j].append(i)

            EDGE_INV[N+j].append(N+i)
            EDGE_INV[i].append(j)

        if abs(y1-y2)<D and i!=j:
            EDGE[N+i].append(j)
            EDGE[N+j].append(i)

            EDGE_INV[j].append(N+i)
            EDGE_INV[i].append(N+j)

QUE = list(range(2*N))
check=[0]*(2*N)
TOP_SORT=[]

def dfs(x):
    if check[x]==1:
        return
    check[x]=1
    
    for to in EDGE[x]:
        if check[to]==0:
            dfs(to)

    TOP_SORT.append(x) # 全ての点からDFSを行い, 帰りがけに点を答えに入れる
    check[x]=1

while QUE:
    x=QUE.pop()
    dfs(x)

USE=[0]*(2*N)
SCC=[]

def dfs2(x):
    Q=[x]
    USE[x]=1
    ANS=[]

    while Q:
        x=Q.pop()
        ANS.append(x)
        for to in EDGE_INV[x]:
            if USE[to]==0:
                USE[to]=1
                Q.append(to)
    return ANS

for x in TOP_SORT[::-1]:
    if USE[x]==0:
        SCC.append(dfs2(x))


PLACE=[-1]*(2*N)
for i in range(len(SCC)):
    for x in SCC[i]:
        PLACE[x]=i

ANS=[-1]*N
flag=1
for i in range(N):
    if PLACE[i]==PLACE[N+i]:
        flag=0
        break
    
    elif PLACE[i]>PLACE[N+i]:
        ANS[i]=F[i][0]
    else:
        ANS[i]=F[i][1]
    
if flag==0:
    print("No")
else:
    print("Yes")
    for ans in ANS:
        print(ans)


Measured memory_bytes: 70760
#include <stdio.h>

int main(void)
{
    char s[110];
    char p[110];
    char adds[110];
    int i = 0, j = 0, k = 0, l = 0;
    int tmp;
    int count=0;
    int flag = 0;

    for (i = 0; i < 110; i++)
    {
        scanf("%c", &s[i]);
        if (s[i] == '\n')
            break;
    }
    for (j = 0; j < 110; j++)
    {
        scanf("%c", &p[j]);
        if (p[j] == '\n')
            break;
    }

    for (k = 0; k < i; k++)
    {
        if (p[l] == s[k])
        { 
            tmp=k;
            count=-1;
            while(1){
                if(p[l]==s[k]){
                    flag=1;
                    count++;
                }
                else {
                    l=0;
                    k=tmp;
                    flag=0;
                    count=0;
                    break;
                }
                if(count==j-1)break;
                l++;
                k++;
                if(k==i)k=0;
            }
        }
        if(flag==1)break;
    }

    if (flag == 1)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

int main()
{
  int A,B;
  char op;
  cin >> A >> op >> B;

  if (op == '+')
  {
    cout << A + B << endl;
  }

  if (op == '-')
  {
    cout << A - B << endl;
  }
}

Measured memory_bytes: 764
S = input()

mid = S[2:-1]
C_count = 0

for i in mid:
    if i == 'C':
        C_count += 1
        
S_lower = S.lower()
S_replace = S.replace('A', 'a').replace('C', 'c')
        
if S[0] == 'A' and C_count == 1 and S_lower == S_replace:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int d1[4] = { 0,1,0,-1 };
int d2[4] = { 1,0,-1,0 };
int main() {
	int n; cin >> n;
	rep(loooooooooooooook, n) {
		int h, w; cin >> h >> w;
		char bag[52][52]; int del[26] = {};
		int alf[26][2][2] = {};
		rep(i, 26) {
			alf[i][0][0] = alf[i][1][0] = max(h, w) + 1;
			alf[i][0][1] = alf[i][1][1] = -1;
		}
		fill(del, del + 26, 1);
		string s;
		rep(i, h) {
			cin >> s;
			rep(j, w) {
				bag[i][j]=s[j];
				if ('A' <= bag[i][j] && bag[i][j] <= 'Z') {
					del[bag[i][j] - 'A'] = 0;
					int x = s[j] - 'A';
					alf[x][0][0] = min(alf[x][0][0], i);
					alf[x][1][0] = min(alf[x][1][0], j);
					alf[x][0][1] = max(alf[x][0][1], i);
					alf[x][1][1] = max(alf[x][1][1], j);
				}
			}
		}
		bool f = true;
		while (f) {
			bool g = false;
			rep(i, 26) {
				if (del[i])continue;
				bool fg=true;
				Rep1(j, alf[i][0][0], alf[i][0][1]) {
					Rep1(k, alf[i][1][0], alf[i][1][1]) {
						char x = bag[j][k];
						if (x != 'A' + i && x != '#') {
							fg = false;
						}
					}
				}
				if (fg) {
					Rep1(j, alf[i][0][0], alf[i][0][1]) {
						Rep1(k, alf[i][1][0], alf[i][1][1]) {
							bag[j][k] = '#';
						}
					}
					del[i] = 1; g = true; break;
				}
			}
			if (!g)f = false;
		}
		f = true;
		rep(i,h) {
			rep(j, w) {
				if ('A' <= bag[i][j] && bag[i][j] <= 'Z') {
					f = false;
				}
			}
		}
		if (f) {
			cout << "SAFE" << endl;
		}
		else {
			cout << "SUSPICIOUS" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
   int X;
   cin>>X;
   int sum=0;
   for(int i=1;i<=X;i++){
      sum+=i;
      if(sum>=X){
         cout<<i<<endl;
         break;
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i,a;
  i=1;
  while(scanf("%d", &a) > 0) {
    if(a != 0) {
      printf("Case %d: %d\n",i,a);
      i++;
    }else{
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 600
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    l,r = map(int,input().split())
    A[l][r] += 1
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[N][1] = A[N][1]
for j in range(2,N+1):
    dp[N][j] = dp[N][j-1]+A[N][j]
for i in range(N-1,0,-1):
    dp[i][1] = dp[i+1][1]+A[i][1]
for i in range(N-1,0,-1):
    for j in range(2,N+1):
        dp[i][j] = A[i][j]+dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(dp[p][q])

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

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  cout << ((N *( N - 1) / 2) + (M * (M - 1) / 2)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n,m; cin >> n >> m;
    if(n>m) swap(n,m);
    if(n==1){
        if(m==1) cout << 1 << endl;
        else cout << max(0ll,m-2) << endl;
    }else if(n==2){
        cout << 0 << endl;
    }else{
        cout << (n-2)*(m-2) << endl;
    }
}



Measured memory_bytes: 256
import math
n=input()
k=int(input())
t=0
def com(a,b):
    if b>a:
        return 0
    else:
        return math.factorial(a)//(math.factorial(b)*math.factorial(a-b))
def su(n,k,i,s):
    if s==0:
        return 1
    if len(n)-i<s:
        return 0
    if n[i]=="0":
        return su(n,k,i+1,s)
    else:
        return (9**s)*(com(len(n)-i-1,s))+(int(n[i])-1)*(9**(s-1))*(com(len(n)-i-1,s-1))+su(n,k,i+1,s-1)
print(su(n,k,0,k))

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

using namespace std;

int main(void) {
	int n = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o')
			n++;
	}
	if (n + (15 - s.size()) >= 8)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

int main() {
  int a,b,N;
    cin >> a >> b;
    N = a * b % 2;
  
  if (N == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  } 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<"0";
            return 0;
        }
    }
    int p=1;
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/p){
            p*=a[i];
        }
        else{
            cout<<"-1";
            return 0;
        }
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	string x; cin >> x;
	int s = 0, ans = 0;
	for( char c : x ){
		if( c == 'S' ) ++s;
		if( c == 'T' and s > 0 ) --s, ++ans;
	}
	cout << x.size()-ans*2 << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	var l float64
	fmt.Scan(&l)
	fmt.Println((l / 3) * (l / 3) * (l / 3))
}


Measured memory_bytes: 1836
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <stack>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<vector<int>> v(n, vector<int>(n, 0));
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        v[a-1][b-1] = 1,  v[b-1][a-1] = 1;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            if(v[i][j]){
                vector<int> visited(n, 0);
                stack<int> Q;
                Q.push(0);
                while(!Q.empty()){
                    int t = Q.top(); Q.pop();
                    visited[t]++;
                    for (int k = 0; k < n; ++k) {
                        if((min(k, t) != j || max(k, t) != i)&& (!visited[k]) && (v[t][k])){
                            Q.push(k);
                        }
                    }
                }
                for (int l = 0; l < n; ++l) {
                    if(!visited[l]) {ans++; break;}
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using ll = long long;

const int MAXN = 44;
int N;
bool A[MAXN*2][MAXN*2];

ll go2(int a, int b, int c, int d);

ll dp[MAXN][MAXN][MAXN];
// inclusive range, with b chosen as special
ll go(int a, int b, int c) {
	if (dp[a][b][c] != -1) {
		return dp[a][b][c];
	}
	if (a == b && c == b) {
		return dp[a][b][c] = 1;
	} else if (a == b || c == b) {
		return dp[a][b][c] = 0;
	}

	ll ans = 0;
	for (int p1 = a; p1 <= b-1; p1++) {
		for (int p2 = b+1; p2 <= c; p2++) {
			ans += go2(a, p1, p2, c) * go(p1+1, b, p2-1);
		}
	}
	return dp[a][b][c] = ans;
}

ll dp2[MAXN][MAXN][MAXN][MAXN];
ll go2(int a, int b, int c, int d) {
	if (dp2[a][b][c][d] != -1) {
		return dp2[a][b][c][d];
	}
	if (b-a+1 == 0 && d-c+1 == 0) {
		return dp2[a][b][c][d] = 1;
	} else if (b-a+1 == 0 || d-c+1 == 0) {
		return dp2[a][b][c][d] = 0;
	}

	ll ans = 0;
	for (int x = a; x <= b; x++) {
		for (int y = c; y <= d; y++) {
			ans += A[x][y] * go(a,x,b) * go(c,y,d);
		}
	}
	return dp2[a][b][c][d] = ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N; N *= 2;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		for (int j = 0; j < N; j++) {
			A[i][j] = bool(s[j] - '0');
		}
	}
	memset(dp, -1, sizeof(dp));
	memset(dp2, -1, sizeof(dp2));
	cout << go2(0,0,1,N-1) << '\n';

	return 0;
}

Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    rep(i,6){
        if(s[i]=='1')cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  char a;
  cin >> a;
  if ('A' <= a && a <= 'Z')
  {
    cout << "A" << endl;
  }
  else
  {
    cout << "a" << endl;
  }
  return 0;
}

Measured memory_bytes: 3616