akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string S,T; cin >> S >> T;
    int ans = 0;
    rep(i,3) if(S.at(i) == T.at(i)) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
        solve();
      out.close();
  }

  private static void solve() {

      int n = sc.nextInt();
      int res = 0;
      if(n >= 400 && n < 600) {
        res = 8;
      } else if(n >= 600 && n < 800) {
        res = 7;
      } else if(n >= 800 && n < 1000) {
        res = 6;
      } else if(n >= 1000 && n < 1200) {
        res = 5;
      } else if(n >= 1200 && n < 1400) {
        res = 4;
      }
       else if(n >= 1400 && n < 1600) {
        res = 3;
      }
       else if(n >= 1600 && n < 1800) {
        res = 2;
      }
       else if(n >= 1800 && n < 2000) {
        res = 1;
      }
      out.println(res);
  }

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
 
  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }
      
      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}

Measured memory_bytes: 32940
s = list(input())

cs = set(s)
ans = 100
for c in cs:
    t = s
    while 1 < len(set(t)):
        tmp = ''
        for i in range(len(t) - 1):
            if t[i] == c or t[i + 1] == c:
                tmp += c
            else:
                tmp += t[i]
        t = tmp
    ans = min(ans, len(s) - len(t))

print(ans)

Measured memory_bytes: 41964
def examB():
    S = SI(); T = SI()
    ans = "No"
    for i in range(len(S)):
        flag = True
        for j in range(len(S)):
            if S[j-i]!=T[j]:
                flag = False
        if flag:
            ans = "Yes"
            break
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
# include <iostream>
# include <cstdlib>
# include <queue>

using namespace std;

typedef struct pp {
	string name;
	int time;
} P;

int main() {
	int n, q, time = 0;
	queue<P> que;

	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		P p;
		cin >> p.name >> p.time;
		que.push(p);
	}

	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.time <= q) {
			time += p.time;
			cout << p.name << " " << time << endl;
		} else {
			p.time -= q;
			time += q;
			que.push(p);
		}
	}

	return 0;
}

Measured memory_bytes: 4404
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long ans;
	char last;
	foreach (c; S)
	{
		if (c != last) ++ans;
		last = c;
	}
	writeln(ans-1);
	stdout.flush();
	//readln();
}

Measured memory_bytes: 2556
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


int max(int a, int b){
  if(a>=b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  char buf[1024];
  char s[10];

  fgets(buf,sizeof(buf),stdin);
  int l=strlen(buf);
  l--;

  int *a=(int *)malloc(sizeof(int)*l);

  rep(i,l){
    if(buf[i]=='A' || buf[i]=='T' || buf[i]=='G' || buf[i]=='C'){
      a[i]=1;
    }
    else{
      a[i]=0;
    }
  }

  int ans=0;
  int temp=0;
  rep(i,l){
    if(a[i]==1){
      temp++;
      ans=max(temp, ans);
    }
    else{
      temp=0;
    }
  }

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

  return 0;

}


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(){
  int r,b;
  char c;
  
  r = b = 0;
  while(cin>>c){
    c=='0'?r++:b++;
  }
  cout << MIN(r,b)*2 << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();

            s += s;

            if (s.Contains(p))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 9816
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,l] <- getIntList
    ct <- replicateM n $ do
        [c,t] <- getIntList
        return (c,t)
    let cs = map fst $ filter ((<= l) . snd) ct
    let ans | null cs = "TLE"
            | otherwise = show $ minimum cs
    putStrLn ans

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
#define all(x) x.begin(),x.end()
typedef pair<int,int>pii;
 
int p[2][200001];
int uni(int j,int i){
	return p[j][i]=p[j][i]&&p[j][i]!=i?uni(j,p[j][i]):i;
}
 
int N,KL[2];
map<pii,int>s;
 
main(){
	cin>>N>>KL[0]>>KL[1];
	for(int j=0;j<2;++j){
		for(int i=0;i<KL[j];++i){
			int a,b;
			cin>>a>>b;
			a=uni(j,a);
			b=uni(j,b);
			if(a!=b){
				p[j][a]=b;
			}
		}
	}
	for(int i=1;i<=N;++i){
		++s[(pii){uni(0,i),uni(1,i)}];
	}
	for(int i=1;i<=N;++i){
		cout<<s[(pii){p[0][i],p[1][i]}]<<(i==N?"\n":" ");
	}
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, M, K;
    cin >> N >> M >> K;
    unsigned long NN = N * N % MOD, MM = M * M % MOD;
    unsigned long d{(N * (MM * (NN - 1)) % MOD + M * (NN * (MM - 1)) % MOD) % MOD}, n{6};
    K -= 2;
    auto NM = N * M - 2;
    for(unsigned long i = 0, j = NM - K; i != K;){
        (d *= ++j) %= MOD;
        (n *= ++i) %= MOD;
    }
    auto p = MOD - 2;
    while(p){
        if(p & 1)(d *= n) %= MOD;
        (n *= n) %= MOD;
        p >>= 1;
    }
    cout << d << endl;
    return 0;
}

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

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

typedef long long ll;

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//これを使うときにはCOMinit();を忘れずに
int main(void){
    COMinit();
    int N; cin >> N;
    ll U = 1;
    ll pow10 = 1, pow8 = 1;
    rep(i, N) U = U*10 % MOD;
    rep(i, N) pow10 = pow10*10 % MOD;
    rep(i, N) pow8 = pow8*8 % MOD;
    ll uniAB = (pow10-pow8) % MOD;
    if(uniAB < 0) uniAB += MOD; //0または9がある数列の個数
    ll pow9 = 1;
    rep(i, N) pow9 = pow9*9 % MOD;
    ll A = (pow10 - pow9) % MOD;
    if(A < 0) A += MOD;
    
    ll ans = (A + A - uniAB) % MOD;
    if(ans < 0) ans += MOD;

    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 15580
# abc130_a.py
# https://atcoder.jp/contests/abc130/tasks/abc130_a

# A - Rounding /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# X,Aは 0 以上 9以下の整数です。
# Xが A 未満の時 0、A 以上の時 10を出力してください。

# 制約
#     0≤X,A≤9
#     入力は全て整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# X A

# 出力
# Xが A 未満の時 0、A 以上の時 10を出力せよ。

# 入力例 1
# 3 5

# 出力例 1
# 0

# 3は 5 未満であるので、0を出力してください。

# 入力例 2
# 7 5

# 出力例 2
# 10

# 7は 5 以上であるので、10を出力してください。

# 入力例 3
# 6 6

# 出力例 3
# 10

# 6は 6 以上であるので、10 を出力してください。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    X, A = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if X < A:
        result = 0
    else:
        result = 10

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 5']
        lines_export = [0]
    if pattern == 2:
        lines_input = ['7 5']
        lines_export = [10]
    if pattern == 3:
        lines_input = ['6 6']
        lines_export = [10]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62196
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        csf: [(usize, usize, usize); n-1],
    }
    let mut time;
    for i in 0..n - 1 {
        time = 0;
        for j in i..n - 1 {
            time = match (time < csf[j].1, time % csf[j].2 == 0) {
                (true, true) => csf[j].1,
                (false, true) => time,
                (false, false) => csf[j].2 + time - time % csf[j].2,
                _ => csf[j].1,
            };
            time += csf[j].0;
        }
        println!("{}", time)
    }
    println!("0");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,count=0;
  cin>>n>>k;  
  int m=n,l=k-n;
     
  for(int i=0;i<k-m+1;i++){  
  int a=n/1000;
  int aaf=a/10,aab=a%10;  
  int af=(n%100)/10,ab=(n%100)%10;    
    n++;
    if(aaf==ab&&aab==af){
      count++;
    }  
  }
  cout<<count<<endl;
  
  
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.valueOf(reader.readLine());
        String s = reader.readLine();

        long[][] dp = new long[count][count];
        dp[0][0] = 1;
        long modulo = 1_000_000_007;

        for (int i = 1; i < count; ++i) {
            if (s.charAt(i - 1) == '<') {
                dp[i][0] = 0;
                for (int j = 1; j <= i; ++j) {
                    dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1];
                    dp[i][j] %= modulo;
                }
            } else {
                dp[i][i] = 0;
                for (int j = i - 1; j >= 0; --j) {
                    dp[i][j] = dp[i][j + 1] + dp[i - 1][j];
                    dp[i][j] %= modulo;
                }
            }
        }

        long res = 0;
        for (int i = 0; i < count; ++i) {
            res += dp[count - 1][i];
            res %= modulo;
        }
        System.out.println(res);
    }
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

//--------------------------------------------------//

int main() {
  use_cio();
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << 0.5 * w * h << " " << (2 * x == w && 2 * y == h) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void inverse(ll n,vector<ll> &inv){
    //要素数:n+1 (0~n)
    inv[0]=1;
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=(mod-inv[mod%i]*(mod/i))%mod;
    }
}

void inverse_u(ll n,vector<ll> &inv){
    //要素数:n+1 (0~n)
    for(ll i=2;i<=n;i++){
        inv[i]=(inv[i]*inv[i-1])%mod;
    }
}

void factorial(ll n,vector<ll> &fac){
    //要素数:n+1 (0~n)
    fac[1]=1;
    for(ll i=2;i<=n;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}

ll nCr(ll n,ll r,vector<ll> &inv,vector<ll> &fac){
    return fac[n]*inv[r]%mod*inv[n-r]%mod;
}

int main(){
    ll n,m,k,ans=0,c=1; cin>>n>>m>>k;
    if(n>1){
    vector<ll> inv(n+1,0),fac(n+1,0);
    inverse(n,inv); inverse_u(n,inv);
    factorial(n,fac);
    rep(i,n-1-k) c=(c*(m-1))%mod;
    for(ll i=k;i>=0;i--){
        ll ad=c*nCr(n-1,i,inv,fac)%mod;
        ans=(ans+ad+mod)%mod;
        c=(c*(m-1))%mod;
    }
    cout<<(ans*m+mod)%mod<<endl;
    }
    else{
        cout<<m<<endl;
    }
}

Measured memory_bytes: 6340
#A
N,A,B,C,D  = map(int,input().split())
S = input()
ans = 'Yes'
if C < D:
    befA = S[A-1]
    for i in range(A,C):
        # print(i)
        if S[i] == '#' and befA =='#':
            ans = 'No'
            break
        befA = S[i]
    befB = S[B-1]
    for j in range(B,D):
        # print(j)
        if S[j] == '#' and befB == '#':
            ans = 'No'
            break
        befB = S[j]
elif D < C:
    befA = S[A-1]
    for i in range(A,C):
        # print(i)
        if S[i] == '#' and befA =='#':
            ans = 'No'
            break
        befA = S[i]
    for k in range(B-1,D):
        ans = 'No'
        if S[k-1]=='.' and S[k] == '.' and S[k+1]=='.':
            ans = 'Yes'
            break
print(ans)

Measured memory_bytes: 3572
package main

import (
	"bufio"
	"fmt"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	_, S := readLine(), readLine()

	fmt.Printf("%d\n", ABC098C(S))
}

// ABC098C ...
func ABC098C(S string) int {
	w, e := make([]int, len(S)), make([]int, len(S))

	for i := 1; i < len(S); i++ {
		if S[i-1] == 'W' {
			w[i] = w[i-1] + 1
		} else {
			w[i] = w[i-1]
		}
	}

	for i := len(S) - 2; i >= 0; i-- {
		if S[i+1] == 'E' {
			e[i] = e[i+1] + 1
		} else {
			e[i] = e[i+1]
		}
	}

	res := len(S)
	for leader := 0; leader < len(S); leader++ {
		tmp := w[leader] + e[leader]
		if tmp < res {
			res = tmp
		}
	}

	return res
}


Measured memory_bytes: 7736
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int left = 0;
	int right = Integer.parseInt(scan.next());
	int top = Integer.parseInt(scan.next());
	int bottom = 0;
	int N = Integer.parseInt(scan.next());

	for (int i = 0; i < N; i++) {
	    int x = Integer.parseInt(scan.next());
	    int y = Integer.parseInt(scan.next());
	    int a = Integer.parseInt(scan.next());
	    switch(a) {
		case 1:
		    if(x > left) left = x;
		    break;
		case 2:
		    if(x < right) right = x;
		    break;
		case 3:
		    if(y > bottom) bottom = y;
		    break;
		case 4:
		    if(y < top) top = y;
		    break;
	    }
	}

	int width = right - left;
	int height = top - bottom;
	int ans = 0;
	if(width > 0 && height > 0) ans = width * height;
	
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

static const int MAX_N = 1000 * 3;
static const ll MOD = 1e9 + 7LL;

int main()
{
    int isPrime[MAX_N];

    memset(isPrime, 0, MAX_N);

    int a, b;

    for (a = 2; a * a < MAX_N; a++) {
        if (isPrime[a] == 1) continue;
        for (b = a * a; b < MAX_N; b += a) isPrime[b] = 1;
    }

    int N;

    scanf("%d", &N);

    ll x = 1LL;

    int i, j, n;

    for (i = 2; i <= N; i++) {
        if (isPrime[i] == 0) {
            n = 1;

            for (j = i; j <= N; j *= i) n += N / j;

            x = (x * n) % MOD;
        }
    }

    printf("%lld\n", x);

    return 0;
}


Measured memory_bytes: 128
N, K = [int(_) for _ in input().split()]

scores = []
max_patterns = 0

for dice in range(1, N + 1):
    score = dice
    coin_counts = 0
    while score < K:
        score *= 2
        coin_counts += 1
    patterns = 2 ** coin_counts
    max_patterns = max(patterns, max_patterns)
    lose = patterns - 1
    win = 1
    scores.append((win, lose, patterns))

total_win = 0
total_lose = 0
for win, lose, patterns in scores:
    ratio = max_patterns // patterns
    total_win += win * ratio
    total_lose += lose * ratio

win_ratio = total_win / (total_win + total_lose)
print(win_ratio)


Measured memory_bytes: 16284
N, K = map(int, input().split())
S = input()
t = ''
if S[K - 1] == 'A':
    t = 'a'
elif S[K - 1] == 'B':
    t = 'b'
else:
    t = 'c'

print(S[:K - 1] + t + S[K:])


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/
vector<vector<string>> v(27);
int main(void)
{
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            string s;
            cin >> s;
            if (s == "snuke")
            {
                cout << (char)(j + 'A') << i + 1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations, combinations,combinations_with_replacement,product

N = int(input())

ls = ['M', 'A', 'R', 'C', 'H']
d = defaultdict(int)
ans = 0

for i in range(N):
    a = input()
    if a[0] in ls:
        d[a[0]] += 1
        
if len(d) <= 2:
    print(0)
else:
    nl = []
    for j in d.values():
        nl.append(j)
    for x in list(combinations(nl, 3)):
        sum = 1
        for y in x:
            sum *= y
        ans += sum
    print(ans)


Measured memory_bytes: 3316
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 100

typedef long long int ll;
using namespace std;


int main(){

	int m, f, r;

	while(true){
	
		scanf("%d %d %d", &m, &f, &r);
	
		if(m == -1 && f == -1 && r == -1)
			break;

		if(m == -1 || f == -1)
			printf("F\n");
		else if(m+f >= 80)
			printf("A\n");
		else if(m+f >= 65)
			printf("B\n");
		else if(m+f >= 50)
			printf("C\n");
		else if(m + f >= 30 && r >= 50)
			printf("C\n");
		else if(m+f >= 30 && r < 50)
			printf("D\n");
		else if(m + f < 30)
			printf("F\n");
	
	}

	return 0;

}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,el,head[maxn],to[maxn*2],nxt[maxn*2],dp[maxn],ans;
inline void add(int u,int v){
	to[++el]=v;nxt[el]=head[u];head[u]=el;
}
void dfs(int u,int f){
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		ans=max(ans,dp[u]+dp[v]+1);
		dp[u]=max(dp[u],dp[v]+1);
	}
}
int main(){
	n=read();
	FOR(i,1,n-1){
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	dfs(1,0);
	puts(ans%3==1?"Second":"First");
}

Measured memory_bytes: 13952
fun main(args: Array<String>) {
    a111(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a111(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    println(args[0].toCharArray().map {
        when (it) {
            '1' -> '9'
            '9' -> '1'
            else -> it
        }
    }.joinToString(separator = ""))
}


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

const int INF = INT_MAX;
const int MAX_V = 1000;
int dist[MAX_V];

typedef pair<int, int> P;

struct edge
{
    int to, cost;
};
typedef vector<vector<edge>> Graph;

vector<int> dijkstra(Graph &G, int s)
{
    vector<int> dist(G.size(), INF);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(make_pair(0, s));
    while (!pq.empty())
    {
        P t = pq.top();
        pq.pop();
        if (t.first > dist[t.second])
            continue;
        dist[t.second] = t.first;
        for (edge &e : G[t.second])
        {
            if (dist[t.second] + e.cost < dist[e.to])
            {
                pq.push(make_pair(dist[t.second] + e.cost, e.to));
            }
        }
    }
    return dist;
}

int main()
{
    int V, E, r;
    cin >> V >> E >> r;
    Graph G(V);
    for (int i = 0; i < E; ++i)
    {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back((edge){t, d});
    }
    vector<int> dist = dijkstra(G, r);
    for (int i = 0; i < (int)dist.size(); ++i)
    {
        if (dist[i] == INF)
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << dist[i] << endl;
        }
    }

    return 0;
}


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

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

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

    ll a; string s;
    cin >> a >> s;

    if(a >= 3200) cout << s <<endl;
    else cout << "red" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    cout << N * N * N << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    int right,left;
    int i,j;
    int ball[10];
    int count;

    
    scanf("%d", &N);
    
    for (i = 0; i < N; i++){
        right = left = 0;
        count = 0;
        scanf("%d", &ball[0]);
        right = ball[0];
        count++;
        for (j = 1; j < 10; j++){
            scanf(" %d", &ball[j]);
            if (right < ball[j] && ball[j] < left){
                right = ball[j];
                count++;
            }else if (left < ball[j] && ball[j] < right){
                left = ball[j];
                count++;
            }else if(right < ball[j] && left < ball[j]){
                right = ball[j];
                count++;
            }else{
                printf("NO\n");
                break;
            }
        }
        if (count == 10){
            printf("YES\n");
        }

    }

    return (0);
}


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

#define MAX		(1000000)

int main(void)
{
	char flag[MAX + 1];
	int count;
	int i, j;
	int input;
	
	memset(flag, 1, MAX);
	flag[0] = flag[1] = 0;
	for (i = 2; i <= 1001; i++) if (flag[i]) for (j = i * 2; j <= MAX; j += i) flag[j] = 0;
	
	while (scanf("%d", &input) != EOF){
		count = 0;
		for (i = 0; i <= input; i++) if (flag[i]) count++;
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {
            
            var input = Console.ReadLine().ToCharArray();
            var count_BlackStart = (input[0] == '0' ? 0 : 1);
            var count_WhiteStart = (input[0] == '1' ? 0 : 1);
            
            var bs_nextColor = '1';
            var ws_nextColor = '0';
            char t;
            
            for(int i = 1; i < input.Length; i++){
            	
            	if(input[i] != bs_nextColor){
            		count_BlackStart++;
            	}
            	if(input[i] != ws_nextColor){
            		count_WhiteStart++;
            	}
            	t = bs_nextColor;
            	bs_nextColor = ws_nextColor;
            	ws_nextColor = t;
            
            }
            
            Console.WriteLine((count_BlackStart > count_WhiteStart) ? count_WhiteStart : count_BlackStart);
            
        }
   
    }
}



Measured memory_bytes: 13176
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int h,w;
  char grid[25][25];
 int b[405][25][25];
int sx,sy;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(int t){
  queue<P> que;
  que.push(P(sx, sy));
  b[t][sx][sy]=0;
  while(que.size()){
    P p=que.front();
    que.pop();
    int nx=p.first;
    int ny=p.second;
for(int i=0;i<=3;i++){
  int nex=dx[i];
  int ney=dy[i];
  if(b[t][nx+nex][ny+ney]==-1 && grid[nx+nex][ny+ney]!='#'){
    que.push(P(nx+nex, ny+ney));
    b[t][nx+nex][ny+ney]=b[t][nx][ny]+1;
  }
}
  }
  return 0;}


int main() {

  cin>>h>>w;

  
    for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      grid[i][j]='#';
    }
  }
  
  
  
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>grid[i][j];
    }
  }
  
 
  for(int i=1;i<=h*w;i++){
    for(int j=0;j<=h+1;j++){
      for(int k=0;k<=w+1;k++){
        b[i][j][k]=-1;
      }
    }
  }
  
  int ans=0;
  int time=0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
       sx=i;
       sy=j;
      time++;
      if(grid[i][j]!='#'){
      bfs(time);}
  for(int k=1;k<=h;k++){
    for(int l=1;l<=w;l++){
         ans=max(ans,b[time][k][l]);
    }
  }
    }
  }
  
  cout<<ans<<endl;
  
  
  

}


Measured memory_bytes: 1280
n, w = map(int, input().split())
dp = [-1 for _ in range(w + 1)]
dp[0] = 0
ans = 0
for w, v in (map(int, input().split()) for _ in range(n)):
    for i in range(len(dp) - 1, w - 1, -1):
        if dp[i - w] >= 0:
            dp[i] = max(dp[i - w] + v, v, dp[i])
            ans = max(ans, dp[i])
print(ans)

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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

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

    long long n;
    cin >> n;
    
    ll count = 0;
    ll ans = 0;
    bool isPrime = true;
    if (n == 1) isPrime = false;

    for (ll i=2; i*i <= n; i++){
        if (n%i == 0){
            isPrime = false;
            while (n%i == 0){
                n /= i;
                count++;
            }
            double now = -0.5 + 0.5*(sqrt(1.0 + 8.0*(double)count));
            //cout << i << " " << count << " " << now << endl; 
            ans += (long long) now;
            count = 0;
            now = 0.0; 
        }
    }
    if (n > 1) ans += 1;
    if (!isPrime)
    cout << ans << endl;
    else cout << 1 << endl;   
    
    return 0;
}


Measured memory_bytes: 3660
W,H,N = map(int,input().split())

_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

rec = [[0 for i in range(W)] for j in range(H)]

for x,y,a in _input:
    if a == 1:
        for i in range(H):
            for j in range(x):
                rec[i][j] = 1

    elif a == 2:
        for i in range(H):
            for j in range(x,W):
                rec[i][j] = 1

    elif a == 3:
        for i in range(y):
            for j in range(W):
                rec[i][j] = 1
    
    else:
        for i in range(y,H):
            for j in range(W):
                rec[i][j] = 1

res = 0
for i in range(H):
    for j in range(W):
        if rec[i][j] == 0:
            res += 1

print(res)




Measured memory_bytes: 3188
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// カード種類数 - 取得
	int liCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liCnt);

	// カード - 取得
	long long llSum = 0;
	int liRem = 0;
	for (i = 0; i < liCnt; i++) {
		long long llCnt;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld", &llCnt);

		// 前回の余り
		if (liRem == 1) {			// あり
			if (llCnt > 0) {
				llSum++;
				llCnt--;
			}
		}

		// 同数ペア
		llSum += llCnt / 2;

		// 余り
		liRem = llCnt % 2;
	}
	
	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

#define ld long double
#define ll long long
#define ull unsigned long long
#define vll vector <ll>
#define pll pair <ll, ll>
#define vpll vector <pll>

#define f first
#define s second

#define ios ios_base::sync_with_stdio(0), cin.tie()
#define pb push_back
#define mp make_pair

#define FOR(i,n) for(ll i=0;i<n;i++)
#define FORIN(v) for(auto i:v)
#define ALL(v) (v.begin(),v.end())

#define pi 3.14159265358979323846264

using namespace std;
int in;
bool isMonth(int m)
{
    return (m<=12 && m>0);
}
int main(){
    ios;
    cin>>in;
    int fr=in/100,bk=in%100;
    if (isMonth(fr) && isMonth(bk))
        cout<<"AMBIGUOUS";
    else if (isMonth(fr))
        cout<<"MMYY";
    else if (isMonth(bk))
        cout<<"YYMM";
    else
        cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
def readinput():
    n,m=list(map(int,input().split()))
    #a=[]
    #b=[]
    ab=[]
    for _ in range(n):
        aa,bb=list(map(int,input().split()))
        #a.append(aa)
        #b.append(bb)
        ab.append((aa,bb))

    return n,m,ab

def main(n,m,ab):
    ab2=sorted(ab)
    price=0
    bought=0
    for i in range(n):
        a,b=ab2[i]
        if(bought+b>=m):
            buy=m-bought
            price+=a*buy
            return price
        bought+=b
        price+=a*b

if __name__=='__main__':
    n,m,ab=readinput()
    ans=main(n,m,ab)
    print(ans)

    

Measured memory_bytes: 23356
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

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

    vector< pair<int, int> > cord(h * w);
    rep (i, h)
    {
        rep(j, w)
        {
            if (i & 1)
            {
                cord[i * w + j] = make_pair(i + 1, w - j);
            }
            else
            {
                cord[i * w + j] = make_pair(i + 1, j + 1);
            }
        }
    }

    vector< vs32 > a(h, vs32(w));
    rep (i, h)
    {
        rep (j, w)
        {
            cin >> a[i][j];
        }
    }

    vector< string > ans;
    rep (i, cord.size())
    {
        if (a[cord[i].first - 1][cord[i].second - 1] & 1 && i + 1 < cord.size())
        {
            ans.push_back(to_string(cord[i].first) + " " + to_string(cord[i].second) +  " " + to_string(cord[i + 1].first) + " " + to_string(cord[i + 1].second));
            a[cord[i + 1].first - 1][cord[i + 1].second - 1] += 1;
        }
    }

    cout << ans.size() << "\n";
    rep (i, ans.size())
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> c(h, vector<int>(w));
  rep(i, h){
    rep(j, w){
      int a;
      cin >> a;
      c.at(i).at(j) = a;
    }
  }

  vector<tuple<int, int, int, int>> ans;
  rep(i, h){
    rep(j, w){
      if(c.at(i).at(j) % 2 != 0){
        if(j != w-1){
          ans.push_back(make_tuple(i+1, j+1, i+1, j+2));
          c.at(i).at(j+1)++;
        }else if(i != h-1){
          ans.push_back(make_tuple(i+1, j+1, i+2, j+1));
          c.at(i+1).at(j)++;
        }
      }
    }
  }

  cout << ans.size() << endl;
  for(auto t : ans){
    cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << " " << get<3>(t) << endl;
  }
  return 0;
}

Measured memory_bytes: 5232
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, R, sum;
    scanf("%d %d", &N, &R);
    if(10-N>0)
    {
        sum = R + (10-N)*100;
        printf("%d", sum );
    }
    else printf("%d", R);
    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int n,t,b;
    vector<int> a;
    t = 1;
    cin >> n;
    REP(i,n){
        cin >> b;
        a.push_back(b);
        if (a[i]%2==0) t*=2;
    }
    cout << (pow(3,n)-t);
}


Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

bool notneed[300][300];

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

  int N, a[300][300]; cin >> N;
  REP(i, N) REP(j, N) cin >> a[i][j];

  REP(k, N) REP(i, N) REP(j, N){
    if(a[i][j] > a[i][k] + a[k][j]){
      cout << -1 << endl;
      return 0;
    }
    if(a[i][j]==a[i][k]+a[k][j] and a[i][k]>0 and a[k][j]>0){
      notneed[i][j] = 1;
    }
  }

  int ans = 0;
  REP(i, N) REP(j, i+1){
    if(!notneed[i][j]) ans += a[i][j];
  }
  cout << ans << endl;

  return 0;
}

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

bool is_even(int* a, int n){
    for (int i=0; i<n; i++) {
        if (a[i] % 2 != 0) {
            return false;
        }
    }
    return true;
}

int A[210];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];

    int counter = 0;
    while(is_even(A, n)) {    
        for (int i = 0; i < n; ++i) A[i] /= 2;
        counter++;
    }

    cout << counter << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
 
public class Main {
 
    private static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        long sum = 0;
        int minimum = BIG_NUM,maximum = -BIG_NUM;
 
        try {
 
            int N = Integer.parseInt(br.readLine());
 
            String first[] = br.readLine().split("[\\s]+");
            int array[] = new int[first.length];
 
            for(int i = 0; i < first.length; i++){
 
                array[i] = Integer.parseInt(first[i]);
                minimum = Math.min(minimum, array[i]);
                maximum = Math.max(maximum, array[i]);
                sum += array[i];
            }
 
            System.out.printf("%d %d %d\n",minimum,maximum,sum);
 
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
}


Measured memory_bytes: 31696
#include<iostream>
using namespace std;
int diff(int a,int b)
{
  if (a>b)
   return(a-b);
  else
   return(b-a);
}
int min(int a,int b)
{
  if (a>b)
  return(b);
  else
  {
    return(a);
  }
  
}
int main()
{
  int n,k,i,j,y;
  long int x;
  cin>>n>>k;
  int l[n];
  for(i=0;i<n;i++)
   cin>>l[i];
  int dp[n+1];
  dp[0]=-1;
  dp[1]=0;
  dp[2]=diff(l[1],l[0]);
  for(i=3;i<n+1;i++)
  { x=10000000000;
    for(j=1;j<min(i,k+1);j++)
    {
      y=diff(l[i-1],l[i-1-j])+dp[i-j];
      if (y<x)
      x=y;
    }
    dp[i]=x;
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 4364
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    string s, t;
    cin >> s >> t;
    int res = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] != t[i])
            res++;
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
double ave(double a,double b){return (a+b)/2;}
int cmp(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}
int power(int x,int y){
  if(y==0)return 1;
  return x*power(x,y-1);}

int main(){
  int n;
  scanf("%d",&n);
  int v[n];
  int i;
  rep(i,n){
    scanf("%d",&v[i]);
  }
  qsort(v,n,sizeof(int),cmp);
  double s;
  s=ave(v[0],v[1]);
  for(i=2;i<n;i++){
    s=ave(s,v[i]);
  }
  
  printf("%f\n",s);
  return 0;
}


Measured memory_bytes: 128