akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 100000 + 5;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

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

int n, m;
vector<int> mem[maxn];
int M = 0;

void solve()
{
	int sum1 = 0, sum2 = 0;
	rep(i,M+1)
	{
		int cnt = 0;
		if(mem[i].size() <= 0) continue;
		for(int j = 0; j < mem[i].size(); j++)
		{
			if(mem[i][j] == -1) cnt++;
			else if(mem[i][j] == 1)
			{
				sum1++;
				sum2 += cnt;
				break;
			}
		}
	}
	cout << sum1 << " " << sum2 << endl;
}

int main()
{
	cin >> n >> m;
	int p; 
	string S;
	rep(i,m)
	{
		cin >> p >> S;
		if(p > M) M = p;
		if(S == "AC") mem[p].pb(1);
		else mem[p].pb(-1);
	}

	// rep(i,10)
	// {
	// 	if(mem[i].size() > 0)
	// 	{
	// 		rep(j,mem[i].size()) printf("%d ", mem[i][j]);
	// 		cout << endl;
	// 	}
	// }
	solve();
}

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

typedef long long ll;


int main(){
	int n,w;
	scanf("%d", &n);
	scanf("%d", &w);
	vector<ll> dp(w + 1, 0);
	for(int i = 1; i <= n; i++){
		ll value;
		int weight;
		scanf("%d", &weight);
		scanf("%lld", &value);
		for(int j = w - weight; j >= 0; j--){
			dp[j + weight] = max(dp[j + weight], dp[j] + value);
		}
	}
	
	printf("%lld\n", dp[w]);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N_MAX = 100005;
vector<int> c(N_MAX, 0);

vector<vector<int>> E(N_MAX);
vector<P> g(N_MAX);

int c_max;

void bfs() {
  queue<P> que;
  int v0 = 1;
  int d0 = E[v0].size();
  c_max = d0;
  rep(i, d0) {
    int e0i = E[v0][i];
    c[e0i] = i + 1;
    int vi = g[e0i].first;
    if(v0 == vi) {
      vi = g[e0i].second;
    }
    que.push(make_pair(vi, e0i));
  }
  while(que.size()) {
    P p = que.front();
    que.pop();
    int v = p.first;
    int e = p.second;
    int d = E[v].size();
    c_max = max(c_max, d);
    int nc = 0;
    rep(i, d) {
      int evi = E[v][i];
      if(c[evi] > 0)
        continue;
      if(++nc == c[e])
        ++nc;
      c[evi] = nc;
      int vi = g[evi].first;
      if(v == vi) {
        vi = g[evi].second;
      }
      que.push(make_pair(vi, evi));
    }
  }
}

int main(void) {
  int n;
  cin >> n;
  rep(i, n) {
    if(!i)
      continue;
    int a, b;
    cin >> a >> b;
    E[a].push_back(i);
    E[b].push_back(i);
    g[i] = make_pair(a, b);
  }
  bfs();
  cout << c_max << endl;
  rep(i, n) {
    if(!i)
      continue;
    cout << c[i] << endl;
  }
  return 0;
}

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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    ll ans = 1e18;
    int b = A[N / 2];
    rep(i, 10) {
        ll s = 0;
        rep(j, N) {
            s += abs(b - 5 + i - A[j]);
        }
        if (s < ans) ans = s;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  vector<int> psort(N);
  rep(i,N)  cin >> p[i];
  copy(all(p),psort.begin());
  sort(all(psort));

  int diff = 0;
  rep(i,N){
    if(p[i] != psort[i]) diff++;
  }

  if(diff <= 2){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
t = input()
p = input()

anslist = []
for i in range(len(t) - len(p) + 1):
    if t[i] == p[0]:
        k = 0
        for j in range(i, i + len(p)):
            if t[j] != p[k]:
                break
            k += 1
        else:
            anslist.append(i)

for ans in anslist:
    print(ans)



Measured memory_bytes: 5572
#include <iostream>

int main(){
    int N;

    std::cin >> N;

    short D[2][N];
    for ( int i = 0; i < N; i++ ) {
        std::cin >> D[0][i];
        std::cin >> D[1][i];
    } 

    int count;
    for ( int i = 0; i < N; i++ ) {
        if (count == 3) break;
        if (D[0][i] == D[1][i]) count++;
        else count = 0;
    } 

    if (count == 3) std::cout << "Yes";
    else std::cout << "No";
  
}

Measured memory_bytes: 3632
n, m, q = map(int, input().split())
kumi = []
for i in range(q):
    kumii = list(map(int, input().split()))
    kumi.append(kumii)

ans = 0
a = [0 for i in range(n)]
def dfs(p):
    global ans
    if p == 0:
        for i in range(1, m+1):
            a[p] = i
            dfs(p+1)
    else:
        for i in range(a[p-1], m+1):
            a[p] = i
            if p != n-1:
                dfs(p+1)
            else:
                temp = 0
                for j in range(q):
                    ai, bi, ci, di = kumi[j]
                    ai, bi = ai-1, bi-1
                    if a[bi] - a[ai] == ci:
                        temp += di
                ans = max(ans, temp)

dfs(0)
print(ans)

Measured memory_bytes: 9228
using System;
using System.Linq;
using System.Threading.Tasks;

static class Program
{
static void Main()
{
    int nGem = int.Parse(Console.ReadLine());
    var values = Console.ReadLine().Split(' ').Select(c => long.Parse(c));
  //int nGem = 5;
  //var values = new long[] { -1000000000,1000000000,-1000000000,1000000000,-1000000000,0,1000000000,-1000000000,1000000000,-1000000000,1000000000};
  bool isEven = (values.Select(v => v < 0 ? 1 : 0).Sum() % 2 == 0);
  isEven |= values.Any(v => v == 0);
  var absValue = values.Select(v => Math.Abs(v));
  long result =   absValue.Sum();
  if(isEven == false)
  {
    long adjust = absValue.Min() * 2;
    result -= adjust;
  }
  Console.WriteLine(result);
}
}

Measured memory_bytes: 28764
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    //int t=testcases;
    while(testcases--){
        int n;
        cin>>n;
        ll a[n],p[n];
        fori(0,n){
            cin>>a[i];
        }
        p[n-1]=0LL;
        ford(n-2,0){
            p[i]=(p[i+1]+a[i+1])%mod;
        }
        ll ans=0;
        fori(0,n){
            ans+=(p[i]*a[i])%mod;
        }
        cout<<ans%mod;
    }               

    return 0;
}

Measured memory_bytes: 6780
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, j) = Scanf.sscanf (read_line ())"%d %d" @@ fun n j -> (n, j)
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()
let v = Array.make n 0

let p = ref 0

let rec tp acc i =
  if v.(i) = 1 then (p := i; acc)
  else (v.(i) <- 1; tp (i :: acc) (a.(i) - 1))
let tp = List.rev @@ tp [] 0

let rec loop acc i =
  if i = 0 then print_int (List.hd acc + 1)
  else if !p = (List.hd acc) then let i = i mod (List.length acc) in print_int ((List.nth acc i) + 1)
  else loop (List.tl acc) (i - 1)

let () = loop tp j

Measured memory_bytes: 33076
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
using namespace::std;
int main(){
int n;
int d;
  cin>>n>>d;
  cout<<n/(2*d+1)+!((n%(2*d+1))==0);

}


Measured memory_bytes: 256
S = int(input())
if S == 1 or S == 2:
    print(0)

elif S == 3:
    print(1)

else:
    mod = 10 ** 9 + 7
    dp = [0 for _ in range(S)]
    dp[0] = dp[1] = 0
    dp[2] = dp[3] = 1

    for i in range(3, S):
        dp[i] = (dp[i - 3] + dp[i - 1]) % mod

    print(dp[-1])

Measured memory_bytes: 9144
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int a,b;
int main()
{
	cin>>s>>a;
	while (s[b])
	{
		if (b%a==0) cout<<s[b];
		b++;
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string str;
    cin>>str;
    stack<char> st;
    fr(i,0,SZ(str))
    {
        if(st.empty())
        {
            st.push(str[i]);
        }
        else
        {
            if(str[i]=='T')
            {
                if(st.top()=='S')
                {
                    st.pop();
                }
                else
                {
                    st.push(str[i]);
                }
            }
            else
            {
                st.push(str[i]);
            }
        }
    }
    cout<<SZ(st)<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

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

using namespace std;

/////////////////////////////////////////////////////
char N[200];
ll K;
ll i,j,k;
ll calc(ll ii,ll kk,bool c,ll d){
    if(kk==0){
        return d;
    }
    ll ret = 0;
    for (ll i = ii; N[i];++i){
        if(c){
            if(N[i]=='0')
                continue;
            ret += calc(i + 1, kk - 1, false, d * (N[i] - '1'));
            ret += calc(i + 1, kk - 1, true, d);
            c = false;
        }else{
            ret += calc(i+1, kk - 1, false, d*9);
        }
    }
    return ret;
}
int main(){
    scanf("%s%lld", N,&K);
    printf("%lld", calc(0, K, true, 1));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int R = scan.nextInt();
			
			double a = 2.0*(double)R*3.1415926535897;
			
			System.out.println(a);
			
		}
		
		
	}
		

}


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

bool check(string s) {
    int length = s.length();
    for (int i = 0; i < (length / 2); ++i) {
        if (s[i] != s[(length - 1) - i]) {
            return false;
        }
    }
    return true;
}

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

    int length = S.length();

    if (!check(S)) {
        cout << "No" << endl;
        return 0;
    }
    if (!check(S.substr(0, (length - 1) / 2))) {
        cout << "No" << endl;
        return 0;
    }
    if (!check(S.substr(((length + 3) / 2) - 1, length))) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	char x, y;
	cin >> x >> y;
	if (x == y) {
		cout << "=" << endl;
	}
	else {
		cout << (x > y ? ">" : "<") << endl;

	}
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
        FasterScanner in = new FasterScanner(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, FasterScanner in, PrintWriter out) {
            String s = in.next();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < s.length() - 3 + 1; i++) {
                ans = Math.min(ans, Math.abs(753 - Integer.parseInt(s.substring(i, i + 3))));
            }
            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 23380
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

vector<int> t_parent;
vi t_ord;

void tree_getorder(const vector<vi> &g, int root) {
	int n = g.size();
	t_parent.assign(n, -1);
	t_ord.clear();

	vector<int> stk; stk.push_back(root);
	while(!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		for(int j = (int)g[i].size() - 1; j >= 0; j --) {
			int c = g[i][j];
			if(t_parent[c] == -1 && c != root)
				stk.push_back(c);
			else
				t_parent[i] = c;
		}
	}
}

int main() {
	int N; int K;
	while(~scanf("%d%d", &N, &K)) {
		vector<int> a(N);
		vector<vi> g(N);
		for(int i = 0; i < N; ++ i) {
			scanf("%d", &a[i]), -- a[i];
			if(i != 0) {
				g[i].push_back(a[i]);
				g[a[i]].push_back(i);
			}
		}
		int ans = a[0] != 0;
		tree_getorder(g, 0);
		vector<int> maxd(N, 0);
		for(int ix = (int)t_ord.size() - 1; ix > 0; -- ix) {
			int i = t_ord[ix], p = t_parent[i];
			if(maxd[i] == K - 1) {
				ans += a[i] != 0;
				maxd[i] = -1;
			}
			amax(maxd[p], maxd[i] + 1);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 8056
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  string s; cin >>s;
  print((s[2]==s[3] and s[4]==s[5])?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef long long ll;
#define loop(n)      for(int i=0;i<(n);i++)
#define lp(x,s,e)    for(int x=(s);x<(e);x++)
#define lpe(x,s,e)    for(int x=(s);x<=(e);x++)
#define MP make_pair
#define PB push_back
#define all(a)  a.begin(),a.end()
#define clr(x,val) memset((x),(val),sizeof(x))
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n],b[n];
    vector<int>sum;
    loop(n){
    cin>>a[i];
    b[i]=a[i];}
    sort(b,b+n);
    int se=0;
    for(int i=b[0];i<=b[n-1];i++){
    for(int j=0;j<n;j++){
    se+=pow((a[j]-i),2);}
    sum.push_back(se);
    se=0;
    }
    sort(sum.begin(),sum.end());
    cout<<sum[0];
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

ulli N;
bool f= true;

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

	cin >> N;
	for(int i = 1; i < 10; i++){
		ulli B = N / i;
		if(B > 0 && B < 10 && N == B*i){
			cout << "Yes\n";
			f = false;
			break;
		}
	}
	if(f){
		cout << "No\n";
	}

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF       numeric_limits<int>::max()
#define NINF      numeric_limits<int>::min()
#define MOD       1000000007

using namespace std;
using Int    = long long;
using Edge   = vector<vector<pair<int, int>>>; // src   -> dst, weight
using Vertex = vector<pair<int, bool>>;        // index -> cost, visited

bool graph_dfs(int         vertex_index,
               const Edge& edge,
               Vertex&     vertex) {

    bool ret = true;
    REP(i, edge[vertex_index].size()) {
        int dst    = edge[vertex_index][i].first;
        int weight = edge[vertex_index][i].second;
        int cost   = vertex[vertex_index].first + weight;

        if(!vertex[dst].second) {
            vertex[dst] = make_pair(cost, true);

            ret = graph_dfs(dst, edge, vertex);
            if(!ret) {
                break;
            }
        }
        else if(vertex[dst].first != cost) {
            return false;
        }
    }

    return ret;
}

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

    int N, M;
    std::cin >> N >> M;

    Edge   edge(N);
    Vertex vertex(N, make_pair(0, false));

    REP(i, M) {
        int l, r, d;
        std::cin >> l >> r >> d;
        edge[l - 1].emplace_back(r - 1,  d);
        edge[r - 1].emplace_back(l - 1, -d);
    }

    string ans = "Yes";
    REP(i, edge.size()) {
        if(edge[i].size() == 0 || vertex[i].second) {
            continue;
        }

        vertex[i].second = true;
        if(!graph_dfs(i, edge, vertex)) {
            ans = "No";
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 12416
H,W=map(int,input().split())
ans=[]
for i in range(H):
  s=input().strip()
  ans.append(s)

for i in range(W+2):
  if i==W+1:
    print("#")
  else:
    print("#",end="")
for i in range(H):
  print("#",end="")
  print(ans[i],end="")
  print("#")
for i in range(W+2):
  if i==W+1:
    print("#")
  else:
    print("#",end="")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var NT = ReadSplitInt();
            var N = NT[0];
            var T = NT[1];
            var t = ReadSplitInt();

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

            ans += T;
            Println(ans);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 28384
using System;
public class Hello{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        
        var Lucas = new long[87];
        Lucas[0] = 2;
        Lucas[1] = 1;
        
        for(var i = 2;i < 87;i++){
            Lucas[i] = Lucas[i - 1] + Lucas[i - 2];
        }
        
        Console.WriteLine(Lucas[N]);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0

signed main() {
	string s, p;
	cin >> s >> p;
	s = s + s;
	for (int i = 0; i < s.size(); i++) {
		string x = s.substr(i, p.size());
		if (x == p) {
			cout << "Yes" << endl;
			END;
		}
	}
	cout << "No" << endl;

	END;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

ll gcd(ll a,ll b)
{
    ll m = max(a, b);
    b = a + b - m, a = m;
    while(a%b!=0)
    {
        ll temp = b;
        b = a % b;
        a = temp;
    }
    return b;
}
int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle;
    angle = abs(h * 30+30*m/60 - m * 6);
    angle = angle > 180 ? (360 - angle) : angle;
    double ans;
    ans = sqrt(a * a + b * b - 2.0 * a*b*cos(3.14159265358979323846/180.0*angle));
    cout << fixed << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 4168
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        sys.exit()
    p = 7       # '7,77,777…'のmod kをいれる変数
    plus = 7    # '70,700,7000…'のmod kをいれる変数
    r = 1       # カウント
    while (p % k) != 0: # kで割り切れるかチェック
        plus = (plus * 10) % k   # pに足すもう1桁のmod kを計算。
        p += plus                # pにもう１桁を足す
        p = p % k                # pのmod kをとる
        r += 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll n, m;
	cin >> n >> m;
	vll a(m);
	rep(i, m) cin >> a[i];
	ll sa = 0;
	rep(i, m) sa += a[i];
	ll ans = -1;
	if(n >= sa) ans = n - sa;
	cout << ans << endl;
}


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

int main()
{
    int a;
    int ev = 0;
    int odd = 0;
    cin >> a;
    for (int i = 1; i <= a; i++)
    {
        if(i % 2 == 0)
        {
            ev++;
        }
        else
        {
            odd++;
        }
    }
    cout << ev * odd;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    n %= 500;
    if(n <= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int m;
    cin >> m;
    ll sum[2] = {};
    int d;
    ll c;
    rep(i, m) {
        cin >> d >> c;
        sum[0] += c;
        sum[1] += c * d;
    }
    cout << sum[0] - 1 + (sum[1] - 1) / 9 << endl;
    return 0;
}

Measured memory_bytes: 3592
void main() {
  problem();
}

void problem() {
  const X = scan!int;
  const N = scan!int;
  const P = scan!int(N);

  int solve() {
    int absolute = 101;
    int answer = 101;

    auto NP = iota(0, 102, 1).filter!(a => !P.canFind(a));

    foreach(p; NP) {
      const a = X > p ? X - p : p - X;
      if (a == absolute && answer > p) {
        answer = p;
        continue;
      }
      if (a < absolute) {
        answer = p;
        absolute = a;
        continue;
      }
    }

    return answer;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2724
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    GVI(a,N);
    int ans=1<<28;
    FORIN(x,-100,101){
        int c=0;
        FOR(i,N){
            c+=(a[i]-x)*(a[i]-x);
        }
        if(ans>c)ans=c;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
require 'prime'

n = gets.to_i

aa = Prime.prime_division(n)

ans = 0
aa.each do |a|
  j = a[1]
  (1..a[1]).each do |i|
    j -= i
    if j < 0
      break
    else
      ans += 1
    end
  end
end

p ans

Measured memory_bytes: 14516
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(S: str, T: str, A: int, B: int, U: str):
    if S == U:
        A -= 1
    if T == U:
        B -= 1
    print(A, B)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    solve(S, T, A, B, U)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, ans;
	cin >> a >> b;
	ans = (a - 1) * (b - 1);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end)
#include <utility> // std::swap


using namespace std;
using ll = long long;

bool exist[1000000001] = {};

int main(int argc, char const* argv[])
{
  
  unordered_map<int,int> count;
  int n,m,a,acc = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    acc = (acc + a) % m;
    if( exist[acc] )
      count[acc]++;
    else{
      count[acc] = 1;
      exist[acc] = true;
    }
  }
  ll sum = 0;
  for( auto a: count){
    if(a.first == 0)
      sum += ll(a.second) * ll(a.second + 1)/2ll;
    else
      sum += ll(a.second) * ll(a.second - 1)/2ll;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 976804
#include<bits/stdc++.h>
using namespace std;
int main(){

int n;
cin>>n;
char s[n];
int cnt=1;

for(int i=0;i<n;i++)
{

    cin>>s[i];


}

for(int i=0;i<n-1;i++)
{
    if(s[i]!=s[i+1])
    {
        cnt++;
    }
}

cout<<cnt<<endl;
exit(0);

}


Measured memory_bytes: 3708
#include <stdio.h>
 
int main(){
  int N, rin;
  int A[200001];
  double B[200001];
  scanf("%d %d", &N, &rin);
  
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
    B[i] = ((double)A[i]+1)/2;
  }
  
  double MAX=0;
  double m=0;
  for(int j=0; j<rin; j++){
    m+=B[j];
  }
  MAX=m;
  for(int i=1; i<(N-rin)+1; i++){
    
    m-=B[i-1];
    m+=B[i+rin-1];
    if(MAX<m) MAX=m;
  }
  
  printf("%f", MAX);
  return 0;
}

Measured memory_bytes: 2560
R,G,B,N = map(int, raw_input().split())
count = 0
while True:
	N2 = N
	while True:
		if(N2 % B == 0):
			count += 1
		N2 -= G
		if(N2 < 0):
			break
	N -= R
	if(N < 0):
		break
print(count)

Measured memory_bytes: 2568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
vector<ll>vec1,vec2,vec3;
ll n,k;
bool check(ll x){
	ll x1=vec1.size();
	ll x2=vec2.size();
	ll x3=vec3.size();
	ll pos=0;
     if(x==0){
		 pos+=(x1*x3);
		 pos+=(x2*x1+x3*x2);
		 pos+=(x2*(x2-1))/2;
		 return pos>=k;
	 }
	 else if(x>0){
		 pos+=(x1*x3);//负数的数量
		 pos+=(x2*x1+x3*x2);//0的数量
		 pos+=(x2*(x2-1))/2;//0的数量
		 for(int i=0;i<x1;i++){
			 ll tmp;
			 if(x%vec1[i]){
                 tmp=x/vec1[i];
			 }
			 else{
			     tmp=x/vec1[i];
			 }
             if(lower_bound(vec1.begin()+i+1,vec1.end(),tmp)==vec1.end()){
                 pos+=0;
			 }
			 else{
				 pos+=vec1.end()-lower_bound(vec1.begin()+i+1,vec1.end(),tmp);
			 }
		//	 pos+=x1-i-(lower_bound(vec1.begin()+i+1,vec1.end(),tmp)-(vec1.begin()+i));
		 }
		  for(int i=0;i<x3;i++){
			 ll tmp;
			 if(x%vec3[i]){
                 tmp=x/vec3[i];
			 }
			 else{
			     tmp=x/vec3[i];
			 }
			 if(upper_bound(vec3.begin()+i+1,vec3.end(),tmp)==vec3.end()){
                 pos+=vec3.end()-(vec3.begin()+i+1);
             }
             else{
                 pos+=upper_bound(vec3.begin()+i+1,vec3.end(),tmp)-1-vec3.begin()-i;
             }
			
		 }
		// cout<<"x:"<<x<<" "<<"pos:"<<pos<<endl;
		 return pos>=k;
	 }
	 else{
		 for(int i=x1-1;i>=0;i--){
			  ll tmp;
			 if(x%vec1[i]){
                 tmp=x/vec1[i]+1;
			 }
			 else{
			     tmp=x/vec1[i];
			 }
			if(lower_bound(vec3.begin(),vec3.end(),tmp)==vec3.end()){
                 pos+=0;
			 }
			 else{
				 pos+=vec3.end()-lower_bound(vec3.begin(),vec3.end(),tmp);
			 }
		 }
		// cout<<x<<" "<<pos<<endl;
		 return pos>=k;
	 }
}
int main(){
	
	cin>>n>>k;
	ll x;
	for(int i=1;i<=n;i++){
        scanf("%lld",&x);
		if(x<0){
          vec1.push_back(x);
		}
		else if(x==0){
          vec2.push_back(x);
		} 
		else{
			vec3.push_back(x);
		}
	}
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	sort(vec3.begin(),vec3.end());
	ll l=-1e18,r=1e18;
	ll mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))r=mid-1;
		else{
            l=mid+1;
		}
		
	}
    cout<<r+1<<endl;

	return 0;
}

Measured memory_bytes: 2548
a,b,c = map(int,input().split())
n = a
mod = []
i = 2
if a == 1:
    print("YES")
    exit()
while True:
    if  a%b not in mod:
        mod.append(a%b)
        a += n
    else:
        print("NO")
        break
    i += 1
    if c in mod:
        print("YES")
        break

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main(){
	ull n, a, b;
	cin>>n>>a>>b;
	
	if(n%(a+b)>a)
		cout<<n/(a+b)*a+a<<endl;
	else
		cout<<n/(a+b)*a+n%(a+b)<<endl;
		
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    long long int s=0;
    for(int i=1;i<=N;i++)
    {
        if(i%3==0 || i%5==0)
            s=s+0;
        else
            s=s+i;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
using namespace std;
typedef long long ll;
ll N,L,X[200010] = {0},S[200010] = {0};

int main(){
	cin >> L >> N;
	for(int i=1;i<=N;i++){
		cin >> X[i];
		S[i] = S[i-1] + X[i];
	}
	ll ans = 0;
	for(ll i=1;i<=N;i++){
		ll now = 0,m = (i+N+1)/2;
		if((i+N)%2==0){
			now = 2*(S[m]-S[i-1])- X[m] + (N-i)*L - 2*(S[N]-S[m]);
		}else{
			now = 2*(S[m-1]-S[i-1]) + (N-i)*L - 2*(S[N]-S[m-1]) + X[m];
		}		
		ans = max(ans,now);
	}
	for(ll i=N;i>=1;i--){
		ll now = 0,m = (i+1)/2;
		if(i%2==0){
			now = 2*S[m] - X[m] + i*L - 2*(S[i]-S[m]);
		}else{
			now = 2*S[m-1] + i*L - 2*(S[i]-S[m-1]) + X[m];
		}
		ans = max(ans,now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
a, b, c, d = [int(i) for i in input().rstrip().split()]
'''
print(a)
print(b)
print(c)
print(d)
'''
#重さ判定
if a + b == c + d:
    print('Balanced')
elif a + b > c + d:
    print('Left')
else:
    print('Right') 

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

int main() {
  string s,t;
  cin >> s >> t ;
  int a=s.size();
  int b=t.size();
  int x=0;
  for (int i=0; i<a-b+1 ; i++)
  {
    int y=0;
    for (int j=0; j<b ; j++)
    {
    if(t[j]==s[i+j])
     {
      y++;
     }
    }
    x=max(x,y);
    
  }
  cout << b-x <<endl;
}


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

const int maxn = 1e5;

int n, a[maxn], b[maxn];


int main() {
	scanf("%d", &n);
	long long asum = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
		asum += a[i];
	}
	long long bsum = 0;
	for (int i = 2; i < 2*n; i+=2) {
		b[i%n] = a[(i-1)%n]-a[(i-2)%n]+b[(i-2)%n];
		bsum += b[i%n];
//		printf("%d %d\n", i%n, b[i%n]);
	}
	b[0] = (asum-2*bsum)/2/n;
	printf("%d", b[0]*2);
	for (int i = 1; i < n; ++i) {
		b[i] += b[0];
		printf(" %d", b[i]*2);
	}
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> v(n), dp(n,1001001001);
  for(int&e:v)cin >> e;
  dp[0] = 0;
  for(int i = 0; i < n; ++i){
   	int n1 = min(n - 1,i + 1), n2 = min(n - 1,i + 2);
    int d1 = abs(v[i] - v[n1]), d2 = abs(v[i] - v[n2]);
    dp[n1] = min(dp[n1], dp[i] + d1);
   	dp[n2] = min(dp[n2], dp[i] + d2);
  }
  cout << dp[n - 1] << endl;
  return 0;
}	

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,x,sum=0;
    cin >> n >> x;
    vll v(n);
    rep(i,n)cin >> v[i];
    for(int i=1;i<n;i++){
        if(v[i]+v[i-1] > x){
            //cout << "000" << endl;
            if(v[i-1] == x){
                sum += v[i];
                v[i] = 0;
            }
            else if(v[i-1] <= x){
                sum += (v[i] + v[i-1] - x);
                v[i] = x-v[i-1];
            }
            else if(v[i-1] >= x){
                sum += (v[i] + v[i-1] - x);
                v[i-1] = x;
                v[i] = 0;
            }
        }
    }
    //rep(i,n)cout << v[i] << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Measured memory_bytes: 219860
#include<bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin>>N;
string S[200010];
for (int i=0; i<N; i++) cin>>S[i];
set<string> t;
for (int i=0; i<N; i++) t.insert(S[i]);
int a=t.size();
cout<<a<<endl;
}

Measured memory_bytes: 25508
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
string S;
int main(){
	cin >> N >> S;
	long long ans = 0;
	rep(i, N - 2) {
		if(S.substr(i, 3) == "ABC") {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3636
import numpy as np
n,m,x = map(int,input().split())
ca = np.array([list(map(int,input().split())) for i in range(n)])
# print(ca)
ans = 10**10
for i in range(2**(n+1)):
    abi = np.zeros(m+1)
    bin_str = format(i, '013b')
    # print(bin_str)
    for i in range(n):
        if bin_str[-i-1] == "1":
            abi += ca[i]
    if min(abi[1:]) >= x:
        ans = min(ans,abi[0])
        # print(bin_str,abi[0])
if ans == 10**10:
    print(-1)
else:
    print(int(ans))

Measured memory_bytes: 27156
A = input().split()
G = []
j = 0
G.append(int(A[0]))

for i in range(1, len(A)):
	if A[i] == "+":
		G[j-1] += G[j]
		G.pop()
		j -= 1
	elif A[i] == "-":
		G[j-1] -= G[j]
		G.pop()
		j -= 1
	elif A[i] == "*":
		G[j-1] *= G[j]
		G.pop()
		j -= 1
	else:
		j += 1
		G.append(int(A[i]))

print(G[0])
		

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P =pair<int,int>;
int main(){
  ll a,n;
  cin>>a>>n;
  ll s=0;
  for(ll i=0;i<n;i++){
    ll b;
    cin>>b;
    s+=b;
  }
  if(a>s)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3624
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);

    if(a==b)printf("Draw\n");
    else if(a==1)printf("Alice\n");
    else if(b==1)printf("Bob\n");
    else if(a>b)printf("Alice\n");
    else printf("Bob\n");

    return 0;

}

Measured memory_bytes: 128