akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007 //998244353
#define mii map<int, int>
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word



const long long N = 200005, INF = 2000000000000000000;
//lld pi = 3.1415926535897932;
int lcm(int a, int b)
{
  int g = __gcd(a, b);
  return a / g * b;
}
int power(int a, int b, int p)
{
  if (a == 0)
    return 0;
  int res = 1;
  a %= p;
  while (b > 0)
  { if (b & 1)
      res = (res * a) % p;
    b >>= 1;
    a = (a * a) % p;
  }
  return res;
}

int testcaseva;

int sq(int x) { return 1ll * x * x; }


int32_t main() {
    int n;
    cin >> n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin >> ar[i];
    sort(ar,ar+n);
    int ans=0;
    ans+=ar[n-1];
    int l=n-2;
    int k=n-2;
    int m=0;
    while(k>0){
        ans+=ar[l];
        k--;
        m++;
        if(m==2){
        m=0;
        l--;
        }

    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

const ll MAX = 2010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


signed main(){
  ll n,k;
  cin>>n>>k;

  COMinit();

  for(int i=1;i <= k;i++)
  {
    ll ans=max(1ll,COM(k-1,i-1)) * COM(n-k+1,i);
    ans%=mod;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
str = list(input())
N = int(input())
for i in range(N):
    cmd,a,b,*c = input().split()
    a = int(a)
    b = int(b)
    if cmd == "print":
        print(*str[a:b+1], sep='')
    elif cmd == "reverse":
        str[a:b+1] = reversed(str[a:b+1])
    elif cmd == "replace":
        str[a:b+1] = c[0]


Measured memory_bytes: 5736
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

print("Yes" if X >= 30 else "No")


Measured memory_bytes: 10036
a = input().split()
N = int(a[0])
L = int(a[1])
a = [0]*N
for i in range(N):
  a[i] = abs(L+i)
for i in range(N):
  if a[i] == min(a):
    c = int((L-1)*N+N*((N+1)/2)-(L+i))
    print(c)
    break

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

#define reps(i,s,n) for(int (i) = (s); (i) < (n) ;(i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long int;
#define MAX_N 100000

int n,m;
int a[3*MAX_N];
int main(){
    
    cin >> n;
    rep(i,3*n){
        cin >> a[i];
    }
    priority_queue<ll,vector<ll>,greater<ll>> q_l;//昇順
    priority_queue<ll> q_r;//降順
    ll sum_l = 0,sum_r = 0;
    rep(i,n){
        q_l.push(a[i]);
        q_r.push(a[3*n-i-1]);
        sum_l += a[i];
        sum_r += a[3*n-i-1];
    }

    auto dl = vector<ll>(n+1,0);
    auto dr = vector<ll>(n+1,0);
    dl[0] = sum_l;
    dr[n] = sum_r;

    rep(i,n){
        q_l.push(a[i+n]);
        sum_l -= q_l.top();
        sum_l += a[i+n];
        q_l.pop();
        dl[i+1] = sum_l;
    }
    rep(i,n){
        q_r.push(a[2*n-i-1]);
        sum_r -= q_r.top();
        sum_r += a[2*n-i-1];
        q_r.pop();
        dr[n-i-1] = sum_r;
    }

    ll ans = -20000000000000000;
    
    rep(i,n+1){
        ans = max(ans, dl[i]- dr[i]);
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    int x;
    cin>>x;
    if(400<=x && x<600){
        cout<<8<<endl;
    }else if(600<= x && x<800){
        cout<<7<<endl;
    }else if(800<= x && x<1000){
        cout<<6<<endl;
    }else if(1000<= x && x<1200){
        cout<<5<<endl;
    }else if(1200<= x && x<1400){
        cout<<4<<endl;
    }else if(1400<= x && x<1600){
        cout<<3<<endl;
    }else if(1600<= x && x<1800){
        cout<<2<<endl;
    }else if(1800<= x && x<2000){
        cout<<1<<endl;
    }
    return 0;
}

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

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

    long long int a[n + 1] = {2,1};

    for(int i = 2; i < n + 1; i++){
        a[i] = a[i - 1] + a[i - 2];
    }

    cout << a[n] << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

N = input()

ans = 0
for s in N:
    i = int(s)
    ans += i

if ans % 9 == 0:
    print('Yes')
else:
    print('No')

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)



Measured memory_bytes: 9344
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

ll A[202020];
vector<vector<int>> G;

void dfs(int v, int pv = -1) {
    for (auto nv : G[v]) {
        if (nv == pv) continue;
        A[nv] += A[v];
        dfs(nv,v);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Q; cin >> N >> Q;
    G.resize(N);
    rep(i,N-1) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    rep(i,Q) {
        int p,x; cin >> p >> x;
        --p;
        A[p] += x;
    }

    dfs(0);

    rep(i,N) cout << A[i] << " ";
    cout << ln;
}

Measured memory_bytes: 21120
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let _: i32 = line.parse().unwrap();
  let line = lines.next().unwrap().unwrap();
  let xs: Vec<i32> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let x_min = xs.iter().min().unwrap();
  let x_max = xs.iter().max().unwrap();
  let e_min: i32 = (*x_min..(*x_max+1)).map(|p| xs.iter().map(|x| (x - p).pow(2)).sum()).min().unwrap();
  println!("{}", e_min);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  string ans = "";
  
  for (int i = 0; i < s.size(); i += 2) {
    ans = ans + s.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
a,b,c=$<.read.split.map(&:to_i)

ret = 0
while a%2==0&&b%2==0&&c%2==0
  if a == b && b == c
    p -1
    exit 0
  end
  a_ = b/2 + c/2
  b_ = a/2 + c/2
  c_ = a/2 + b/2
  a,b,c = [a_,b_,c_]
  ret += 1
end

p ret


Measured memory_bytes: 1788
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxN = 5000 * 100 + 100; 

int a[maxN]; 

int main() { 
    int n; cin >> n;
    for( int i = 0 ; i < 3*n ; i++) 
        cin >> a[i]; 
    sort( a , a + 3*n ); 
    ll ans = 0;
    for( int i = 3*n - 2 , j = 0 ; j < n ; j++ , i -= 2 ) 
        ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

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

    // i  19   18                                          0
    // b  1    0    0    1    1    0        1    1    0    1
    // n  20   19   18                           3    2    1
    // 2   2^18 2^17 2^16 2^15 2^14           2^2  2^1  2^0

    int _L = 1;
    int N = 0;
    while (_L <= L) {
        _L <<= 1; N++;
    }

    bitset<20> Lbit(L);

    vector<pair<pair<int, int>, int>> edge;
    for (int i = 0; i < N - 1; ++i) {
        edge.emplace_back(mp(i + 1, i + 2), 0);
        edge.emplace_back(mp(i + 1, i + 2), 1 << i);

        if (Lbit[i]) {
            L ^= 1 << i;
            edge.emplace_back(mp(i + 1, N), L);
        }
    }

    cout << N << " " << edge.size() << endl;
    rep(i, edge.size()) {
        cout << edge[i].first.first << " " << edge[i].first.second << " " << edge[i].second << endl;
    }
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<vector<ll>> G;

ll dfs(ll id) {
    vector<ll> v;
    for(int i=0;i<G[id].size();i++) {
        v.push_back(dfs(G[id][i]));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    tmp = 0;
    for(int i=0;i<v.size();i++) {
        tmp = max(tmp, 1+i+v[i]);
    }
    return tmp;
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll a;
        cin >> a;
        a--;
        G[a].push_back(i+1);
    }
    cout << dfs(0) << endl;
    return 0;
}

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

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

  vector<vector<int>> arr(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> arr[i][j];
    }
  }

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int distance = 0;
      for (int k = 0; k < d; ++k) {
        distance += (arr[i][k] - arr[j][k]) * (arr[i][k] - arr[j][k]);
      }
      int sqrt_distance = static_cast<int>(sqrt(distance));
      if (distance == sqrt_distance * sqrt_distance) ++cnt;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
program main;
var a, b, c, d : integer;
begin
	readln(a, b, c, d);
    
    repeat
        if (a > 0) and (c > 0)
            then c := c - b;
            if (c > 0)
                then a := a - d;
    until ((a <= 0) or (c <= 0)) ;
    
    if a <= 0
        then writeln('No')
        else writeln('Yes');
end.

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-5;
//const long long INF=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T& b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T& b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	REP(i,q)
		t*=p;
	return t;
}

//print for container
/*
template<typename Iterator>
void print(const Iterator& first, const Iterator& last)
{
	auto&& back=prev(last);
	for(auto e=first; e!=last; e=next(e))
		cout<<*e<<" \n"[e==back];
}*/

template<typename Head>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


constexpr long long INF64 = 1e18;
 
using Weight=long long;

struct edge{
	int to,cap,cost,rev;
};

const int MAX_V=100;
int V;
vector<vector<edge>> G(MAX_V);
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost)
{
	G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
	G[to].push_back((edge){from, 0, -cost, (int)G[from].size()-1});
}

int min_cost_flow(int s, int t, int f)
{
	int res=0;
	while(f>0)
	{
		fill(dist, dist+V, INF);
		dist[s]=0;
		bool update=true;
		while(update)
		{
			update=false;
			for(int v=0;v<V;v++)
			{
				if(dist[v]==INF) continue;
				for(int i=0;i<G[v].size();i++)
				{
					edge &e=G[v][i];
					if(e.cap>0 && dist[e.to] > dist[v] + e.cost)
					{
						dist[e.to] = dist[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update=true;
					}
				}
			}
		}

		if(dist[t]==INF)
		{
			return -1;
		}

		int d=f;
		for(int v=t;v!=s;v=prevv[v])
		{
			d=min(d, G[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*dist[t];
		for(int v=t;v!=s;v=prevv[v])
		{
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}

int main()
{
	REP(i,MAX_V)
		dist[i]=INF;
	int n,m,f;
    cin>>n>>m>>f;
	V=n;
    for(int i=0;i<m;++i){
        int u,v;
        Weight cap,cost;
        cin>>u>>v>>cap>>cost;
        add_edge(u,v,cap,cost);
    }
    cout<<min_cost_flow(0,n-1,f)<<endl;
}

Measured memory_bytes: 3196
data = input().split()
a = int(data[0])
b = int(data[1])
c = int(data[2])
k = int(data[3])
ans = 0

if k - a >0:
    ans += a
    k -= a
else:
    ans += k
    k = 0
if k - b >0:
    k -= b
else:
    k = 0
ans -= k
print(ans)    

Measured memory_bytes: 9196
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-06-17 09:17:14

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int a[MAXN];
int main(int argc, char const *argv[])
{	
	int n, x;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i)	cin >> a[i];
	// sort(a+1, a+1+n);
	int cur = 0, ans = 1;
	for(int i = 1; i <= n; ++i){
		// cout << "# " << cur << endl;
		cur += a[i];
		if(cur > x)	break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int n;
    while (cin>>n) {
        vector<int>v(n);int i;
        for(i=0,v[0]=2;i<n;i++)if(i)v[i]+=v[i-1]+i+1;
        cout<<v[n-1]<<endl;
    }
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>

using namespace std;


int main() {
    int n,m;
    cin >> n >> m;
    vector h(n,0);
    for (int i=0; i<n; i++) cin >> h[i];

    vector<vector<int>> g(n);
    for (int i=0; i<m; i++) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    for (int i=0; i<n; i++) {
        bool f = true;
        for (const auto &item : g[i]) {
            if (h[i] <= h[item]) f = false;
        }
        if (f) ans++;
    }

    cout << ans << endl;
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int n;
	cin>>n;
	for(int x=1; x<=n; x++){
		int tn=x*1.08;
		if(tn==n){
			cout<<x<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}

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

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


    int i = s.length() - 1;
    int lengthW = 0;

    long ans = 0;

    while (i >= 0) {
        if (s.at(i) != 'B') {
            lengthW++;
        } else {
            ans += lengthW;
        }
        i--;
    }

    cout << ans << endl;

    return 0;
}


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

struct Process{
	string name;
	int time;
};

int main(void)
{	queue<Process> que;
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < n; i++){
		Process P;
		cin >> P.name >> P.time;
		que.push(P);
	}
	
	int count_time = 0;
	
	while(que.empty() == false){
		Process P = que.front();
		que.pop();
		
		if(P.time <= q){
			count_time += P.time;
			cout << P.name << " " << count_time << endl;
		} 
		else{
			P.time = P.time - q;
			count_time += q;
			que.push(P);
		}
	}

	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

vi enu(int x) {
	vi res;
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) {
			while (x % i == 0) {
				x /= i;
			}
			res.pb(i);
		}
	}
	if (x != 1) {
		res.pb(x);
	}
	return res;
}

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

	vi cand;
	for (int i = 2; i <= N; ++i) {
		bool f = 1;
		for (int j = 2; j * j <= i; ++j) {
			if (i % j == 0) {
				f = 0;
			}
		}
		if (f) {
			cand.pb(i);
		}
	}

	int d = -1;

	for (int i = 0; i <= N; ++i) {
		int t = abs(a[i]);
		if (d == -1) {
			d = t;
		} else {
			d = __gcd(d, t);
		}
	}

	vi u = enu(d);

	set<int> st;
	for (int x : cand) {
		st.insert(x);
	}
	for (int x : u) {
		st.insert(x);
	}

	for (auto x : st) {
		vi coef = a;
		for (int &v : coef) {
			v %= x;
		}

		for (int i = 0; i + x <= N; ++i) {
			(coef[i + (x - 1)] += coef[i]) %= x;
			coef[i] = 0;
		}
		bool ok = 1;
		for (int &t : coef) {
			if (t) {
				ok = 0;
			}
		}
		if (ok) {
			cout << x << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> A(n+1,0);
    vector<int> B(n+1,0);
    B[0]=0;
    REP(i,n-1){
        if(s[i]=='A' && s[i+1]=='C') B[i+2]= 1;
    }
    A[0]=0;
    FOR(i,1,n+1){
        A[i]= A[i-1]+B[i];
        // cout << A[i]; 
    }
    vector<int>ans(m);
    REP(i,m){
        ll a,b;
        cin >> a >>b;
        ans[i]= A[b]-A[a];
    }
    REP(i,m){
        cout << ans[i] << endl;
    }
}

    

Measured memory_bytes: 2256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<int> v(n,1);
    vector<int> red(n,0);
    red[0] = 1;
    int ans = 0;
    rep(i,m) {
        int x, y; cin >> x >> y;
        x--; y--;
        v[x]--;
        v[y]++;
        if(red[x]) red[y] = 1;
        if(!v[x]) red[x] = 0;
    }
    rep(i,n) {
        if(red[i]&&v[i]) ans++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#define INF 9999999999999999999999

using namespace std;

long A[100][100], tmpA[100][100];
int V, E;

void import(int s, int t, int d){
    A[s][t] = d;
    return;
}

void set(){
    for(int i=0;i<100;++i){
        for(int j=0;j<100;++j){
            tmpA[i][j] = A[i][j];
        }
    }
    return;
}

void check(int a){
    for(int i=0;i<V;++i){
        for(int j=0;j<V;++j){
            if(tmpA[i][a] == INF || tmpA[a][j] == INF){
             continue;   
            }
            if(tmpA[i][j] > (tmpA[i][a]+tmpA[a][j])){
                A[i][j] = tmpA[i][a]+tmpA[a][j];
            }
        }
    }
    return;
}

int main(){
    for(int i=0;i<100;++i){
        for(int j=0;j<100;++j){
            A[i][j] = INF;
            tmpA[i][j] = A[i][j];
        }
    }
    
    
    int s, t, d;
    
    cin >> V >> E;
    for(int i=0;i<V;++i){
        import(i,i,0);
    }
    for(int i=0;i<E;++i){
        cin >> s >> t >> d;
        import(s,t,d);
    }
    
    for(int i=0;i<V;++i){
        for(int j=0;j<V;++j){
            check(j);
            set();
            if(A[j][j]<0){
                cout << "NEGATIVE CYCLE" << endl;
                return 0;
            }
        }
    }
    
    for(int i=0;i<V;++i){
        for(int j=0;j<V;++j){
            if(j!=0){
                cout << " ";
            }
            
            if(A[i][j] == INF){
                cout << "INF";
            }else{
                cout << A[i][j];
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);
    int pi = distance(a.begin(), max_element(a.begin(), a.end()));
    int ai = a.at(pi);
    a.erase(a.begin() + pi);
    vector<int> b = a;
    for (int i = 0; i < n - 1; i++) b.at(i) = abs(b.at(i) * 2 - ai);
    int aj = a.at(distance(b.begin(), min_element(b.begin(), b.end())));
    cout << ai << " " << aj << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;


	cin >> l >> r >> n;
	fr(i,l,1+r)	
		if(i%n == 0)
			k++;
	cout << k;


eNd();
  return 0;
 
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template<class T> struct SintMIN{
    int n;
    T e;
    vector<T> dat;

    SintMIN(T n_,T e_){
        n=1;e=e_;
        while(n<n_) n*=2;
        dat.resize(2*n-1,e);
    }

    void ud(int be,int en,T t,int k,int l,int r){
        if(r<=be||en<=l) return ;
        if(be<=l&&r<=en){
            dat[k]=min(dat[k],t);
            return;
        }
        ud(be,en,t,k*2+1,l,(l+r)/2);
        ud(be,en,t,k*2+2,(l+r)/2,r);
    }

    void ud(int be,int en,T t){
        ud(be,en,t,0,0,n);
    }

    T gt_sub(int k){
        if(k==0) return dat[k];
        return min(dat[k],gt_sub((k-1)/2));
    }

    T gt(int i){
        return gt_sub(i+n-1);
    }
};

template<class T> void cc(vector<T> a,map<T,int>& nm,vector<int>& c){
    sort(a.begin(),a.end());
    fr(i,a.size()){
        if(i<a.size()-1&&a[i]==a[i+1]) continue;
        nm[a[i]]=c.size();
        c.pb(a[i]);
    }
}

int main(){
    ll N=0,M,q,A,B,C;
    map<ll,int> nm;vector<ll> a;vector<int> c;
    cin>>M>>q;
    vector<ll> d(q);
    vector<pair<ll,pair<ll,ll>>> xst;
    fr(i,M){
        cin>>A>>B>>C;
        if(B<C) continue;
        if(A<C) A=C;
        xst.emplace_back(C,mp(A,B));
        a.pb(xst[N].ft);
        if(A>C) a.pb(A-C);
        a.pb(B-C);
        N++;
    }
    fr(i,q){
        cin>>d[i];
        a.pb(d[i]);
    }
    a.pb(0);
    sort(a.begin(),a.end());
    cc(a,nm,c);
    SintMIN<int> sg(c.size(),1e9+1);
    fr(i,N){
        sg.ud(nm[-(xst[i].ft-xst[i].sd.ft)],nm[-(xst[i].ft-xst[i].sd.sd)],xst[i].ft);
    }
    fr(i,q){
        ll ans=sg.gt(nm[d[i]]);
        if(ans==1e9+1) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 75660
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
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 (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n,m,k; cin >> n >> m >> k;
    vector<ll> a(n+1,0), b(m+1,0);
    rep(i,n) {
        int A; cin >> A;
        a[i+1] = a[i]+A;
    }
    rep(i,m) {
        int B; cin >> B;
        b[i+1] = b[i]+B;
    }
    int ans = 0;
    rep(i,n+1) {
        if (a[i]>k) break;
        int j = upper_bound(all(b), k-a[i])-b.begin()-1;
        chmax(ans, i+j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6428
#include<queue>
#include<cstdio>

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

using namespace std;

struct item{
	double v,x; // ¿l, i¨Ìå«³
	bool operator<(const item &a)const{ return v<a.v; }
	bool operator>(const item &a)const{ return a<*this; }
};

int main(){
	int n;
	double cap; scanf("%d%lf",&n,&cap);

	double ans=0;
	int n_po=0,n_ne=0;
	priority_queue<item> po;
	priority_queue< item,vector<item>,greater<item> > ne;
	rep(i,n){
		int cost,val; scanf("%d%d",&cost,&val);

		// ÌRXgÅ³Ì¿lÌi¨ÍK¸g¤
		if(cost<=0 && val>=0){
			cap-=cost;
			ans+=val;
		}
		// ³ÌRXgÅÌ¿lÌi¨ÍgíÈ¢
		else if(cost>=0 && val<=0);
		// »êÈOÍg¤©Ç¤©í©çÈ¢ ( RXgð 1 É³K»µÄÖ )
		else if(cost>=0 && val>=0){
			po.push((item){(double)val/cost,cost});
		}
		else{
			ne.push((item){(double)val/cost,cost});
		}
	}

	// ibvUbNª¢ÁÏ¢ÉÈéÜÅ greedy Élßé
	while(cap>0 && !po.empty()){
		item a=po.top(); po.pop();
		if(cap>a.x){
			ans+=a.v*a.x;
			cap-=a.x;
		}
		else{
			ans+=a.v*cap;
			a.x-=cap;
			cap=0;
			po.push(a);
		}
	}

	// ne Ìi¨ðüê½Ù¤ªæ¢êÍ»êðüêÄAó¢½ª¾¯ po Ìi¨àüêé
	while(!po.empty() && !ne.empty() && po.top().v>ne.top().v){
		item a=po.top(); po.pop();
		item b=ne.top(); ne.pop();
		if(a.x>-b.x){
			ans+=(a.v-b.v)*(-b.x);
			a.x-=-b.x;
			po.push(a);
		}
		else{
			ans+=(a.v-b.v)*a.x;
			b.x+=a.x;
			ne.push(b);
		}
	}

	printf("%.9f\n",ans);

	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

player = {}
player['a'] = input()
player['b'] = input()
player['c'] = input()

turn = 'a'
card = player[turn]

while card:
    head = card[0]
    player[turn] = player[turn][1:]
    turn = head
    card = player[turn]

print(turn.upper())


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
using namespace std;
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
 for(int i=0;i<=x;i++){
  if(2*i+4*(x-i)==y){
   puts("Yes");
   return 0;
  }
 }
 puts("No");
return 0;}


Measured memory_bytes: 3764
import java.util.Scanner;

/**
 * C
 */
public class Main {
    static int len;
    static long ans = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.nextLine();
        len = S.length();
        calc(S, "");

        System.out.println(ans);
        sc.close();
    }
    
    static void calc(String s, String rest) {
        long n1 = Long.parseLong(s);
        long n2 = 0;
        if (rest.length() != 0) {
            n2 = Long.parseLong(rest);
        }
        
        ans += n1 + n2;
        ans += (Math.pow(2, s.length() - 1) - 1) * n2;

        for (int i = 1; i < s.length(); i++) {
            calc(s.substring(0, i), s.substring(i, s.length()));
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <unordered_map> 
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> vec(n);
    unordered_map<string,int> mp;
    long long count=0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        if(mp[s]==0){
            mp[s]=1;
            //cout<<"ご新規"<<endl;
        }else{
            count += mp[s];
            mp[s]++;
        }
    }
    cout<<count<<endl;
    
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n,1);
  vector<int> ok(n,0);
  ok[0] = 1;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cnt[x]--;
    cnt[y]++;
    if (ok[x]) ok[y] = 1;
    if (cnt[x] <= 0) ok[x] = 0;
  }
  cout << accumulate(ok.begin(), ok.end(), 0) << endl; 
  return 0;
} 

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (n, totalTime) = readLine()!!.split(' ').map(String::toInt)
    val abArray = Array(n + 1) { Pair(0, 0) }
    (1..n).forEach {
        val (x, y) = readLine()!!.split(' ').map(String::toInt)
        abArray[it] = Pair(x, y)
    }

    val dp = Array(n + 1) { LongArray(totalTime + 1) { 0L } }
    val prev = Array(n + 1) { IntArray(totalTime + 1) { 0 } }
    for (i in 1..n) {
        val (time, value) = abArray[i]
        for (cur in 0 until totalTime) {
            if (cur >= time) {
                if (dp[i][cur] < dp[i - 1][cur - time] + value) {
                    dp[i][cur] = dp[i - 1][cur - time] + value
                    prev[i][cur] = cur - time
                }
            }
            if (dp[i][cur] < dp[i - 1][cur]) {
                dp[i][cur] = dp[i - 1][cur]
                prev[i][cur] = cur
            }
        }
    }

    var curW = totalTime - 1
    for (i in n downTo 1) {
        val t1 = prev[i][curW]
        val t2 = curW - abArray[i].first
        if (t1 == t2) {
            abArray[i] = Pair(0, 0)
        }
        curW = prev[i][curW]
    }
    val max = abArray.maxBy { it.second }?.second ?: 0

    println(dp[n][totalTime - 1] + max)
}

Measured memory_bytes: 178764
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,ti,ai;
  long t,a,k;
  cin >> n >> t >> a;
  for (i=0;i<n-1;i++){
    cin >> ti >> ai;
    k=(t+ti-1)/ti;
    if (a>ai*k) k=(a+ai-1)/ai;
    t=ti*k;
    a=ai*k;
  }
  cout << t+a << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
l = input().split()
for i in range(N):
    l[i] = int(l[i])

now = 0
ans = 0
m_ans = 0
while now < N-1:
    if l[now] >= l[now + 1]:
        ans += 1
    else:
        ans = 0
    if m_ans < ans:
        m_ans = ans

    now += 1
print(m_ans)


Measured memory_bytes: 11132
import math

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

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy = 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy))
print(ret)

Measured memory_bytes: 39408
package main

import (
	"fmt"
	"strings"
)

var (
	n int
	m []map[string]int
)

func dfs(cnt int, last3 string) int {
	if v, ok := m[cnt][last3]; ok {
		return v
	}

	if cnt == n {
		return 1
	}

	ans := 0
	for _, r := range "ACGT" {
		if isNotAGC(last3 + string(r)) {
			ans = (ans + dfs(cnt+1, last3[1:]+string(r))) % 1000000007
		}
	}

	m[cnt][last3] = ans
	return ans
}

func isNotAGC(last4 string) bool {
	s := make([]rune, 4)
	for i := range last4 {
		copy(s, []rune(last4))
		if i < 3 {
			s[i], s[i+1] = s[i+1], s[i]
		}

		if strings.Contains(string(s), "AGC") {
			return false
		}
	}
	return true
}

func main() {
	fmt.Scan(&n)

	m = make([]map[string]int, n+1)
	for i := range m {
		m[i] = make(map[string]int)
	}
	fmt.Println(dfs(0, "TTT"))
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	f(i,0,tt)
		test();
	return 0;
}

void test(){
	ll n,x;
	cin >> n >> x;
	vector<ll> d(n+1,0),l(n);
	f(i,0,n) cin >> l[i];
	f(i,1,n+1){
		d[i] = d[i-1]+l[i-1];
		if(d[i]>x){
			cout << i << "\n";
			return;
		}
	}
	cout << n+1 << "\n";
}

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

bool is_int(char& c) {
	int tmp = int(c - '0');
	if (0 <= tmp && tmp <= 9) return true;
	else return false;
}

int main() {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;

	if (S.size() != A + B + 1 || S[A] != '-') {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < S.size(); i++) {
		if (i == A) continue;
		if (!is_int(S[i])) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
t = input()
for i in range(n):
    for j in range(n-i):
        if s[i+j] != t[j]:
            break
    else:
        print(n+i)
        break
else:
    print(n*2)

Measured memory_bytes: 64492
using System;

using System.Collections.Generic;

namespace ABC172
{
    class Program
    {
        static void Main()
        {
            string S = Console.ReadLine().Trim();
            string T = Console.ReadLine().Trim();
            int count = S.Length;
            int sum = 0;
            for (int i = 0; i < count; i++) {
                if (S[i] != T[i]) sum++;
            }

            Console.WriteLine(sum);

        }


    }

}


Measured memory_bytes: 27440
#include <iostream>
#include <algorithm>
#define inf 999999

using namespace std;

int main(int argc, char **argv)
{
	int f[21][21], n, m, a, b, c, d;
	
	while(cin >> n >> m){
		fill(&f[1][1], &f[n+1][n+1], inf);
		
		for(int i = 1; i <= n; i++){
			f[i][i] = 0;
		}
		while(m--){
			scanf("%d,%d,%d,%d", &a, &b, &c, &d);
			f[a][b] = c;
			f[b][a] = d;
		}
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		
		for(int k = 1; k <= n; k++){
			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){
					f[i][j] = (f[i][j] < f[i][k]+f[k][j])? f[i][j] : f[i][k]+f[k][j];
				}
			}
		}
		cout << (c-d-f[a][b]-f[b][a]) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
Module Module1

    Sub Main()
        Dim ketasu As Integer
        Dim jokensu As Integer

        Dim tempstr(1) As String
        tempstr = Console.ReadLine().Split(" "c)

        ketasu = CInt(tempstr(0))
        jokensu = CInt(tempstr(1))

        Dim joken(jokensu - 1, 1) As Integer

        For i As Integer = 0 To jokensu - 1
            Dim tempjoken(1) As String
            tempjoken = Console.ReadLine().Split(" "c)
            joken(i, 0) = CInt(tempjoken(0))
            joken(i, 1) = CInt(tempjoken(1))
        Next

        Dim sonzaiflg As Boolean = True
        Dim ansval(ketasu - 1) As Integer
        For a As Integer = 0 To ketasu - 1
            ansval(a) = -1
        Next



        For t As Integer = 0 To jokensu - 1
            If ketasu <> 1 AndAlso (joken(t, 0) = 1 AndAlso joken(t, 1) = 0) Then
                sonzaiflg = False
                Exit For
            End If
            If ansval(joken(t, 0) - 1) <> -1 AndAlso ansval(joken(t, 0) - 1) <> joken(t, 1) Then
                sonzaiflg = False
            End If

            ansval(joken(t, 0) - 1) = joken(t, 1)
        Next
        If Not sonzaiflg Then
            Console.WriteLine("-1")
            Console.ReadKey()
            Exit Sub
        End If


        Dim printans As String = ""
        For k As Integer = 0 To ansval.Length - 1
            If k = 0 AndAlso ansval.Length = 1 AndAlso ansval(0) = -1I Then
                printans = "0"
                Exit For
            ElseIf k = 0 AndAlso ansval.Length <> 1 AndAlso ansval(0) = -1I Then
                printans = "1"
                Continue For
            End If

            If ansval(k) = -1I Then
                printans = printans & "0"
            Else
                printans = printans & ansval(k).ToString
            End If

        Next


        Console.WriteLine(printans)








    End Sub




End Module

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

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

  if (S == "SUN") {
    cout << "7" << endl;
  }
  if (S == "MON") {
    cout << "6" << endl;
  }
  if (S == "TUE") {
    cout << "5" << endl;
  }
  if (S == "WED") {
    cout << "4" << endl;
  }
  if (S == "THU") {
    cout << "3" << endl;
  }
  if (S == "FRI") {
    cout << "2" << endl;
  }
  if (S == "SAT") {
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[1000];
int main(){
	cin >> s;
	REP(i,strlen(s) - 8)
		cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
            }

            int[] c = new int[m];
            int[] d = new int[m];
            for (int i = 0; i < m; i++) {
                c[i] = in.nextInt();
                d[i] = in.nextInt();
            }

            for (int i = 0; i < n; i++) {
                int idx = -1;
                int min = Integer.MAX_VALUE;
                for (int j = 0; j < m; j++) {
                    int dist = d(a[i], b[i], c[j], d[j]);
                    if (min > dist) {
                        min = dist;
                        idx = j;
                    }
                }

                out.println(idx + 1);
            }
        }

        public int d(int x1, int y1, int x2, int y2) {
            return Math.abs(x1 - x2) + Math.abs(y1 - y2);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A[3][3];
    REP(i,3) REP(j,3) cin>>A[i][j];
    bool B[3][3]={};
    int N;cin>>N;
    REP(q,N){
        int b;cin>>b;
        REP(i,3) REP(j,3){
            if(A[i][j]==b) B[i][j]=true;
        }
    }
    bool ans=false;
    REP(i,3){
        bool ok=true;
        REP(j,3) if(!B[i][j]){
            ok=false;
        }
        ans|=ok;
    }
    REP(j,3){
        bool ok=true;
        REP(i,3) if(!B[i][j]){
            ok=false;
        }
        ans|=ok;
    }
    ans|=(B[0][0]&&B[1][1]&&B[2][2]);
    ans|=(B[2][0]&&B[1][1]&&B[0][2]);
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
const long long int MOD=1e9+7;

int main(){
  string s;
  cin >>s;
  bool ans=true;
  for(int i=0;i<s.length();i++){
    if(i%2==0){
      if(s[i]=='L'){
        ans=false;
        break;
      }
    }
    else{
      if(s[i]=='R'){
        ans=false;
        break;
      }
    }
  }
  cout << (ans?"Yes": "No") << endl;
}


Measured memory_bytes: 256