akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	REP(i, d){
		REP(j, c) printf("1");
		REP(j, b-c) printf("0");
		printf("\n");
	}
	REP(i, a-d){
		REP(j, c) printf("0");
		REP(j, b-c) printf("1");
		printf("\n");
	}
}


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

typedef long long int ll;

int main()
{
    ll A, B, m;
    cin >> A >> B >> m;
    vector<ll> a(A), b(B);
    for(ll i = 0;i < A;i++){
        cin >> a[i];
    }
    for(ll i = 0;i < B;i++){
        cin >> b[i];
    }
    vector<tuple<ll,ll,ll>> xyz(m);
    for(ll i = 0;i < m;i++){
        cin >> get<0>(xyz[i]) >> get<1>(xyz[i]) >> get<2>(xyz[i]);
    }


    ll ans = a[get<0>(xyz[0]) - 1] + b[get<1>(xyz[0]) - 1] - get<2>(xyz[0]);
    for(ll i = 0;i < m;i++){
        ans = min(ans,a[get<0>(xyz[i]) - 1] + b[get<1>(xyz[i]) - 1] - get<2>(xyz[i]));
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
  
    ans = min(ans,a[0] + b[0]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 4096
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(T,X):
    return T/X

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int res=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            res++;
            a[i]=-1;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t N, M, C, B[20], A[20][20];
    int64_t sum, ans = 0;

    scanf("%"PRId64"%"PRId64"%"PRId64, &N, &M, &C);
    for (int i = 0; i < M; i++) {
        scanf("%"PRId64, &B[i]);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            scanf("%"PRId64, &A[i][j]);
        }
    }
    
    for (int i = 0; i < N; i++) {
        sum = 0;
        for (int j = 0; j < M; j++) {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0) ans++;
    }

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

    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s,t;
    cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<char>());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    long n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n);
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
char a[205];
	
int main(){
	IOS
	cin >> a;
	int n=strlen(a);
	for(int i=n-2;i;i-=2){
		if(strncmp(a, a+i/2, i/2)==0){
			cout << i << '\n'; 
			return 0;
		}
	}
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

char s;

int main(){
  cin >> s;
  s = s + 1;
  cout << s <<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10 ** 9 + 7

def main():
    s = SI()
    n = len(s)
    dp = [[0] * 13 for _ in range(n + 1)]
    # dp[i][m]...iケタ目までみたときに、余りがmになる数の個数
    dp[0][0] = mint(1)
    e10 = 1
    for i, c in enumerate(s[::-1]):
        for m in range(13):
            pre = dp[i][m]
            if pre == 0: continue
            if c == "?":
                for d in range(10):
                    nm = (m + d * e10) % 13
                    dp[i + 1][nm] += pre
            else:
                nm = (m + int(c) * e10) % 13
                dp[i + 1][nm] += pre
        e10 = e10 * 10 % 13
    print(dp[n][5])

main()


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N, M,X;
ll C[1010];
ll A[1010][1010];
ll mk[1010];
ll ans;
ll i, j, k;
int main(){
    scanf("%lld%lld%lld", &N, &M,&X);
    fornum(i,0,N){
        scanf("%lld", &C[i]);
        fornum(j,0,M){
            scanf("%lld", &A[i][j]);
        }
    }
    ans = 1e18;
    fornum(i,0,1<<N){
        fornum(j,0,M){
            mk[j] = 0;
        }
        ll c = 0;
        fornum(j,0,N){
            if(i&(1<<j))
                continue;
            c += C[j];
            fornum(k,0,M){
                mk[k] += A[j][k];
            }
        }
        fornum(j,0,M){
            if(X>mk[j])
                break;
        }
        if(j==M){
            ans = min(ans, c);
        }
    }
    if(ans==1e18){
        printf("-1\n");
    }else{
    printf("%lld", ans);
    }
    return 0;
}

Measured memory_bytes: 3816
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int ans = 0;
		for(int i = 0; i < 3; i++) ans += S.charAt(i) - '0';
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	fmt.Scan(&s)

	reg := regexp.MustCompile(`^A[a-z][a-z]*C[a-z]*[a-z]$`)
	result := "WA"
	if reg.MatchString(s) {
		result = "AC"
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
if __name__ == '__main__':
  def linearSearch(t):
    S.append(t)
    #print(S)
    i=0
    while S[i]!=t:
      i+=1
    del S[n]
    return 1 if i!=n else 0

  n=int(input())
  S=list(map(int,input().split()))
  q=int(input())
  T=set(map(int,input().split()))

  ans=0
  for t in T:
    ans+=linearSearch(t)
    #print(t,ans)
  print(ans)



Measured memory_bytes: 6556
#include<iostream>
#include<cstdio>
#include<numeric>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
const int maxn=1e9+7;
int main(){
	int n;
	cin>>n;
	vector<ll>a(n+10,0);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	vector<ll>dp(n+10,0);
	vector<ll>pre_sum(n+10,0);
	pre_sum[1]=a[1];
	for(int i=2;i<=n;i++){
		pre_sum[i]=pre_sum[i-2]+a[i];
	}
	//注意：dp[1]为0，因为dp[3]表示的含义是有三个元素，只要取一个，所以要么取3，要么不取三，那么结果就是dp[2]
	for(int i=2;i<=n;i++){
		if(i&1){//如果是奇数的话
			dp[i]=max(dp[i-2]+a[i],dp[i-1]);//如果奇数不选的情况下，一定是dp[i-1]中找，因为剩下是偶数个，i-1可以选择，以上可以不用选择的。。。
		}else{
			dp[i]=max(dp[i-2]+a[i],pre_sum[i-1]);//偶数不选的时候，前面还有奇数个元素，那么如果要选择出一半元素，前面每隔一个是必须选择的，所以是pre_sum[i-1]
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 7968
#define _GLIBCXX_DEBUG

#include "iostream"
#include "vector"

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    
    ll n,m;
    cin >> n >> m;

    ll total = 0;
    
    if(2*n <= m){
        total = n;
        m = m - 2*n;
        total += m/4;
        cout << total << endl;
        return 0;
    }
    else{
        total = m/2;
        cout << total << endl;
        return 0;
    }

    //return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer P = Integer.parseInt(scan.next());
        Integer Q = Integer.parseInt(scan.next());
        Integer R = Integer.parseInt(scan.next());

        System.out.println(P+Q < P+R ? (P+Q < Q+R ? P+Q : Q+R) : (P+R < Q+R ? P+R : Q+R) );
    }
}

Measured memory_bytes: 25172
#include<stdio.h>
void abc(int input[]);
void yasuko(int data[]);
int main()
{
	int i,t;
	int data[5];
	yasuko(data);
	for(i=0;i<5;i++){
		for(t=i+1;t<5;t++){
			if(data[i]<data[t]){
				int work=data[i];
				data[i]=data[t];
				data[t]=work;
			}
		}
	}
	abc(data);
	return 0;
}

void yasuko(int data[]){
	scanf("%d %d %d %d %d",&data[0],&data[1],&data[2],&data[3],&data[4]);
	return ;
}


void abc(int input[]){
	printf("%d %d %d %d %d\n",input[0],input[1],input[2],input[3],input[4]);	
	return ;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    int ans =1;
    for(int i=0;i<n-1;i++){
        if(a[i] ==a[i+1])continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  int ans = 0;
  for (auto &x: a) {
    while (x % 2 == 0) {
      x /= 2;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#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 each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    vl a(n);
    vvl xy(n, vl(n, -1));

    rep(i, n) {
        cin >> a[i];

        rep(_, a[i]) {
            ll x, y;
            cin >> x >> y;
            x--;
            xy[i][x] = y;
        }
    }

    ll ans = 0;
    rep(i, pow(2, n)) {
        vl tmp(n, -1); // 1:正直, -1:未定, 0:不親切決定
        bool out = false;
        rep(j, n) { // j番目の人
            if (1 & i >> j) { // jbit目を正直とする
                if (tmp[j] == 0) out = true;
                tmp[j] = 1;
                rep(l, n) {
                    if (xy[j][l] == -1) continue;
                    if (tmp[l] == -1) tmp[l] = xy[j][l];
                    else if (tmp[l] != xy[j][l]) {
                        out = true;
                        break;
                    }
                }
            } else {
                if (tmp[j] == 1) out = true;
                tmp[j] = 0;
            }
        }
        ll res = 0;
        rep(j, n) if (tmp[j] == 1) res++;
        if (!out) ans = max(ans, res);
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
	string x;
	cin>>x;
	long long int temp=0;
	long long int len=x.length()-1;
	for(int i=0;i<=len;i++){
		int b;
		b=x[i]-'0';
		temp+=b;
	}
	if(temp%9==0){
		cout<<"Yes"<<endl;
	}
	else
	
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    
    if(abs(x - a) < abs(x - b)){
        cout << "A";
    } else{
        cout << "B";
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n, m;
    cin >> n;
    string s;
    map<string, int> v;

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

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

    int cnt=0;

    for(auto itr=v.begin(); itr != v.end(); ++itr){
        cnt = max(cnt, itr->second);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

if N%2:
    for i in range(M):
        print(2+i, N-i)
else:
    used = set()
    s = 1
    for i in list(range(2, M+1, 2)[::-1])+list(range(1, M+1, 2)[::-1]):
        while 1:
            if not s in used and not (s+i) in used:
                used.add(s)
                used.add(s+i)
                print(s, s+i)
                break
            s += 1

Measured memory_bytes: 20496
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int n;
int a[N];
int dp[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 0;
    }
    int mx = 0;
    for(int i = 2; i <= n; i++){
        if(a[i - 1] >= a[i]){
            dp[i] = dp[i - 1] + 1;
        }
        mx = max(mx , dp[i]);
    }
    cout << mx << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  string s;
  cin >> s;
  int f = 0;
  if (s[2] == s[3]) f++;
  if (s[4] == s[5]) f++;
  if (f == 2) cout << "Yes";
  if (f != 2) cout << "No";
  return 0;
}

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

#define int long long

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

int X, Y;

signed main() {
    cin >> X >> Y;
    int ans = 0;
    while (X <= Y) {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c = 2 * c;
  int ans = 1e9;
  for (int i = 0; i <= max(x, y); ++i) {
    int cnt1 = max(0, x - i);
    int cnt2 = max(0, y - i);
    ans = min(ans, a * cnt1 + b * cnt2 + c * i);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int N = 100010;

vector<int> g[N];
int parent[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    queue<int> q;
    memset(parent, -1, sizeof(parent));
    q.push(1);
    parent[1] = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g[u]) {
            if (parent[v] == -1) {
                q.push(v);
                parent[v] = u;
            }
        }
    }

    bool ans = true;
    for (int i = 1; i <= n; ++i) {
        if (parent[i] == -1) {
            ans = false;
            break;
        }
    }
    if (!ans) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
        for (int i = 2; i <= n; ++i) {
            cout << parent[i] << '\n';
        }
    }
    return 0;
}


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

typedef long long ll;
int q, h, s, d, n;
ll one, two, three, four;

int main() {
	cin >> q >> h >> s >> d >> n;
	one = q;
	two = min(1ll * q * 2, 1ll * h);
	three = min(min(1ll * q * 4, 1ll * h * 2), 1ll * s);
	four = min(min(min(1ll * q * 8, 1ll * h * 4), 1ll * s * 2), 1ll * d);
	ll ans = 0;
	ans += (n / 2) * four;
	n -= (n / 2) * 2;
	ans += n * three;
	cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll M;
  scanf("%lld",&M);
  cout << 48-M << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main(){
  int A,B,C;cin >> A >> B >> C;
  if(A==B&&B==C){
    cout << "No" << endl;
  }else if(A!=B&&B!=C&&C!=A){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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


def treeDist(u, E):
    D = [-1]*len(E)
    q = [(u, 0)]
    while q:
        i, d = q.pop()
        if D[i] != -1:
            continue
        D[i] = d
        for j in E[i]:
            q.append((j, d+1))
    return D


def main():
    N, u, v = map(int, input().split())
    E = [[] for i in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a-1].append(b-1)
        E[b-1].append(a-1)

    D1 = treeDist(u-1, E)
    D2 = treeDist(v-1, E)
    ans = 0
    for d1, d2 in zip(D1, D2):
        if d1 < d2:
            ans = max(ans, d2)
    print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33424
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

ll power(ll x, ll n){
    if (n==0) return 1;
    else if (n%2 == 0) return power((x*x)%998244353, n/2);
    else return (x*power(x, n-1))%998244353;
}

int N;
int D[100001];
ll S[100001];
ll dp[100001];
int main(void){
    cin >> N;
    REP(i,N) cin >> D[i];

    if(D[0] > 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        if(D[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }

    REP(i,N) S[D[i]] += 1;

    dp[0] = 1;
    bool f = false;
    for(int i=1;i<N;i++){
        if(S[i] == 0){
            f = true;
            dp[i] = dp[i-1];
            continue;
        }
        if(f == true and S[i] > 0){
            cout << 0 << endl;
            return 0;
        }
        dp[i] = (dp[i-1]*power(S[i-1], S[i]))%998244353;
    }
    cout << dp[N-1] << endl;

    return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int ans = 1;
	int x = n - k;
	if (x > 0) {
		ans += x / (k-1);
		if (x % (k-1)) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

struct UnionFind{
  vector<int> data;
  UnionFind(int n): data(n, -1){};

  void unite(int a, int b){
    a = find(a), b = find(b);
    if(a==b) return;
    if(data[a] > data[b]) swap(a, b);
    data[a] += data[b];
    data[b] = a;
  }
  int find(int x){
    if(data[x] < 0){
      return x;
    }
    return find(data[x]);
  }
  bool same(int a, int b){
    return find(a) == find(b);
  }
  int size(int x){
    return -data[find(x)];
  }
};
struct Edge{
  int a, b;
  long long weight;
  Edge(int a, int b, ll weight): a(a), b(b), weight(weight){};
  bool operator< (const Edge & r) const{
    return weight < r.weight;
  }
};
struct Point {
  int x, y, id;
  Point(int x, int y, int id): x(x), y(y), id(id){};
  Point(){};
};

bool cmp1(Point l, Point r){
  return l.x < r.x;
}

bool cmp2(Point l, Point r){
  return l.y < r.y;
}

int main(){
  int N;
  cin >> N;
  vector<Point> xy(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    xy[i] = Point(x, y, i);
  }
  sort(xy.begin(), xy.end(), cmp1);
  vector<Edge> edges;
  REP(i, N-1){
    edges.push_back(Edge(xy[i].id, xy[i+1].id, xy[i+1].x - xy[i].x));
  }
  sort(xy.begin(), xy.end(), cmp2);
  REP(i, N-1){
    edges.push_back(Edge(xy[i].id, xy[i+1].id, xy[i+1].y - xy[i].y));
  }
  sort(edges.begin(), edges.end());

  ll ans = 0;
  int E = edges.size();
  UnionFind uf(N);
  REP(i, E){
    int a = edges[i].a, b = edges[i].b;
    if(uf.same(a, b)) continue;
    ans += edges[i].weight;
    uf.unite(a, b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8604
#include <iostream>
#include <algorithm>
using namespace std;
long long n , mod = 1e9+7;
long long sol()
{
	long long a=1 ,b=1 ,c=1 ,res = 0 ,t=0;
	while(t++<n)
	{
		a = (a*10)%mod; 
		b = (b*9)%mod; 
		c = (c*8)%mod;
	} 
	b = (b*2)%mod;
	res = ((a-b+mod)%mod+c)%mod;
	return res;				
}

int main() 
{	
	cin >> n;
	cout<<sol()<<'\n';
}

Measured memory_bytes: 3156
package main

import "fmt"

// 2018-08-12T13:34:47+0800
// 2018-08-12T13:48:22+0800
func main() {
	var N, T int
	fmt.Scanf("%d%d", &N, &T)
	t := 0
	out := 0
	end := 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &t)
		if t >= end {
			out += T
		} else {
			out += T - (end - t)
		}
		end = t + T
	}
	fmt.Println(out)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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 (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int  n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll n;
ll a[300000];
int main(){
    cin >> n;
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }
    sort(a,a+n*3);
    reverse(a,a+n*3);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[2*i+1];
    }
    cout << ans << endl;
}

 

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll a[100000];
int b[100000];

int jg(int k, ll sum){
    if(b[k] == 1)return 1;
    if(b[k] == -1)return -1;
    if((sum + a[k])*2 >= a[k+1])return b[k] = jg(k+1, sum + a[k]);
    jg(k+1, sum + a[k]);
    return b[k] = -1;
}
int main(void){
    int n; cin >> n; for(int i = 0;i < n;i++)cin >> a[i];
    sort(a, a + n);
    int count = 0; ll sum = 0;
    fill(b, b + n, 0);
    b[n-1] = 1;
    jg(0, 0);
    int ans = 0;
    while(b[n-ans-1] == 1)ans++;
    cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <set>
#include <string>
typedef long long ll;
using namespace std;

int main(void) {
  string s;
  int i, j, k;
  set<string> se;
  cin >> s >> k;
  for(i = 0; i < s.size(); ++i) {
    string t;
    t += s[i];
    se.insert(t);
    set<string>::iterator it = se.end();
    it--;
    if(se.size() > 5) se.erase(it);
    for(j = i + 1; j < s.size(); ++j) {
      t += s[j];
      se.insert(t);
      it = se.end();
      it--;
      if(se.size() > 5) se.erase(it);
    }
  }
  set<string>::iterator it = se.begin();
  string ans;
  for(i = 0; i < k; ++i) {
    ans = *it;
    it++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
from numba import njit, i8


@njit(i8(i8, i8, i8[:], i8[:]), cache=True)
def solve(N, W, weights, values):
    dp = np.full((N + 1, W + 1), 0, dtype=np.int64)
    dp[0][0] = 0
    for i in range(N):
        for j in range(W + 1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            if j + weights[i] <= W:
                dp[i + 1][j + weights[i]] = max(
                    dp[i + 1][j + weights[i]], dp[i][j] + values[i]
                )
    return dp[-1].max()


N, W = map(int, input().split())
weights = np.zeros(N, dtype=np.int64)
values = np.zeros(N, dtype=np.int64)
for i in range(N):
    w, v = map(int, input().split())
    weights[i] = w
    values[i] = v
print(solve(N, W, weights, values))


Measured memory_bytes: 185252
import collections

n, t = map(int, input().split())
tpls = list(sorted(tuple(map(int, input().split())) for _ in range(n)))
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = tpls[i]

dp = [[0] * (t + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(t):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        k = min(t, j + a[i])
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + b[i])
print(max(map(max, dp)))

Measured memory_bytes: 117336
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class Rng>
void in(Rng& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class Rng>
void in(vector<Rng>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;
	LL ans = 0;
	ans += 2 * O;
	LL p, q, r;
	p = I;
	q = J;
	r = L;
	LL oddc = 0;
	oddc += p % 2;
	oddc += q % 2;
	oddc += r % 2;
	LL temp = 0;
	if (min(p, min(q, r)) == 0) {
		temp += (p / 2) * 4;
		temp += (q / 2) * 4;
		temp += (r / 2) * 4;
	}
	else {
		temp = 2 * (p + q + r);
		if (oddc == 3 || oddc == 0)temp -= 0;
		else temp -= 2;
	}
	ans += temp;
	cout << ans / 2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a , b, k;
  cin >> k >> a >> b;
  
  if( k > a && k > b )
  {
    cout<<"NG";
    return 0;
  }
  int r = a % k;

  int q = (a/k);
  if( r == 0 || (q + 1)*k <= b) 
  	cout<<"OK";
  else
    cout<<"NG";
return 0;      
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


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

  std::vector<ll> a(n,s+1);

  if(s==1000000000){
    for(ll i=0;i<n;i++){
      a.at(i)=1;
    }

    for(ll i=0;i<k;i++){
      a.at(i)=s;
    }
    
  }


  else{for(ll i=0;i<k;i++){
    a.at(i)=s;
  }
}

for(ll i:a){
  cout << i << endl;
}
  }


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  vector<int> R(3);
  rep(i,3)cin>>R[i];
  sort(begin(R),end(R));
  cout<<R[0]+R[1]<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(){
  int N, M, a, b;
  int one[200000] = {0};
  int shimaN[200000] = {0};
  int check[200000] = {0};

  cin >> N >> M;

  for(int i = 0;i < M;i++){
    cin >> a >> b;
    if(a == 1){
      one[b-1] = 1;
    } else if (b == 1){
      one[a-1] = 1;
    } else if (a == N){
      shimaN[b-1] = 1;
    } else if (b == N){
      shimaN[a-1] = 1;
    }
  }

  for(int i = 0;i < N;i++){
    check[i] = one[i] + shimaN[i];
  }

  for(int i = 0;i < N;i++){
    if(check[i] == 2){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.length();
  vector<string> vs;
  map<string, int> mp;
  for(int i = 0; i < n; i++) {
    for(int j = 1; j <= k; j++) {
      if(i + j > n) {
        break;
      }
      if(mp[s.substr(i, j)] == 1) {
        continue;
      } else {
        mp[s.substr(i, j)] = 1;
        vs.push_back(s.substr(i, j));
      }
    }
  }
  sort(vs.begin(), vs.end());
  cout << vs[k - 1] << endl;
  return 0;
}

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

int main(){
    int n, w; cin >> n >> w;
    vector<vector<int> > dp(n+1, vector<int>(w+1, 0));
    vector<int> W(n);
    vector<int> V(n);
    for(int i = 0; i < n; i++){
        cin >> V[i] >> W[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int l = 0; l <= w; l++){
            if(l-W[i-1] >= 0){
                dp[i][l] = max(dp[i-1][l], max(dp[i-1][l-W[i-1]] + V[i-1], dp[i][l-W[i-1]] + V[i-1]));
            }else{
                dp[i][l] = dp[i-1][l];
            }
            ans = max(ans, dp[i][l]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6840
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N;vl A(N);rep(i,N)cin>>A[i];
  vl sa(N+10);sa[0]=abs(A[0]);sa[N]=abs(A[N-1]);
  ll tot= sa[0]+sa[N];
  for(int i=1;i<N;i++){
    sa[i]=abs(A[i]-A[i-1]);
    tot +=sa[i];
  }
  cout<<tot-sa[0]-sa[1]+abs(A[1])<<endl;
  for(int i=1;i<N-1;i++){
    cout<<tot-sa[i]-sa[i+1]+abs(A[i-1]-A[i+1])<<endl;
  }
  cout<<tot-sa[N-1]-sa[N]+abs(A[N-2])<<endl;
}





Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	int points[ 3 ];
	string T;
	cin >> N >> K;
	cin >> points[ 0 ] >> points[ 1 ] >> points[ 2 ];
	cin >> T;
	vector <int> vec( N );
	rep( i, 0, N ){
		switch (T[ i ]){
		case 'r':
			vec[ i ] = 2;
			break;
		case 's':
			vec[ i ] = 0;
			break;
		default:
			vec[ i ] = 1;
		}
	}
	int sum = 0;
	vector <int> arr;
	rep( i, 0, N ){
		if(i < K){
			arr.push_back( vec[ i ] );
		}
		else {
			if (vec[ i ] != vec[ i - K ] || arr[ i - K ] == -1){
				arr.push_back( vec[ i ] );
			}
			else {
				arr.push_back( -1 );
			}
		}
	}
	for(auto v: arr){
		if (v != -1)
			sum += points[ v ];
	}
	cout << sum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

char maze[50][51];
int sx,sy,gx,gy;
int d[50][51];
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};
int H,W;

int bfs(){
    queue<P> que;
    rep(i,0,50) rep(j,0,51) d[i][j]=INF;
    d[sy][sx]=0;
    que.push(P(sy,sx));
    while(que.size()){
        P p=que.front(); que.pop();
        if(p.first==gy&&p.second==gx) break;
        rep(i,0,4){
            int ny=p.first+dy[i], nx=p.second+dx[i];
            if(0<=nx&&nx<W&&0<=ny&&ny<H&&d[ny][nx]==INF&&maze[ny][nx]!='#'){
                que.push(P(ny,nx));
                d[ny][nx]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gy][gx];
}

int main(){
    cin>>H>>W;
    int white=0;
    rep(i,0,H) rep(j,0,W){
        cin>>maze[i][j];
        if(maze[i][j]=='.') white++;
    }
    sx=0,sy=0,gx=W-1,gy=H-1;
    int ans=bfs();

    if(ans==INF) cout << -1 << endl;
    else cout<<white-ans-1<<endl;

}

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

UF = list(range(N + 1))
SIZE = [0] + [1] * N  # 1-indexed


def find(x):
    if UF[x] != x:
        UF[x] = find(UF[x])
    return UF[x]


def unite(x, y):
    X, Y = find(x), find(y)
    SX, SY = SIZE[X], SIZE[Y]
    if SX > SY:
        m = X
    else:
        m = Y
    SIZE[m] = SX + SY
    #SIZE[X + Y - m] = 0
    UF[X + Y - m] = m


def is_same(x, y):
    return find(x) == find(y)


def scan_uf():
    for i in range(len(UF)):
        find(i)


ans = [N * (N - 1) // 2]
for a, b in AB[::-1]:
    if not is_same(a, b):
        ans += [ans[-1] - SIZE[find(a)] * SIZE[find(b)]]
        unite(a, b)
    else:
        ans += [ans[-1]]
print(*ans[-2::-1], sep='\n')


Measured memory_bytes: 31048
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n;
	string s;

	cin >> n >> s;

	for (int i = 0; i < s.size(); i++) {
		int ch = (s[i] -'A') + n;
		char ch2 = (ch % 26) + 'A';

		cout << (char)ch2 ;

	}

	cout << endl;

	return 0;
}


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


class Program {
    internal static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int max = A.Max();
        int min = A.Min();

        WriteLine(max - min);
    } 
}

Measured memory_bytes: 13396
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int partition(vector<int> &a,int p,int r){
    int i=p-1;
    for(int j=p;j<r;j++){
        if(a.at(j)<=a.at(r)) {
            i++;            
            swap(a.at(i),a.at(j));
        }
    }
    swap(a.at(r),a.at(i+1));
    return i+1;
}

int main(void){
    ll n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a.at(i);
    int x=partition(a,0,n-1);
    for(int i=0;i<n;i++){
        if(i==x)cout<<"[";
        cout<<a.at(i);
        if(i==x)cout<<"]";
        if(i!=n-1)cout<<" ";
    }
    cout<<endl;
    return 0;
}



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

int main(){
  ios_base::sync_with_stdio(false);

  int n;
  int ans = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    int s,t;
    cin >> s >> t;
    ans += t-s+1;
  }
  
  cout << ans << endl;  

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    int c = 0;
    int cn = n;
    while(cn > 0) {
        c += cn % 10;
        cn /= 10;
    }

    print(n % c == 0 ? "Yes" : "No");

}

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

int main(){
  int i,op[100],t=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      op[t-2]=op[t-2]+op[t-1];
      t--;
    }
    else if ( s[0] == '-' ){
      op[t-2]=op[t-2]-op[t-1];
      t--;
    }
    else if ( s[0] == '*' ){
      op[t-2]=op[t-2]*op[t-1];
      t--;
    }
    else op[t++] = atoi(s);
    
  }
  printf("%d\n",op[0]);

  return 0;
}




Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>

using namespace std;

vector< vector<int> > dp;
vector<int> w,v;
int n,weight;

int rec(int i,int j){

	if(dp[i][j]>=0) return dp[i][j];

	int res;
	if(i==n) res=0;
	else if(j<w[i]) res=rec(i+1,j);
	else res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);

	return dp[i][j]=res;
}

int main(){

	int count=1;
	cin>>weight;
	while(weight!=0){
		cin>>n;
		w.resize(n); v.resize(n);
		for(int i=0;i<n;i++) scanf("%d,%d",&v[i],&w[i]);

		dp = vector< vector<int> >(n+1);
		for(int i=0;i<n+1;i++) dp[i]=vector<int>(weight+1,-1);

		for(int i=0;i<weight+1;i++) dp[n][i]=0;

		for(int i=n-1;i>=0;i--){
			for(int j=0;j<weight+1;j++){
				if(j<w[i]) dp[i][j]=dp[i+1][j];
				else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
			}
		}

		cout<<"Case "<<count<<":"<<endl<<dp[0][weight]<<endl;
		for(int i=weight-1;i>=0;i--){
			if(dp[0][i]!=dp[0][weight]){
				cout<<i+1<<endl;
				break;
			}
		}
		count++;
		cin>>weight;
	}


	return 0;

}

Measured memory_bytes: 4968
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for i in range(3):
    if (A[i][0] in B and A[i][1] in B and A[i][2] in B) or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        print("Yes")
        exit()
if (A[0][0] in B and A[1][1] in B and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B):
    print("Yes")
    exit()
print("No")


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

using namespace std;

int main(int, char**) {
        int n, m;
        cin >> n >> m;
        vector<vector<int>> G;
        G.assign(n, vector<int>());
        for (int i=0; i<m; i++) {
                int a, b;
                cin >> a >> b;
                a--; b--;
                G[a].push_back(b);
                G[b].push_back(a);
        }
        vector<int> num(n, 0);
        num.at(0) = 1;
        queue<int> que;
        que.push(0);
        int cnt = 1;

        while (!que.empty()) {
                int q = que.front();
                que.pop();
                int len = G[q].size();
                for (int i=0; i<len; i++) {
                        int p = G[q][i];
                        if (num[p]==0) {
                                num[p] = q + 1;
                                que.push(p);
                                cnt++;
                                //cout << p << endl;
                                //cout << cnt << endl;
                        }
                }
        }
        if (cnt==n) {
                cout << "Yes" << endl;
                for (int i=1; i<n; i++) {
                        cout << num[i] << endl;
                }
        } else {
                cout << "No" << endl;
        }
        return 0;
}


Measured memory_bytes: 10244