akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector<int> a[2010];
int dp[2010], ans[2010];
int main(){
    int n, x, y;
    while(cin>>n>>x>>y){
        for(int i=1; i<n; ++i){
        	a[i].push_back(i+1);
        	a[i+1].push_back(i);
        }
        a[x].push_back(y);
        a[y].push_back(x);
        for(int i=1; i<=n; ++i){
        	queue<pair<int, int> > q;
        	q.push(mk(i, 0));
        	memset(dp, -1, sizeof dp);
        	pair<int, int> tmp;
        	while(!q.empty()){
        		tmp=q.front();
        		q.pop();
        		if(dp[tmp.fs]!=-1){
        			continue;
        		}
        		dp[tmp.fs]=tmp.sc;
        		++ans[tmp.sc];
        		for(int j=0; j<a[tmp.fs].size(); ++j){
        			q.push(mk(a[tmp.fs][j], tmp.sc+1));
        		}
        	}
        }
        for(int i=1; i<n; ++i){
        	printf("%d\n",ans[i]/2);
        }
    }
  return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A,B,C,D;
    cin >> A >> B >> C >> D;
  	if(A+B > C+D){
    	cout << "Left" << endl;
    }
  	else if(A+B < C+D){
    	cout << "Right" << endl;
    }
  	else{
    	cout << "Balanced" << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k; cin>>k;
    ll n = (k+49)/50;
    ll a = 50*n-k;
    cout<<50<<endl;
    rep(i,a){
        if (i!=0) cout<<" ";
        cout<<n+a-2;
    }
    rep(i,50-a){
        if (!(a==0&&i==0)) cout<<" ";
        cout<<49+n+a;
    }
    cout<<"\n";
    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

const int MX = 100005;
vector<Pint> g[MX];
int x[MX];
bool used[MX];

vector<int> ans;
int dfs(int v) {
  used[v] = true;
  int res = x[v];
  for(Pint e: g[v]) {
    if(used[e.first]) continue;
    int r = dfs(e.first);
    if(r) ans.push_back(e.second);
    // 0-0->0, 0-1->1, 1-0->1, 1-1->0なのでxorでスイッチするか決めて実行した後の親の状態が取れる
    res ^= r;
  }
  return res;
}


int main(int argc, char const* argv[])
{
  int n, m;
  cin>>n>>m;
  vector<Pint> as(n);
  REP(i,n) cin>>as[i].first>>as[i].second;
  sort(ALL(as));
  x[0] = as[0].second;
  REP(i,n-1) x[i+1] = as[i+1].second ^ as[i].second;
  x[n] = as[n-1].second;

  REP(i,m) {
    int l, r;
    cin>>l>>r;
    l = lower_bound(ALL(as), Pint(l,0)) - as.begin();
    r = upper_bound(ALL(as), Pint(r,1)) - as.begin();
    g[l].emplace_back(r,i+1);
    g[r].emplace_back(l,i+1);
  }

  REP(i,n+1) {
    if(used[i]) continue;
    if(dfs(i)) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans.size() << endl;
  if(ans.size()) {
    sort(ALL(ans));
    REP(i,ans.size()-1) printf("%d ", ans[i]);
    printf("%d\n", ans[ans.size()-1]);
  }

  return 0;
}

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

typedef long long ll;
int N;
vector<int> A;
vector<char> O;
vector<ll> psum;
vector<int> sidx;
vector<ll> res;

int main() {
    scanf("%d", &N);
    A.resize(N);
    O.resize(N - 1);
    for(int i = 0; i < N - 1; i++) {
        scanf("%d %c", &A[i], &O[i]);
    }
    scanf("%d", &A[N - 1]);

    psum.resize(N);
    for(int i = 0; i < N; i++) {
        psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    for(int i = 0; i < N - 1; i++) {
        if(O[i] == '-') sidx.push_back(i);
    }

    ll ans = A[0];
    res.resize(N);
    res[0] = ans;

    for(int i = 1; i < N; i++) {
        ans += O[i - 1] == '+'? A[i] : -A[i];
        res[i] = ans;
    }

    sidx.push_back(N - 1);

    for(int i = 0; i < (int)sidx.size() - 1; i++) {
        int now = sidx[i];
        int nxt = sidx[i + 1];

        ans = max(ans, res[now] + -(psum[nxt] - psum[now]) + psum[N - 1] - psum[nxt]);
    }

    printf("%lld", ans);
}


Measured memory_bytes: 2808
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    A[i] -= 1

path = [0]
went = {0: 0}
while True:
    town = A[path[-1]]
    if town in went.keys():
        break
    else:
        went[town] = len(path)
        path.append(town)
start = went[town]
if K < len(path):
    ans = path[K]
else:
    ans = path[(K - start) % (len(path) - start) + start]
ans += 1
print(ans)
pass


Measured memory_bytes: 39240
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int INF = 1e9, SEGMENT_TREE_SIZE = 1 << 19;
 
long long f[200005];
struct info{int L, R;};
info merge(info a, info b) {info x = {f[a.L]-a.L < f[b.L]-b.L ? a.L : b.L, f[a.R]+a.R < f[b.R]+b.R ? a.R : b.R}; return(x);}
 
template <class T>
class SegmentTree {
    T * a; int * L, * R;
    void divide(int i, int l, int r) {
        L[i] = l; R[i] = r;
        if (L[i] == R[i]) return;
        divide(2*i+1, l, (l+r)/2);
        divide(2*i+2, (l+r)/2+1, r);
    }
    void update(int i, int pos, T x) {
        if (L[i] > pos || R[i] < pos) return;
        if (L[i] == pos && R[i] == pos) {a[i] = x; return;}
        update(2*i+1, pos, x);
        update(2*i+2, pos, x);
        a[i] = merge(a[2*i+1], a[2*i+2]);
    }
    T search(int i, int l, int r) {
        if (L[i] >= l && R[i] <= r) return a[i];
        if (R[2*i+1] >= r) return search(2*i+1, l, r);
        if (L[2*i+2] <= l) return search(2*i+2, l, r);
        return merge(search(2*i+1, l, r), search(2*i+2, l, r));
    }
public:
    SegmentTree(int l, int r) {
        a = new T [SEGMENT_TREE_SIZE];
        L = new int [SEGMENT_TREE_SIZE];
        R = new int [SEGMENT_TREE_SIZE];
        divide(0, l, r);
    }
    void setval(int pos, T x) {update(0, pos, x);}
    T getval(int l, int r) {return search(0, l, r);}
};
 
int main() {
    int N, Q, A, B; scanf("%d%d%d%d", &N, &Q, &A, &B);
    fill(f + 1, f + N + 1, INF); f[A] = 0;
    SegmentTree<info> T(1, N);
    for (int i = 1; i <= N; ++i) {info x = {i, i}; T.setval(i, x);}
    int cur, prv = B; long long inc = 0, ans = 0;
    for (int i = 1; i <= Q; ++i) {
        scanf("%d", &cur); inc += abs(cur - prv);
        int l = T.getval(0, cur).L, r = T.getval(cur, N).R;
        ans = min(ans, f[prv] = min(f[l] + cur - l, f[r] - cur + r) - abs(cur - prv));
        info x = {prv, prv}; T.setval(prv, x); prv = cur;
    }
    printf("%lld", ans + inc);
    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll A,B;
    cin >>A>>B;
    
    cout << lcm(A,B) << endl;


    return 0;
    

}

Measured memory_bytes: 3612
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
#a, v = map(int, sys.stdin.readline().split())
#s = input()
x = list(map(int, sys.stdin.readline().split()))
     

for i in range(5):
    if x[i] == 0:
        print(i+1)





















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

int n, dp[5][41];

int min(int a, int b){
    return a < b ? a : b;
}

int main(void){
    int x, y, z;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(x = 1; x <= 4; x++){
        for(y = 40; y >= 0; y--){
            for(z = 0; z <= min(y, 9); z++){
                dp[x][y] += dp[x-1][y-z];
            }
        }
    }
    while(scanf("%d", &n) != EOF){
        printf("%d\n", dp[4][n]);
    }
    return 0;
}

Measured memory_bytes: 596
n = int(input())
a = list(map(str, input().split()))
b = a.copy()


def bubble_sort():
    for i in range(n):
        for j in reversed(range(i+1, n)):
            num = int(a[j][1])
            num_ = int(a[j-1][1])
            if num < num_:
                a[j], a[j-1] = a[j-1], a[j]
    return a


def selection_sort():
    for i in range(n):
        minv = int(b[i][1])
        mink = i
        for j in range(i, n):
            if int(b[j][1]) < minv:
                minv = int(b[j][1])
                mink = j
        if int(b[i][1]) != minv:
            b[i], b[mink] = b[mink], b[i]
    return b


bubble = bubble_sort()
selection = selection_sort()


def check_stable():
    if selection == bubble:
        return 'Stable'
    else:
        return 'Not stable'


check_selection = check_stable()


print(*bubble)
print('Stable')
print(*selection)
print(check_selection)


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

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

int main() {
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    ll lcm = a[0];
    for (int i = 1; i < N; i++) {
        lcm = lcm/gcd(lcm, a[i])*a[i];
        if (lcm > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < N; i++) {
        if ((lcm/a[i])%2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ((M/lcm+1)/2) << endl;
    return 0;
}


Measured memory_bytes: 1024
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

ll n;
char c;
vector<char> v;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	string s="";
	 while(n){
	    c=(n-1)%26+'a';
	 	v.pb(c);
	 	if(n%26==0) n=n/26-1;
	 	else n/=26;
	 }
     for(int i=v.size()-1;i>=0;--i){
     	cout<<v[i];
     }
    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    std::string s[100];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 1; i < n; i++) {
        std::string prev = s[i - 1], now = s[i];
        if (prev[prev.size() - 1] != now[0]) {
            cout << "No" << endl;
            return 0;
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (now == s[i])
                count++;
        }
        if (count >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 888
import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# n, m, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
#
#  abc = [int(input()) for i in range(5)]
n = int(input())
# w = list(map(int, input().split()))
#A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
# a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
ab_sorted = sorted(ab, key=lambda x: x[1])
# print(ab_sorted)

total = 0
for i in range(n):
    total += ab_sorted[i][0]
    if total > ab_sorted[i][1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 49836
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a := nextInt()
	b := nextInt()
	k := nextInt()

	if a >= k {
		fmt.Printf("%d %d", a - k, b)
	} else if a + b >= k {
		fmt.Printf("0 %d", a + b - k)
	} else {
		fmt.Printf("0 0")
	}
}


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

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

	int	n;
	cin >> n;
	vector<int> V(n);
	rep(i, n)
	{
		int a;
		cin >> a;
		V.at(a - 1) = i + 1;
	}
	rep(i, n)
	{
		if (i)
			cout << ' ';
		cout << V.at(i);
	}
	cout << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string op;
  int A, B;
  cin >> A >> op >> B;
  
  if (op == "+"){
	cout << A + B << endl;
  }
  else if (op == "-"){
    cout << A - B << endl;
  }
}

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

int main()
{
    long long N, W;
    cin >> N >> W;

    vector<long long> w(N + 1, 0);
    vector<long long> v(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
    }

    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W)
            {
                dp[i][j + w[i]] = max(dp[i - 1][j + w[i]], dp[i - 1][j] + v[i]);
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i <= W; i++)
    {
        ans = max(ans, dp.back()[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;

    vector<bool> alpha(26);

    string ans = "";
    string tmp = "";
    if (s[0] != 'z') ans = s[0]+1;
    //cout << ans << endl;
    rep(i, s.size()){
        tmp += s[i];
        int num = s[i] - 'a';
        alpha[num] = true;
        
        bool ok = false;
        char parts;
        char next = (i == s.size()-1) ? -1 : s[i+1]-'a'; 
        for (int j = next + 1; j < 26; j++)
        {
            if (!alpha[j]) {
                ok = true;
                parts = j + 'a';
                break;
            }   
        }
        if (ok == true){
            ans = tmp + parts;
        }
        //cout << tmp << ";" << parts << ":" << (int)next <<endl;
    }

    if (ans == ""){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long 
#define ld long double
using namespace std;
const int N = 1e5+5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;cin>>n;
	int b[n-1];
	int sum = 0;
	for(int i = 0; i < n-1; i++)
		cin>>b[i];
	sum+=b[n-2];
	int prev = b[n-2];
	for(int i = n-3; i >= 0; i--)
	{
		prev = min(b[i], b[i+1]);
		// cout<<prev<<"\n";
		sum+= prev;
	}
	// cout<<prev<<"\n";
	sum+= b[0];
	cout<<sum<<"\n";
	return 0;
}







Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


input = sys.stdin.readline


def main():
    N = int(input())
    d = [int(i) for i in input().split()]

    ans = 0
    for i in range(N):
        for j in range(i):
            ans += d[i]*d[j]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
from fractions import gcd

N, X = map(int, input().split())
xlist = list(map(int, input().split()))
gaplist = []
for i in range(N):
    tmp = abs(xlist[i] - X)
    if tmp==0:
        tmp = 1
    gaplist.append(tmp)

ans = gaplist[0]
for i in range(1,N):
    ans = gcd(ans, gaplist[i])
    #次のxとの最大公約数を動的計画法求めるメソッド O(logX)

print(ans)



Measured memory_bytes: 16280
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
typedef long long int lli;
typedef unsigned long long int uli;
using namespace std;
int main(){
  int a,b,c,x,y,n,m;
  string s,t;
  char d,e;
  cin>>a>>b;
  rep(i,0,a)
    s+=to_string(b);
  rep(i,0,b)
    t+=to_string(a);
  ou(min(s,t));
}

Measured memory_bytes: 256
//============================================================================
// Name        : ITP_1_4_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a,b;
	char op;
	while(1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		switch(op) {
		case '+' :
			printf("%d\n",a+b);
			break;
		case '-' :
			printf("%d\n",a-b);
			break;
		case '*' :
			printf("%d\n",a*b);
			break;
		case '/' :
			printf("%d\n",a/b);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3132
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}


struct data{
	int id;
	int g;
	double d;
	data(){};
	data(int id, int g, double d){
		this-> id = id;
		this->g = g;
		this->d = d;
	}
};

bool comp(data d1, data d2){
	return d1.d < d2.d;
}

data ds[24];
bool used[24];

int main(){
	fill(used, used + 24,false);
	rep(i, 24){
		cin >> ds[i].id >> ds[i].d;
		ds[i].g = i / 8;
	}
	sort(ds, ds + 24, comp);
	int cnt = 0;
	rep(i, 24){
		if(cnt < 2 && !used[i] && ds[i].g == 0){
			cnt++;
			used[i] = true;
			cout << fixed << setprecision(2) <<  ds[i].id << " " << ds[i].d << endl;
		}
	}
	cnt = 0;
	rep(i, 24){
			if(cnt < 2 && !used[i] && ds[i].g == 1){
			cnt++;
			used[i] = true;
			cout << ds[i].id << " " << ds[i].d << endl;
		}
	}
	cnt = 0;
	rep(i, 24){
		if(cnt < 2 && !used[i] && ds[i].g == 2){
			cnt++;
			used[i] = true;
			cout << ds[i].id << " " << ds[i].d << endl;
		}
	}
	cnt = 0;
	rep(i, 24){
		if(cnt < 2 && !used[i]){
			cnt++;
			used[i] = true;
			cout << ds[i].id << " " << ds[i].d << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
target = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(target[int(input()) - 1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a * b, c * d) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc149d()
}

fun abc149d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val points = readLine()!!.split(' ').map { it.toInt() }
    val t = readLine()!!.map {
        when (it) {
            'r' -> 0
            's' -> 1
            else -> 2
        }
    }.toIntArray()

    fun cap3(value: Int): Int {
        return if (value >= 3) value % 3 else value
    }

    val dp = Array(n) { 0 to -1 }
    dp[0] = points[cap3(t[0] + 2)] to cap3(t[0] + 2)

    for (i in 1 until n) {
        val win = cap3(t[i] + 2)

        if (i + 1 <= k || dp[i - k].second != win) {
            dp[i] = dp[i - 1].first + points[win] to win
        } else {
            dp[i] = dp[i - 1].first to -1
        }
    }

    val answer = dp.last().first

    println(answer)
}


Measured memory_bytes: 43552
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  string ans = (s == "ABC" ? "ARC" : "ABC");
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n;
	cin>>n;
	int cnt = 0;
	for(int i=1;i<=n;i++)
		for(int j=1;j*i<=n;j++)
		{
			// debug2(i,j)
			if(n-i*j>=1)
			{
				// debug3(i,j,n-i*j)
				++cnt;
			}
		}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3592
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    ans = 0
    for i,item in enumerate(x):
        a = item
        b = abs(item-k)
        ans += min(a,b)
    ans *= 2
    print(ans)
    return

if __name__=='__main__':
    n,k = I(),I()
    x = list(IL())
    solve()

Measured memory_bytes: 27168
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define ALL(x)	(x).begin(), (x).end()
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7,N=1000010;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;cin>>n>>m;
	vector<string>grid;
	rep(i,0,n){
		string s;cin>>s;
		grid.pb(s);
	}
	ll dp[n][m];
	rep(i,0,n){
		rep(j,0,m){
			if (grid[i][j]=='#'){
				dp[i][j]=0;
				continue;
			}
			if (i==0&&j==0)dp[i][j]=1;
			else if (i==0)dp[i][j]=(dp[i][j-1])%MOD;
			else if (j==0)dp[i][j]=(dp[i-1][j])%MOD;
			else dp[i][j]=((dp[i-1][j])%MOD+(dp[i][j-1])%MOD)%MOD;
		}
	}
	cout<<dp[n-1][m-1]%MOD<<"\n";
return 0;
}


Measured memory_bytes: 9088
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int H,W,D;
int zahyo[100000][2];
int ans[100000];
int func(int a){
    //printf("[%d]\n",a);
    if(ans[a]!=-1)return ans[a];
    if(H*W<a+D){
        ans[a]=0;
        return 0;
    }
    int ppp;
    ppp=func(a+D)+(abs(zahyo[a][0]-zahyo[a+D][0])+abs(zahyo[a][1]-zahyo[a+D][1]));
    ans[a]=ppp;
    return ppp;
}
int main(){
    for(int i=0;i<100000;i++){
        ans[i]=-1;
    }
    cin>>H>>W>>D;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a;
            cin>>a;
            zahyo[a][0]=i;
            zahyo[a][1]=j;
        }
    }

    for(int i=1;i<=H*W;i++){
        ans[i]=func(i);
        for(int i=1;i<=H*W;i++){
            //printf("%d:[%d]\n",i,ans[i]);
        }
        //puts("\n==============");
    }

    //ans[5]=func(5);

    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int a,b;
        cin>>a>>b;
        cout<<ans[a]-ans[b]<<endl;
    }

    for(int i=1;i<=H*W;i++){
        //printf("%d:[%d]\n",i,ans[i]);
    }

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  bool ans = false;
  while(N > 0) {
    if(N%10==7) ans = true;
    N /= 10;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll numb = b - (b/c + b/d - b/lcm(c,d));
    --a;
    ll numa = a - (a/c + a/d - a/lcm(c,d));

    // cout << numa << " " << numb << endl;
    cout << numb - numa << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
ll n,m;

int main(){
	cin>>n>>m;
	ll zero=0;
	ll ans=0;	
	if(n>=2&&m>=2){
		ans=n*2+(m-2)*2;
	}
	else if(n>=2){
		ans=2;
	}
	else if(m>=2){
		ans=2;
	}
	else{
		ans=0;
	}
	cout<<(n*m)-ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
t = input()
s = []
for i in range(N):
    s.append(t[i])
ans = 0
for i in range(K):
    if s[i] == 'r':
        ans += P
        s[i] = 'a'
    elif s[i] == 's':
        ans += R
        s[i] = 'b'
    else:
        ans += S
        s[i] = 'c'
T = []
for i in range(K,N):
    if s[i] == 'r':
        if s[i-K] != 'a':
            ans += P
            s[i] = 'a'
    elif s[i] == 's':
        if s[i-K] != 'b':
            ans += R
            s[i] = 'b'
    else:
        if s[i-K] != 'c':
            ans += S
            s[i] = 'c'
print(ans)


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

typedef pair<int,int> P;
typedef pair<P,P> PP;
#define fr first
#define sc second

const int t=29;
const int N=200000;

vector<PP> ret;

void pp(int i,int j,int k){
	ret.push_back(PP(P(0,i),P(j,k)));
	//printf("+ %d %d %d\n",i,j,k);
}
void po(int i,int j,int k){
	ret.push_back(PP(P(1,i),P(j,k)));
	//printf("< %d %d %d\n",i,j,k);
}

void make_power(){
	po(N-1,0,N-2);
	for(int i=1;i<=t;i++){
		pp(N-2-i+1,N-2-i+1,N-2-i);
	}
	po(N-1,1,N-50);
}
void POW(int k,int s){
	for(int i=0;i<s;i++){
		pp(k,k,k);
	}
}

int x_times_B(int k){ //x=0,1
	po(k,N-50,N-51);
	for(int i=1;i<=t;i++){
		pp(k+i-1,k+i-1,k+i);
	}
	for(int i=t;i>=0;i--){
		pp(k+t+3,k+i,k+t+2);
		po(k+t+2,1,k+t+1);
		po(N-51,k+t+1,k+t+1);
		POW(k+t+1,i);
		pp(k+t+3,k+t+1,k+t+3);
		//pp(k+t+3,N-1,k+t+2);
	}
	po(N-51,N-50,N-51);
	pp(k+t+3,N-51,k+t+3);
	return k+t+3;
}

void solve(){
	int x=3,y=4;
	int nex=5;
	for(int i=t;i>=0;i--){
		pp(x,N-2-i,nex);
		po(nex,0,nex+1);
		pp(nex+1,N-1,nex+2);
		POW(nex+1,i);
		pp(x,nex+1,x);
		int z=x_times_B(nex+2);
		POW(z,i);
		pp(y,z,y);
		nex=z+1;
	}
	pp(N-2,N-1,nex);
	int z=x_times_B(nex);
	pp(y,z,2);
}

int main(){
	make_power();
	solve();
	
	printf("%d\n",(int)ret.size());
	for(PP p: ret){
		int i=p.fr.sc;
		int j=p.sc.fr;
		int k=p.sc.sc;
		if(p.fr.fr==0){
			printf("+ %d %d %d\n",i,j,k);
		}
		else {
			printf("< %d %d %d\n",i,j,k);
		}
	}
}

Measured memory_bytes: 3768
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        boolean[] dislike = new boolean[10];
        st = new StringTokenizer(br.readLine());

        for(int i=0; i<K; i++){
            int d = Integer.parseInt(st.nextToken());
            dislike[d]=true;
        }

        int ans = 0;
        String n = Integer.toString(N);
        boolean inc=false;
        boolean raised=false;
        for(int i=0; i<n.length(); i++){
            int cur = n.charAt(i)-'0';
            int k=cur;
            if(raised)
                k=0;
            while(k<10){
                if(!dislike[k]){
                    ans=ans*10+k;
                    break;
                }
                k++;
            }
            if(k!=cur)
                raised=true;
            if(k==10){
                inc=true;
                k=0;
                while(k<10){
                    if(!dislike[k]){
                        ans=ans*10+k;
                        break;
                    }
                    k++;
                }
            }
        }
        if(inc){
            int k=0;
            while(k<10){
                if(!dislike[k]){
                    ans=ans*10+k;
                    break;
                }
                k++;
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[15][15],p[15],a[15];
bool sw[15];
int c=0,C=0,ans=0;
int main(void){
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++)cin>>s[i][j];
    }
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            sw[j]=0;
            if(i&(1<<j))sw[j]=1;
        }
        for(int j=0;j<m;j++){
            c=0;
            for(int k=0;k<a[j];k++){
                if(sw[s[j][k]-1])c++;
            }
            if(c%2==p[j])C++;
        }
        if(C==m)ans++;
        C=0;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

int n,m;
int c;
int a[20000];
int r[200][200];

int main()
{
#ifdef _MSC_VER
	//freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	cin>>n>>m>>c;
	REP(i,c) cin>>a[i];
	int p=0;
	REP(i,n) REP(j,m)
	{
		for (;a[p]==0;++p);
		--a[p];
		r[i][(i&1)?(m-1-j):j]=p;
	}
	REP(i,n)
	{
		REP(j,m)
		{
			if (j>0) printf(" "); 
			printf("%d",r[i][j]+1);
		}
		printf("\n");
	}
	return 0;
}



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

struct UnionFind{
private:
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> size;
public:
    UnionFind(int n){
        par=std::vector<int>(n);
        rank=std::vector<int>(n);
        size=std::vector<int>(n);
        for(int i=0;i<n;++i){
            par[i]=i;
            rank[i]=1;
            size[i]=1;
        }
    }

    int root(int x){
        if(par[x]==x)return x;
        else {
            par[x]=root(par[x]);
            return par[x];
        }
    }

    bool same(int x,int y){//0-indexed
        return root(x)==root(y);
    }

    void unite(int x,int y){//0-indexed
        x=root(x);
        y=root(y);
        if(x==y)return;

        if(rank[x]<rank[y]){//parent:y, child:x
            par[x]=y;
            size[y]+=size[x];
        }
        else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y])++rank[x];
        }
    }

    int rootsize(int x){
        return size[root(x)];
    }
};

int main(){
    long long n,m;
    cin>>n>>m;
    UnionFind uf(static_cast<int>(n));
    vector<pair<int,int>> bri(m);
    for (int i = 0; i < m; ++i) {
        cin>>bri[i].first>>bri[i].second;
        --bri[i].first;
        --bri[i].second;
    }

    long long tans=((n-1)*n)/2;
    vector<long long> ans(m);
    for (int i = m-1; i >= 0; --i) {
        ans[i]=tans;
        long long x=bri[i].first;
        long long y=bri[i].second;
        long long a=uf.rootsize(x);
        long long b=uf.rootsize(y);
        //cout<<i<<" "<<a<<" "<<b<<endl;
        if(!uf.same(x,y))tans-=a*b;
        uf.unite(x,y);
    }
    for (auto i:ans)cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int a,b,c; cin >>a>>b>>c;

  if (a == b && a != c) {
    cout << "Yes" << endl;
  } else if (a == c && a != b) {
    cout << "Yes" << endl;
  } else if (b == c && a != b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;


ll dp[1010][20020];

int main(){
  rep(i,1010){
    rep(j,20020)dp[i][j]=1e18;
  }
  int h,n;
  cin >>h >>n;
  ll ma=0;
  dp[0][0]={};
  rep(i,n){
    ll a,b;
    cin >> a >>b;
    chmax(ma,a);
    rep(j,20010){
      if(j<a){dp[i+1][j]=min(dp[i][j],b);}else{
        dp[i+1][j]=min(dp[i][j],dp[i+1][j-a]+b);
      }
    }
  }
  ll ans=1e18;
  rep(i,ma){
    chmin(ans,dp[n][i+h]);
  }
  cout << ans << endl;
}

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

const ll INF = 100000000000LL;
int main () {
  int A, B, Q;
  cin >> A >> B >> Q;

  vector<ll> s(A+2), t(B+1);

  s[0] = - INF; t[0] = -INF;
  rep(i,A) cin >> s[i+1];
  rep(i,B) cin >> t[i+1];
  s[A+1] = INF; t[B+1] = INF;

  rep(i,Q) {
    ll x;
    cin >> x;

    vector<ll>::iterator it;
    it = lower_bound(s.begin(), s.end(), x);
    vector<ll> ss = {*it, *(it-1)};

    it = lower_bound(t.begin(), t.end(), x);
    vector<ll> ts = {*it, *(it-1)};

    ll ans = INF;
    for(ll s : ss) {
      for(ll t : ts) {
        ans = min(ans, abs(x-s) + abs(s-t));
        ans = min(ans, abs(x-t) + abs(t-s));
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    b_s = list(map(int, input().split(' ')))
    c_s = list(map(int, input().split(' ')))

    result = 0
    pre = -1
    for a in a_s:
        result += b_s[a-1]
        if a == (pre+1):
            result += c_s[pre-1]
        pre = a
    print(result)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
//
// Created on 2019/12/09.
//

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
using gragh = vector<vector<int>>;

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

    int ans = 0;

    vector<vector <int > > condition (M,vector<int >(0));

    for (int i = 0; i < M; ++i) {
        int k;
        cin>>k;
        for (int j = 0; j < k; ++j) {
            int s;
            cin>>s;
            s--;
            condition[i].push_back(s);
        }
    }
    vector<int>p(M);
    for (int l = 0; l < M; ++l) {
        cin>>p[l];
    }

    for (int bit = 0; bit < (1 << N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int on =0;
            for (int j = 0; j < condition[i].size(); ++j) {
                if (bit & (1<<condition[i][j])) on++;
            }
            if (on % 2 != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
MAX_V = 999999999999999999999
while 1:
    n,m = list(map(int,input().split()))
    if n == 0:break
    costs = {x:[] for x in range(1,n+1)}
    passed = [[False for x in range(2)] for y in range(n+1)]
    result = [MAX_V,MAX_V]
    for i in range(m):
        a,b,c = list(map(int,input().split()))
        costs[a].append((b,c))
        costs[b].append((a,c))

    spam = [(0,1,2)] #(cost,num,free tickets count)
    while len(spam) > 0:
        mc = min(spam)
        spam.remove(mc)

        tic_i = 0 if mc[2] == 2 else 1

        if mc[2] != 1 and passed[mc[1]][tic_i] :
            continue

        if mc[2] != 1:
            passed[mc[1]][tic_i] = True
            if n == mc[1]:
                result[tic_i] = mc[0]

        if max(result) < MAX_V:break

        #移動できる場所の登録
        for cv in costs[mc[1]]:
            #チケット不使用
            if mc[2] != 1:
                spam.append((mc[0] + cv[1],cv[0],mc[2]))
            #チケット使用
            if mc[2] > 0:
                spam.append((mc[0],cv[0],mc[2]-1))

    print(min(result))

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  if(s=="Sunny") cout<<"Cloudy"<<endl;
  else if(s=="Cloudy") cout<<"Rainy"<<endl;
  else if(s=="Rainy") cout<<"Sunny"<<endl;
  
  
}

Measured memory_bytes: 3632
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[a-1 for a in A]
Arrived=[-1 for i in range(N)]
Appeared=[]
k=0
location=0
T=0
T_List=[]
while k<=K:
    k+=1
    Arrived[location]=k-1
    Appeared.append(location)
    location=A[location]
    if Arrived[location]!=-1:
        T=k-Arrived[location]
        T_List=Appeared[k-T:k]
        break
if len(T_List)==0:
    print(Arrived.index(k-1)+1)
else:
    Destination=(K-(k-T-1))%T
    print(T_List[Destination-1]+1)

    

Measured memory_bytes: 118764
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		
		Set<Character> set = new HashSet<>();
		for(int i = 0;i < S.length();++i)
			set.add(S.charAt(i));
		if(set.size() == 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21972