akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
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,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:i64, m:i64};
    let ans:i64 = min(n, m/2);
    let n = n - ans;
    let m = m - ans*2;
    //debug!(n,m);

    println!("{}", ans + m/4);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,X,K,Y,p[200005],sum[200005]={};
string S[55];
double res=0;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>K;
    for(long long int i = 1; i <= N; i++){
        cin>>p[i];
        p[i]++;
    }
    
    for(long long int i = 1; i <= N; i++){
        sum[i]+=sum[i-1]+p[i];
    }
    for(long long int i = 1; i <= N-K+1; i++){
        res=max(res,(double)(sum[i+K-1]-sum[i-1]));
    }
    cout<<res/2.0<<endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> v;
    v.push_back(a * c);
    v.push_back(a * d);
    v.push_back(b * c);
    v.push_back(b * d);
    cout << *max_element(v.begin(), v.end()) << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define maxn 200086

using namespace std;

int n;
vector<int> v[maxn];
int x, y;
int dia;

int dfs(int i, int fa){
	int mx = 0;
	for(int j = 0;j < v[i].size();j++){
		int to = v[i][j];
		if(to == fa) continue;
		int x = dfs(to, i);
		dia = max(dia, mx + x);
		mx = max(mx, x);
	}
	return mx + 1;
}

int main(){
	scanf("%d", &n);
	for(int i = 1;i < n;i++){
		scanf("%d%d", &x, &y);
		v[x].push_back(y), v[y].push_back(x);
	}
	dfs(1, 0);
	printf((dia - 1) % 3 ? "First" : "Second");
}

Measured memory_bytes: 23548
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque

N, M = map(int, input().split())
G = [[] for i in range(N)]
P = [-2] * N
deg_in = [0] * N


def bfs(s):
    P[s] = -1
    q = deque()
    q.append(s)

    while len(q):
        u = q.popleft()
        for v in G[u]:
            deg_in[v] -= 1
            if deg_in[v] == 0:
                P[v] = u
                q.append(v)


def main():
    for i in range(N+M-1):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        deg_in[b-1] += 1

    root = -1
    for i in range(N):
        if not deg_in[i]:
            root = i
            break

    bfs(root)

    for i in range(N):
        print(P[i]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63904
K = int(input())
import math
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        value = math.gcd(i,j)
        for k in range(1, K+1):
            sum += math.gcd(value,k)

print(sum)
# print(gcd(2,6))


Measured memory_bytes: 9116
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
					/*多倍長整数/cpp_intで宣言
					#include <boost/multiprecision/cpp_int.hpp>
					using namespace boost::multiprecision;
					*/

					//#pragma GCC target ("avx2")
					//#pragma GCC optimization ("O3")
					//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	string s, t;
	scans(s); scans(t);
	int ans = 0, start = s.length();
	rep(i, s.length()) {
		if (s.substr(i, n).find(t.substr(0, n - i)) != string::npos) {
			start = i;
			break;
		}
	}
	printf("%d\n", max(start + (int)t.length(), n));

	Please AC;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='L'){
			cout<<"No\n";
			return 0;
		}
	}
	for(int i=1;i<s.size();i+=2){
		if(s[i]=='R'){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	

	return 0;
}

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

int main()
{
  string s;
  cin>>s;
  int stack[100000],top=-1,count=0;
  if(s[0]=='0')
    stack[++top]=0;
  else stack[++top]=1;
  for(int i=1;i<s.length();i++)
  {
    if(stack[top]==0 and s[i]=='1' and top>=0)
    { top--;
     count+=2;}
    else if (stack[top]==1 and s[i]=='0' and top>=0)
    {  top--;
     count+=2;}
    else stack[++top]=s[i]-48;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 896
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N = int(input())


def DFS(s):
    if int(s) > N:
        return 0

    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0

    for c in '753':
        ret += DFS(s + c)
    return ret


print(DFS('0'))


Measured memory_bytes: 3060
// header {{{
// header {{{
using namespace std;
#include <bits/stdc++.h>
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y
 
#define ASSERT(expr...) assert((expr))
 
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;
 
#define M5 100007
#define M9 1000000000
 
// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}
 
template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}
 
template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key)
{
}
 
int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;
 
        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }
 
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}
 
bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}
 
int toInt(char a)
{
    return a - '0';
}
 
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
 
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
 
void solve()
{
    ll R;
    cin >> R;
    cout << R * 2 * PI;
}
 
signed main()
{
 
    solve();
 
    return 0;
}

Measured memory_bytes: 3780
#include<cstdio>
#include<cstring>
#include<algorithm>
int m[100010];
int main()
{
    int n,a;
    while(~scanf("%d",&n))
    {
        memset(m,0,sizeof(m));
        int t=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a);
            m[a]++;
            m[a-1]++;
            m[a+1]++;
            if(t<m[a])
                t=m[a];
            if(t<m[a-1])
                t=m[a-1];
            if(t<m[a+1])
                t=m[a+1];
        }
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
struct Line{
  Point p1,p2;
  Line(){}
  Line(Point p1, Point p2):p1(p1),p2(p2){}
};
int ccw(Point a,Point b,Point c){
  Point t1=b-a,t2=c-a;
  if(t1.det(t2)> eps) return 1;//counter clockwise
  if(t1.det(t2)< -eps) return -1;//clockwise
  if(t1.dot(t2)< -eps) return 2;//c-a-b online
  if(t1.norm()<t2.norm()) return -2;//a-b-c online
  return 0;//a-c-b online
}
bool intersectSS(Point a,Point b,Point c,Point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
bool intersectSS(Line l1,Line l2){
  return intersectSS(l1.p1,l1.p2,l2.p1,l2.p2);
}
bool isOrthogonal(Point a,Point b){
  return fabs(a.dot(b))<eps;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Point a,Point b){
  return fabs(a.det(b))<eps;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
Point CrossPoint(Line l1,Line l2){
    double a=(l1.p2-l1.p1).det(l2.p2-l2.p1);
    double b=(l1.p2-l1.p1).det(l1.p2-l2.p1);
    if(fabs(a)<eps&&fabs(b)<eps) return l2.p1;
    return l2.p1+(l2.p2-l2.p1)*(b/a);
}
Point project(Line l,Point p){
  Point base=l.p2-l.p1;
  double r=(p-l.p1).dot(base)/base.norm();
  return l.p1+base*r;
}
Point reflect(Line l,Point p){
  return p+(project(l,p)-p)*2.0;
}
int main(){
    int q;
    double xp0,yp0,xp1,yp1,xp2,yp2;
    cin>>xp0>>yp0>>xp1>>yp1;
    Point p0(xp0,yp0),p1(xp1,yp1);
    cin>>q;
    while(q--){
        cin>>xp2>>yp2;
        Point p2(xp2,yp2);
        int a=ccw(p0,p1,p2);
        string ans;
        if(a==-1) ans+="CLOCKWISE";
        else if(a==1) ans+="COUNTER_CLOCKWISE";
        else if(a==2) ans+="ONLINE_BACK";
        else if(a==-2) ans+="ONLINE_FRONT";
        else if(a==0) ans+="ON_SEGMENT";
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3272
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;

int col[10][10];

int main(void)
{
  // freopen("aaa.in","r",stdin);
  int H,W,K;
  scanf("%d%d%d",&H,&W,&K);
  char s[10];
  for (int i=1;i<=H;i++)
  
  {
    scanf("%s",s);
    for (int j=0;j<W;j++)
    if (s[j]=='.') col[i][j+1] = 0;
    else col[i][j+1] = 1;
  }
  // cout<<col[1][2]<<" "<<col[2][2]<<endl;
  int ans = 0;
  int a[10],b[10];

  for (int i=0;i<(1<<H);i++)
  for (int j=0;j<(1<<W);j++)
  {
      int cnta = 0,cntb = 0;
      for (int k=0;k<H;k++)
      if (((1<<k)&i)==0) a[++cnta] = k+1;
      
      for (int k=0;k<W;k++)
      if (((1<<k)&j)==0) b[++cntb] = k+1;

      int tmp = 0;
      for (int ki=1;ki<=cnta;ki++)
      for (int kj=1;kj<=cntb;kj++)
      tmp+=col[a[ki]][b[kj]];

      if (tmp==K) 
      {
        ans++;
        // cout<<i<<" "<<j<<endl;
        // for (int ki=1;ki<=cnta;ki++)
        // for (int kj=1;kj<=cntb;kj++)
        // cout<<a[ki]<<" "<<b[kj]<<endl;
        // cout<<"---------"<<endl;
      }  
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

int func(int n) {
  if (n == 3) return 100000;
  else if (n == 2) return 200000;
  else if (n == 1) return 300000;
  else return 0;
}

int main()
{
  int X, Y;
  cin >> X >> Y;

  int ans = 0;
  ans += func(X);
  ans += func(Y);
  if (X == 1 && Y == 1) ans += 400000;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*function prototype
*********************************/


/*********************************
*function
*********************************/
int main( void )
{
	int x;
	int y;
	int z;
	
	scanf( "%d %d %d", &x, &y, &z );
	
	if ( ( x < y ) && ( y < z ) ) {
		printf( "Yes\n" );
	} else {
		printf( "No\n" );
	}

	return ( 0 );
}

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

using namespace std;

int A, B, C, k;

int main() {
	cin >> A >> B >> C >> k;
	while(k-- && (A >= B || B >= C)) {
		if(A >= B) B <<= 1;
		else C <<= 1;
	}
	if(A < B && B < C) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] tenH = new int[N];
	for(int i=0;i<N;i++){
	    tenH[i] = sc.nextInt();
	}
	boolean[] good = new boolean[N];
	for(int i=0;i<N;i++) good[i] = true;
	
	for(int i=0;i<M;i++){
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    if(tenH[A-1] >= tenH[B-1]){
		good[B-1] = false;
	    }
	    if(tenH[A-1] <= tenH[B-1]){
		good[A-1] = false;
	    }
	}
	int count=0;
	for(int i=0;i<N;i++){
	    if(good[i]==true) count++;
	}
	System.out.print(count);
    }
}


Measured memory_bytes: 59420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;


ll n,k;

vector <ll> dp;
vector <vector<ll>> graph;

void dfs(ll p,ll v,ll color){
	dp[v] = color;
	if (p != 0)color = k-1;
	for (int z=0;z<graph[v].size();z++){
		if (graph[v][z] == p) continue;
		color--;
		dfs(v,graph[v][z],color);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	dp.resize(n+1);
	graph.resize(n+1);
	for (int z=0;z<n-1;z++){
		ll u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	dfs(0,1,k);
	ll ans = 1;
	for (int z=1;z<=n;z++){
		ans *= dp[z];
		ans %= ll(1e9+7);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9984
import sys
input = sys.stdin.readline

def Main(n):
    ans = False
    for i in range(1, 10):
        if(n % i == 0):
            nn = n // i
            if(nn >= 10):
                ans = False
                continue
            if(n % nn == 0):
                ans = True
                break
    return 'Yes' if ans else 'No'
        

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

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

using namespace std;

int main()
{
    fastio;
    // ifstream f("f.txt");
    // ofstream g("out.txt");
    int x;
    cin >> x;
  	cout<<(x>=30?"Yes":"No")<<"\n";
   

    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<vector<LL>> A(K);
	repp(i,0,N){
		int C; LL V; cin >> C >> V;
		A[C-1].push_back(V);
	}
	vector<int> t(K),w(K);
	repp(i,0,K){
		sort(A[i].begin(),A[i].end(),greater<LL>());
		A[i].push_back(-1e18);
		w[i] = t[i] = i;
	}
	sort(w.begin(),w.end(),[&](const int &i, const int &j){return A[i][0]+A[i][1] > A[j][0]+A[j][1];});
	sort(t.begin(),t.end(),[&](const int &i, const int &j){return A[i][0]+A[i][1]+A[i][2] > A[j][0]+A[j][1]+A[j][2];});
	vector<LL> ans(N+3,-1);
	priority_queue<LL> Q;
	vector<int> b(K,0);
	ans[1] = A[w[0]][0]+A[w[0]][1];
	repp(i,2,A[w[0]].size()-1) Q.push(A[w[0]][i]);
	int	wp = 1, tp = 0, m = 0;
	b[w[0]] = 1;
	while(tp < K && A[t[tp]][2] < 0) ++tp;
	if(A[t[0]][2] >= 0){
		ans[2] = A[t[0]][0]+A[t[0]][1]+A[t[0]][2];
	}
	while(tp < K && (b[t[tp]] == 1 || A[t[tp]][2] < 0)) ++tp;
	repp(i,3,N){
		if(m == 0){
			int z = 0;
			if(Q.size() >= 2){
				LL r = Q.top(); Q.pop();
				if(ans[i] < ans[i-2]+r+Q.top()){
					ans[i] = ans[i-2]+r+Q.top();
					z = 1;
				}
				Q.push(r);
			}
			if(wp < K && ans[i] < ans[i-2]+A[w[wp]][0]+A[w[wp]][1]){
				ans[i] = ans[i-2]+A[w[wp]][0]+A[w[wp]][1];
				z = 2;
			}
			if(tp < K) ans[i+1] = ans[i-2]+A[t[tp]][0]+A[t[tp]][1]+A[t[tp]][2];
			if(z == 2){
				if(!Q.empty() && tp < K) ans[i+2] = ans[i-2]+Q.top()+A[t[tp]][0]+A[t[tp]][1]+A[t[tp]][2];
				b[w[wp]] = 1;
				repp(i,2,A[w[wp]].size()-1) Q.push(A[w[wp]][i]);
				++wp;
				while(tp < K && (b[t[tp]] == 1 || A[t[tp]][2] < 0)) ++tp;
				m = 1;
			} else {
				if(!Q.empty()) Q.pop();
				m = 0;
			}
		} else {
			if(!Q.empty()) ans[i] = max(ans[i],ans[i-1]+Q.top());
			m = 0;
		}
	}
	repp(i,0,N) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 13824
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-09-13 19:58:03
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    print(1-int(input()))
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 62580
#include<stdio.h>
#include<string.h>
int main()
{
    
    char s[5],a[5]="SUN",b[5]="MON",c[5]="TUE",d[5]="WED",e[5]="THU",f[5]="FRI",g[5]="SAT";
    scanf("%s",s);
    if(strcmp(s,a)==0)
    {
        printf("7");
    }
    else if(strcmp(s,b)==0)
    {
        printf("6");
    }
    else if(strcmp(s,c)==0)
    {
        printf("5");
    }
    else if(strcmp(s,d)==0)
    {
        printf("4");
    }
    else if(strcmp(s,e)==0)
    {
        printf("3");
    }
    else if(strcmp(s,f)==0)
    {
        printf("2");
    }
    else if(strcmp(s,g)==0)
    {
        printf("1");
    }
    return 0;
}














Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a<=c && c<=b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
check = [0] * N 
ans_l = []
for i in range(N):
    c[i], t[i] = map(int, input().split())
    if t[i] <= T:
        check[i] = 1
    if check[i] == 1:
        ans_l.append(c[i])

if len(ans_l) != 0 :
    print(min(ans_l))
else:
    print('TLE')

Measured memory_bytes: 3064
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(){
    set<long long> st;
    int n;
    cin >> n;
    long long a;
    rep(i,n){
        cin >> a;
        if (st.count(a) == 0) st.insert(a);
        else st.erase(a);

    }
    cout << st.size();
    

    return 0;
}

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



// v[1]がルート
template <typename T>
struct SegmentTree {
	vector<T> v;
	int ofs;
	using F = function<T(T&, T&)>;
	const F comb;
	const T unit;
	SegmentTree( int n, F comb, const T& unit ) : comb(comb), unit(unit) {
		for ( ofs = 1; ofs < n; ofs *= 2 )
			;
		v = vector<T>(ofs*2,unit);
	}
	
	
	void update( int i, const T& x ){
		i += ofs;
		v[i] = x;
		i /= 2;
		
		while ( i ){
			v[i] = comb( v[i*2], v[i*2+1] );
			i /= 2;
		}
	}
	
	//  begin .. end-1 の区間の計算結果を得る
	T range( int begin, int end ){
		return range2( begin, end, 1, 0, ofs );
	}
	
	// v[node] は 区間 l .. r-1 の計算結果を持っている
	T range2( int begin, int end, int node, int l, int r ){
		if ( end <= l || r <= begin )
			return unit;
		if ( begin <= l && r <= end )
			return v[node];
		T lval = range2( begin, end, node*2,   l,       (l+r)/2 );
		T rval = range2( begin, end, node*2+1, (l+r)/2, r       );
		return comb(lval,rval);
	}
};

ll n;
string s;
ll q;

ll comb(ll a, ll b){return a|b;}


int main(){
	
	cin >> n >> s >> q;
	int len = s.size();
	
	SegmentTree<ll> st(len,comb,0);
	
	for ( int i = 0; i < len; i++ ){
		st.update(i, 1LL << (s[i]-'a'));
	}
	
	
	for ( int i = 0; i < q; i++ ){
		int type, pos, l, r;
		string c;
		cin >> type;
		if ( type == 1 ){
			cin >> pos >> c;
			st.update(pos-1,1LL << (c[0]-'a'));
		}
		else {
			cin >> l >> r;
			l--;
			r--;
			ll result = st.range( l, r+1 );
			cout << __builtin_popcount(result) << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
bool dp[100005] = {};
void solve(long long N, long long K, long long R, long long S, long long P,
           std::string T) {
  string TT = T;
  lli ans = 0;
  rep(i, N){
    lli plus = 0;
    if(T[i]=='r'){
      plus = P;
    }
    if(T[i]=='s'){
      plus = R;
    }
    if(T[i]=='p'){
      plus = S;
    }

    dp[i] = true;
     if(i-K>=0){
      if(TT[i-K]==T[i] && dp[i-K])
      {
       plus = 0;
       dp[i] = false;
      }
     }
     ans += plus;
  }
  cout << ans << endl;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  long long R;
  scanf("%lld", &R);
  long long S;
  scanf("%lld", &S);
  long long P;
  scanf("%lld", &P);
  std::string T;
  std::cin >> T;
  solve(N, K, R, S, P, T);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

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

    Abra_Ka_Dabra

    int n;
    cin>>n;
    int res;
    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;
    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;

int main( int argc , char ** argv ){

	uint64_t X=0;
	cin >> X;

	uint64_t counter = 1;
	uint64_t sum = 0;
	while(1){
		sum += (counter++);
		if(X <= sum) break;
	}

	cout << counter-1 << "\n";
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    ll n,a[100005];
    cin>>n;
    ll cnt=0;
    rep1(i,n)
    {
        ll temp;
        cin>>temp;
        a[temp]=i;
    }
    rep1(i,n)
        cout<<a[i]<<" ";
}


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

int main()
{
  string s;
  cin>>s;
  int j = s.length()-1,ans=0;
  for(int i=0;i<j;i++,j--)
  {
    if(s[i]!=s[j])
      ans++;
  }
  cout<<ans<<"\n";
  
  return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  ll n,m;cin>>n>>m;
  deque<ll> A(n);
  deque< pair<ll, ll> > B;
  for(ll i=0;i<n;i++)cin>>A[i];
  for(ll i=0;i<m;i++){
    ll b,c;cin>>b>>c;
    B.push_back({c,b});
  }
  sort(A.begin(), A.end());
  sort(B.rbegin(), B.rend());
  ll cnt=0;
  ll ans=0;
  while(cnt<n){
    if(B.size()==0 || A.front()>=B.front().first){
      ans+=A.front();A.pop_front();
      cnt++;
      continue;
    }else{
      ans+=B.front().first;B.front().second--;
      if(B.front().second==0)B.pop_front();
      A.pop_front();
      cnt++;
      continue;
    }
  }
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 5532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


int main(){
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> A(N);
	REP(n, N) {
		ll K;
		cin >> K;
		ll num;
		REP(k, K) {
			cin >> num;
			A[n].push_back(num);
		}
	}

	map<ll, ll> suki;
	REP(n, N) {
		REP(k, A[n].size()) {
			ll num = A[n][k];
			suki[num]++;
		}
	}

	ll res = 0;
	REP(i, M) {
		if (suki[i+1]==N) res++;
	}
	cout << res << "\n";
    return 0;
}


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

int main(){
  int n, W;
  cin >> n >> W;
  int w[n];
  long v[n];
  long dp[W+1];
  for(int i = 0;i < n;i++)
    cin >> w[i] >> v[i];
  for(int i = 0;i <= W;i++)
    dp[i]=0;
  for(int i = 0;i < n;i++){
    for(int j = W;j >= w[i];j--){
      dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
    }
  }
  cout << dp[W] << endl;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=364;
int dist[Nmax][Nmax];
bool dame[Nmax][Nmax];

signed main(){
	int n=read(),ans=0;
	REP(i,n)REP(j,n)
		dist[i][j]=read();
	REP(i,n)REP(j,n)REP(k,j)if(i!=j&&i!=k){
		if(dist[i][j]+dist[i][k]<dist[j][k]){
			cout<<-1<<endl;
			return 0;
		}
		if(dist[i][j]+dist[i][k]==dist[j][k])
			dame[j][k]=1;
	}
	REP(i,n)REP(j,i)if(!dame[i][j])
		ans+=dist[i][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
def check(rx, ry, gem):
    for k in range(len(gem)):
        if gem[k][0] == rx and gem[k][1] == ry:
            return k
        elif k == len(gem) - 1:
            return -1


while True:
    x = 10
    y = 10
    N = int(input())
    if N == 0:
        break
    Gem = []
    for i in range(N):
        X, Y = list(map(int, input().split()))
        Gem.append([X, Y])
    M = int(input())
    GemCount = [0]*N
    for i in range(M):
        C, m = input().split()
        if C == "N":
            for j in range(int(m)):
                y += 1
                reg = check(x, y, Gem)
                if reg != -1:
                    GemCount[reg] = 1
        elif C == "E":
            for j in range(int(m)):
                x += 1
                reg = check(x, y, Gem)
                if reg != -1:
                    GemCount[reg] = 1
        elif C == "S":
            for j in range(int(m)):
                y -= 1
                reg = check(x, y, Gem)
                if reg != -1:
                    GemCount[reg] = 1
        else:
            for j in range(int(m)):
                x -= 1
                reg = check(x, y, Gem)
                if reg != -1:
                    GemCount[reg] = 1
    if GemCount.count(0) == 0:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 5620
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

result = 0
for i in range(N):
  result += B[A[i]-1]
  if i != 0:
    if A[i] == A[i-1] + 1:
      result += C[A[i-1]-1]

print(result)

Measured memory_bytes: 3064
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
type Node struct {
	p, count int
}

func sum(cur int, T []Node, memo []int) int {
	if cur == -1 {
		return 0
	}
	if memo[cur] != -1 {
		return memo[cur]
	}
	node := T[cur]
	res := node.count + sum(node.p, T, memo)
	memo[cur] = res
	return res
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, Q := sc.nextInt(), sc.nextInt()
	memo := make([]int, N)
	for i := 0; i < N; i++ {
		memo[i] = -1
	}
	G := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}
	P := make([]int, N)
	for i := 0; i < Q; i++ {
		id, plus := sc.nextInt()-1, sc.nextInt()
		P[id] += plus
	}
	var dfs func(cur, from, point int)
	dfs = func(cur, from, point int) {
		memo[cur] = point
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if next != from {
				dfs(next, cur, point+P[next])
			}
		}
		return
	}
	dfs(0, -1, P[0])
	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, memo[i])
	}
	fmt.Fprintln(wtr)

	wtr.Flush()
}


Measured memory_bytes: 73984
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
 
class dice{
public:
    int d[6], tmp[6];
    dice(int n[6]){
        for (int i = 0; i < 6; i++){
            d[i] = n[i];
        }
    }
    void throwdice(char c){
        for (int i = 0; i < 6; i++){
            tmp[i] = d[i];
        }
        if (c == 'N'){
            d[0] = tmp[1];
            d[1] = tmp[5];
            d[2] = tmp[2];
            d[3] = tmp[3];
            d[4] = tmp[0];
            d[5] = tmp[4];
        }
        else if (c == 'E'){
            d[0] = tmp[3];
            d[1] = tmp[1];
            d[2] = tmp[0];
            d[3] = tmp[5];
            d[4] = tmp[4];
            d[5] = tmp[2];
        }
        else if (c == 'W'){
            d[0] = tmp[2];
            d[1] = tmp[1];
            d[2] = tmp[5];
            d[3] = tmp[0];
            d[4] = tmp[4];
            d[5] = tmp[3];
        }
        else if (c == 'S'){
            d[0] = tmp[4];
            d[1] = tmp[0];
            d[2] = tmp[2];
            d[3] = tmp[3];
            d[4] = tmp[5];
            d[5] = tmp[1];
        }
        else if (c == 'R'){
            d[0] = tmp[0];
            d[1] = tmp[3];
            d[2] = tmp[1];
            d[3] = tmp[4];
            d[4] = tmp[2];
            d[5] = tmp[5];
        }
    }
};
int main()
{
    int m[6], n[6];
    for (int i = 0; i < 6; i++){
        cin >> m[i];
    }
    dice dice1(m);
    for (int i = 0; i < 6; i++){
        cin >> n[i];
    }
    dice dice2(n);
        bool upsame = false;
        for (int i = 0; i < 4; i++){
            dice1.throwdice('S');
            if (dice1.d[0] == dice2.d[0]){
                upsame = true;
                break;
            }
        }
        if (!upsame){
            while (true){
                dice1.throwdice('W');
                if(dice1.d[0] == dice2.d[0]){
                    break;
                }
            }
        }
 
        for (int i = 0; i < 4; i++){
            dice1.throwdice('R');
            if (dice1.d[1] == dice2.d[1]){
                break;
            }
        }
        bool same = true;
        for (int i = 0; i < 6; i++){
            if (dice1.d[i] != dice2.d[i]){
                same = false;
            }
        }
        if (same){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
     
 
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <time.h>
#include <random>
using namespace std;

typedef pair<int,int> P;
int main(){
    int N,M;
    cin>>N>>M;
    vector<P> S,C;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        S.emplace_back(a,b);
    } 
    for(int i=0;i<M;i++){
        int c,d;
        cin>>c>>d;
        C.emplace_back(c,d);
    }
    for(int i=0;i<N;i++){
        int p = 0;
        for(int j=1;j<M;j++){
            if(abs(C[p].first-S[i].first)+abs(C[p].second-S[i].second)>abs(C[j].first-S[i].first)+abs(C[j].second-S[i].second))
                p=j;
        }
        cout<<p+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {
	string S, T, U;
	cin >> S >> T >> U;
	cout << 'A' << T[0] << 'C';

	system("PAUSE");
}

Measured memory_bytes: 504
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!int;

  bool include3(int x) {
    for (; x > 0; x /= 10)
      if (x % 10 == 3) return true;

    return false;
  }

  foreach (i; 1..n + 1)
    if (i % 3 == 0 || include3(i)) write(" ", i);

  writeln;
}

Measured memory_bytes: 2508