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

public class Main{
    public static void main(String[] args) throws UnsupportedEncodingException{
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        char[] c = new char[n];
        boolean b = true;
        if(n % 2 == 0){
            for(int i = 0; i < n; i++){
                c[i] = s.charAt(i);
                if(i < n / 2){
                    if(c[i] == s.charAt(i + n / 2) && b){
                        b = true;
                    }else{
                        b = false;
                    }
                }
            }
        }else{
            b = false;
        }
        if(b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int[] group = new int[13] { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
		int x = GetInt();
		int y = GetInt();		
		Console.WriteLine(group[x] == group[y] ? "Yes" : "No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var N = LnInt();
        var Hs = LnInts();
        var dp = new int[N + 1];
        //i番目にいくにはどちらが効率いいかを検証するテーブル
        for (int i = 0; i < dp.Length; i++) { dp[i] = int.MaxValue; }
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            if (i < N - 1) dp[i + 1] = Min(dp[i + 1], dp[i] + Abs(Hs[i + 1] - Hs[i]));
            if (i < N - 2) dp[i + 2] = Min(dp[i + 2], dp[i] + Abs(Hs[i + 2] - Hs[i]));
        }
        Console.WriteLine(dp[N-1]);
    }

    static bool isLunLun(int i)
    {
        var vs = i.ToString().ToCharArray();
        var lastnum = int.Parse(vs[0].ToString());
        for (int n = 0; n < vs.Length; n++)
        {
            var cur = int.Parse(vs[n].ToString());
            if (Abs(lastnum - cur) > 1) { return false; }
            lastnum = cur;
        }
        return true;
    }


    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		char c[] = s.toCharArray();
		for(int i = 0; i < c.length; i++){
			if(Character.isUpperCase(c[i])){
				c[i] = Character.toLowerCase(c[i]);
			}else if(Character.isLowerCase(c[i])){
				c[i] = Character.toUpperCase(c[i]);
			}
		}
		System.out.println(String.copyValueOf(c));
	}

}

Measured memory_bytes: 24104
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	if 2*K >= B+1-A {
		for i := A; i < B+1; i++ {
			fmt.Println(i)
		}
	} else {
		for i := A; i < A+K; i++ {
			fmt.Println(i)
		}
		for i := B + 1 - K; i < B+1; i++ {
			fmt.Println(i)
		}
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	long long int n,w;
	cin>>n>>w;
	vector<vector<long long int> > pro(n,vector<long long int>(2));
	for (long long int i = 0; i < n; ++i)
	{
		long long int a,b;
		cin>>a>>b;
		pro[i][0] = a;
		pro[i][1] = b;
	}
	
	vector<vector<long long int> > value(w+1,vector<long long int>(n+1,0));
	for (long long int i = 1; i < w+1; ++i)
	{
		for (long long int j = 1; j < n+1; ++j)
		{
			if(pro[j-1][0]>i)
				value[i][j] = value[i][j-1];
			else
		     value[i][j] = max(value[i][j-1],value[i-pro[j-1][0]][j-1]+pro[j-1][1]);
		}
	}
	cout<<value[w][n];
}
int main()
{  

    
    solve();
    return 0;

 }

Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

lli n, a, b;

int main()
{
  while (scanf("%lld %lld %lld", &n, &a, &b) != EOF)
  {
    lli ans = n / (a + b) * a + min(a, n % (a + b));
    printf("%lld\n", ans);
  }
  return 0;
}

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

int main() {
	long long int n,i,a[100005],curr_price,ans=0,curr_max=1;
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>a[i];
	}
	
	if(a[0]>=2) {
		ans+=(a[0]-1);
	}
	
	for(i=1;i<n;i++) {
		// cout<<"i is "<<i<<" a[i]: "<<a[i]<<endl;
		curr_price = curr_max+1;
		if(curr_price<a[i]) {
			if(curr_max==1) {
				if(a[i]%2==0) {
					ans+=(a[i]/2-1);
					a[i]=1;
				} else {
					ans+=(a[i]/2);
					a[i]=1;
				}
			} else if(a[i]%curr_price>0) {
				ans+=(a[i]/curr_price);
				a[i]=a[i]%curr_price;
			} else {
				ans+=(a[i]/curr_price-1);
				a[i]=curr_max;
			}
		}
		curr_max=max(curr_max,a[i]);
		// cout<<"ans: "<<ans<<" "<<"curr_max: "<<curr_max<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
//Name: Dowsing Machine
//Level: 2
//Category: シミュレーション,BFS
//Note: RUPC 2014 Day3

/**
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

const int DR[] = {0, -1, 0, 1};
const int DC[] = {1, 0, -1, 0};

int H, W;

void paint(int r, int c, vector<string> &field) {
    for(int d = 0; d < 4; ++d) {
        const int nr = r + DR[d];
        const int nc = c + DC[d];
        if(nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
        if(field[nr][nc] != '.') continue;
        field[nr][nc] = 'D';
        paint(nr, nc, field);
    }
}

bool solve() {
    int D, N;
    if(!(cin >> H >> W >> D >> N)) return false;

    vector<string> field(H);
    for(int i = 0; i < H; ++i) {
        cin >> field[i];
    }
    for(int r = 0; r < H; ++r) {
        for(int c = 0; c < W; ++c) {
            if(field[r][c] == 'D') {
                paint(r, c, field);
                goto next;
            }
        }
    }

next:
    vector<int> rs;
    rs.push_back(-1);
    for(int i = 0; i < D; ++i) {
        int r;
        cin >> r;
        rs.push_back(r);
    }
    rs.push_back(max(H, W));

    vector<vector<int>> cnt(H, vector<int>(W, 0));
    for(int i = 0; i < N; ++i) {
        int X, Y, S;
        cin >> X >> Y >> S;
        for(int dy = -rs[S+1]; dy <= rs[S+1]; ++dy) {
            const int y = Y + dy;
            if(y < 0 || y >= H) continue;
            for(int dx = -rs[S+1]; dx <= rs[S+1]; ++dx) {
                const int x = X + dx;
                if(x < 0 || x >= W) continue;
                if(abs(dy) <= rs[S] && abs(dx) <= rs[S]) continue;
                cnt[y][x]++;
            }
        }
    }

    bool broken = true;
    bool can_reach = false;
    bool cant_reach = false;
    for(int r = 0; r < H; ++r) {
        for(int c = 0; c < W; ++c) {
            if(field[r][c] == '#') continue;
            if(cnt[r][c] == N) {
                broken = false;
                if(field[r][c] == 'D') {
                    can_reach = true;
                } else {
                    cant_reach = true;
                }
            }
        }
    }
    if(broken) {
        cout << "Broken" << endl;
    } else if(can_reach && cant_reach) {
        cout << "Unknown" << endl;
    } else {
        cout << (can_reach ? "Yes" : "No") << endl;
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int ans = 0;
  for(int i=S.size()/2-1;i>0;--i) {
    if(S.substr(0, i)==S.substr(i, i)) {
      ans = 2*i;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll i,s=0;string n;
	cin>>n;
	fr(i,0,n.length())
	{
		s+=n[i]-'0';
	}
	if(s%9==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int T,n,m;
ll a[maxn],b[maxn];
int main() {
	for(int i=0;i<=1000;i++)
		a[i] = i;
	int N,L;
	cin>>N>>L;
	int flag = 0;
	for(int i=1;i<=N;i++){
		a[i]=a[i]+L-1;
		//cout<<a[i]<<endl;
		if(a[i]==0){
			flag = 1;
		}
	}
	
	ll sum=0;
	if(flag){
		for(int i=1;i<=N;i++)
			sum+=a[i];
		cout<<sum<<endl;
		return 0;
	}
	if(L>=0)
	for(int i=2;i<=N;i++){
		sum+=a[i];
	}
	else {
		for(int i=1;i<N;i++){
		sum+=a[i];
		}
	}
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
size = gets.chomp.to_i
input_values = []

input_strings = gets.chomp.split
for i in 0..size-1
  input_value = input_strings[i].to_i
  input_values.push(input_value)
end



# def insertion_sort(array, size)
#  for i in 0..(size-2)
#    if array[i] > array[i+1]
#      tmp = array[i+1]
#      array[i] = array[i+1]
#      array[i+1] = tmp
#     end
#   end
# end
def insertion_sort(array, size)
puts array.join(' ')
  for i in 1..(size-1)
    target = array[i]
    while (i > 0) && (array[i-1] > target)
      array[i] = array[i-1]
      i += -1
    end
    array[i] = target
    puts array.join(' ')
  end
  return array
end

insertion_sort(input_values, size)

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

const int MAXN = 2000005;

char C[MAXN];
int cnt, sol;

int main() {
	scanf("%s", C);
	sol = strlen(C);
	for (int i = 0; C[i]; ++i) {
		if (C[i] == 'S') cnt++;
		if (C[i] == 'T' && cnt > 0) {
			cnt--;
			sol -= 2;
		}
	}

	printf("%d\n", sol);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

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

int h,w;
int ans;
int flg[10],t[10][10000];

int count(void){
	int i,j;
	int tmp, res = 0;

	rep(j,w){
		//1Ìð¦é
		tmp = 0;
		rep(i,h) if(flg[i] && !t[i][j] || !flg[i] && t[i][j]) tmp++;

		if(tmp < h - tmp){
			res += h - tmp;
		}
		else{
			res += tmp;
		}
	}
	return res;
}

void solve(int idx){
	int res;

	if(idx == h){
		res = count();
		if(ans < res) ans = res;
		return;
	}

	//idxsÚð Ô³È¢
	flg[idx] = 0;
	solve(idx+1);

	//idxsÚð Ô·
	flg[idx] = 1;
	solve(idx+1);
}

int main(void){
	int i,j;

	while(scanf("%d%d",&h,&w) && (h||w)){
		rep(i,h) rep(j,w) scanf("%d",&t[i][j]);
		ans = 0;
		solve(0);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> a(n+1),b(n);
  int64_t i;
  for(i=0;i<n+1;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n;i++){
    cin >> b.at(i);
  }
  int64_t sum=0;
  for(i=0;i<n;i++){
    if(a.at(i)+a.at(i+1)<=b.at(i)){
      sum+=a.at(i)+a.at(i+1);
      a.at(i)=0;
      a.at(i+1)=0;
   }else if(a.at(i)<=b.at(i)){
      a.at(i+1)=a.at(i+1)-(b.at(i)-a.at(i));
      a.at(i)=0;
      sum+=b.at(i);
    }else{
      a.at(i)-=b.at(i);
      sum+=b.at(i);
    }
  }
  cout << sum;
} 
  
    
  


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, mut a: usize, b: usize);
    let a0 = a;
    let mut x = 0usize;
    for _ in 0..(n - 2) {
        parse!(it, y: usize);
        x ^= y;
    }
    let m = 43;
    let mut s: usize = a + b;
    let mut dp = vec![vec![vec![-1i64; 2]; 2]; m];
    dp[0][0][0] = 0;
    for i in 0..(m - 1) {
        for j in 0..=1 {
            for k in 0..=1 {
                if dp[i][j][k] == -1 {
                    continue;
                }
                let x = x & 1;
                let s = s & 1;
                let a = a & 1;
                for na in 0..=1 {
                    for nb in 0..=1 {
                        if na ^ nb != x {
                            continue;
                        }
                        if (na + nb + j) % 2 != s {
                            continue;
                        }
                        let nk = match (a, na) {
                            (0, 1) => 1,
                            (1, 0) => 0,
                            _ => k,
                        };
                        let ni = i + 1;
                        let nj = ((na + nb + j) / 2) as usize;
                        dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] + (na << i) as i64);
                    }
                }
            }
        }
        x >>= 1;
        s >>= 1;
        a >>= 1;
    }
    let d = dp[m - 1][0][0];
    if d == -1 || d == 0 {
        println!("{}", -1);
    } else {
        println!("{}", a0 as i64 - d);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}


Measured memory_bytes: 2196
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long h=sc.nextLong(),w=sc.nextLong();
    if(h==2 || w==2) {
    	System.out.println(0);
    }else {
    	System.out.println(Math.max(h-2,1)*Math.max(w-2, 1));
    }
  }
}


Measured memory_bytes: 21844
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

ans = R * G * B

for i in range(N-1):
  for d in range(1, N):
    j = i + d
    k = j + d
    if j >= N or k >= N:
      break
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
        ans -= 1
        
print(ans)

Measured memory_bytes: 73540
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N=ri()
A=rl()

d = [0]*(N+1)
d[0] = A[0]
sum = abs(A[0])
for i in range(1,N):
    dif = A[i]-A[i-1]
    d[i] = dif
    sum += abs(dif)
d[N]= 0-A[N-1]
sum += abs(A[N-1])


for i in range(1,N+1):
    if d[i-1]*d[i] >= 0:
        print(sum)
    else:
        print(sum-2*min(abs(d[i-1]),abs(d[i])))


Measured memory_bytes: 14176
#!/usr/bin/python3
# -*- coding: utf-8 -*-


N,X = map(int, input().split())
Ln = [0] + list(map(int, input().split())) + [X+1]

csum = 0
ans = 0
for i,l in enumerate(Ln):
  if csum<=X and csum+l>X:
    ans = i
  csum += l
print(ans)

Measured memory_bytes: 38256
#include <iostream>

const int MAXN = (int)2e5;

int a[MAXN];

int solve(int n, int k) {
  int max_dis = a[0] + k - a[n - 1];
  for (int i = 1; i < n; ++i) {
    int cur = a[i] - a[i - 1];
    if (cur > max_dis) max_dis = cur;
  }
  return k - max_dis;
}

int main() {
  int k, n;
  std::cin >> k >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  std::cout << solve(n, k) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>

int main(void){
    int N, L[2005], x, y, r, i, j, k[3];
    scanf("%d", &N);
    for (i=1; i<=N; i++) {
        scanf("%d", &L[i]);
        L[i]=-L[i];
    }
    std::sort(L+1, L+N+1);
    for (i=1; i<=N; i++) L[i]=-L[i];
    // for (i=1; i<=N; i++) printf("%d ", L[i]);
    
    x=0;
    for (i=1; i<=N-2; i++) {
        for (j=i+1; j<=N-1; j++) {
            // printf("!");
            r=L[i]-L[j];
            // printf("(%d, %d): %d\n", i, j, r);
            k[0]=j+1, k[1]=N;
            while (1) {
                k[2]=(k[0]+k[1])/2;
                // printf("(%d, %d, %d)\n", k[0], k[1], k[2]);
                if (k[1]-k[0]<=1) {
                    if (k[1]-k[0]==1) {
                        if (L[k[1]]>r) {
                            y=k[1]-j;
                            break;
                        }
                    }
                    if (k[0]==j+1) {
                        if (L[k[0]]>r) y=1;
                        else y=0;
                        break;
                    }
                    y=k[0]-j;
                    break;
                }
                if (L[k[2]]>r) {
                    k[0]=k[2];
                }
                else {
                    k[1]=k[2]-1;
                }
            }
            x+=y;
        }
    }
    printf("%d", x);
    return 0;
}

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

double d, a, x, y, p;

int main() {
	while (scanf("%lf,%lf",&d,&a) && (d || a)) {
		y += d * cos(p / 180.0 * M_PI);
		x += d * sin(p / 180.0 * M_PI);
		p += a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b, c; cin >> a >> b >> c;
  ll ans = min(a + b + 1, c) + b;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3652
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    for i in range(2):
        if s[i] == s[i + 1] == s[i + 2]:
            print("Yes")
            return
    print("No")
    return

#B
def B():
    return

#C
def C():
    abcd = list(map(int, S()))
    op = itertools.product(range(2), repeat=3)
    for opx in op:
        ans = abcd[0]
        for num, opi in enumerate(opx):
            if opi:
                ans += abcd[num + 1]
            else:
                ans -= abcd[num + 1]
        if ans == 7:
            print(abcd[0],end="")
            for num, opi in enumerate(opx):
                print(["-", "+"][opi] + str(abcd[num + 1]), end="")
            print("=7")
            return
    return

#D
def D():
    h, w = LI()
    edg = LIR(10)
    for k in range(10):
        for x in range(10):
            for y in range(10):
                edg[x][y] = min(edg[x][k] + edg[k][y], edg[x][y])
    a = LIR(h)
    ans = 0
    for y in range(h):
        for x in range(w):
            if a[y][x] == -1:
                continue
            ans += edg[a[y][x]][1]
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40788
fun main (args : Array<String>) {
	val (a, b, k) = readLine()!!.split(" ").map(String::toInt)
	val A : Int = a.toInt()
	val B : Int = b.toInt()
	val K : Int = k.toInt()
	var result : MutableList<Int> = mutableListOf()
	for (i in 1..100) {
		if ( (A % i == 0) && (B % i == 0) ) {
			result.add(i)
		}
	}
	result.reverse()
	println("${result[K - 1]}")
}

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

int main()
{   int a,b,c[7]={1,3,5,7,8,10,12},d[4]={4,6,9,11},q=0,w=0,i;
    scanf("%d%d",&a,&b);
    for(i=0;i<7;i++)
        {if(a==c[i])
        q++;
        if(b==c[i])
            q++;}
            for(i=0;i<4;i++)
                {if(a==d[i])
        w++;
        if(b==d[i])
            w++;}
            if(q==2||w==2)
    printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi v;
    for (int i = 111; i <= 999; i += 111) {
      v.push_back(i);
    }
    rep(i, 0, v.size()) {
      if (v[i] >= n) {
        cout << v[i];
        break;
      }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int X = sc.nextInt();
    	sc.close();
    	long ans = 0L;
    	ans = (X / 500) * 1000;
    	X = X % 500;
    	ans += (X / 5) * 5;
    	X = X % 5;
    	System.out.println(ans);
    }

}

Measured memory_bytes: 23892
<?php
fscanf(STDIN,"%d",$n);
$row2 = trim(fgets(STDIN));
$num = explode(" ",$row2);
rsort($num);

for($i=0; $i<$n; $i++){
    if($i % 2 == 0){
        $a[] = $num[$i];
    }else{
        $b[] = $num[$i];
    }
}

echo array_sum($a) - array_sum($b);
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    bool h=1;
    int ans=0;
    rep(i,s.size()-1){
        
        if(s[i]==s[i+1]&&h){
            i++;
            ans++;
            h=0;
        }
        else{
            h=1;
            continue;
        }
    }
    std::cout << s.size()-ans << std::endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int count = 0;
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 && b == 0)
				break;
			List<Integer> list = new ArrayList<Integer>();
			for (int i = a; i <= b; i++) {
				if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)) {
					list.add(i);
				}
			}
			if (count != 0) {
				System.out.println();
			}
			if (list.size() == 0) {
				System.out.println("NA");
			} else {
				for (int t : list)
					System.out.println(t);
			}
			count++;
		}
	}

}

Measured memory_bytes: 20656
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
using namespace std;

int main(){
	int n, cnt;
	
	int rep[] = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999};
	vector< int > repdig(rep, rep + (sizeof(rep) / sizeof(int)));
	
	while(cin >> n, n){
		
		if(find(repdig.begin(), repdig.end(), n) != repdig.end()){
			cout << "NA" << endl;
			continue;
		}
		
		cnt = 0;
		
		while(n != 6174){
			stringstream ss;
			ss << setfill('0') << setw(4) << n;
			string str = ss.str();
			
			sort(str.begin(), str.end());
			
			int s = atoi(str.c_str());
			
			reverse(str.begin(), str.end());
			
			int l = atoi(str.c_str());
			
			n = l - s;
			++cnt;
		}
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    bool same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    bool merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u == v) return false;
        root[u] = v;
        size[v] += size[u];
        return true;
    }
private:
    vector<int> root;
    vector<int> size;
};

int solve(const vector<int>& a, const vector<int>& b){
    const int N = a.size();
    auto ca = a, cb = b;
    int sumA = 0, sumB = 0;
    for(auto& t : a) sumA ^= t;
    for(auto& t : b) sumB ^= t;
    ca.push_back(sumA);
    cb.push_back(sumB);
    sort(ca.begin(), ca.end());
    sort(cb.begin(), cb.end());
    if(ca != cb) return -1;
    ca.erase(unique(ca.begin(), ca.end()), ca.end());
    map<int, int> mp;
    for(int i=0;i<ca.size();i++) mp[ca[i]] = i;
    UnionFind uf(ca.size());
    vector<int> chg(ca.size(), 0);
    int comp = 0;
    int sub = 0;
    int res = 0;
    for(int i=0;i<N;i++){
        if(a[i] != b[i]){
            if(a[i] == sumA) sub = 1;
            int p = mp[a[i]];
            int q = mp[b[i]];
            if(!chg[p]) ++comp;
            if(uf.merge(p, q)) --comp;
            ++res;
            chg[p] = 1;
        }
    }
    return res + comp - sub;
}

int main(){
    int N; cin >> N;
    vector<int> a(N), b(N);
    for(auto& t : a) cin >> t;
    for(auto& t : b) cin >> t;
    cout << solve(a, b) << endl;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

struct pq {
    INT64 val;
    int i;
    int j;
    int k;

    bool operator<(const pq& lhs) const{
        return val < lhs.val;
    }
    
    bool operator==(const pq& lhs) const {
        if (i != lhs.i) return false;
        if (j != lhs.j) return false;
        if (k != lhs.k) return false;
        return true;
    }
    
};

int main(void)
{
    IOS
    //const int KMAX = 3000;
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<INT64> a(x), b(y), c(z);
    REP(x) cin >> a[i];
    REP(y) cin >> b[i];
    REP(z) cin >> c[i];

    sort(RALL(a));
    sort(RALL(b));
    sort(RALL(c));
    
    //int ai , bi , ci = 0;
    priority_queue<pq> p;
    vector<pq> v;
    int ki = 0;
    pq f = {a[0]+b[0]+c[0],0,0,0};
    p.push(f);
    while(ki < k) {
        pq top = p.top();
        pq tmp;
        p.pop();ki++;
        cout << top.val << endl;

        if (top.i < x-1) {
            tmp = {a[top.i+1]+b[top.j]+c[top.k],top.i+1,top.j,top.k};
            auto itr = find(ALL(v),tmp);
            if (itr == v.end()) {
                //cerr << "i:" << aq.i << " j:" << aq.j << " k:" << aq.k << endl;
                v.emplace_back(tmp);
                p.emplace(tmp);
            }
        }
        if (top.j < y-1) {
            tmp = {a[top.i]+b[top.j+1]+c[top.k],top.i,top.j+1,top.k};
            auto itr = find(ALL(v),tmp);
            if (itr == v.end()) {
                //cerr << "i:" << bq.i << " j:" << bq.j << " k:" << bq.k << endl;
                v.emplace_back(tmp);
                p.emplace(tmp);
            }
        }
        if (top.k < z-1) {
            tmp = {a[top.i]+b[top.j]+c[top.k+1],top.i,top.j,top.k+1};
            auto itr = find(ALL(v),tmp);
            if (itr == v.end()) {
                //cerr << "i:" << cq.i << " j:" << cq.j << " k:" << cq.k << endl;
                v.emplace_back(tmp);
                p.emplace(tmp);
            }
        }
        //cerr << p.size() << endl;
    }


    return 0;
}


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

int main(){
  int n;
  cin >> n;

  char mark;
  int num;
  int heart[14]={0};
  int spade[14]={0};
  int daiya[14]={0};
  int kurabu[14]={0};
 
  for(int i=1;i<=n;i++){
    cin >> mark >> num;
    switch(mark){
      case 'H':
	heart[num]=1;
	break;
      case 'S':
	spade[num]=1;
	break;
      case 'D':
	daiya[num]=1;
	break;
      case 'C':
	kurabu[num]=1;
	break;
    }
  }
  
   for(int i=1;i<=13;i++){
      if(spade[i]==0) cout << "S" << " " << i << endl;
    }
    for(int i=1;i<=13;i++){
      if(heart[i]==0) cout << "H" << " " << i << endl;
    }
    for(int i=1;i<=13;i++){
      if(kurabu[i]==0) cout << "C" << " " << i << endl;
    }
    for(int i=1;i<=13;i++){
      if(daiya[i]==0) cout << "D" << " " << i << endl;
    }
}



Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

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

int main(){

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

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if( s[i][j] == '.' ) continue;
      int cnt = 0;
      for(int k=0; k<4; k++){
        int x = j + dx[k];
        int y = i + dy[k];
        if( x < 0 || y < 0 || x >= w || y >= h ) cnt++;
        else if( s[y][x] == '#' ) cnt++;
      }
      if(cnt == 0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}





//


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

for i in range(1, n+1, 1):
    if i % 3 ==0:
        print(" ", end = "")
        print(i, end="")
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(" ",end = "")
                print(i, end="")
                break
            x//=10
print()


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int N, K, h[100000];
	cin >> N >> K;
	for (int i = 0; i < N; i++){
		cin >> h[i];
	}
	sort(h, h + N);
	int m = INF;
	for (int i = 0; i <= N - K; i++){
		m = min(m, h[i + K - 1] - h[i]);
	}
	cout << m << endl;

	return 0;
}


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

int main() {
  int h, w;
  while (cin >> h >> w, h | w) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i + j) & 1) cout << ".";
        else cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
int ans;
if (b < 10)  ans = a*10 + b;
else if (b < 100) ans = a*100 + b;
else ans = a*1000 + b;

int c = sqrt(ans);
if (c - sqrt(ans) == 0) cout << "Yes" << endl;
else cout << "No" << endl;



return 0;
}

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

fn main() {
    let (n, m) = get!(usize, usize);
    let mut gr = vec![vec![std::usize::MAX / 3; n]; n];
    let mut ps = Vec::new();
    for _ in 0..m {
        let (a, b, c) = get!(usize, usize, usize);
        gr[a-1][b-1] = c;
        gr[b-1][a-1] = c;
        ps.push((a-1, b-1, c));
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if gr[i][j] > gr[i][k] + gr[j][k] {
                    gr[i][j] = gr[i][k] + gr[j][k];
                }
            }
        }
    }
    let mut cnt = 0;
    for (a, b, c) in ps {
        if c > gr[a][b] { cnt += 1; }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
MOD = 10 ** 9 + 7

MN = M * N
A_gt = [0] * MN
B_gt = [0] * MN
ans = 1
for Ai in A:
    if A_gt[Ai - 1] > 0:
        ans = 0
        break
    A_gt[Ai - 1] = 1
for Bi in B:
    if B_gt[Bi - 1] > 0:
        ans = 0
        break
    B_gt[Bi - 1] = 1

if ans != 0:
    for i in range(MN - 2, -1, -1):
        A_gt[i] += A_gt[i + 1]
        B_gt[i] += B_gt[i + 1]
    ans = A_gt[MN - 1] * B_gt[MN - 1]
    for i in range(MN - 2, -1, -1):
        is_max_in_A = A_gt[i] != A_gt[i + 1]
        is_max_in_B = B_gt[i] != B_gt[i + 1]
        if is_max_in_A and is_max_in_B:
            ans *= 1
        elif is_max_in_A:
            ans *= B_gt[i]
        elif is_max_in_B:
            ans *= A_gt[i]
        else:
            ans *= A_gt[i] * B_gt[i] - (MN - 1 - i)
        ans %= MOD
print(ans)


Measured memory_bytes: 82164
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin >> a >> b >> k;
    long long taka, ao;
    taka = a;
    ao = b;
    /*for(long long i=1; i<=k; i++){
        if(taka>0){
            taka--;
        }else if(ao>0){
            ao--;
        }else{
            break;
        }
    }*/
    if(k<=a){
        cout << taka-k <<  " " << ao << endl;
    }else if( k <= a+b){
        cout << 0 << " " << ao - (k-taka) << endl;
    }else{
        cout <<  0 << " " << 0 << endl;
    }
}




Measured memory_bytes: 256
#2020-03-21
import math
a, b, deg = map(int, input().split())

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(deg)))

s = (a+b+c)/2

area = (s * (s - a) * (s - b) * (s - c))**0.5

h = area * 2 / a

print(area)
print(a+b+c)
print(h)


Measured memory_bytes: 5720
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()

  c=0
  for i in range(1,n+1):
    a=str(i)
    if len(a)%2==1:
      c+=1

  return c

# main()
print(main())


Measured memory_bytes: 7844
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<b){
      System.out.println("0");
    }else{
      System.out.println("10");
    }
  }
}


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

#include <vector>
#include <iostream>

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

using namespace std;

typedef long long ll;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);



int main(void){
    ll m;
    cin >> m;
    cout << 48-m << endl;
};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >>s;
	unordered_map<char, int> mp;
	for(int i = 0; i < 3; i++)
		mp[s[i]]++;
	if(mp['A'] > 0 && mp['B'] > 0) {
		cout <<"Yes";
	}
	else {
		cout <<"No";
	}
	return 0;
}


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

int main(){ 
  vector<int> a(4);
  rep(i,4) cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int x[101];
  int y[101];
  int h[101];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  int hmax = h[0];
  int hmaxi = 0;
  for (int i = 0; i < N; i++) {
    if (hmax < h[i]) {
      hmax = h[i];
      hmaxi = i;
    }
  }

  int CX, CY, H;
  for (CX = 0; CX <= 100; CX++) {
    for (CY = 0; CY <= 100; CY++) {
      H = hmax + abs(CX - x[hmaxi]) + abs(CY - y[hmaxi]);
      bool ispassed = false;
      for (int k = 0; k < N; k++) {
        if (max(H - abs(x[k] - CX) - abs(y[k] - CY), 0) != h[k])
          break;
        if (k == N - 1)
          ispassed = true;
      }
      if (ispassed) {
        cout << CX << " " << CY << " " << H << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define int long long int

using namespace std;

int32_t main(void) {
    fast;
    int h, n, sum=0; cin>>h>>n;
    for(int i=0; i<n; i++) {
        int x; cin>>x;
        sum += x;
    }
    if(h > sum) cout<<"No";
    else cout<<"Yes";
}



Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc =  new Scanner(System.in);
        while(sc.hasNext()) {
            int  a = sc.nextInt();
            int b = sc.nextInt();
            int x,y;
            int temp = 0;
            if (a < b) {
                x = b;
                y = a;
            } else {
                x = a;
                y = b;
            }
            while(b != 0) {
                temp = b;
                b = a % b;
                a = temp;
            }
            System.out.println(a + " " + (x * (y / a)));
        }
    }
}

Measured memory_bytes: 26292
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

path = [[] for _ in range(N)]

for a, b in AB:
    a -= 1
    b -= 1

    path[a].append(b)
    path[b].append(a)

for i in range(N):
    path[i].append(i)

ans = []
j = 0
cnt = 0
for p in path:
    t = 0
    for i in p:
        if t < H[i]:
            t = H[i]
            hh = i
    if hh == j:
        cnt += 1
    j += 1

print(cnt)



Measured memory_bytes: 106560
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int n;
vi v;
inline bool f(int i, int t) {
	if(t == 0) return true;
	if(i >= n) return false;
	return f(i + 1, t) || f(i + 1, t - v[i]);
}
int main() {
	cin >> n;
	v.resize(n); rep(i, 0, n) cin >> v[i];
	int m; cin >> m;
	int t;
	rep(i, 0, m) {
		cin >> t;
		P(f(0, t) ? "yes" : "no");
	}
	return 0;
}

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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll a,b;
  cin>>a>>b;
  ll ans=0;
  reps(i,b-a+1){
    ans+=i;
  }
  cout<<ans-b<<endl;
  return 0;
}


Measured memory_bytes: 3608
#ifndef TEMPLATE
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define mp make_pair
#define sz(a) ((int)(a).size())
#define mem(x,v) memset((x),(v),sizeof((x)));
#define A(x) (x).begin(),(x).end()
#define re(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define erp(i,k,n) for(int i=n;i>=k;i--)
#define input(v,n) re(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using vvi = vector<vi>;
using tp = tuple<int,int,int>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = 1e11+6;
#endif
// ===================== MANASH =================== //

int n;

void test() {

      int W; cin >> n >> W;
      vvi dp(101,vi(nax,inf));
      vpi vec(n+1);
      rep(i,1,n) {
            cin >> vec[i].second >> vec[i].first;
      }
      dp[0][0] = 0;
      // Minimum Weight with Given Points.
      for( int i = 1; i <= n; i++) {
            dp[i] = dp[i-1];
            for( int p = vec[i].first; p < nax; p++) {
                  dp[i][p] = min(dp[i-1][p-vec[i].first]+vec[i].second,dp[i][p]);
            }
      }
      for( int p = nax-1; p >= 0; p--) if (dp[n][p] <= W) {
            cout << p;
            return;
      }
      assert(false);
}

signed main() {

      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
      int T = 1;
      //cin >> T;
      for( int tt = 1; tt <= T; tt++) {
            //cout << "Case #" << tt << " ";
            test();
            cout << "\n";
      }
      return 0;

}

Measured memory_bytes: 83192