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

int main() {
	// your code goes here
	long long int n;
	cin>>n;
	map<string,int> m;
	while(n--)
	{
	    string s;
	    cin>>s;
	    m[s]++;
	}
	int flag=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
	    if(it->first=="AC")
	    {
	        flag=1;
	        cout<<"AC x "<<it->second<<endl;
	        break;
	    }
	}
	if(flag!=1)
	{
	    cout<<"AC x "<<"0"<<endl;
	}
	flag=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
	    if(it->first=="WA")
	    {
	        flag=1;
	        cout<<"WA x "<<it->second<<endl;
	        break;
	    }
	}
	if(flag!=1)
	{
	    cout<<"WA x "<<"0"<<endl;
	}
	flag=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
	    if(it->first=="TLE")
	    {
	        flag=1;
	        cout<<"TLE x "<<it->second<<endl;
	        break;
	    }
	}
	if(flag!=1)
	{
	    cout<<"TLE x "<<"0"<<endl;
	}
	flag=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
	    if(it->first=="RE")
	    {
	        flag=1;
	        cout<<"RE x "<<it->second<<endl;
	        break;
	    }
	}
	if(flag!=1)
	{
	    cout<<"RE x "<<"0"<<endl;
	}
}


Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  int cnt = 0;
  for (int i = 0; i < S.size(); ++i)
  {
    if (S[i] != T[i])
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3916
#include <stdio.h>
#include <string.h>
#define M 1000000
#define L 14

char H[M][L];
int GetChar(char ch){
        if(ch=='A') return 1;
        else if(ch=='C') return 2;
        else if(ch=='G') return 3;
        else if(ch=='T') return 4;
        else return 0;
}
int h1(int key){
        return key % M;
}
int h2(int key){
        return 1+(key % (M-1));
}
long long IntegerKey(char str[]){
        long long sum=0,p=1,i;
        for(i=0; i<strlen(str); i++) {
                sum+=p*(GetChar(str[i]));
                p*=5;
        }
        return sum;
}


int Find(char str[]){
        long long key,i,h;
        key=IntegerKey(str);
        for(i=0;; i++) {
                h = (h1(key) + i * h2(key)) % M;
                if(strcmp(H[h],str)==0) return 1;
                else if(strlen(H[h])==0) return 0;
        }
        return 0;
}

int insert(char str[]){
        long long key,i,h;
        key=IntegerKey(str);
        for(i=0;; i++) {
                h = (h1(key) + i * h2(key)) % M;
                if(strcmp(H[h],str)==0) return 1;
                else if(strlen(H[h])==0) {
                        strcpy(H[h],str);
                        return 0;
                }
        }
        return 0;
}

int main(){
        int i,n,h;
        char str[L],com[9];

        for(i = 0; i < M; i++) H[i][0]='\0';
        scanf("%d",&n);
        for(i=0; i<n; i++) {
                scanf("%s %s",com,str);

                if(com[0]=='i') {
                        insert(str);
                }
                else {
                        if( Find(str) ) {
                                printf("yes\n");
                        }
                        else{
                                printf("no\n");
                        }
                }
        }
        return 0;


}



Measured memory_bytes: 15428
// atcoder/abc175/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int h, w, k;
  while (cin >> h >> w >> k) {
    map<pair<int, int>, lli> m;
    for (int i = 0; i < k; ++i) {
      int r, c, v;
      cin >> r >> c >> v;
      m[{r - 1, c - 1}] = v;
    }

    const int N = 3000 + 3;
    static lli dp[N][N][5];
    fill(&dp[0][0][0], &dp[N - 1][N - 1][5 - 1], 0);
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        for (int t = 0; t <= 3; ++t) {
          setmax(dp[i + 1][j][0], dp[i][j][t]);
          setmax(dp[i][j + 1][t], dp[i][j][t]);
          if (m.count({i, j}) && t < 3) {
            setmax(dp[i][j + 1][t + 1], dp[i][j][t] + m[{i, j}]);
            setmax(dp[i + 1][j][0], dp[i][j][t] + m[{i, j}]);
          }
        }
      }
    }

    cout << *max_element(&dp[0][0][0], &dp[N - 1][N - 1][5 - 1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 368316
N = int(input())
S = list(input())

l = 0
r = 0

for s in S:
    if s == '(':
        r += 1
    else:
        if r == 0:
            l += 1
        else:
            r -= 1

# print(l, r)
print('(' * l + ''.join(S) + ')' * r)


Measured memory_bytes: 2940
#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 (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    rep(i, dx) cout << "R";
    rep(i, dy) cout << "U";

    rep(i, dx) cout << "L";
    rep(i, dy) cout << "D";
    cout << "D";
    rep(i, dx + 1) cout << "R";
    rep(i, dy + 1) cout << "U";
    cout << "L";

    cout << "U";
    rep(i, dx + 1) cout << "L";
    rep(i, dy + 1) cout << "D";
    cout << "R";

    cout << 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;



ll stoLL(string str){
  int digits = str.length();
  ll num = 0;
  for(const char c : str){
    num += (c-48) * pow(10,digits-1);
    digits--;
  }
  return num;
}

ll splitandsum(string str){
  string subStr;
  ll sum = 0;
  for(const char c : str){
    if(c != '+') subStr += c;
    else{
      ll num = stoLL(subStr);
      sum += num;
      subStr.clear(); //中身を空っぽにする
    }
  }
  ll num = stoLL(subStr);
  sum += num;
  return sum;
}

int main(){
  string S; cin >> S;
  ll sum = 0;
  rep(bit,pow(2,S.length()-1)){ //bit全探索
    string tmp = S;
    int inserted_idx = 1;
    rep(j,S.length()-1){
      if(bit >> j & 1){
        tmp.insert(inserted_idx,"+");
        inserted_idx += 2;
      }
      else inserted_idx++;
    }
    sum += splitandsum(tmp);
  }
  cout << sum << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int d=n%10;
  n/=10;
  int c=n%10;
  n/=10;
  int b=n%10;
  n/=10;
  int a=n;
  char x,y,z;
  if(a+b+c+d==7){
    x='+',y='+',z='+';
  }
  else if(a+b+c-d==7){
    x='+',y='+',z='-';
  }
  else if(a+b-c+d==7){
    x='+',y='-',z='+';
  }
  else if(a+b-c-d==7){
    x='+',y='-',z='-';
  }
  else if(a-b+c+d==7){
    x='-',y='+',z='+';
  }
  else if(a-b+c-d==7){
    x='-',y='+',z='-';
  }
  else if(a-b-c+d==7){
    x='-',y='-',z='+';
  }
  else if(a-b-c-d==7){
    x='-',y='-',z='-';
  }
  cout << a << x << b << y << c << z << d << "=7" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 llpvec pair(n);
 ll a,b;
 rep(i,0,n){
  sc(a);sc(b);
  pair[i]={b,a};
 }
 sort(pair);
 ll sum=0; 
 rep(i,0,n){
  sum+=pair[i].second;
  if(sum>pair[i].first){
   pn;return 0;
  }
 }
 py;
  
  return 0;}

Measured memory_bytes: 6428
#include <iostream>
using namespace std;
int main()
{
  int n,t,p=0;
  cin>>n;
  for(int i=0; i<=n; i++)
  {
    t=n%10;
    
    if(n!=0)
    {
    	if (t==7)
    		p++;
    }
    n=n/10;
  }
  if (p>0)
      cout<<"Yes";
    else
      cout<<"No";
  return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll>a(n),b(n);
  rep(i,n)cin >> a[i] >> b[i];
  ll ans = 0;
  for(int i = n - 1; i >= 0; i--){
    if(b[i] == 1 || (a[i] + ans) % b[i] == 0)continue;
    else ans += abs(((a[i] + ans) % b[i]) - b[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
char maze[1001][1001];
int d[1001][1001];
bool pre[1001][1001];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N, Y, Z, K;
	cin >> N;
	ll ans = 0;
	for (i = 1; i*i <N; i++) {
		if (N%i == 0 && i + 1 < N / i) {
			ans += N / i - 1;
		}
	}
	output(ans);
	return 0;
}













Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll x;
cin>>x;
ll ans=1;
for(int i=2;i<x;i++){
    for(int j=3;j<50;j++){
        if(pow(i,j)>x&&pow(i,j-1)<=x){
            chmax(ans,(ll)pow(i,j-1));
        }
    }
}
cout<<ans<<endl;
}












Measured memory_bytes: 256
# input
n = gets.chomp.to_i
polls = {}

# main
n.times do
  tmp = gets.chomp
  if polls.has_key?(tmp) then
    polls[tmp] += 1
  else
    polls[tmp] = 1
  end
end

ans = polls.values.max
result = polls.to_a.sort_by {|x| x[0]}

# output
result.each do |d|
  if d[1] == ans then
    puts d[0]
  end
end


Measured memory_bytes: 43256
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 1e5 + 10;
struct Edge
{
    int next, to, v;
}e[N];
int head[N], n, m, cnt = 1, cur[N], h[N], q[N], ans, S, T;
int a[N], b[N], c[N], d[N];
void ins(int u, int v, int w)
{
    e[++ cnt].to = v;
    e[cnt].next = head[u];
    e[cnt].v = w;
    head[u] = cnt;
}

void insert(int u, int v, int w)
{
    ins(u, v, w);
    ins(v, u, 0);
}

int bfs()
{
    int t = 0, w = 1;
    memset(h, -1, sizeof(h));
    h[S] = 0;
    q[0] = S;
    while(t != w)
    {
        int now = q[t ++];
        if(t == N) t = 0;
        for(int i = head[now]; i; i = e[i].next)
        {
            int y = e[i].to;
            if(h[y] == -1 && e[i].v)
            {
                h[y] = h[now] + 1;
                q[w ++] = y;
                if(w == N) w = 0;
            }
        }
    }
    if(h[T] == -1) return 0;
    else return 1;
}

int dfs(int x, int f)
{
    if(x == T) return f;
    int used = 0, w;
    for(int i = cur[x]; i; i = e[i].next)
    {
        int y = e[i].to;
        if(h[y] == h[x] + 1 && e[i].v)
        {
            w = dfs(y, min(e[i].v, f - used));
            used += w;
            e[i].v -= w;
            if(e[i].v) cur[x] = i;
            e[i ^ 1].v += w;
            if(used == f) return f;
        }
    }
    if(!used) h[x] = -1;
    return used;
}


int dinic()
{
	int ans = 0;
    while(bfs())
    {
        for(int i = S; i <= T; i ++)
            cur[i] = head[i];
        ans += dfs(S, INF);
    }
    return ans;
}

int main()
{
	n = read();
	rep(i, 1, n)
	{
		a[i] = read();
		b[i] = read();
	}
	rep(i, 1, n)
	{
		c[i] = read();
		d[i] = read();
	}

	rep(i, 1, n)
		rep(j, 1, n)
			if(a[i] < c[j] && b[i] < d[j])
				insert(i, j + n, INF);
	S = 0;
	T = 2 * n + 1;
	rep(i, 1, n)
		insert(S, i, 1), insert(i + n, T, 1);
	cout << dinic();
	return 0;
}


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

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    for (int i=0; i<s.size(); i++) {
        if (i == a) {
            if (s[i] != '-') ans = false;
        }
        else {
            if (!('0' <= s[i] && s[i] <= '9')) ans = false;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*w+(j))

int cond(char *board,int h,int w){
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(board[POS(i,j)]=='.') continue;
      int d[]={1,0,-1,0,1};
      int k;
      for(k=0;k<4;k++){
	int x=i+d[k];
	int y=j+d[k+1];
	if(x>=0 && x<h && y>=0 && y<w && board[POS(x,y)]=='#') break;
      }
      if(k==4) return 0;
    }
  }
  return 1;
}

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char board[2501];
  int i;
  for(i=0;i<h;i++) scanf("%s",board+POS(i,0));
  printf("%s\n",cond(board,h,w)?"Yes":"No");
}

int main(void){
  run();
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int n;
    cin >> n;
    int min = 0, ans = 0;
    rep(i, n){
        int a; cin >> a;
        if(a <= min || min == 0) {
            ans++;
        }
        if(min == 0 || min > a) min = a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    int ans = 0;

    for (int i = 0; i < a.length(); i++)
        if (a[i] != b[i])
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int t[100010], a[100010], rec[100010];
signed main() {
    int n; cin >> n;
    rep(i,0,n) cin >> t[i];
    rep(i,0,n) cin >> a[i];
    memset(rec, -1, sizeof(rec));

    int ans = 1;
    bool T[100010], A[100010] = {};
    T[0] = true, A[n-1] = true;
    rep(i,0,n-1) {
        if(t[i] < t[i+1]) T[i+1] = true;
    }
    repr(i,n-1,1) {
        if(a[i] < a[i-1]) A[i-1] = true;
    }
    rep(i,0,n) {
        // printf("i = %lld, T[i] = %d, A[i] = %d\n", i, T[i], A[i]);
        if(T[i] && A[i]) {
            if(t[i] != a[i]) ans *= 0;
        }
        else if(T[i]) {
            if(t[i] > a[i]) ans *= 0;
        }
        else if(A[i]) {
            if(a[i] > t[i]) ans *= 0;
        }
        else ans = (ans * min(t[i], a[i])) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const N = tmp[0]|0, S = tmp[1];
  let count = 0;
  let usedi = [0,0,0,0,0,0,0,0,0,0];
  for ( let i = 0; i < N-2; i++ ) {
    if ( usedi[S[i]] ) continue;
    usedi[S[i]] = 1;
    let usedj = [0,0,0,0,0,0,0,0,0,0];
    for ( let j = i+1; j < N-1; j++ ) {
      if ( usedj[S[j]] ) continue;
      usedj[S[j]] = 1;
      let usedk = [0,0,0,0,0,0,0,0,0,0];
      for ( let k = j+1; k < N; k++ ) {
        if ( usedk[S[k]] ) continue;
        usedk[S[k]] = 1;
        count++;
      }
    }
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


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



int main() {
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool t = true;
	while (a>0 && c>0) {
		if (t) {
			c -= b;
			t = false;
		} else {
			a -= d;
			t = true;
		}
	}

	if (a <= 0) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b  =sc.nextInt();
		
		int ans = 0;
		if(a > b){
			ans = a+a-1;
		}else if(b > a){
			ans = 2*b-1;
		}else{
			ans = 2 * a;
		}
		System.out.print(ans);
	}
	


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    string s;

    cin >> n;
    cin >> s;

    int ans = 0;

    rep(i, n - 2){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int prog[1000000];
	int i,j,k;
	int a,d,n;
	
	
	for(i=2;i<1000000;i++)
	    prog[i] = 1;
		
	for(j=2;j*j<1000000;j++){
	    for(k=j*j;k<1000000;k=k+j)	
	    prog[k] = 0;	
	}
	    
 
	while(1){
	   scanf("%d %d %d",&a,&d,&n);
	   if(!a && !d && !n)
	      break;
	   int x,y,z=0;   
	   for(x=a;z!=n;x=x+d){
	      if(prog[x] == 1)
	      z++;
	      y=x;
	      }
	
	   printf("%d\n",y);
	   }
	return 0;
}

Measured memory_bytes: 4504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		double t = sc.nextDouble(), a = sc.nextDouble();
		double tem = Double.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			double h = sc.nextDouble();
			double ave = t - h * 0.006;
			if(tem > Math.abs(a - ave)) {
				tem = Math.abs(a - ave);
				ans = i+1;
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 35884
#include <iostream>

using namespace std;
int main(){
  int n, t=1;
  cin >> n;
  while(n--){
    int s;
    cin >> s;
    cout << "Case " << t++ << ":" <<endl;
    for(int i=0; i<10; i++){
      s = s*s;
      s/=100;
      s%=10000;
      cout << s << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	int l=read();
	double a=(double)l/3;
	printf("%.8f",a*a*a); 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
double matrix_x(int,int,int,int,int,int);
double matrix_y(int,int,int,int,int,int);
double sisyagonyu(double);

int main() {
int a,b,c,d,e,f;

while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF)

printf("%.3f %.3f\n",matrix_x(a,b,c,d,e,f),matrix_y(a,b,c,d,e,f));

return 0;
}


double matrix_x(int a,int b,int c,int d,int e,int f){
double x;
x=(double)c/a-(matrix_y(a,b,c,d,e,f))*(double)b/a;
return sisyagonyu(x);
}

double matrix_y(int a,int b,int c,int d,int e,int f){
double y;
y=(f-(double)c*d/a)/(e-(double)b*d/a);
return sisyagonyu(y);
}

double sisyagonyu(double n){
int n1;
n1=n*10000;
if(n1%10>=5)  n1+=10;
return (double)n1/10000;
}

Measured memory_bytes: 636
from collections import Counter
def main():
    N = int( input())
    S = [ input() for _ in range(N)]
    C = Counter(S)
    print("AC", "x", C["AC"])
    print("WA", "x", C["WA"])
    print("TLE", "x", C["TLE"])
    print("RE", "x", C["RE"])

if __name__ == '__main__':
    main()


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

int main(){
  int N,M;

  cin >> N;
  vector <string> vec_n(N);
  for (int j_1 = 0; j_1 < N; j_1 ++) cin >> vec_n.at(j_1);
  cin >> M;
  vector <string> vec_m(M);
  for (int j_2 = 0; j_2 < M; j_2 ++) cin >> vec_m.at(j_2);


  vector <int> vec_s(N,1);
  for (int j_3 = 0; j_3 < N; j_3 ++){//j_3はvec_nの何番目を考えているか
    for (int i_3_1 = j_3 +1; i_3_1 < N; i_3_1 ++){//vec_nの自分より後ろの文字列の中で，自分と一致するものがあればカウントする
      if (vec_n.at(j_3) == vec_n.at(i_3_1)){
        vec_s.at(j_3) ++ ;
      }
    }


    for (int i_3_2 = j_3; i_3_2 > 0; i_3_2 --){//自分より前に一致するものがあれば0にする（同じ文字列は最大値しか表示させない）
      if (vec_n.at(j_3) == vec_n.at(i_3_2 -1)){
        vec_s.at(j_3) = 0;
        break;
      }
    }
  }//vec_sの準備が完了


  for (int j_4 = 0; j_4 < N; j_4 ++){//j_4はvec_nの何番目を考えているか
    for (int i_4_1 = 0; i_4_1 < M; i_4_1 ++){//i_4_1はvec_mの何番目を考えているか
      if (vec_n.at(j_4) == vec_m.at(i_4_1)){//vec_mのなかで一致するものがあれば減ずる
        vec_s.at(j_4) --;
      }
    }
  }

  int ans = 0;
  for (int j_5 = 0; j_5 < N; j_5 ++){
    if (j_5 == 0) ans = vec_s.at(0);
    else{
      if (vec_s.at(j_5) > ans){
        ans = vec_s.at(j_5) ;
      }
    }
  }


  if (ans > 0)cout << ans << endl;
  else cout << 0 <<endl;


}


Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m;
ll k;
string s,t;

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

	string ans=s;
	bool changed=0;
	RREP(i, (int)s.size()){
		if(!changed)if(s[i]==t[0] || s[i]=='?')if(s.size()-i>=t.size()){
			bool f=1;
			REP(j,(int)t.size())
				f *= s[i+j]==t[j] || s[i+j] == '?';
			if(f){
				changed=1;
				REP(j,t.size()){
					ans[i+j]=t[j];
				}
				continue;
			}
		}
		if(s[i]=='?'){
			ans[i]='a';
			continue;
		}
		ans[i]=s[i];
	}
	if(!changed){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	cout << ans;
	cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int q = scanner.nextInt();
			IntStream.range(0, q).mapToLong(i -> getResult(scanner.nextInt(), scanner.nextInt()))
					.forEach(System.out::println);
		}
	}

	/**
	 * 順位が高橋より低い最大の人数を計算する
	 * 
	 * @param a 高橋の1回目の順位
	 * @param b 高橋の2回目の順位
	 * @return 順位が高橋より低い最大の人数
	 */
	private static long getResult(long a, long b) {
		if (1 >= Math.abs(a - b)) {
			return 2 * Math.min(a, b) - 2;
		}
		long c = (long) Math.sqrt(a * b);
		if (c * c == a * b) {
			c--;
		}
		if (c * (c + 1) >= a * b) {
			return 2 * c - 2;
		} else {
			return 2 * c - 1;
		}
	}
}


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

using namespace std;

int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	// ios_base::sync_with_stdio(false);
	// cin.tie(0);

	int a,b,c,x,y;

	cin >> a >> b >> c >> x >> y;

	int onlyC, AandB, other;
	int answer;

	AandB = a*x + b*y;
	onlyC = 2*c*max(x,y);
	if (x>y)
	{
		other = 2*c*(y) + a*(x-y);
	}
	else
	{
		other = 2*c*(x) + b*(y-x);
	}
	answer = min(onlyC,min(AandB,other));
	cout << answer;


	return 0;
}

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

int w, n;
int v[1000], c[1000];
int dp[10001];
int main() {
  cin >> w >> n;
  for (int i = 0; i < n; ++i) {
    cin >> v[i] >> c[i];
  }
  
  for (int k = 1; k <= w; ++k) {
    dp[k] = 1e9;
  }
  
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k <= w; ++k) {
      dp[k] = min(dp[k], (k - v[i] < 0 ? 0 : dp[k - v[i]]) + c[i]);
    }
  }
  cout << dp[w] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define CHAL_BC_APNE_BAAP_KO_MAT_SIKHA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fr first
#define se second
#define mod 1000000007
signed main()
{
	CHAL_BC_APNE_BAAP_KO_MAT_SIKHA;		
	int a,b;
	cin>>a>>b;
	int u=min(a,b);
	int y=max(a,b);
	for(int i=1;i<=y;i++)
		cout<<u;
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))

# 最も離れている家の距離を探し、円周からそれを除くと解となる
dists = []
for i in range(N):
    if i == 0:
        dists.append(A[i]+K-A[-1])
    else:
        dists.append(A[i]-A[i-1])
# print(dists)

print(K-max(dists))


Measured memory_bytes: 32372
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    vl A(N); REP(i, N) cin >> A[i];
    
    const ll mod = 1e9+7;
    
    vvl dp(N+1, vl(K+1, 0));
    dp[0][0] = 1;
    REP(i, N){
        vl sum(K+2, 0);
        REP(j, K+1){
            sum[j+1] = (sum[j] + dp[i][j]) % mod;
        }
        
        REP(j, K+1){
            if(j < A[i]) dp[i+1][j] = sum[j+1];
            else dp[i+1][j] = (sum[j+1] - sum[j-A[i]] + mod) % mod;
        }
    }
    
    cout << dp[N][K] << endstr;
    return 0;
}


Measured memory_bytes: 81908
Poi = []
Tea = []
while True:
    
    p,s = map(int,input().split(","))
    if p == 0 and s == 0:
        break
    Poi.append(s)
    Tea.append(p)
Poi_ran = sorted(sorted(set(Poi), key=Poi.index))
while True:
    try:
        q = int(input())
        point = Poi[Tea.index(q)]
        print(len(Poi_ran) - Poi_ran.index(point))
    except EOFError:
        break

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

struct Edge {
  Edge(int from_, int to_) : from(from_), to(to_) {}
  int from;
  int to;
};

struct Range {
  Range() : lower(-(1<<27)), upper((1<<27)) {}
  Range(int lower_, int upper_) : lower(lower_), upper(upper_) {}
  int lower;
  int upper;
};
Range nullWindow(-(1<<29), -(1<<29)-2);
bool operator== (Range a, Range b) {
  return a.lower == b.lower and a.upper == b.upper;
}

Range operator&& (Range a, Range b) {
  if( a.upper < b.lower ) return nullWindow;
  if( a.lower > b.upper ) return nullWindow;
  if( a.lower != -(1<<27) ) {
    if( (a.lower + b.lower) % 2 == 1 ) return nullWindow;
    if( (a.upper + b.upper) % 2 == 1 ) return nullWindow;
  }
  return Range(std::max(a.lower, b.lower), std::min(a.upper, b.upper));
}

std::vector<Edge> edges[112345];
std::vector<Edge> alledges;
int n, k;
int num[112345];
Range range[112345];

void fillRange(int i, Range nowRange) {
  Range tempRange = range[i] and nowRange;
  if( range[i] == tempRange ) return;
  range[i] = range[i] and nowRange;
  for(Edge edge : edges[i]) {
    if( num[edge.to] != -(1<<28) ) continue;
    fillRange(edge.to, Range(nowRange.lower - 1, nowRange.upper + 1));
  }
}

bool ansIsNo() {
  for(int i = 1; i <= n; ++i) {
    // printf("%d : [%d, %d]\n", i, range[i].lower, range[i].upper);
    if( range[i] == nullWindow ) return true;
    if( (range[i].upper + range[i].lower) % 2 == 1 ) return true;
  }
  for(Edge edge : alledges) {
    if( num[edge.from] != -(1<<28) and num[edge.to] != -(1<<28) ) {
      if( std::abs( num[edge.from] - num[edge.to] ) != 1 ) return true;
    }
  }
  return false;
}

int main() {
  for(int i = 0; i < 112345; ++i) num[i] = -(1<<28);

  scanf("%d", &n);
  for(int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    edges[a].push_back(Edge(a, b));
    edges[b].push_back(Edge(b, a));
    alledges.push_back(Edge(a, b));
  }
  scanf("%d", &k);
  for(int i = 0; i < k; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    num[a] = b;
  }

  // step 1
  for(int i = 1; i <= n; ++i) {
    if( num[i] != -(1<<28) ) {
      fillRange(i, Range(num[i], num[i]));
    }
  }
  if( ansIsNo() ) {
    printf("No\n");
    return 0;
  }
  else {
    printf("Yes\n");
  }

  // step 2
  for(int i = 1; i <= n; ++i) {
    printf("%d\n", range[i].lower);
  }
  
  return 0;
}


Measured memory_bytes: 11380
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) {
    string s,t;
    cin>>s>>t;
    ll n1=s.length(),n2=t.length(),i,j;
    ll ans=n2;
    for(i=0;i<=n1-n2;i++) {
        ll c=0;
        for(j=0;j<n2;j++) {
            if(s[i+j]!=t[j])
                ++c;
        }
        ans=min(ans,c);
    }
    cout<<ans;
}
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    char a[101][101];
int    k=0,n=0,i,h,w,j,flag;
    scanf("%d%d\n",&h,&w);
    for(i=0;i<h;i++){
            scanf("%s",a[i]);
        }
    for(i=0;i<h;i++){
        k=0;
        for(j=0;j<w;j++){
            if(a[i][j]=='.'){
                k+=1;
            }
            }if(k==w){
                
        for(j=0;j<w;j++){
            a[i][j]='b';
        }
       
      }
       
    }
        
     for(j=0;j<w;j++){
         n=0;
        for(i=0;i<h;i++){
            if(a[i][j]=='.'||a[i][j]=='b'){
                n+=1;
            }
        }
        if(n==h){
            for(i=0;i<h;i++){
            a[i][j]='b';
        }
        
     }
        
     }
    for(i=0;i<h;i++){
        flag=0;
        for(j=0;j<w;j++){
            if(a[i][j]!='b'){
            printf("%c",a[i][j]);
            flag=1;
            }
        }
        if(flag==1){printf("\n");}
    }

    return 0;
}




Measured memory_bytes: 128
vals = [int(i) for i in input().split()]
a = vals[0]
b = vals[1]
c = vals[2]
d = vals[3]
res2 = a//d + (1 if(a % d > 0) else 0)
res1 = c//b + (1 if(c % b > 0) else 0)
res = "Yes" if(res1 <= res2) else "No"
print(res)

Measured memory_bytes: 9196
#define A for(i=0;i<k;i++)t*=2
main(a,b,c,k,i,t,s){scanf("%d%d%d%d",&a,&b,&c,&k);t=a;A;s=t+b+c;t=b;A;s<t+a+c?s=t+a+c:0;t=c;A;s<t+a+b?s=t+a+b:0;printf("%d",s);}

Measured memory_bytes: 128
object Main {

  def main(args: Array[String]): Unit = {
    val input = io.StdIn.readLine().split(" ")
    val inputList: Array[Int] = input.map(_.toInt)
    val answer = solve(inputList(0), inputList(1), inputList(2))
    println(answer.toString)
  }

  private def solve(a: Int, b: Int, c: Int): Int = {
    if (c - (a - b) <= 0) 0
    else c - (a - b)
  }

}

Measured memory_bytes: 25532
N=int(input())
L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])

D={}
for i in range(N):
    for j in range(N):
        D[(L[i][0]-L[j][0],L[i][1]-L[j][1])]=1
#print(D)

ANS=N

for i in D.keys():
    cnt=0
    for j in range(len(L)):
        for k in range(len(L)):
            if j==k:
                continue
            elif i[0]==(L[j][0]-L[k][0]) and i[1]==(L[j][1]-L[k][1]):
                cnt+=1
    ANS=min(ANS,N-cnt)
print(ANS)

Measured memory_bytes: 42220
import sys
from itertools import permutations
input = sys.stdin.buffer.readline
inf = float('inf')

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
adj = [[inf for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    a, b, c = map(int, input().split())
    adj[a][b] = c
    adj[b][a] = c

for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j])

ans = inf
for r_list in permutations(r):
    ans_new = 0
    for i in range(R-1):
        ans_new += adj[r_list[i]][r_list[i+1]]
    ans = min(ans, ans_new)

print(ans)


Measured memory_bytes: 68572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Painting_problem
{
    class Program
    {
        static int height = 0;
        static int width = 0;
        static int[,] datas = new int[51, 51];
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            try
            {
                height = Int32.Parse(input.Split(' ')[0]);
                width = Int32.Parse(input.Split(' ')[1]);
            
                for (int i = 0; i < height; i++)
                {
                    input = Console.ReadLine();
                    for (int j = 0; j < width; j++)
                    {
                        if (input[j].Equals('#'))
                        {
                            datas[i, j] = 1;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("形式エラー");
                Console.ReadLine();
                return;
            }
            //Paint
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (!PaintOut(i, j))
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }

        static Boolean PaintOut(int x, int y)
        {
            if (datas[x,y] == 1)
            {
                bool isSuccess = false;
                if (x > 0)
                {
                    isSuccess = isSuccess || datas[x - 1, y] != 0;
                }
                if (y > 0)
                {
                    isSuccess = isSuccess || datas[x, y - 1] != 0;
                }
                isSuccess = isSuccess || datas[x + 1, y] != 0;
                isSuccess = isSuccess || datas[x, y + 1] != 0;
                return isSuccess;
            }
            return true;
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,m,x,y,cnt,tot,eg,hd[MAXN],ver[2*MAXN],nx[2*MAXN],in[MAXN],vis[MAXN];
void add_edge (int x,int y) {
	ver[++eg]=y;
	nx[eg]=hd[x];
	hd[x]=eg,in[y]++;
	return;
}
void dfs (int x) {
	tot++,vis[x]=1;
	for (int i=hd[x];i;i=nx[i]) {
		if (vis[ver[i]]) {continue;}
		dfs(ver[i]);
	}
	return;
} 
int main () {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&x,&y);
		add_edge(x,y),add_edge(y,x);
	}
	for (int i=1;i<=n;i++) {
		if (in[i]&1) {printf("No\n");return 0;}
	}
	for (int i=1;i<=n;i++) {
		if (in[i]>=6) {printf("Yes\n");return 0;}
	}
	for (int i=1;i<=n;i++) {
		if (in[i]==4) {y=i,cnt++;}
	}
	if (cnt>=3) {printf("Yes\n");return 0;}
	if (cnt<=1) {printf("No\n");return 0;}
	vis[y]=1;
	dfs(y==1?2:1);
	if (tot==n-1) {printf("No\n");return 0;}
	else {printf("Yes\n");return 0;}
	return 0;
}

Measured memory_bytes: 3584