akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc132/tasks/abc132_e

#include "algorithm"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
using PL = pair<ll, ll>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

// BFS
void solve() {
  ll N, M;
  cin >> N >> M;

  VVL edges(N, VL());
  const ll STEP = 3;

  rep(i, M) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    edges[u].push_back(v);
  }

  ll S, T;
  cin >> S >> T;
  S--, T--;

  ll INF = 1e18;

  VVL dist(N, VL(STEP, INF));
  dist[S][0] = 0;

  queue<PL> q;
  q.push({S, 0});

  while (!q.empty()) {
    PL cur = q.front();
    q.pop();

    ll cp = cur.first;
    ll parity = cur.second;

    ll n_parity = (parity + 1) % STEP;

    for (auto np : edges[cp]) {
      if (dist[np][n_parity] != INF) continue;
      dist[np][n_parity] = dist[cp][parity] + 1;
      q.push({np, n_parity});
    }
  }

  ll res = dist[T][0] == INF ? -1 : dist[T][0] / STEP;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

// コストがあるとした場合のダイクストラ
void solve2() {
  ll N, M;
  cin >> N >> M;

  V<V<PL>> edges(N, V<PL>());
  const ll STEP = 3;

  rep(i, M) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    ll cost = 1;
    edges[u].push_back({v, cost});
  }

  ll S, T;
  cin >> S >> T;
  S--, T--;

  ll INF = 1e18;

  VVL dist(N, VL(STEP, INF));
  dist[S][0] = 0;

  priority_queue<pair<ll, PL>, V<pair<ll, PL>>, greater<pair<ll, PL>>> q;
  q.push({0, make_pair(S, 0)});

  while (!q.empty()) {
    auto p = q.top();
    q.pop();

    PL v = p.second;
    ll cp = v.first;
    ll parity = v.second;

    ll c_cost = p.first;
    if (c_cost > dist[cp][parity]) continue;

    ll n_parity = (parity + 1) % STEP;

    for (auto n : edges[cp]) {
      ll np = n.first;
      ll cost = n.second;

      ll n_cost = c_cost + cost;
      if (chmin(dist[np][n_parity], n_cost)) {
        q.push({n_cost, PL(np, n_parity)});
      }
    }
  }

  ll res = dist[T][0] == INF ? -1 : dist[T][0] / STEP;
  cout << res << endl;
}

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 11264
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
    ll z=0,n,h,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t,u;
    cin >> s;
    char c='A';
    rep(i,s.size()){
      if (s[i] == 'B') {
        if (c != 'B') sum++;
        c = 'B';
      }
      else if (s[i] == 'W') {
        if (c != 'W') sum++;
        c = 'W';
      }
    }
    pri(sum - 1);
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int N,i;
  scanf("%d",&N);

  int a[N],min=1001,max=-1;

  for(i=0;i<N;i++){
    scanf("%d", &a[i]);
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }

  printf("%d", max-min);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#define rep(i, n) for(ll i = 0; i < n; i++)

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};


int main(){
    ll n, k;
    cin >> n >> k;
    vector<P> s;
    for (ll i = 1; i*i <= n; i++){
        s.push_back(P(i,0));
        s.push_back(P(n/i,0));
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    rep(i,s.size()-1) {
        ll l = n/s[i+1].first;
        ll r = n/s[i].first;
        s[i].second = r-l;
    }
    s.back().second = 1;
    ll m = s.size();



    map<ll,ll> mp;
    rep(i,m) mp[s[i].first] = i;
    vector<vector<mint> > dp(k+1, vector<mint>(m));
    dp[0][mp[n]] = 1;
    rep(i,k) {
        for(ll j = m - 2; j >= 0; j--) dp[i][j] += dp[i][j+1];
        rep(j,m) {
            ll nj = mp[n/s[j].first];
            dp[i+1][j] += dp[i][nj]*s[j].second;
        }
    }
    mint ans = 0;
    rep(j,m) ans += dp[k][j];
    cout << ans.x << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

double dp[3252][3252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	double p;
	cin>>n;
	dp[0][0]=1;
	REP(i, n){
		cin>>p;
		REP(j, i+1){
			dp[i+1][j]+=dp[i][j]*(1-p);
			dp[i+1][j+1]+=dp[i][j]*p;
		}
	}
	double ans=0;
	FOR(i, n/2+1, n+1){
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(12)<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 76544
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

vector<int> to[10005];

int main() {
	int h,w;
	cin >> h >> w;
	vector<vector<char>> zu(h + 2, vector<char>(w + 2));
	int count = 0;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> zu[i][j];
			if (zu[i][j] == '#') {
				count++;
			}
		}
	}

	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (zu[i][j] == '#') continue;

			if (zu[i + 1][j] == '.')to[i * w + j].push_back((i + 1) * w + j);
			if (zu[i - 1][j] == '.')to[i * w + j].push_back((i - 1) * w + j);
			if (zu[i][j + 1] == '.')to[i * w + j].push_back(i * w + j + 1);
			if (zu[i][j - 1] == '.')to[i * w + j].push_back(i * w + j - 1);
		}
	}

	int start = 1 * w + 1;
	int goal = h * w + w;
	vector<int> dist(goal + 1, -1);
	queue<int> que;
	dist[start] = 1;
	que.push(start);

	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int nv : to[v]) {
			if (dist[nv] != -1)continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}

	if (dist[goal] == -1) {
		cout << -1 << endl;
		return 0;
	}

	int ans = 0;
	ans = h * w - dist[goal] - count;

	cout << ans << endl;

	return 0;
}


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

long long int dp[3001][3001][2];

long long int solve(long long int *a,long long int i,long long int j,long long int turn)
{
    if(i > j)
        return 0;

    if(dp[i][j][turn] != -1)
        return dp[i][j][turn];
    
    if(turn == 1)
    {
        return dp[i][j][turn] = max((a[i] + solve(a,i+1,j,0)),(a[j] + solve(a,i,j-1,0)));
    }
    else
    {
        return dp[i][j][turn] = min(solve(a,i+1,j,1),solve(a,i,j-1,1));
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long int n;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    long long int *a = new long long int[n]{0};
    long long int sum = 0;
    for(long long int i=0;i<n;++i)
    {
        cin>>a[i];
        sum += a[i];
    }   
    long long int turn = 1;
    long long int X = solve(a,0,n-1,1);
    long long int Y = sum - X;
    cout<<(X - Y)<<endl;
    return 0;
}

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

const long long int MOD=1e9+7;

int main(){
  int n;
  cin>>n;
  vector<char> c(n);
  for(int i=0;i<n;i++) cin>>c[i];
  vector<vector<vector<long long int>>> dp(n+1,vector<vector<long long int>>(n+1,vector<long long int>(n+1,0)));
  dp[0][0][0]=true;
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=n;k++){
	if(c[i]=='D'){
	  dp[i+1][j][k]=(j+1<=n ? dp[i][j][k] : 0)*j+(j+1<=n && k+1<=n ? dp[i][j+1][k+1]*(j+1)*(k+1):0);
	}
	else if(c[i]=='U'){
	  dp[i+1][j][k]=dp[i][j][k]*k+(j-1>=0 && k-1>=0 ? dp[i][j-1][k-1] : 0);
	}
	else{
	  dp[i+1][j][k]=dp[i][j][k];
	}
	dp[i+1][j][k]%=MOD;
	
      }
    }
  }

  cout<<dp[n][0][0]<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define fast ios::sync_with_stdio(false), cout.tie(), cin.tie();
#define sz(s) int(s.size())

int main(){
	string s, t;
	cin >> s >> t;
	cout << t + s;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = 0;
		int max = 0;
		int min = 1000000001;

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

			a = sc.nextInt();

			if (max < a) {
				max = a;
			}

			if (min > a) {
				min = a;
			}
		}

		System.out.println(max - min);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vl vector <long>
#define vll vector < ll >
#define pll pair < ll , ll >
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MODCONST 1000000007
//#define v[i] abs(v[i])

using namespace std;

void solve()
{
    ll n,w,k;
    cin>>n>>w;
    vll weights,values;
    rep(i,0,n){
        cin>>k; weights.pb(k);
        cin>>k; values.pb(k);
    }
    ll dp[n+1][w+1];
    // init dp
    rep(i,0,n+1){
        dp[i][0] = 0;
        //cout<<dp[i][0];
    }
    rep(i,0,w+1){
        dp[0][i] = 0;
        //cout<<dp[0][i];
    }
    rep(i,1,n+1){
        rep(j,1,w+1){
            if(weights[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],values[i-1] + dp[i-1][j-weights[i-1]]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

int main()
{
    fastio ;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll tc=1;
    //cin>>tc; //for number of testcases
    //ll ts = tc;
    while(tc--){
        //cout<<"Case #"<<ts-tc<<": ";
        solve();
    }
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 >= 22) {
    cout << "bust" << endl;
    return 0;
  }
  cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
        int a, b, found = 0;
        cin >> a >> b;
        for (int i = 1; i <= 1010 && found == 0; i++)
        {   
                if ((i * 8) / 100 == a  && (i * 10) / 100 == b)
                {   
                        found = 1;
                        cout << i << endl;
                }   
        }   
        if (found == 0)
                cout << "-1" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int dat[3][3];
    for (int i = 0; i < 3; i++){
        for (int j = 0; j< 3; j++){
            cin >> dat[i][j];
        }
    }

    bool isValid = true;

    for (int i = 0; i < 2; i++){
        int diff = dat[i + 1][0] - dat[i][0];
        for (int j = 1; j < 3; j++){
            if (dat[i + 1][j] - dat[i][j] != diff ){
                isValid = false;
            }
        }
    }

    for (int j = 0; j < 2; j++){
        int diff = dat[0][j + 1] - dat[0][j];
        for (int i = 1; i < 3; i++){
            if (dat[i][j + 1] - dat[i][j] != diff ){
                isValid = false;
            }
        }
    }

    if (isValid){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

   return 0;
}


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

int main() {
  ll w,h; cin >> w >> h;
  ll x,y; cin >> x >> y;

  cout << w*h/2.0 << endl;

  bool flag = (x*2 == w && y*2 == h);

  cout << flag << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        int hoge2 = sc.nextInt();

        if(hoge > 2 * hoge2){
            System.out.println(hoge-2*hoge2);
        }else{
            System.out.println(0);
        }   
    }   
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int N;
    map<string, int> M;
    int ans = 0;
    cin >> N;
    int ma = 0;
    for(int i = 0 ; i < N; i++){
        string s;
        cin >> s;
        M[s]++;
        ma=max(ma,M[s]);
    }
    vector<string> S;
    for(auto it = M.begin(); it != M.end(); it++){
        if(it->second == ma){
            S.push_back(it->first);
        }
    }
    sort(S.begin(),S.end());
    for(int i= 0 ; i < S.size(); i++){
        cout << S[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 27348
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 20000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){IOS;
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

def GCD(A,B):
    if A%B==0:
        return(B)
    return(GCD(B,A%B))

GCD_L = [0]*(N+1)
GCD_R = [0]*(N+1)

GCD_L[0] = A[0]*A[-1]
GCD_R[N] = A[0]*A[-1]

for i in range(N):
    GCD_L[i+1] = GCD(A[i],GCD_L[i])
    GCD_R[N-1-i] = GCD(A[N-1-i],GCD_R[N-i])

GCD_BB = [0] * N
for i in range(N):
    GCD_BB[i] = GCD(GCD_L[i],GCD_R[i+1])

print(max(GCD_BB))


Measured memory_bytes: 63984
import java.util.*;
import java.io.*;

public class Main {

  private static void solve() {
    int n = nextInt();
    long x = nextLong();

    long[] l = new long[n + 1];
    long[] p = new long[n + 1];

    l[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= n; i++) {
      l[i] = 2 * l[i - 1] + 3;
      p[i] = 2 * p[i - 1] + 1;
    }

    System.out.println(get(n, x, l, p));
  }

  private static long get(int n, long x, long[] l, long[] p) {
    if (n == 0) {
      return 1;
    }

    if (x == 1) {
      return 0;
    }

    x--;

    if (x <= l[n - 1]) {
      return get(n - 1, x, l, p);
    }

    x -= l[n - 1];

    if (x == 1) {
      return p[n - 1] + 1;
    }

    x--;

    if (x == l[n - 1] + 1) {
      x--;
    }
    
    return p[n - 1] + 1 + get(n - 1, x, l, p);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 22484
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#define MP make_pair
#define PB push_back
#define px first
#define py second
#define fi first
#define se second

#ifdef DEBUG
#include "Debug.h"
#endif

using namespace std;

const int INF = 2147483647;

int max(int a, int b, int c){
    return max(a, max(b, c));
}

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a+b, a-b, a*b);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

def pow_k(x, n):
    
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (x*K) % (10**9+7)
        x = (x*x) % (10**9+7)
        n //= 2

    return (K * x) % (10**9+7)
  
A = pow_k(10,n)
B = pow_k(9,n)
C = pow_k(8,n)

print((A+C-2*B)%(10**9+7))

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define N 5
int n,m,ans[N];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) ans[i]=-1;
	for(int i=1,x,y;i<=m;++i)
	{
		scanf("%d %d",&x,&y);
		if(~ans[x] && ans[x]!=y) {puts("-1");return 0;}
		ans[x]=y; 
	}
	if(!ans[1] && n>1) {puts("-1");return 0;}
	if(~ans[1]) printf("%d",ans[1]);
	else if(n==1) putchar('0');else putchar('1');
	for(int i=2;i<=n;++i)
		if(ans[i]==-1) putchar('0');
		else printf("%d",ans[i]);return 0; 
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();
			int n = int.Parse(input.Split(' ')[0]);
			int k = int.Parse(input.Split(' ')[1]);

			int max = n - k + 1;
			if (k > 1)
			{
				Console.WriteLine(max - 1);
			}
			else
			{
				Console.WriteLine(0);
			}
		}
	}
}


Measured memory_bytes: 13140
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ac = collections.Counter(a)
    t = 0
    for k, v in ac.items():
        t += v * (v - 1) // 2
    for v in a:
        print(t - (ac[v] * (ac[v] - 1) // 2) + ((ac[v] - 1) * (ac[v] - 2) // 2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71024
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, a, b;
char tmp[maxn];
string s;

int read() {
  if (scanf("%d%d%d", &n, &a, &b) < 3) {
    return false;
  }
  scanf("%s", tmp);
  s = tmp;
  return true;
}

void solve() {
  int cntall = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (cntall < a + b) {
        printf("Yes\n");
        cntall++;
      } else {
        printf("No\n");
      }
    } else if (s[i] == 'b') {
      if (cntall < a + b && cnt < b) {
        printf("Yes\n");
        cntall++;
        cnt++;
      } else {
        printf("No\n");
      }
    } else {
      printf("No\n");
    }
  }
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    int K;
    cin >> N >> K;
    ll a[K], b[K];
    for (int i = 0; i < K; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < K; i++) {
        ll x = a[i];
        ll y = b[i];
        if (x > (N + 1) / 2) {
            x = N - a[i] + 1;
        }
        if (y > (N + 1) / 2) {
            y = N - b[i] + 1;
        }
        if (y > x) {
            y = x;
        }
        //cout << x << " " << y << "\n";
        if (y % 3 == 1) {
            cout << "1";
        } else if (y % 3 == 2) {
            cout << "2";
        } else {
            cout << "3";
        }
        cout << "\n";

    }
    return 0;
}


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

int main() {
    ll n, tmp = 0;
    cin >> n;

    vector<ll> a(n), b(n);
    for (int i = n-1; i >= 0; i--)
    {
        cin >> a[i] >> b[i];
    }

    for (int i = 0; i < n; i++)
    {
        a[i] += tmp;
        
        if (a[i] % b[i] == 0) continue;

        tmp += b[i] - (a[i] % b[i]);
        
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 4844
d, gl = map(int, input().split())
p = []
g = []
for i in range(d):
  P,G = map(int, input().split())
  p.append(P)
  g.append(G)
ans = sum(p)
for i in range(1<<d):
  tmp = 0
  c = 0
  b = [0 for i in range(d)]
  for j in range(d):
    if i&(1<<j):
      tmp += g[j] + (j+1)*p[j]*100
      c += p[j]
      b[j] = 1
  s = d-1
  while tmp < gl and s >= 0:
    if b[s] == 1:
      s -= 1
    else:
      for k in range(p[s]):
        tmp += 100*(s+1)
        c += 1
        if tmp >= gl:
          break
      s -= 1
  if tmp >= gl:
    ans = min(ans,c)
print (ans)

Measured memory_bytes: 9188
#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; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll ans = min(A[0], B[0]);
    B[0] = max(0, B[0] - A[0]);
    rep(i, N) {
        if (B[i] > A[i + 1]) {
            ans += A[i + 1];
        }
        else {
            A[i + 1] -= B[i];
            ans += B[i];

            if (A[i + 1] > 0) {
                ans += min(A[i + 1], B[i + 1]);
                B[i + 1] = max(0, B[i + 1] - A[i + 1]);
            }
        }
    }

    write(ans);
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

double get_area(double a){
	return sin(a) / 2;
}

int main(){
	int n, m;
	while(cin >> n && n){
		double sum1 = 0;
		double sum2 = 0;
		double area1 = 0;
		double area2 = 0;
		double theta;
		rep(i, n-1) {
			cin >> theta;
			area1 += get_area(theta / 180.0 * M_PI);
			sum1 += theta / 180.0 * M_PI;
		}
		area1 += get_area(2 * M_PI - sum1);
		area1 = abs(area1);
		cin >> m;
		rep(i, m-1){
			cin >> theta;
			area2 += get_area(theta / 180.0 * M_PI);
			sum2 += theta / 180.0 * M_PI;
		}
		area2 += get_area(2 * M_PI - sum2);
		area2 = abs(area2);
		if(abs(area1 - area2) < EPS) cout << 0 << endl;
		else if(area1 > area2) cout << 1 << endl;
		else cout << 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vi >
#define vvl vector< vl >
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector< pii >
#define vpll vector< pll >
#define rep(i, a, b) for(int i = a; i < b; i++) 
#define repll(i, a, b) for(ll i = a; i < b; i++) 
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define F first
#define S second
#define string_to_int(s) stoi(s)
#define string_to_ll(s) stoll(s)
#define int_to_string(n) to_string(n)
#define ll_to_string(n) to_string(n)
#define char_to_int(c) c-'0'
#define int_to_char(c) c+'0'

int main() {

	int a, b;
	cin >> a >> b;
	int x, y, z;
	x = a+b;
	y = a-b;
	z = a*b;
	if(x >= y && x >= z) cout << x << "\n";
	else if(y >= x && y >= z) cout << y << "\n";
	else if(z >= x && z >= y) cout << z << "\n";


	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

// 3.5 ??????????????????
//     Generic????????¨
namespace ALDS1_2_C
{
    class Card : IComparable
    {
        public char Suit { get; private set; }
        public int Num { get; private set; }
        public Card(char suit, int num)
        {
            Suit = suit;
            Num = num;
        }
        public int CompareTo(Object other)
        {
            var obj = (Card)other;
            return Num - obj.Num;
        }
        public override string ToString()
        {
            return "" + Suit + Num.ToString();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int.Parse(Console.ReadLine());
            var line = Console.ReadLine();
            var arrayForBubble = line.Split(' ').Select(e => new Card(e[0], e[1] - '0')).Cast<Card>().ToArray();
            var arrayForSelection = (Card[])arrayForBubble.Clone();

            bubbleSort(arrayForBubble);
            Console.WriteLine(string.Join(" ", arrayForBubble.Select(e => e.ToString()).ToArray()));
            Console.WriteLine("Stable");

            selectionSort(arrayForSelection);
            Console.WriteLine(string.Join(" ", arrayForSelection.Select(e => e.ToString()).ToArray()));
            if (Enumerable.SequenceEqual(arrayForBubble, arrayForSelection))
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.WriteLine("Not stable");
            }
        }
        static int bubbleSort<T>(T[] array) where T: IComparable
        {
            int swapCnt = 0;
            for (var i = 0; i < array.Count(); i++)
            {
                for (var j = array.Count() - 1; j > i; j--)
                {
                    if (array[j - 1].CompareTo(array[j]) > 0)
                    {
                        var tmp = array[j - 1];
                        array[j - 1] = array[j];
                        array[j] = tmp;
                        swapCnt++;
                    }
                }
            }
            return swapCnt;
        }
        static int selectionSort<T>(T[] array) where T: IComparable
        {
            var swapCnt = 0;
            for (var i = 0; i < array.Length - 1; i++)
            {
                var min = array[i];
                var minIndex = i;
                for (var j = i + 1; j < array.Length; j++)
                {
                    if (array[j].CompareTo(min) < 0)
                    {
                        min = array[j];
                        minIndex = j;
                    }
                }
                if (min.CompareTo(array[i]) != 0)
                {
                    var tmp = array[i];
                    array[i] = array[minIndex];
                    array[minIndex] = tmp;
                    swapCnt++;
                }
            }
            return swapCnt;
        }
    }
}

Measured memory_bytes: 9724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  private static final String DELIMITER = " ";

  /**
   * Ai1B1 + Ai2B2 + ... + C > 0
   *
   * 2 3 -10
   * 1 2 3
   * 3 2 1
   * 1 2 2
   *
   * @param args
   */
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String firstLine = scanner.nextLine();
    String[] firstArray = firstLine.split(DELIMITER);
    int n = Integer.valueOf(firstArray[0]);
    int m = Integer.valueOf(firstArray[1]);
    int c = Integer.valueOf(firstArray[2]);

    String secondLine = scanner.nextLine();
    String[] secondArray = secondLine.split(DELIMITER);

    List<Integer> ok = new ArrayList<>();

    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      int sum = 0;
      String[] lineArray = line.split(DELIMITER);
      for (int i = 0; i < m; i ++) {
        sum += Integer.valueOf(lineArray[i]) *  Integer.valueOf(secondArray[i]);
      }
      if (sum + c > 0) ok.add(0);
    }

    System.out.println(ok.size());
  }
}


Measured memory_bytes: 23380
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int cnt;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long a;
        cin>>a;
        for(int j=1;j<=1000;j++)
        {
            if(a==0)break;
            if(a%2==0){a/=2;cnt++;}
            if(a%2!=0)break;
        }
    }
    cout<<cnt;
system("pause");
return 0;
}

Measured memory_bytes: 504
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        m: i32,
    }
    if m <= 1 {
        println!("0");
        return;
    }
    let mut x = 1;
    loop {
        if n * x - (x - 1) >= m { break; }
        x += 1;
    }
    println!("{}", x);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define bit(n,m)((n>>m)&1)
int main(){
  char a[5];
  scanf("%s",a);
  rep(i,0,8){
    int ans=a[0]-48;
    rep(j,0,3)ans+=bit(i,j)?a[j+1]-48:48-a[j+1];
    if(ans==7){
      rep(j,0,3)printf("%c%c",a[j],bit(i,j)?'+':'-');
      printf("%c=7",a[3]);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

int MOD=1000000007;

int main()
{
  long long N,A;
  cin >> N;
  for(long long i=0; i<N; i++){
    cin >> A;
    if(A%2==0){
      if(A%3==0 || A%5==0){
      }else{
          cout << "DENIED" << endl;
          return 0;
      }
    }
  }cout << "APPROVED" << endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	vector<string> ss{"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
  	cin >> s;
    for(int i=0;i<7;i++){
    	if(ss[i]==s){
        	cout << 7-i << endl;
        }
    }
}


Measured memory_bytes: 256
dp=[[0 for j in range(10)] for i in range(10)]
import numpy as np

h,w=map(int,input().split())
dp=np.array(dp)
for i in range(10):
    s=list(map(int,input().split()))
    for j in range(10):
        dp[i][j]=s[j]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
c=0
for i in range(h):
    s=list(map(int,input().split()))
    for j in range(w):
        if s[j]!=-1 and s[j]!=1:
            c+=dp[s[j]][1]
print(c)


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

int main(){
  string s,a,b;
  int n;
  int count = 0;
  cin >> s;
  n = s.size();
  rep(i,n) a[i] = s[n-1-i];
  rep(i,n){
    if(s[i] != a[i]){
      ++count;  
    }
  }
  cout << count/2 << endl;
  return 0;
}
    


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

print(' '.join(map(str, A)))
    
for i in range(1, N):

    v = A[i]
    j = i - 1
        
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
            
    A[j+1] = v
    print(' '.join(map(str, A)))


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int N; cin >> N;
    vi A(N), B(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    sort(all(A));
    sort(all(B));
    int res=0;
    if(N%2 == 1){
        int id=(N-1)/2;
        res=B[id]-A[id]+1;
        cout << res << endl; 
    }
    else{
        int id1=(N-2)/2, id2=N/2;
        res=B[id2]-A[id2]+1+B[id1]-A[id1];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4788
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    A_1 = list(int(_) for _ in input().split())
    A_2 = list(int(_) for _ in input().split())
    
    ans = 0
    for i in range(N):
        tmp = sum(A_1[0:i+1])+sum(A_2[i:N])
        ans = max(ans,tmp)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
        ll n;
        cin>>n;
        while(n>0){
        if(n%10==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        n = n/10;
        }
        cout<<"No"<<endl;
    return 0;
}


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

class S{
public:
	S(int pos,int cost){
		p=pos;
		c=cost;
	}
	int p,c;
};
bool operator<(S a,S b){
	return a.c>b.c;
}
int m;
vector<S> edge[100][2];
void add_edge(int a,int b,int c,int t){
	edge[a][0].push_back(S(b,c));
	edge[a][1].push_back(S(b,t));
	edge[b][0].push_back(S(a,c));
	edge[b][1].push_back(S(a,t));
}


int solve(int p,int q,int r){
	int ans=0;
	bool use[100];
	for(int i=0;i<100;i++){
		use[i]=0;
	}
	
	priority_queue<S> que;
	que.push(S(p,0));
	
	while(!que.empty()){
		S n=que.top();que.pop();
		
		if(n.p==q){
			ans=n.c;
			break;
		}
		
		if(use[n.p]){
			continue;
		}
		use[n.p]=1;
		
		
		for(int i=0;i<edge[n.p][r].size();i++){
			if(!use[edge[n.p][r][i].p]){
				que.push(S(edge[n.p][r][i].p,n.c+edge[n.p][r][i].c));
			}
		}
	}
	return ans;
}



int main(){
	int n;
	while(cin>>n>>m,n!=0||m!=0){
		for(int i=0;i<100;i++){
			for(int j=0;j<2;j++){
				edge[i][j].clear();
			}
		}
		for(int i=0;i<n;i++){
			int a,b,c,t;
			cin>>a>>b>>c>>t;
			a--;b--;
			add_edge(a,b,c,t);
		}
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int p,q,r;
			cin>>p>>q>>r;
			p--;q--;
			cout<<solve(p,q,r)<<endl;
		}
	}
}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
int n,k;
char o[2000];

int main() {
    scanf("%d %d",&n,&k);
    scanf("%s",o+1);
    o[k]=o[k]-'A'+'a';
    printf("%s\n",o+1);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)2e5 + 7, MOD = (int)1e9 + 7;

int n;

ll dp[N][5];

vector<int> v[N];

void dfs(int x,int p=-1){
	ll X1=1,X2=1;
	for(int i=0;i<sz(v[x]);i++){
		int to = v[x][i];
		if(to == p)continue;
		dfs(to,x);
		X1 *= dp[to][0];
		X1 %= MOD;
		X2 *= (dp[to][0] + dp[to][1]);
		X2 %= MOD;
	}
	dp[x][1] = X1 % MOD;
	dp[x][0] = X2 % MOD;
}

int main(){
		
	NFS

	cin >> n;
	
	for(int i=1;i<n;i++){
		int x,y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	
	dfs(1);
	
	cout << (dp[1][1] + dp[1][0]) % MOD << endl;
	
	ioi
}

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

using i64 = int64_t;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    int ans = v[0];
    for(int i=1;i<n;++i)ans = gcd(ans, v[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int n,k;
const int N = 2e5+5;
bool in[N];int a[N];
int sz=0;
set<int> st;

int main()
{
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=k;i++){
		st.insert(a[i]);
		if(i<k)sz+=a[i]<a[i+1];
	}
	bool t=0;
	int ans = 0;
	if(sz!=k-1)ans++;
	else t=1;
	for(int i=2,j=k+1;j<=n;i++,j++){
		sz -= a[i-1]<a[i];sz += a[j-1]<a[j];
		int s = 0;
		if(*st.begin()==a[i-1])s++;
		st.erase(a[i-1]),st.insert(a[j]);
		if(a[j]==*st.rbegin())s++;
		if(s<2 && sz != k-1){
			ans ++ ;
		}
		if(sz==k-1) t=1;
		// cout << i << ":" << j << ":" << ans << endl;
	}
	if(t)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& v : values) std::cin >> v;
	std::sort(values.begin(), values.end());
	std::cout << std::distance(values.begin(), std::unique(values.begin(), values.end())) << std::endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> seqs(2001, -1);
vector<bool> sumi(2001, false);

mint redis(ll S){
    if(S == 0){
        return 1;
    }
    if(S < 3){
        return 0;
    }
    mint val = 0;
    rep(i, S-2){
        if(sumi.at(S-(i+3))){
            val += seqs.at(S-(i+3));
        }
        else{
            seqs.at(S-(i+3)) = redis(S-(i+3));
            sumi.at(S-(i+3)) = true;
            val += seqs.at(S-(i+3));
        }
    }
    return val;
}

int main()
{
    ll S;
    cin >> S;
    seqs.at(0) = 1;
    seqs.at(1) = 0;
    seqs.at(2) = 0;
    sumi.at(0) = true;
    sumi.at(1) = true;
    sumi.at(2) = true;
    cout << redis(S) << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;
	int ans = 700;
	for (int i = 0; i < input.size(); i++)
	{
		if (input[i] == 'o')
			ans += 100;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

typedef long long  ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define INPUT(arr,n) for(ll i = 0;i<n;i++) cin>>arr[i];
#define PRINT(arr,n) for(ll i = 0;i<=n;i++) printf("%lld ",arr[i]);printf("\n");
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define mp make_pair
#define pb push_back

const ll NMAX = 3000+7;
const ll MOD = 1000*1000*1000+7;
const ll INT_BITS = 32 ;
ll arr[NMAX];
ll dp[NMAX][NMAX][2];

inline ll add(ll a, ll b) {
  ll r = a + b;
  return (r >= MOD ? r - MOD : r);
}

inline ll sub(ll a, ll b) {
  ll r = a - b;
  return (r < 0 ? r + MOD : r);
}

inline ll mul(ll a, ll b) {
  ll r = a * b;
  return (r >= MOD ? r % MOD : r);
}

ll N;

ll solve(ll i, ll j,ll turn){
	if(i>j) return 0;
	if(dp[i][j][turn] != -1)return dp[i][j][turn];
	ll res;
	if(turn){
		res = max(solve(i+1,j,1-turn)+arr[i], solve(i,j-1,1-turn)+arr[j]);
	}
	else{
		res = min(solve(i+1,j,1-turn)-arr[i], solve(i,j-1,1-turn)-arr[j]);
	}
	return dp[i][j][turn]=res;
}
int main(int argc, char const *argv[])
{
	cin>>N;
	INPUT(arr,N);
	MEM(dp,-1);
	cout<<solve(0,N-1,1)<<endl;
	return 0;
}

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

set<int> ST;

int n, x;

int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%d", &x);
		if(ST.count(x)){
			ST.erase(x);
		} else {
			ST.insert(x);
		}
	}
	printf("%d\n", ST.size());
	return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int n,i;
    string a;
    cin>>n;
    cin>>a;
    if(n%2!=0)
    {
        cout<<"No";
        return 0;
    }
    for(i=0;i<n/2;i++)
    {
        if(a[i]!=a[i+n/2])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256