akhauriyash/Code-Regression huggingface dataset:
import itertools
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, X, D = list(map(int, sys.stdin.buffer.readline().split()))
if D < 0:
    X += (N - 1) * D
    D = -D

if X == D == 0:
    print(1)
    exit()

if D == 0:
    print(N + 1)
    exit()

# 差じゃなくて高橋くんが作れる数だけ考える
# lr[k]: mod D が k になる数のどっからどこまで作れるか
ranges = defaultdict(list)
for n in range(N + 1):
    # 選ぶ数を決めると、選ぶ数の合計 mod D が決まる
    # 選ぶ数の合計を X*n + D*y とすると
    # d を使う数は最小で 0 から n-1 までの合計
    y_min = (n - 1) * n // 2
    # d を使う数は最大で N-1 + N-2 + ... + N-n == N*n - (1 から n までの合計)
    y_max = N * n - (n + 1) * n // 2
    k = X * n % D
    ranges[k].append((X * n // D + y_min, X * n // D + y_max + 1))


def compress(li, origin=0):
    """
    座圧
    :param li:
    :param int origin:
    :rtype: list of int
    """
    *ret, = map({v: i + origin for i, v in enumerate(sorted(set(li)))}.__getitem__, li)
    return ret


def cumsum(it):
    """
    累積和
    :param collections.Iterable it:
    :return:
    """
    cs = 0
    ret = []
    for v in it:
        cs += v
        ret.append(cs)
    return ret


def count(lr):
    if len(lr) == 1:
        l, r = lr[0]
        return r - l

    # mod D で分けてるから座圧できる
    flatten = list(itertools.chain.from_iterable(lr))
    ranks = compress(flatten, origin=1)
    orig = [0] * (max(ranks) + 1)
    for r, f in zip(ranks, flatten):
        orig[r] = f

    imos = [0] * (len(ranks) + 10)
    for l, r in zip(ranks[::2], ranks[1::2]):
        imos[l] += 1
        imos[r] -= 1
    cum = cumsum(imos)

    ret = 0
    for i in range(len(cum) - 1):
        if cum[i] == 0 and cum[i + 1] > 0:
            left = orig[i + 1]
        if cum[i] > 0 and cum[i + 1] == 0:
            ret += orig[i + 1] - left
    return ret


ans = 0
i = 0
for lr in ranges.values():
    ans += count(lr)
    i += 1
print(ans)


Measured memory_bytes: 99828
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second

int a, b, m;
int c[111111], d[111111];

int main() {
    cin >> a >> b >> m;
    rep(i, a)cin >> c[i];
    rep(i, b)cin >> d[i];
    int ans = 1e9;

    rep(i, m) {
        int x, y, co;
        cin >> x >> y >> co;
        x--; y--;
        ans = min(ans, c[x]+d[y]-co);
    }
    sort(c, c + a);
    sort(d, d + b);
    ans = min(ans, c[0] + d[0]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
def d_maximum_average_sets():
    from functools import reduce
    N, A, B = [int(i) for i in input().split()]
    V = sorted([int(i) for i in input().split()], reverse=True)

    def combination(n, r):
        numerator = reduce(lambda x, y: x * y, range(n, n - r, -1))
        denominator = reduce(lambda x, y: x * y, range(1, r + 1))
        return numerator // denominator

    if V[0] == V[A - 1]:  # V の上位 A 個がすべて同じ値 (v_max とおく)
        # V で値が v_max である x 個から A 個以上 B 個以下選ぶ
        x = V.count(V[0])
        count = sum([combination(x, i) for i in range(A, B + 1)])
    else:
        # 上位 A 個のうち最も値が小さな要素の値を v_min とおき、
        # v_min が上位 A 個のうち a 個あったとする。
        # V で値が v_min である x 個から a 個選ぶ。
        v_min = V[A-1]
        x, a = V.count(v_min), V[:A].count(v_min)
        count = combination(x, a)
    return '{}\n{}'.format(sum(V[:A]) / A, count)

print(d_maximum_average_sets())

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int  main(void){
int a=32;
string s1,s2,s3,s4;
char ss,sss,ssss;
cin>>s1>>s2>>s3;
ss=(int)s1[0]-a;
sss=(int)s2[0]-a;
ssss=(int)s3[0]-a;
cout<<ss<<sss<<ssss<<endl;
}


Measured memory_bytes: 256
class SegTree:
    op = max
    e = 0
    
    def __init__(self, N, init=None):
        self.N = N
        self.T = [self.e]*(2*N)
        if init is not None:
            assert len(init) == N
            for i, val in enumerate(init, N):
                self.T[i] = val
            for i in range(N-1, 0, -1):
                self.T[i] = self.op(self.T[i<<1], self.T[i<<1|1])

    def get(self, l, r):
        l += self.N; r += self.N
        ret = self.e
        while l < r:
            if l & 1:
                ret = self.op(ret, self.T[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.op(ret, self.T[r])
            l >>= 1; r >>= 1
        return ret

    def __setitem__(self, i, val):
        i += self.N
        self.T[i] = val
        while i>1:
            i >>= 1
            self.T[i] = self.op(self.T[i<<1], self.T[i<<1|1])


import sys
N,K, *A = map(int, open(0).read().split())

MAX = 300_001
S = SegTree(MAX)

for a in A:
    l = max(0, a-K)
    r = min(MAX, a+K+1)
    x = S.get(l, r)+1
    S[a] = x

print(S.get(0,MAX))


Measured memory_bytes: 111844
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
const int N=200200;
VI es[N];
int col[N];
VI cc[2];
int ans[N];
void dfs(int x,int fa=-1,bool isB=true){
	col[x]=isB?0:1;
	cc[col[x]].push_back(x);
	for(VI::iterator it=es[x].begin();it!=es[x].end();it++){
		if(*it!=fa){
			dfs(*it,x,!isB);
		}
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		es[u].push_back(v);
		es[v].push_back(u);
	}
	dfs(1);
	unsigned c1=(n+2)/3;
	unsigned c2=(n+1)/3;
	unsigned c3=(n+0)/3;
	if(cc[0].size()>cc[1].size()){
		swap(cc[0],cc[1]);
	}
	if(cc[0].size()>=c1&&cc[1].size()>=c2){
		for(unsigned i=0;i<c1;i++){
			ans[cc[0].back()]=i*3+1;
			cc[0].pop_back();
		}
		for(unsigned i=0;i<c2;i++){
			ans[cc[1].back()]=i*3+2;
			cc[1].pop_back();
		}
		for(unsigned i=0;i<c3;i++){
			if(!cc[0].empty()){
				ans[cc[0].back()]=i*3+3;
				cc[0].pop_back();
			}
			else{
				ans[cc[1].back()]=i*3+3;
				cc[1].pop_back();
			}
		}
	}
	else{
		assert(cc[0].size()<=c3);
		for(unsigned i=0;i<c3;i++){
			if(!cc[0].empty()){
				ans[cc[0].back()]=i*3+3;
				cc[0].pop_back();
			}
			else{
				ans[cc[1].back()]=i*3+3;
				cc[1].pop_back();
			}
		}
		for(unsigned i=0;i<c1;i++){
			ans[cc[1].back()]=i*3+1;
			cc[1].pop_back();
		}
		for(unsigned i=0;i<c2;i++){
			ans[cc[1].back()]=i*3+2;
			cc[1].pop_back();
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d ",ans[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 19828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int i;
  int sumW[300010];
  int sumE[300010];

  if(s[0]=='E'){
    sumE[0] = 1;
    sumW[0] = 0;
  }else{
    sumE[0] = 0;
    sumW[0] = 1;
  }
  
  for(i=1;i<n;i++){
    if(s[i]=='E'){
      sumE[i] = sumE[i-1]+1;
      sumW[i] = sumW[i-1];
    }else{
      sumE[i] = sumE[i-1];
      sumW[i] = sumW[i-1]+1;
    }
  }
  int min = sumE[n-1]-sumE[0];

  for(i=1;i<n;i++){
      if(min>(sumW[i-1]+sumE[n-1]-sumE[i]))min = (sumW[i-1]+sumE[n-1]-sumE[i]);
  }
  cout << min;
}



  



Measured memory_bytes: 2948
n,x,*a=map(int,open(0).read().split())
ans=0
if a[0]>x:
  ans=a[0]-x
  a[0]=x
for i in range(n-1):
  if a[i+1]+a[i]>x:
    d=a[i+1]+a[i]-x
    a[i+1]-=d
    ans+=d
print(ans)

Measured memory_bytes: 14092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll n;
	cin >> n;
	cout << (n*(n-1)/2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t K=c-a-b;
  if(K<=0){
    cout << "No" << endl;
    return 0;
  }
  if(K*K>4*a*b){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,n;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
     }
    for(i=n-1;i>=0;i--){
        if(i==0){
            printf("%d\n",a[i]);
        }else{
            printf("%d ",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  int count=0;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    if(a.at(i)>=k){
      count+=1;
    }
    else{
      int unko=0;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int n,i,x[maxn]={0};
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&x[i]);
	sort(x+1,x+1+n);
	int ans=2e9;
	for(int j=x[1];j<=x[n];j++)
	{
		int sum=0;
		for(i=1;i<=n;i++)
		sum=sum+(x[i]-j)*(x[i]-j);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n, m;
   cin>>n>>m;

   if(n == 1 && m == 1) cout<<1;
   else if(n == 1) cout<<m-2;
   else if(m == 1) cout<<n-2;
   else cout<<(n-2)*(m-2);

   cout<<'\n';
}

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(int i=0;i<N-1;i++){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5192
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(str(input()))
b = []
for i in range(m):
    b.append(str(input()))

f = [0]*m
tmp = []
for j in range(m):
    f[j] = a[j].find(b[j])
    if f[j] != -1:
        tmp.append(j)
while -1 in f: f.remove(-1)

try:
    if len(f) == 0:
        print('No')
    else:
        count = 0
        for i in range(len(tmp)):
            count += 1
            if (b[tmp[i]] in a[tmp[i]]) == False:
                count = 0
        if count == m:
            print('Yes')
        else:
            print('No')
except:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>


using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

#define MOD 1000000007

ll INFLL =  pow(10,9)+1;




string periodic_table[104] = {
    "None","H(1)","He(2)", //2
    "Li(3)","Be(4)","B(5)","C(6)","N(7)","O(8)","F(9)","Ne(10)", //10
    "Na(11)","Mg(12)","Al(13)","Si(14)","P(15)","S(16)","Cl(17)","Ar(18)", //18
    "K(19)","Ca(20)","Sc(21)","Ti(22)","V(23)","Cr(24)","Mn(25)","Fe(26)","Co(27)","Ni(28)","Cu(29)","Zn(30)","Ga(31)","Ge(32)","As(33)","Se(34)","Br(35)","Kr(36)", //36
    "Rb(37)","Sr(38)","Y(39)","Zr(40)","Nb(41)","Mo(42)","Tc(43)","Ru(44)","Rh(45)","Pd(46)","Ag(47)","Cd(48)","In(49)","Sn(50)","Sb(51)","Te(52)","I(53)","Xe(54)", //54
    "Cs(55)","Ba(56)","La(57)","Ce(58)","Pr(59)","Nd(60)","Pm(61)","Sm(62)","Eu(63)","Gd(64)","Tb(65)","Dy(66)","Ho(67)","Er(68)","Tm(69)","Yb(70)","Lu(71)","Hf(72)","Ta(73)","W(74)","Re(75)","Os(76)","Ir(77)","Pt(78)","Au(79)","Hg(80)","Tl(81)","Pb(82)","Bi(83)","Po(84)","At(85)","Rn(86)", //86
    "Fr(87)","Ra(88)","Ac(89)","Th(90)","Pa(91)","U(92)","Np(93)","Pu(94)","Am(95)","Cm(96)","Bk(97)","Cf(98)","Es(99)","Fm(100)","Md(101)","No(102)" //102
};

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll s = x/d;
    ll r = x-s*d;
    if(s>k){
        cout<<x-k*d;
    }
    else{
        k-=s;
        x=r;
        if(k%2==0){
            cout<<x<<endl;
        }
        else{
            x=abs(x-d);
            cout<<x<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3624
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

S = input()

print("{} {}".format(S[:4], S[4:]))

Measured memory_bytes: 5432
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;
int main() {
    int N;
    long long A[200000], B[200000];
    cin >> N;
    for (int i=0; i<N; i++) cin >> A[i] >> B[i];
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](int i1, int i2){return B[i1]<B[i2];});
    long long work = 0;
    for (int i : idx) {
        if (A[i] + work <= B[i]) {
            work += A[i];
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;i++)
    cin>>l.at(i);
  sort(l.begin(),l.end(),greater<int>());
  int s=0;
  for(int i=0;i<k;i++)
    s+=l.at(i);
  cout<<s<<endl;
}

Measured memory_bytes: 256
N, M = input().split()
N = int(N)
M = int(M)
L_list =[]
R_list = []
for h in range(M):
    L, R = input().split()
    L_list.append(L)
    R_list.append(R)

L_list = map(int,L_list)
R_list = map(int,R_list)

L = max(L_list)
R = min(R_list)

if L <= R:
    print(R-L+1)
else:
    print(0)


Measured memory_bytes: 16040
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int x;
    cin >> x;
    if (x >= 30)
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3608
/*Matrix Multiplication

Write a program which reads a n×m matrix A and a m×l matrix B, and prints their product, a n×l matrix C. An element of matrix C is obtained by the following formula:

cij=∑k=1maikbkj
where aij, bij and cij are elements of A, B and C respectively.

Input
In the first line, three integers n, m and l are given separated by space characters

In the following lines, the n×m matrix A and the m×l matrix B are given.

Output
Print elements of the n×l matrix C (cij). Print a single space character between adjacent elements.

Constraints
1≤n,m,l≤100
0≤aij,bij≤10000*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n, m, l; 
	cin>>n>>m>>l;
	long long int A[n][m];long long int B[m][l];long long int C[n][l];
	
	// 数组一定要注意初始化！！！ 
	for(int i=0;i<n;i++)
		for(int j=0;j<l;j++)
			C[i][j] = 0;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>A[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin>>B[i][j];
		}
	}
	
	
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			for(int k=0;k<l;k++)
				C[i][k]+=((A[i][j])*(B[j][k]));
	
	for(int i=0;i<n;i++){
		for(int j=0;j<l-1;j++){
			printf("%lld ", C[i][j]);
		}
		printf("%lld\n", C[i][l-1]);
	}
		
			
	
	return 0;
}


Measured memory_bytes: 3464
#include <iostream>
// #include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

long long gcd(long long a, long long b, long long c) {
    return gcd(gcd(a, b), c);
}

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

    long long res = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                res += gcd(a, b, c);
            }
        }
    }

    cout << res << endl;

}


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

now = 0
ans = 0

for i in range(len(s)):
  if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
    now += 1
    if ans < now:
      ans = now
  else:
    now = 0

print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
int main(void)
{
    int x,y,i;
    for(i=1;i<=3000;i++){
        scanf("%d %d",&x,&y);
        if((x==0)&&(y==0))break;
        else if(x<y)
            printf("%d %d\n",x,y);
        else
            printf("%d %d\n",y,x);
    }
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<queue>
#include<math.h>
#include<ctime>
#include<deque>
#include<set>
#include<string.h>
#include<algorithm>
#include<map>
#include<stack>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ls rt<<1
#define rs rt<<1|1
#define mmm(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e17;
const double pi = acos(-1.0);
const int maxn = 1e6+5;
ll kase;
ll n,m,p;
ll f[maxn],vis[maxn];
map<ll,int>st;
void run(){
    ll tmp;
    cin>>n>>m>>p;
    ll ans=0;
    if(n<(ll)maxn){
        for(int i=0;i<n;i++){
            if(m==0)break;
            ans+=m;
            m=m*m%p;
        }
        cout<<ans<<'\n';
    }
    else {
        ll len=0,s;
        tmp=m;
        for(ll i=0;i<n;i++){
            if(m==0){
                cout<<ans<<'\n';
                return;
            }
            if(st.count(m)){
                s=st[m];
                len=i-s;
                break;
            }
            st[m]=i;
            ans+=m;
            m=m*m%p;
        }
        ll tans=0;
        for(int i=0;i<s;i++){
            tans+=tmp;
            tmp=tmp*tmp%p;
        }
        ans-=tans;
        n-=s;
        ans*=(n/len);
        n%=len;
        ans+=tans;
        for(int i=0;i<n;i++){
            ans+=m;
            m=m*m%p;
        }
        cout<<ans;
    }
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    cin>>kase;
//    while(kase--)
        run();
    return 0;
}


Measured memory_bytes: 6248
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n;
vll a;
 
ll solve(bool isp){
    ll sum = 0LL;
    ll ret = 0LL;
    rep(i, n){
        sum += a[i];
        if(isp and sum <= 0){
            ret += -sum + 1;
            sum = 1LL;
        }
        if(not isp and sum >= 0){
            ret += sum + 1;
            sum = -1LL;
        }
        isp ^= 1;
    }
    return ret;
}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    cin >> n;
    a = vll(n); for(auto& e : a) cin >> e;
 
    ll res = min(solve(0), solve(1));
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 1024
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    s = sread()
    s = set(s)
    if len(s) == 2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
def main():
    from sys import stdin
    input = stdin.readline

    n, m, r = map(int, input().split())
    l = [int(i) - 1 for i in input().split()]
    d = [[10**8] * n for _ in range(n)]
    for _ in range(m):
        i, j, k = map(int, input().split())
        d[i-1][j-1] = k
        d[j-1][i-1] = k

    # Warshall-Floyd algorithm
    for k in range(n):
        for i in range(n-1):
            for j in range(i+1, n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
                    d[j][i] = d[i][j]

    # full search
    # 8! = 40320
    from itertools import permutations

    answer = 10**8
    for i in permutations(l):
        ans = 0
        for j in range(r-1):
            ans += d[i[j]][i[j+1]]
        if ans < answer:
            answer = ans

    print(answer)

main()


Measured memory_bytes: 74148
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 100001
#define max_m 50
#define max_w 1000
#define max_h 1000
#define max_k 10000
#define max_l 10000
#define INF 9999999

typedef long long lint;

int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H'){
            cout<<'H'<<endl;
        }else{
            cout<<'D'<<endl;
        }
    }else{
        if(b=='H'){
            cout<<'D'<<endl;
        }else{
            cout<<'H'<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,i;
    cin >> N;
    for(i=6;0<=i;i--){
        if(pow(2,i)<= N && N < pow(2,(i+1))){
            cout << pow(2,i) << endl;
            break;
        }
    }
}


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


int main (int argc, char const *argv[])
{
    int x;
    int y;
    cin>>x>>y;
    int a[13];
    a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=1;
    a[2]=3;
    a[4]=a[6]=a[9]=a[11]=2;

    
    if (a[x]==a[y]) {
        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 namespace std;
int main(){
	int n;cin>>n;
	vector<int>a(n);rep(i,n)cin>>a.at(i);
	sort(a.begin(),a.end());
	cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

x,y,a,b,c = inm()
p = inl()
q = inl()
r = inl()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pt = x-1
qt = y-1
rt = 0
while rt<c and (pt>=0 and p[pt]<r[rt] or qt>=0 and q[qt]<r[rt]):
    if pt>=0 and (qt<0 or p[pt]<q[qt]):
        pt -= 1
        rt += 1
    elif qt>=0 and (pt<0 or p[pt]>=q[qt]):
        qt -= 1
        rt += 1
print(sum(p[:pt+1])+sum(q[:qt+1])+sum(r[:rt]))


Measured memory_bytes: 105444
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;

int main() {

  int n; cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  sort(d.begin(), d.end());

  vector<int> a(24, 0);
  a[0]++;
  for(int i=0; i<n; i++){
    if( i % 2 == 0 ) a[ d[i]%24 ]++;
    else a[ (24-d[i])%24 ]++;
  }

  int mn = 1e9;
  for(int i=0; i<24; i++){
    if( a[i] > 1 ){
      cout << 0 << endl;
      return 0;
    }
    if( a[i] == 0 ) continue;
    for(int j=i+1; j<24; j++){
      if( a[j] == 0 ) continue;
      mn = min(mn, (j-i));
    }
  }
  cout << (mn==24 ? 0 : mn) << endl;

  return 0;
}

// EOF


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  ll X;
  scanf("%lld", &X);

  map<ll, int> u;
  map<int, ll> v;
  rep(i, 0, 6001) {
    ll x = i, y = 1L;
    rep(j, 0, 5) y *= x;
    u[y] = x;
    v[x] = y;
  }

  rep(i, 0, 6001) {
    ll A5 = v[i];
    ll del = abs(X - A5);
    auto it = u.find(del);
    if (it != u.end()) {
      ll B5 = X - A5;
      int sgn = B5 < 0 ? 1 : -1;
      B5 = del;
      printf("%d %d\n", u[A5], sgn * u[B5]);
      return;
    }
  }
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}



Measured memory_bytes: 4508
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 8;

int b[MAXN][MAXN], w[MAXN][MAXN], sumb[MAXN][MAXN], sumw[MAXN][MAXN];

int main()
{
    #ifdef LOCAL
    freopen("b.txt", "r", stdin);
    //freopen("b.out", "w", stdout);
    int T = 1;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);

    int n, k, i, j, x, y, modx, mody, ansb, answ;
    char ch;
    cin >> n >> k;
    for(i = 0; i < n; i++){
        cin >> x >> y >> ch;
        modx = x / k, mody = y / k;
        x -= min(modx, mody) * k;
        y -= min(modx, mody) * k;
        if(modx > mody){
            x -= (modx - mody) / 2 * 2 * k;
        }
        else{
            y -= (mody - modx) / 2 * 2 * k;
        }
        //cout << x << " " << y <<" " << ch << endl;
        if(ch == 'W'){
            if(x / k) b[x % k][y]++;
            else if(y / k) b[x][y % k]++;
            else w[x][y]++;
        }
        else{
            if(x / k) w[x % k][y]++;
            else if(y / k) w[x][y % k]++;
            else b[x][y]++;
        }
    }
    for(i = 0; i < k; i++){
        for(j = 0; j < k; j++){
            if(i == 0){
                if(j == 0){
                    sumb[i][j] = b[i][j];
                    sumw[i][j] = w[i][j];
                }
                else{
                    sumb[i][j] =  sumb[i][j-1] + b[i][j];
                    sumw[i][j] =  sumw[i][j-1] + w[i][j];
                }
            }
            else{
                if(j == 0){
                    sumb[i][j] =  sumb[i-1][j] + b[i][j];
                    sumw[i][j] =  sumw[i-1][j] + w[i][j];
                }
                else{
                    sumb[i][j] =  sumb[i-1][j] + sumb[i][j-1] + b[i][j] - sumb[i-1][j-1];
                    sumw[i][j] =  sumw[i-1][j] + sumw[i][j-1] + w[i][j] - sumw[i-1][j-1];
                }
            }

        }
    }
    //cout << k << endl;
    int ans = 0;
    for(i = 0; i < k; i++){
        for(j = 0; j < k; j++){
           // cout << ans << " " << sumb[i][j] + sumw[k-1][k-1] - sumw[i][j] << " " << sumw[i][j] + sumb[k-1][k-1] - sumb[i][j] << endl;
            ansb = sumb[i][j] + sumw[k-1][j] - sumw[i][j] + sumw[i][k-1] - sumw[i][j] + sumb[k-1][k-1] - sumb[i][k-1] - sumb[k-1][j] + sumb[i][j];
            answ = sumw[i][j] + sumb[k-1][j] - sumb[i][j] + sumb[i][k-1] - sumb[i][j] + sumw[k-1][k-1] - sumw[i][k-1] - sumw[k-1][j] + sumw[i][j];
            ans = max(ans, max(ansb, answ));
        }
    }
    cout << ans << endl;


    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}



Measured memory_bytes: 16128
N, X = map(int, input().split())
q = [1]*(N+1)
p = [1]*(N+1)
for i in range(1, N+1):
    q[i] = 2*q[i-1]+3
    p[i] = 2*p[i-1]+1

ans = 0
s = [(X, N)]
while s:
    x, n = s.pop()
    if n==0:
        if x:
            ans += 1
        continue
    if x==0:
        continue
    
    a = q[n-1] + 2
    b = p[n-1] + 1

    if x > a:
        ans += b
        s.append((x-a, n-1))
    elif x == a:
        ans += b
    else:
        s.append((x-1, n-1))

print(ans)

Measured memory_bytes: 3064
/*
B - 81 : https://atcoder.jp/contests/abc144/tasks/abc144_b
*/
#include<iostream>
using namespace std;
int main(){
int N,X=0;
cin>>N;

for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
        if(i*j == N ){
           cout<<"Yes"<<endl;
           return 0;
        }
    }
}
  cout<<"No"<<endl;
 return 0;
} // END


Measured memory_bytes: 256
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

int digit[10010],dp[10010][110][2];
signed main() {
    string s;int d;cin >>s>>d;int n=s.size();
    rep(i,s.size()){
        digit[i]=(s[i]-'0');
    }
    memset(dp,0LL,sizeof(dp));


    rep(i,10){
        if(i<digit[0])dp[0][i%d][0]+=1;
        else if(i==digit[0])dp[0][i%d][1]+=1;
    }

    rep(i,n-1){
        rep(j,d){
                rep(k, 2) {
                    rep(nn,10) {
                        if (k == 1) {
                            if (nn < digit[i+1]) {
                                dp[i + 1][(j + nn) % d][0] += dp[i][j][1] % mod;
                                dp[i + 1][(j + nn ) % d][0] %= mod;
                            } else if (nn == digit[i+1]) {
                                dp[i + 1][(j + nn)%d][1] += dp[i][j][1] % mod;
                                dp[i + 1][(j + nn ) % d][1] %= mod;
                            }
                        }
                        else {
                            dp[i + 1][(j + nn) % d][0] += dp[i][j][0] % mod;
                            dp[i + 1][(j + nn) % d][0] %= mod;
                        }
                    }
                    }
                }

        }



    int ans=(dp[n-1][0][1]+dp[n-1][0][0]+1000000006)%mod;
    cout <<ans<<endl;
}

















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

int main(){
  int n, T;
  cin >> n >> T;
  int t[n];
  for ( int i = 0; i < n; i++){
    cin >> t[i];
  }

  long long ans = 0;
  for ( int i = 0; i < n-1; i++){
    if ( t[i+1] - t[i] >= T){
      ans += T;
    } else {
      ans += (t[i+1] - t[i]);
    }
  }

  ans += T;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modp 998244353
#define Maxn 3007
int a,b,c,d;
int f[Maxn][Maxn];
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for (int i=a;i<=c;i++)
        for (int j=b;j<=d;j++)
        {
            if (i==a&&j==b) f[i][j]=1;
            else if (i==a) f[i][j]=(1LL*i*f[i][j-1])%modp;
            else if (j==b) f[i][j]=(1LL*j*f[i-1][j])%modp;
            else
            {
                f[i][j]=(1LL*i*f[i][j-1])%modp;
                f[i][j]=(1LL*j*f[i-1][j]+f[i][j])%modp;
                f[i][j]-=(1LL*(i-1)*(j-1)*f[i-1][j-1])%modp;
                f[i][j]=(f[i][j]%modp+modp)%modp;
            }
        }
    printf("%d\n",f[c][d]);
    return 0;
}

Measured memory_bytes: 38788
# include<cstdio>
# include<cstring>
# define LL long long
LL n,mark[1000];
int main(){
	memset(mark,0,sizeof(mark));
	scanf("%lld",&n);
	mark[0]=2,mark[1]=1;
	for(int i=2;i<=86;i++)
	mark[i]=mark[i-1]+mark[i-2];
	printf("%lld",mark[n]); 
	return 0;
} 

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

using namespace std;

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

	long long n, W;
	cin >> n >> W;

	vector<long long> weight(n,0), value(n,0);
	long long sum = 0;
	for(long long i = 0; i < n; i++){
		cin >> weight[i] >> value[i];
		sum += value[i];
	}

	vector<long long> k(sum+1, 1e18);
	k[0] = 0;
	for(long long i = 0; i < n; i++){
		for(long long j = sum - value[i]; j >= 0; j--){
			k[j+value[i]] = min(k[j+value[i]], k[j]+weight[i]);
		}
	}

	long long ans = 0;
	for(long long i = 0; i <= sum; i++){
		if(k[i] <= W)
			ans = max(ans,i);
	}

	cout << ans;

	return 0;
}

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

long long int solutions;
bool grandFlag;

void print(vector<vector<int> >& pz){
  for(int i=0; i<pz.size(); i++){
    for(int j=0; j<5; j++)
      cout << pz[i][j] << " ";
    cout << endl;
  }
};

void solve(vector<vector<int> >& pz){
  for(int i=pz.size()-1; i>=0; i--){
    int a = pz[i][0], x = 1, pos = 0;
    bool yes = false;
    for(int j=1; j<5; j++){
      if(pz[i][j] == a && a!=0)
	x++;
      else if(x>=3) {
	yes = true;
	pos = j-1;
	break;
      }
      else{
	x = 1;
	a = pz[i][j];
      }
      if(j == 4 && x>=3){
	yes = true;
	pos = j;
      }
    }
    if(yes == 1){
      for(int j=pos; j>pos-x; j--)
	pz[i][j] = 0;
      solutions += (a*x);
      grandFlag = true;
    }
  }
};

void simplify(vector<vector<int> >& pz){
  int lowest; bool set;
  for(int j=0; j<5; j++){
    lowest = pz.size();
    set = false;
    for(int i=pz.size()-1; i>=0; i--){
      if(pz[i][j] == 0 && !set){
	lowest = i;
	set = true;
      }
      else if(pz[i][j] != 0 && set){
	swap(pz[i][j], pz[lowest][j]);
	lowest--;
      }
    }
  }
};

void slv(vector<vector<int> >& pz){
  while(grandFlag){
    grandFlag = false;
    solve(pz);
    simplify(pz);
  }
};

int main(){
  int h;
  cin >> h;
  while(h!=0){
    solutions = 0;
    grandFlag = true;
    vector<vector<int> > pz(h, vector<int>(5));
    for(int i=0; i<h; i++)
      for(int j=0; j<5; j++)
	cin >> pz[i][j];

    slv(pz);
    cout << solutions << endl;
    cin >> h;
  }

  return 0;
}

Measured memory_bytes: 1216
N,M = map(int, input().split())
s = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()]

ans = 0
for i in range(2**N):
    switch = [0]*N
    for j in range(N):
        if ((i >> j) & 1 ):
            switch[j] += 1
    on = 0
    for k in range(M):
        count = 0
        for l in range(1,s[k][0]+1):
            if switch[s[k][l]-1] == 1:
                count += 1
        if count % 2 == p[k]:
            on += 1
    if on == M:
        ans += 1
    
print(ans)


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

#A
def A():
    m = II()
    print(48-m)
    return

#B
def B():
    a, b = LI()
    s = S()
    ans = list(map(str, range(10)))
    for num, si in enumerate(s):
        if num != a:
            if si in ans:
                continue
            print("No")
            return
        else:
            if si == "-":
                continue
            print("No")
            return
    print("Yes")
    return

#C
def C():
    return

#D
def D():
    a = II()
    ans = inf
    b = 0
    for k in range(1, 10 ** 5):
        b += a
        ans = min(ans, sum(list(map(int, list(str(b))))))
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define scch(x) scanf("%c", &x)
#define scld(x) scanf("%Lf", &x)
#define scll(x) scanf("%lld", &x)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define trill pair<ll,pill>
#define F f
#define S s.f
#define Th s.s


using namespace std;

const ll N = 2011;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n, k;

bool del[N];

vector<ll> g[N];

ll gl[N][N];

void bfs(ll s) {
	queue<pill> x;
	x.push({s, 0});
	bool w[N] = {0};
	w[s] = 1;
	while(x.size()) {
		ll v = x.front().f, rst = x.front().s;
		gl[s][v] = rst;
		x.pop();
		for(auto u : g[v]) {
			if(!w[u] && !del[u])
				w[u] = 1,x.push({u, rst + 1});
		}
	}
}

int main() {
	speed;
	cin >> n >> k;
	rep(1, n, 1) {
		ll a,b;
		cin >> a >> b;
		g[a].pb(b), g[b].pb(a);
	}
	for(int i = 1; i <= n; i++)
		bfs(i);
	ll ans = n;
	for(int x = 1 ; x <= n ; x++) {
		if(k % 2) {
			for(auto u : g[x]) {
				ll z = n;
				for(int i = 1; i <= n; i++) {
					if(min(gl[x][i], gl[u][i]) <= k / 2 )
						z--;
				}
				ans = min(z, ans);
			}
		} else {
			ll z = n;
			for(int i = 1; i <= n ; i++)
				if(gl[x][i] <= k / 2)
				z--;
			ans = min(z, ans);
		}
	}
	cout << ans;
}

/*
	Code written by
	Codeforces : I_Love_Trott
	mail : dzhon.snoudin@mail.ru
*/



Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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 r,d,x;

int main(){
	cin >> r >> d >> x;
	FOR(i,1,10){
		x = r*x - d;
		cout << x << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>wq1,wq2;
int main()
{
    int g,t,z,lo2,hi2,m2;
    ll q,x,sp,lo1,hi1,m1,ntz=0;
    scanf("%d %lld",&t,&q);
    for(g=0;g<t;g++){
        scanf("%d",&z);
        if(z>0)wq1.push_back(z);
        else if(z<0)wq2.push_back(z);
        else ntz++;
    }
    sort(wq1.begin(),wq1.end());
    sort(wq2.begin(),wq2.end());
    lo1=-1e18, hi1=1e18;
    while(lo1<hi1){
        m1=(lo1+hi1)>>1;
        if(m1<0)for(g=sp=0;g<wq2.size();g++){
            lo2=0, hi2=wq1.size()-1;
            while(lo2<=hi2){
                m2=(lo2+hi2)>>1;
                x=1LL*wq2[g]*wq1[m2];
                if(x<=m1)hi2=m2-1;
                else lo2=m2+1;
            }
            sp+=(wq1.size()-hi2-1);
        }
        else if(m1>0){
            sp=1LL*wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
            for(g=0;g<wq1.size();g++){
                lo2=g+1, hi2=wq1.size()-1;
                while(lo2<=hi2){
                    m2=(lo2+hi2)>>1;
                    x=1LL*wq1[g]*wq1[m2];
                    if(x>m1)hi2=m2-1;
                    else lo2=m2+1;
                }
                sp+=(lo2-1-g);
            }
            for(g=0;g<wq2.size();g++){
                lo2=g+1, hi2=wq2.size()-1;
                while(lo2<=hi2){
                    m2=(lo2+hi2)>>1;
                    x=1LL*wq2[g]*wq2[m2];
                    if(x>m1)lo2=m2+1;
                    else hi2=m2-1;
                }
                sp+=(wq2.size()-hi2-1);
            }
        }
        else{
            sp=1LL*wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
        }
        if(sp>=q)hi1=m1;
        else lo1=m1+1;
    }
    printf("%lld\n",hi1);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define f(x) ((a*x/b)-a*(x/b))
ll INF=1000000000000000001;
ll mod=1000000007;

ll i,j,k;



int main(){
    ll a,b,n;cin>>a>>b>>n;

    ll ng=n+1,ok=0;
    while(ng-ok>1){
        ll mid=(ng+ok)/2;
        
        if(f(mid)>=f(ok)){
            ok=mid;
        }else{
            ng=mid;
        }
    }

    cout<<f(ok)<<endl;
    return 0;
}

Measured memory_bytes: 3588
#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) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=a;s>0?i<n:i>n;i+=s)
#define rep(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10, mod = 1e9+7; const long long llinf = 1e18;
// head

int main(){
  int n;
  cin >> n;
  vector<vector<int>> A(n,vector<int>(n,0));
  rep(i,n) rep(j,n) cin >> A[i][j];

  vector<vector<int>> dp(n+1,vector<int>(1<<n,0));
  dp[0][0] = 1;
  rep(i,n)rep(bit,1<<n) if (dp[i][bit]){
    rep(k,n){
      if (!(bit >> k & 1) && A[i][k]){
        dp[i+1][bit|1 << k] = (dp[i+1][bit|1 << k] + dp[i][bit]) % mod;
      }
    }
  }
cout << dp[n][(1 << n)-1] << endl;
}

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

int main(void) {
	int a, b, i;
	char op;
	
	for (i = 0;;i++) {
		scanf("%d %c %d", &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;
			default: break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

int main(void) {
   ll N;
   cin>>N;
   string S,T;
   cin>>S;
   cin>>T;
   rep(i,0,N) {
      cout<<S[i]<<T[i];
   }
   cout<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, val = 0;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		val ^= a[i];
	}
	for(int i = 1; i <= n; i++)
		cout << (val ^ a[i]) << " ";
	return 0;
}


Measured memory_bytes: 5104
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  temp=list(map(str,input()))
  a.append(temp)
for i in range(m):
  temp=list(map(str,input()))
  b.append(temp)
temp=[]
ans=0
for i in range(n-m+1):
  for j in range(n-m+1):
    count=0
    for k in range(m):
      for l in range(m):
        if b[k][l]==a[k+i][l+j]:
          count=count+1
    if count==m*m:
      ans=1
if ans==1:
  print("Yes")
else:
  print("No")

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

int main(){
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i])
       count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3916