akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    lint M = LLONG_MAX;
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<lint>> d(n, vector<lint>(n, M));
    for (int i = 0; i < n; i++) {
        d[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        d[--a][--b] = c;
        d[b][a] = c;
    }
    for (int k = 0; k < n; k++) {          // 経由する頂点
        for (int i = 0; i < n; i++) {      // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if (d[i][k] == M || d[k][j] == M) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    vector<vector<lint>> e(n, vector<lint>(n, M));
    for (int i = 0; i < n; i++) {
        e[i][i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (d[i][j] <= l) {
                e[i][j] = 1;
                e[j][i] = 1;
            }
        }
    }
    for (int k = 0; k < n; k++) {          // 経由する頂点
        for (int i = 0; i < n; i++) {      // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if (e[i][k] == M || e[k][j] == M) continue;
                e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        if (e[--s][--t] == M) {
            cout << -1 << endl;
        } else {
            cout << e[s][t] - 1 << endl;
        }
    }
}

Measured memory_bytes: 1920
//ProblemC

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemC

#define MAXN 50
#define MAXP 50

class Solve {
private:
	int maxp = 0;
	int minp = 100;

	bool can(int a, int b, bool used[], int n) {
		bool path[MAXP +1][MAXP +1]{};
		for (int i = 1; i <= MAXP; i++) {
			for (int j = 1; j < MAXP; j++) {
				if (used[j]) {
					path[i][i % j] = true;
				}
			}
		}
		for (int i = 0; i <= MAXP; i++) {
			path[i][i] = true;
		}

		for (int k = 0; k <= MAXP; k++)
			for (int i = 0; i <= MAXP; i++)
				for (int j = 0; j <= MAXP; j++) {
					path[i][j] = path[i][j] || path[i][k] && path[k][j];
				}
		return path[a][b];
	}

	bool can(int a[], int b[], bool used[], int n) {
		for (int i = 0; i < n; i++) {
			if (!can(a[i], b[i], used, n)) {
				return false;
			}
		}
		return true;
	}

	void solve() {
		int n;
		int a[MAXN], b[MAXN];

		cin >> n;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) cin >> b[i];

		bool must[MAXP]{};
		for (int i = 1; i < MAXP; i++) must[i] = true;

		if (!can(a, b, must, n)) {
			cout << -1 << endl;
			return;
		}

		for (int i = MAXP - 1; i >= 1; i--) {
			must[i] = false;
			if (!can(a, b, must, n)) {
				must[i] = true;
			}
		}

		long long rst = 0;
		for (int i = 1; i < MAXP; i++) if(must[i]) rst += 1LL << i;
		cout << rst << endl;

	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



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

    int N;cin >> N;
    vector<long long> A(N),B(N);
    long long sumA = 0,sumB = 0;
    for(int i = 0;i<N;i++) cin >> A.at(i),sumA += A.at(i);
    for(int i = 0;i<N;i++) cin >> B.at(i),sumB += B.at(i);
    if(sumA < sumB){
        cout << -1 << endl;
        return 0;
    }
    long long minusSUM = 0;
    int ans = 0;
    vector<long long> plus;
    for(int i = 0;i<N;i++){
        if(A.at(i) > B.at(i)){
            plus.push_back(A.at(i)-B.at(i));
        }
        else if(A.at(i) < B.at(i)){
            ans++;
            minusSUM += B.at(i)-A.at(i);
        }
    }
    sort(plus.begin(),plus.end(),greater<long long>());
    
    for(int i = 0;i<plus.size();i++){
        if(minusSUM <= 0) continue;
        ans++;
        minusSUM -= plus.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5368
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int w = sc.nextInt();
                while(w >= 0){ 
                        System.out.println(4280-charge(w));
                        w = sc.nextInt();
                }   
                sc.close();
        }   
        static int charge(int w){
                int charge = 0;
                if(w > 30){
                        charge += 160*(w-30);
                        w = 30; 
                }   
                if(w > 20){
                        charge += 140*(w-20);
                        w = 20; 
                }   
                if(w > 10){
                        charge += 125*(w-10);
                        w = 10; 
                }   
                return charge + 1150;
        }   
}

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

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

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



Measured memory_bytes: 3088
#include <stdio.h>

int main(){
	int A;
	scanf("%d", &A);
	int B;
	scanf("%d",&B);
	if(A==1 && B==2){
		printf("%d\n", 3);
	} else if(A==2 && B==1){
		printf("%d\n", 3);
	} else if(A==2 && B==3){
		printf("%d\n", 1);
	} else if(A==3 && B==2){
		printf("%d\n", 1);
	} else if(A==1 && B==3){
		printf("%d\n", 2);
	} else if(A==3 && B==1){
		printf("%d\n", 2);
	} else {
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2148
n = int(input())
h_list = list(map(int,input().split()))

a_dict = dict()
b_dict = dict()

for i in range(n):
    a = h_list[i]+i
    b = i-h_list[i]
    if not a in a_dict:
        a_dict[a] = 1
    else:
        a_dict[a] += 1
    if not b in b_dict:
        b_dict[b] = 1
    else:
        b_dict[b] += 1

count = 0
for a in a_dict:
    if a in b_dict:
        count += a_dict[a]*b_dict[a]
print(count)


Measured memory_bytes: 56524
/*-----Deep D. Savani------------
	-------DAIICT,INDIA--------------
	*/
	#include<bits/stdc++.h>
	#define pb push_back
	#define ff first
	#define ss second
	#define mp make_pair
	#define mod 1000000007
	#define deb(x) cout<<#x<<" : "<<x<<endl;
	#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
	#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
	#define nax 1000010
	#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	typedef long long ll;
	    
	using namespace std;

	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 

	#define T ll  
	#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> 
	    
	long long modulo(long long base,long long exponent,long long modulus);
	long long choose(ll n,ll k);
	ll inverse(ll a,ll m);



	void build()
	{
	    //freopen("input.txt","r",stdin);
	    //freopen("output.txt","w",stdout);
	}
	map<ll,ll> freq;    
	    
	int main(){

	    build();
	    ll n;
	    cin>>n;

	    vector<ll> a(n);
	    for(int i=0;i<n;i++)
	    {
	    	cin>>a[i];
	    	freq[a[i]]++;
	    }
	    sort(a.begin(),a.end(),greater<ll>());

	    ll ans=0;
	    for(int i=0;i<n;i++)
	    {
	    	if(freq[a[i]]<=0)
	    		continue;

	    	ll log=log2(a[i]);
	    	ll num=1LL<<log;
	    	num=num*2;

	    	//deb3(a[i],log,num);

	    	if(num==2*a[i])
	    	{
	    		if(freq[a[i]]>1)
	    		{
	    			freq[a[i]]-=2;
	    			ans++;
	    		}
	    	}
	    	else if(freq[num-a[i]]>0)
	    	{
	    		freq[a[i]]--;
	    		freq[num-a[i]]--;
	    		ans++;
	    	}
	    }
	    cout<<ans<<endl;
	    return 0;
	}
	    
	        
	    
	long long modulo(long long base,long long exponent,long long modulus)
	{
	    if(modulus ==1)
	        return 0;
	    
	    long long result=1;
	    base=base % modulus;
	    while(exponent>0)
	    {
	        if(exponent%2==1)
	        {
	            result=(result*base) % modulus;

	        }
	        exponent=exponent>>1;
	        base = (base*base) % modulus;
	    }
	        return result;
	}
	    
	long long choose(ll n,ll k)
	{
	    if(k==0)  return 1;
	    return (n* choose(n-1,k-1))/k;
	}
	    
	void EE(ll a,ll b,ll &co1,ll &co2)
	{
	    if(a%b==0)
	    {
	        co1=0;
	        co2=1;
	        return;
	    }
	    EE(b,a%b,co1,co2);
	    ll temp=co1;
	    co1=co2;
	    co2=temp-co2*(a/b);
	}
	    
	ll inverse(ll a,ll m)
	{
	    ll x,y;
	    EE(a,m,x,y);
	    if(x<0) x+=m;
	    return x;
	}

Measured memory_bytes: 27008
from itertools import permutations
import math


N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

lst = list(range(N)) 
distance = 0

for root in permutations(lst):
    for i in range(N-1):
        distance += math.sqrt((xy[root[i]][0]-xy[root[i+1]][0])**2
                              + (xy[root[i]][1] -xy[root[i+1]][1])**2)
distance /= math.factorial(N)
print(distance)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = long.Parse(Console.ReadLine());
        long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var a = input[0];
        var b = input[1];
        var c = input[2];
        var k = input[3];

        long ans = 0;
        long count = k;
        count = count - a;
        if (count > 0)
        {
            ans = a;
        }
        else
        {
            ans = k;
            Console.WriteLine(ans);
            return;
        }

        count = count - b;
        if (count > 0)
        {
            //
        }
        else
        {
            //
            Console.WriteLine(ans);
            return;
        }

        count = count - c;
        if (count > 0)
        {
            ans += c * -1;
        }
        else
        {
            ans += (c + count) * -1;
            Console.WriteLine(ans);
            return;
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28172
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#include <map>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef pair< int , pair<int, int> > pip;
typedef unsigned long long ull;
const double EPS = 10e-6;
bool flg[1000005]={};

int main()
{

	int n,ori;
	cin>>n;
	ori=n;
	cout<<n<<":";
	for(int i=2;i<=1000005;i++)
	{
		if(flg[i])
		{
			;
		}
		else
		{
			for(int l=i;l<=1000005;l+=i)
			{
				flg[l]=true;
			}
		}
	}
	while(1)
	{
		if(n==1)
		{
				cout<<endl;
				break;
		}
		for(int i=2;i<=1000005;i++)
		{
			if(n%i==0)
			{
				cout<<" "<<i;
				n/=i;
				break;
			}
		}
		if(n==ori)
		{
			cout<<" "<<ori<<endl;
			break;
		}
	}
}

Measured memory_bytes: 2144
using System;

class test {
    static void Main() {
        string s = Console.ReadLine();
        bool a = false;
        bool b = false;
        bool c = false;
        for (int i = 0; i < 3; i++) {
            switch (s[i]) {
                case 'a':
                    a = true;
                    break;
                case 'b':
                    b = true;
                    break;
                case 'c':
                    c = true;
                    break;
            }
        }
        if (a && b && c)Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

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

const int maxn = 2e6+10;
int n;
ll a[maxn];
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

ll minv[maxn<<2];
void build(int l,int r,int rt){
    if(l==r){
        scanf("%lld",a+l);
        minv[rt]=a[l];return;
    }
    int mid=l+r>>1;
    build(lson);build(rson);
    minv[rt]=min(minv[rt<<1],minv[rt<<1|1]);
}
int query(int L,int R,int l,int r,int rt){
    if(L<=l&&R>=r)return minv[rt];
    int mid=l+r>>1,ret=0x3f3f3f3f;
    if(L<=mid)ret=min(ret,query(L,R,lson));
    if(R>mid)ret=min(ret,query(L,R,rson));
    return ret;
}

int main(){
    int t=1;//cin>>t;
    while(t--){
        scanf("%d",&n);
        build(1,n,1);
        ll ans=0;
        int l,r,mid;
        ll len1,len2;
        for(int i=1;i<=n;i++){
            l=0,r=i+1;
            while(r-l>1){
                mid=l+r>>1;
                if(query(mid,i,1,n,1)==a[i])r=mid;
                else l=mid;
            }
            len1=i-r+1;
            l=i-1,r=n+1;
            while(r-l>1){
                mid=l+r>>1;
                if(query(i,mid,1,n,1)==a[i])l=mid;
                else r=mid;
            }
            len2=l-i+1;
            ans+=1ll*a[i]*len1*len2;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <limits>
#define LL long long

using namespace std;

int main() {
	int n, t, c, recC=-1, minC, maxC, p, maxP, minimumRisk;
	minC = numeric_limits<int>::max();
	maxP = minimumRisk = numeric_limits<int>::min();
	cin >> n;

	for(t=0;t<n;t++){
		cin >> c;

		if(c<minC){
			minC = c;
			maxC = 0;
		} else {
			if(c>maxC){
				maxC = c;
				p = maxC - minC;
				if(p>maxP){
					maxP = p;
				}
			}
		}

		if(recC!=-1){
			p = c - recC;
			if(p>minimumRisk){
				minimumRisk = p;
			}
		}
		recC = c;
	}

	if(maxP==numeric_limits<int>::min()){
		maxP = minimumRisk;
	}

	cout << maxP << endl;

	return 0;
}



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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll size = s.length();
    for(ll i=0;i<min(size,n);i++)
    {
        cout<<s[i];
    }
    if(size>n)
        cout<<"...";
  
}
    // Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3648
x = int(input())
list = [int(i) for i in range(x, 120000)]
for t in list:
    f = 0
    for i in range(2,x//2):
        i = int(i)
        if t % i == 0:
            #print(i)
            f = 1
        if f == 1:
            break
    if f == 0:
        print(t)
        break

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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  vector<ll> v;
  vector<ll> memory(n + 1, 0);
  v.push_back(1);
  memory[1] = 1;
  ll next;
  for (ll i = 0; i < n; i++)
  {
    if (memory[a[v[i] - 1]] == 1)
    {
      next = a[v[i] - 1];
      break;
    }
    v.push_back(a[v[i] - 1]);
    memory[a[v[i] - 1]] = 1;
  }
  ll ind = distance(v.begin(), find(v.begin(), v.end(), next));
  if (k < ind)
  {
    cout << v[k] << endl;
  }
  else
  {
    cout << v[(k - ind) % (v.size() - ind) + ind] << endl;
  }
}


Measured memory_bytes: 8432
import sys
import collections


def r(n, a, b, c):

    cnt = 0
    for i in range(len(a)):
        cn = collections.Counter([a[i], b[i], c[i]])
        cc = [k for k, v in cn.items() if v == 1]
        if len(cc) == 3:
            cnt += len(cc) - 1
        else:
            cnt += len(cc)

    return cnt

def main():
    input = sys.stdin.readline
    n = int(input())
    a = input()
    b = input()
    c = input()

    print(r(n, a, b, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()


W, H, x, y = map(int, input().split())
ans1 = str((W * H) / 2)

ans2 = "0"
cnt = 0
if H % 2 == 0 and y == H // 2:
    cnt += 1
if W % 2 == 0 and x == W // 2:
    cnt += 1

# nx = min(x, W - x)
# ny = min(y, H-y)
# if nx * Y == ny * X:
#     ans += 2
if cnt >= 2:
    ans2 = "1"
print(ans1, ans2)


Measured memory_bytes: 38480
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


int main(){
    int n;
	cin >> n;
	int a[n+5];
	int cnt = 0;
	FOR0(i,n){
		cin >> a[i];
		if((i+1)%2 == 1 && a[i]%2 == 1){
			cnt++;
		}
	}	
	cout << cnt << endl;
}

Measured memory_bytes: 3596
def main():
    from collections import deque
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))

    c = deque(c)
    t = 0
    while c:
        d, f = c.popleft()
        t += d
        if f < t:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()


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

int main(){
      int curr;cin >> curr;
      map<int, int> m;
      m[curr] = 1;
      int i = 1;
      while(true){
            i++;
            if(curr & 1)curr = (3 * curr) + 1;
            else curr /= 2;
            m[curr]++;
            if(m[curr] == 2)return cout << i, 0;
      }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[510][20];
int g[30][30];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<26;i++)for(int j=0;j<26;j++)g[i][j]=0;
		for(int i=0;i<26;i++)g[i][i]=1;
		bool ok=true;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				int k;
				for(k=0;str[i][k]&&str[j][k];k++){
					if(str[i][k]!=str[j][k]){
						g[str[i][k]-'a'][str[j][k]-'a']=1;break;
					}
				}
				if(str[i][k]&&!str[j][k])ok=false;
			}
		}
		for(int k=0;k<26;k++)for(int i=0;i<26;i++)for(int j=0;j<26;j++)
			g[i][j]|=(g[i][k]&g[k][j]);
		
		for(int i=0;i<26;i++)for(int j=0;j<26;j++)if(i!=j&&g[i][j]&&g[j][i])ok=false;
		if(ok)printf("yes\n");
		else printf("no\n");
	}
}

Measured memory_bytes: 1024
// 2018/12/10 Tazoe

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

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

	int a[10];
	for(int i=0; i<N; i++){
		cin >> a[i];
	}

	int w[10];
	for(int i=0; i<N; i++){
		cin >> w[i];
	}

	int wmin0 = 1001;
	int wmin1 = 1001;

	for(int i=0; i<N; i++){
		if(a[i]==0){
			wmin0 = min(wmin0, w[i]);
		}
		else{
			wmin1 = min(wmin1, w[i]);
		}
	}

	if(wmin0==1001 || wmin1==1001){
		cout << 0 << endl;
	}
	else{
		cout << wmin0+wmin1 << endl;
	}

	return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

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

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)

int calc(int a, int b, char ope) {
    if (ope == '+') return a + b;
    if (ope == '-') return a - b;
    if (ope == '*') return a * b;
    return -1;
}

bool isten(string s) {
    int ans;
    if (s[1] == '(') {
        int a, b, c, d;
        a = s[2] - '0';
        b = s[6] - '0';
        c = s[11] - '0';
        d = s[16] - '0';
        ans = calc(calc(calc(a,b,s[4]), c, s[9]), d, s[14]);
    }else {
        int a, b, c, d;
        a = s[1] - '0';
        b = s[5] - '0';
        c = s[11] - '0';
        d = s[15] - '0';
        ans = calc(calc(a, b, s[3]), calc(c, d, s[13]), s[8]);
    }
    return ans == 10;
}

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)


vector<char> operands = {'+', '-', '*'};
random_device rd;

char getRandomOperand() {
    return operands[rd() % 3];
}

void solve41(int a, int b, int c, int d) {
    vector<int> nums;
    nums.push_back(a), nums.push_back(b), nums.push_back(c), nums.push_back(d);
    sort(ALL(nums));
    do {
        REP(i,500) {
            string eq1, eq2;
            eq1 = "((" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " " + to_string(nums[2]) +
            ") " + getRandomOperand() + " " + to_string(nums[3]);
            eq2 = "(" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " (" + to_string(nums[2]) +
            " " + getRandomOperand() + " " + to_string(nums[3]) + ")";
            if (isten(eq1)) {
                cout << eq1 << endl;
                return;
            }else if (isten(eq2)) {
                cout << eq2 << endl;
                return;
            }
        }
    }while (next_permutation(nums.begin(), nums.end()));
    cout << 0 << endl;
}

int main() {
    int a, b, c, d;
    while(cin >> a >> b >> c >> d, a + b + c + d) {
        solve41(a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 3144
K = int(input())

if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K

if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    rest = 1
    ans = 0
    while True:
        rest *= 10
        ans += 1
        rest = rest % L
        if rest == 1:
            break
    print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   bool flg = 0;
   for(int i=1;i<=n;i++){
      int res = i*1.08;
      if(res == n) {
         cout << i << endl;
         flg = 1;
         break;
      }
   }

   if(!flg) cout << ":(" << endl;



   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;
#define gc getchar()
inline int read(){
    register int x(0);register char c(gc);
    while(c>'9'||c<'0')c=gc;
    while(c>='0'&&c<='9')x=x*10+c-48,c=gc;
    return x;
}
const int N=1100,M=520000;
int X[M],Y[M],mustdie[N],n,m,ans;
bitset<810> mustlive[N];
int main(){
    n=read();m=read();
    register int i,j;
    for(i=1;i<=m;i++)X[i]=read(),Y[i]=read();
    for(i=1;i<=n;i++){
        mustlive[i][i]=1;
        for(j=m;j>=1;j--)
            if(mustlive[i][X[j]]&&mustlive[i][Y[j]]){
                mustdie[i]=1;break;
            }
            else if(mustlive[i][X[j]])mustlive[i][Y[j]]=1;
            else if(mustlive[i][Y[j]])mustlive[i][X[j]]=1;
    }
    for(i=1;i<n;i++){
        if(mustdie[i])continue;
        for(j=i+1;j<=n;j++){
            if(mustdie[j])continue;	
            if(!(mustlive[i]&mustlive[j]).any())ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int x;
int ans=0;
rep(i,3){
	cin>>x;
	ans=ans*10+x;
}
if(ans%4) cout<<"NO";
else cout<<"YES";
 return 0;
}

Measured memory_bytes: 256
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split()) 
    X.append(x)      
    Y.append(y)      
    H.append(h)      

for cx in range(101):
    for cy in range(101):
        for i in range(N):
            if H[i] > 0:
                height = H[i] + abs(X[i]-cx) + abs(Y[i]-cy)
        ok = True
        for i in range(N):
            if max(height - abs(X[i]-cx) - abs(Y[i]-cy), 0) != H[i]:
                ok = False
        if ok:
            print(cx, cy, height)
            exit()


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


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N; cin >> N;
    long long A[N],B[N],C[N];
    
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }

    long long value = 0;
    int B_index_b = A[0];
    for (int i=0;i<N;i++){
        int B_index = A[i];
        value += B[B_index-1];
        if ((B_index - B_index_b) == 1){
            value += C[B_index_b - 1];

        }
        B_index_b = B_index;
    }
    cout << value << endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    
    ans = 0
    x = []
    for i in range(N):
        x.append(S[i])
        xj = ''.join(x)
        if(S[i+1:].count(xj)):
            ans = max(ans, len(xj))
        else:
            x.pop(0)

    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bool func() {
	long long N;
	cin >> N;
	vector<long long> A(N);
	for (auto& x : A) cin >> x;
	long long s = 0;
	for (auto x : A) s += x;
	long long m = N * (N+1) / 2;
	if (s % m) return false;
	long long n = s / m;
	vector<long long> B(N);
	B[0] = A[0] - A[N-1] - n;
	for (int i = 1; i < N; ++ i) {
		B[i] = A[i] - A[i-1] - n;
	}
	for (auto x : B) {
		if (x > 0) return false;
		if (-x % N != 0) return false;
	}
	return true;
}
int main() {
	cout << (func() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
    vector<int> par; // uf(x,y)->y
    UnionFind() {}
    UnionFind(int NV) { init(NV); }
    void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) { x = operator[](x); y = operator[](y); if (x != y) par[x] = y; }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	UnionFind uf(N);
	rep(i, 0, M) {
		int x, y, z; cin >> x >> y >> z;
		x--; y--;
		uf(x, y);
	}

	int ans = 0;
	rep(i, 0, N) if (uf[i] == i) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 1016
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  invs.length=n+1,invs[0]=invs[1]=1;
  for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],inv(fac[r]),inv(fac[n-r]));}
function npr(n,r){return mul(fac[n],finv[r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,m,k] = nexts(3);
  var ans = 0;
  fset(Math.max(n,m));
  for(var i = 0; i <= k; i++){
    var t = ncr(n-1,i);
    t = mul(m,t);
    t = mul(t,pow(m-1,n-1-i));
    ans += t;
    ans %= mod;
  }
  return ans;
}

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

public class Main {

    private static int N;
    private static int M;
    private static int[] A;
    private static int[] B;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        A = new int[M];
        B = new int[M];
        for (int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }
        System.out.println( solve() );
    }

    private static int solve() {
        Set<Integer> path = new HashSet<>();
        path.add(1);
        return _solve(1, path);
    }

    private static int _solve(int node, Set<Integer> path) {
        if( path.size() == N ) return 1;

        int ans = 0;
        for (int i = 0; i < M; i++) {
            if( A[i] == node ) {
                int to = B[i];
                if( !path.contains(to) ) {
                    Set<Integer> newPath = new HashSet<>(path);
                    newPath.add(to);
                    ans += _solve(to, newPath);
                }
            }

            if( B[i] == node ) {
                int to = A[i];
                if( !path.contains(to) ) {
                    Set<Integer> newPath = new HashSet<>(path);
                    newPath.add(to);
                    ans += _solve(to, newPath);
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 30036
def  gcd(a,b):
  while b:
    a,b = b,a%b
  return a

def  lcm(a,b):
  return a*b//gcd(a,b)

n = int(input())

if 360%n == 0:
    print(360//n)
else:
    print(lcm(n,360)//n)

Measured memory_bytes: 9172
#include <iostream>
#include <map>
#include <vector>
#include <cassert>
#include <unordered_set>
#include <set>
#include <bitset>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<long double> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }

    vector<int> p(n);
    for (int i = 0; i < n; ++i)
        p[i] = i;

    long double sum = 0;
    int num = 0;
    do {
        long double ans = 0;
        for (int i = 0; i + 1 < n; ++i) {
            ans += sqrt(sqr(x[p[i]] - x[p[i + 1]]) + sqr(y[p[i]] - y[p[i + 1]]));
        }

        sum += ans;
        ++num;

        // cout << ans << "\n";
    } while (next_permutation(all(p))) ; 

    cout << fixed << setprecision(10) << sum / num << "\n";
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int a;
	cin >> a;

	if (a < 1200) {
		cout << "ABC" << endl;
	}
	else if(a<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  long long n,r=0;
  cin>>n;
  rep(i,n-1) r += i + 1;
  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N , P;
	cin >> N >> P;
	ll dp[N+1][2]={};
	dp[0][0] = 1;
	dp[0][1] = 0;
	FOR(i,1,N+1){
		ll k;
		cin >> k;
		if(k%2){
			dp[i][1] = dp[i-1][1] + dp[i-1][0];
			dp[i][0] = dp[i-1][1] + dp[i-1][0];
		}else{
			dp[i][1] = dp[i-1][1]*2;
			dp[i][0] = dp[i-1][0]*2;
		}
	}
	cout << dp[N][P] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	int a[n+1],b[n+1],c[n+1];
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
	int d[n+1][3];
	d[1][1]=a[1],d[1][2]=b[1],d[1][3]=c[1];
	for(int i=2;i<=n;i++){
		d[i][1]=max(d[i-1][2],d[i-1][3])+a[i];
		d[i][2]=max(d[i-1][1],d[i-1][3])+b[i];
		d[i][3]=max(d[i-1][1],d[i-1][2])+c[i];
	}
	cout<<max(d[n][1],max(d[n][2],d[n][3]));
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

bool check(double x,double y,double z,double r){  
	return sqrt(x*x+y*y) < r*2;
}  
int main(){  
	int data[3],r,n;
	while(cin >> data[0] >> data[1] >> data[2],data[0]){      
		cin >> n;    
		for(int i=0;i<n;i++){        
			cin >> r;    
			bool ret = false; 
			sort(data,data+3);      
			do{         
				ret |= check(data[0],data[1],data[2],r);     
			}
			while(next_permutation(data,data+3));   
			cout << (ret?"OK":"NA") << endl; 
		} 
	}
} 

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

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> A(n);
  rep(i,n){
    cin >> A[i];
  }
  int ans=0;
  rep(i,n){
    ans++;
    for(int j=1;;++j){
      if(j*A[i] + 1 > d) break;
      ans++;
    }
  }
  cout << ans + x << endl;
  return 0;
}

Measured memory_bytes: 256
"use strict"

var inputs = '';
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
})

reader.on('line', function(input) {
  inputs = input
})

reader.on('close', function() {
  let items = inputs.trim().split(' ')
  let n = parseInt(items[0])
  let a = parseInt(items[1])
  let b = parseInt(items[2])
  let train = n * a
  let taxi = b
  if(train < taxi){
    console.log(train)
  }else
    console.log(taxi)
})

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int A,B;
    string s;
    cin >> A >> B >> s;
    int f = true;
    for(int i = 0; i < A+B+1; i++){
        if(i < A-1){
            if(s[i] == '-'){f = false; break;}
        }else if(i == A){
            if(s[i] != '-'){f = false; break;}
        }else{
            if(s[i] == '-'){f = false; break;}
        }
    }
    cout << (f ? "Yes" :"No") << endl;
}

Measured memory_bytes: 256
var
  n,i,ans:longint;
  a,b:array[1..1000] of longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      readln(a[i],b[i]);
      inc(ans,b[i]-a[i]+1);
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;
ll a[3];
ll b[3];

ll func(vector<ll>& AtoB, ll N, ll *a, ll *b) {
  if (len(AtoB) == 1) {
    ll i = AtoB[i];
    ll g = (N/a[i]);
    N -= g*a[i];
    N += g*b[i];
  } else if (len(AtoB) == 2) {
    ll ma = 0;
    for (ll n = 0; n <= N; ++n) {
      ll m = N-n;
      ll tmp = N;
      ll i = AtoB[0], j = AtoB[1];
      ll g = (n/a[i]);
      ll s = (m/a[j]);
      tmp -= g*a[i] + s*a[j];
      tmp += g*b[i] + s*b[j];
      ma = max(ma, tmp);
    }
    N = ma;
  } else if (len(AtoB) == 3) {
    ll ma = 0;
    for (ll n = 0; n <= N; ++n) {
      for (ll m = 0; m <= (N-n); ++m) {
        ll l = (N-m-n);
        ll tmp = N;
        ll i = AtoB[0], j = AtoB[1], k = AtoB[2];
        ll g = (n/a[i]);
        ll s = (m/a[j]);
        ll br = (l/a[k]);
        tmp -= g*a[i] + s*a[j] + br*a[k];
        tmp += g*b[i] + s*b[j] + br*b[k];
        ma = max(ma, tmp);
      }
    }
    N = ma;
  }

  return N;
}

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

  cin >> N;
  cin >> a[0] >> a[1] >> a[2];
  cin >> b[0] >> b[1] >> b[2];

  vector<ll> AtoB, BtoA;
  if (a[0] < b[0]) AtoB.push_back(0);
  if (a[0] > b[0]) BtoA.push_back(0);
  if (a[1] < b[1]) AtoB.push_back(1);
  if (a[1] > b[1]) BtoA.push_back(1);
  if (a[2] < b[2]) AtoB.push_back(2);
  if (a[2] > b[2]) BtoA.push_back(2);

  N = func(AtoB, N, a, b);
  N = func(BtoA, N, b, a);

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> x(n);
    rep(i, n) cin >> a[i];
    rep(i, n){
        if(i%2==0)  x[0]+=a[i];
        else        x[0]-=a[i];
    }
    x[0]/=2;
    rep(i,n-1){
        x[i+1]=a[i]-x[i];
    }
    rep(i, n){
        cout << x[i]*2 << endl;
    }
    return 0;
}




Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = long long int;
using uli = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;
    for (size_t i = 0; i < s.size(); i++) {
        if (i % 2 == 0)
            cout << s.at(i);
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
#define NUM 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,m;
    cin>>n>>m;
    ll ans=1;
    if(abs(n-m)>1) ans=0;
    ll g=max(n,m),l=min(n,m);
    for(ll i=1;i<=l;i++){
        ans*=i*i;
        ans%=NUM;
    }
    for(ll i=l+1;i<=g;i++){
        ans*=i;
        ans%=NUM;
    }
    if(n==m) ans=(ans*2)%NUM;
    cout<<ans;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    vector<ll> t(n);
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    ll ans = 1;
    for(int i = 0; i < n; i++)
    {
        ll g = gcd(ans, t[i]);
        ll a = ans / g;
        ll b = t[i] / g;
        ans = g * a * b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Warshall-Floyd

#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<long long> c(M);
    vector<vector<long long>> d(N, vector<long long>(N, LLONG_MAX / 2));
    vector<vector<vector<bool>>> used(N, vector<vector<bool>>(N, vector<bool>(M, false)));
    for(int i = 0; i < M; i++){
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
        used[a[i]][b[i]][i] = true;
        used[b[i]][a[i]][i] = true;
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                if(d[j][k] > d[j][i] + d[i][k]){
                    d[j][k] = d[k][j] = d[j][i] + d[i][k];
                    for(int m = 0; m < M; m++) used[j][k][m] = used[j][i][m] || used[i][k][m];
                    for(int m = 0; m < M; m++) used[k][j][m] = used[j][i][m] || used[i][k][m];
                }
            }
        }
    }

    vector<bool> check(M, false);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            // cout << i << " " << j << " " << d[i][j] << " ";
            for(int m = 0; m < M; m++){
                // cout <<  " " << *itr;
                check[m] = check[m] || used[i][j][m];
            }
            // cout << endl;
        }
    }

    int ans = 0;
    for(auto itr = check.begin(); itr != check.end(); itr++) if(!*itr) ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2176