akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=3005,mod=1000000007;
typedef long long LL;
const LL inv2=(mod+1)/2;
int n,m,a[N];
struct data{int x,y;} dat[N];
LL f[N][N],g[N][N],A,ans;

int getint()
{	
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void inc(LL &x,LL y)
{
	x=(x+y)*inv2%mod;
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,n) a[i]=getint();
	rep(i,1,m) dat[i].x=getint(),dat[i].y=getint();
	rep(i,1,n) rep(j,1,i-1) f[i][j]=1;
	A=1;
	repd(i,m,1)
	{
		int x=dat[i].x,y=dat[i].y;
		rep(j,1,n)
		{
			g[x][j]=f[x][j];
			g[y][j]=f[y][j];
			g[j][x]=f[j][x];
			g[j][y]=f[j][y];
		}
		rep(j,1,n) if(j!=x && j!=y)
		{
			inc(f[y][j],g[x][j]),inc(f[j][y],g[j][x]);
			inc(f[x][j],g[y][j]),inc(f[j][x],g[j][y]);
		}
		inc(f[x][y],g[y][x]),inc(f[y][x],g[x][y]);
		A=A*2%mod;
	}
	rep(i,1,n) rep(j,1,n) if(a[i]<a[j]) ans=(ans+f[i][j])%mod;
	printf("%lld\n",ans*A%mod);
	return 0;
}

Measured memory_bytes: 142464
n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))


def count_steps(NN):

    steps = [0] * (NN + 3)
    steps[1] = 1
    steps[2] = 2
    for i in range(3, NN + 1):
        steps[i] = steps[i - 1] + steps[i - 2]
    return steps[NN]

if m == 0:
    ans = count_steps(n)
else:
    if a[0] == 1:
        ans = 1
    else:
        ans = count_steps(a[0] - 1)

    for i in range(1, len(a)):
        temp = a[i] - a[i - 1] - 2
        if temp < 0:
            ans = 0
        elif temp == 0:
            ans *= 1
        else:
            ans *= count_steps(temp)

    temp = n - a[-1] - 1
    if temp > 0:
        ans *= count_steps(temp)
print(ans%1000000007)

Measured memory_bytes: 460020
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    for(int i=0; i<N; i++) scanf("%lld", &A[i]);

    ll X = 0;
    for(int i=0; i<N; i+=2) {
        X ^= (A[i] ^ A[i+1]);
    }

    for(int i=0; i<N; i++) printf("%lld%c", A[i] ^ X, " \n"[i + 1 == N]);
    return 0;
}


Measured memory_bytes: 4856
#include <stdio.h>

struct dataset{
	int a, b;
	int num_digits;
};

int main(){
	dataset data[200];
	int i, j, sum;

	i = 0;
	do{
		if(scanf("%d %d", &data[i].a, &data[i].b) == EOF) break;
		else i += 1;

		sum = data[i-1].a + data[i-1].b;
		data[i-1].num_digits = 0;
		do{
			data[i-1].num_digits += 1;
			sum /= 10;
		}while(sum != 0);
	}while(i < 200);

	for(j = 0; j < i; j++) printf("%d\n", data[j].num_digits);

	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		
		long d = c - a - b;
		if (d > 0 && d * d > 4 * a * b)
			System.out.println("Yes");
		else
			System.out.println("No");
		
		sc.close();
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=S.size(),flag=1;
  
  string sample;
  for(int i=0;i<7;i++){
    sample=S.substr(0,i)+S.substr(N-7+i);
    if(sample=="keyence")flag=0;
  }
  if(S.substr(0,7)=="keyence")flag==0;
  if(flag==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    int r = in.read<int>();

    out << r * r * 3;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,K;

int main(){
    cin>>N>>K;
    if(K==1)out(0);
    else out(N-K);
    
    
    
}


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

namespace Miscelleneous {
   class Program {
      public static int cin() { return int.Parse(Console.ReadLine()); }
      public static int[] cins() {
         string s = Console.ReadLine();
         if (string.IsNullOrEmpty(s)) return new int[]{ };
         string[] ss = s.Split(',');
         int[] Res = new int[ss.Length];
         for (int i = 0; i<ss.Length; i++) Res[i]=int.Parse(ss[i]);
         return Res;
      }
      public static void print(object s) { Console.WriteLine(s.ToString()); }
      static void Main(string[] args) {
         int[] I,S=new int[11];
         int L;
         int mc, mm;
         int Res;
         while (true) {
            I=cins();
            if (I.Length==0) break;
            L=I.Take(10).Sum();
            mm=I[10]+I[11];
            mc=L*I[10];
            S[0]=0;
            Res=10;
            for (int i = 1; i<11; i++) {
               S[i]=S[i-1]+I[i-1]*mm;
               if (S[i]>=mc) { Res=i; break; }
            }
            print(Res);
         }
      }
   }
}

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int mod=1000000007;
    int n,ans=0;
    char s[55];
    scanf("%d",&n);
    scanf("%s",s);
    for (int i=0;i<n;i++) if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int a[n];
    long long int temp1,temp2;
    long long int res=1;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }}
    for(int i=0;i<n;i++){
        
        if(a[i]>1000000000000000000/res){
            cout << -1 << endl;
            return 0;
        }
        res*=a[i];
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;

const int N = 1e5 + 5;
int ans[N][3];
int arr[N][3];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    for(int i = 0; i < 3; i++)
    {
        ans[0][i] = arr[0][i];
    }
    for(int i = 1; i < n; i++)
    {
        ans[i][0] = max(ans[i - 1][1], ans[i - 1][2]) + arr[i][0];
        ans[i][1] = max(ans[i - 1][0], ans[i - 1][2]) + arr[i][1];
        ans[i][2] = max(ans[i - 1][0], ans[i - 1][1]) + arr[i][2];
    }
    cout << max(max(ans[n - 1][0], ans[n - 1][1]), ans[n - 1][2]);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,n,ans,sum,x,y,temp,diff,t,T,c,test=0,min=10000000;
    vector<long long int>v,v1;
    cin>>n>>T;
    for(i=0; i<n; i++)
    {
        cin>>x>>y;
        v.push_back(x);
        v1.push_back(y);
    }
    for(i=0; i<v1.size(); i++)
    {
        if(v1[i]<=T)
        {
            test=1;
            break;
        }
    }
    if(test==0)
    {
        cout<<"TLE"<<endl;
    }
    else
    {

        for(i=0; i<v1.size(); i++)
        {
            if(v1[i]>T)
            {
                v1[i]=-1;
            }
        }
    for(i=0; i<v.size();i++)
    {
        if(v[i]<min&&v1[i]!=-1)
        {
            min=v[i];
        }
    }
    cout<<min<<endl;
}
}


Measured memory_bytes: 256
#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() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (10 % p == 0) {  // 2,5
    ll ans = 0;
    rep(r, n) {
      if ((s[r] - '0') % p == 0) {
        ans += r + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<int> d(n + 1);
  int ten = 1;
  for (int i = n - 1; i >= 0; --i) {
    int a = (s[i] - '0') * ten % p;
    d[i] = (d[i + 1] + a) % p;
    ten *= 10;
    ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1412
#include <stdio.h>

int main()
{
    int h,w,i,j,cnt = 0;
    char a[9][9];

    scanf("%d %d",&h,&w);

    for (i = 0; i < h; i++)
    {
        scanf("%s",a[i]);
    }

    for (i = 0; i < h; i++)
    {
        for (j = 0; j < w; j++)
        {
            if(a[i][j] == '#')cnt++;
        }
    }
    
    if(cnt == h + w - 1)printf("Possible");
    else printf("Impossible");
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost
    char c, d;
    cin >> c;
    d = c + 1;
    cout << d << nl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

ll memo[100];

ll lucas(int n){
    if(memo[n]) return memo[n];
    if(n==0) return 2;
    if(n==1) return 1;
    return memo[n] = lucas(n-1) + lucas(n-2);
}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n;cin>>n;
    cout << lucas(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define db(...) " [" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "] "
using ii=long long;
const int N = 1<<17;
int A[N], B[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        B[A[i]] = i;
    }
    for (int i = 1; i <= n; ++i) {
        cout << B[i] << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,y,z,a,b,c;
    scanf("%d%d%d",&x,&y,&z);
    a=x+y;
    b=z/2;
    c=a*b;
    printf("%d",c);
    return 0;
}


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

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

  cout << (K / 2) * ((K + 1) / 2) << endl;
  return 0;
}

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

const int N=500100;
int f[N],g[N],n,ans;
char s[N],t[N];
void mp(char*s,int*f){
	f[0]=-1;
	for(int i=1,j=0;i<n;f[++i]=++j)
		for(;~j&&s[i]!=s[j];j=f[j]);
}

bool chk(int x,int*f){return !f[x]||x%(x-f[x]);}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;n=strlen(s);
	for(int i=0;i<n;++i)t[i]=s[n-i-1];
	mp(s,f);mp(t,g);
	int all_same=1;
	for(int i=1;i<n;++i)if(s[i]!=s[0])all_same=0;
	if(all_same){
		cout<<n<<'\n'<<1<<'\n';
		return 0;
	}
	if(chk(n,f)){
		cout<<1<<'\n'<<1<<'\n';
		return 0;
	}
	for(int i=0;i<n;++i)
		if(chk(i+1,f)&&chk(n-i-1,g))++ans;
	cout<<2<<'\n'<<ans<<'\n';
	return 0;
}


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


int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++) cin>>p.at(i);
  
  bool ans=true;
  
  for(int i=0;i<N;i++){
    if(p.at(i)%2==0){
      if(p.at(i)%3==0 || p.at(i)%5==0) ans=true;
      else {
        ans=false;
        break;
      }
    }
  }
  if(ans) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  

}



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;
const int INF = 1e9;

int main() {
  ll n, h, ans = 0, tot = 0;
  cin >> h >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i], tot += a[i];

  cout << (h - tot <= 0 ? "Yes" : "No") << endl;
  return 0;
}


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

int main()
{
	queue<int> list;
	int i, j;
	int a, b;
	char c;

	while ( ( c = cin.get() ) != EOF ) {
		while( !list.empty() )
			list.pop();
		list.push(c-'0');
		for (i = 1; i < 10; i++)
			list.push(cin.get()-'0');
		cin.ignore(0xFF, '\n');
		i = 1;
		j = 10;
		while (list.size() > 1) {
			a = list.front();
			list.pop();
			b = list.front();
			if (++i == j) {
				list.pop();
				i = 1;
				j--;
			}
			list.push( (a+b)%10 );
		}
		cout<<list.front()<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
//クラスカル法
//辺のコストが小さい順に貪欲に選んでいく
//両端がすでに連結である場合はだめ
// O(E log E + E)
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp


#include<bits/stdc++.h>
using namespace std;

struct UnionFind{

    vector<int> par;     //par[i] := iの親の番号

    //最初は全てが寝であるとして初期化
    UnionFind(int n) : par(n){
        for(int i = 0; i < n; i++) par[i] = i;
    }

    //データ x が属する木の根を再帰で得る : root(x) = {x の木の根}
    int root(int x){
        if(par[x] == x) return x;
        return root(par[x]);
    }

    //x と y の木を併合
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }

    //x と y のが属する木が同じか
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

struct info{
    int s, t, w;
    info(){}
    info(int s, int t, int w):s(s),t(t),w(w){}
    bool operator<(const info &a) const{
        return w < a.w;
    }
    bool operator>(const info &a) const{
        return w > a.w;
    }
};

int main(){

    int v, e; cin >> v >> e;
    UnionFind unionfind(v);
    vector<info> edge;
    for(int i = 0; i < e; i++){
        int s, t, w; cin >> s >> t >> w;
        edge.push_back(info(s, t, w));
    }

    sort(edge.begin(), edge.end());

    int ans = 0;
    for(auto x : edge){
        if(!unionfind.same(x.s, x.t)){
            ans += x.w;
            unionfind.unite(x.s, x.t);
        }
    }

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



Measured memory_bytes: 4544
num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: 
      count += 1
    else: 
      smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Measured memory_bytes: 25768
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

class P
{
public:
  double x,y;
  P(){};P(double x,double y):x(x),y(y){};
  P operator+(const P&q){P t;t.x=x+q.x;t.y=y+q.y;return t;}
  P operator+=(const P&q){x+=q.x;y+=q.y;return *this;}
  P operator-(const P&q){P t;t.x=x-q.x;t.y=y-q.y;return t;}
  P operator-=(const P&q){x-=q.x;y-=q.y;return *this;}
  template<typename T> P operator*(T d){return P(x*d,y*d);}
  template<typename T> P operator*=(T d){x*=d;y*=d;return *this;}
  template<typename T> P operator/(T d){return P(x/d,y/d);}
  template<typename T> P operator/=(T d){x/=d;y/=d;return *this;}
  bool operator<(const P&q){return (x!=q.x)?(x<q.x):(y<q.y);}
  bool operator>(const P&q){return (x!=q.x)?(x>q.x):(y>q.y);}
  double norm(void){return sqrt(x*x+y*y);}
  double arg(void){return acos(x/this->norm())*P(1,0).sign(*this);}
  P nvec(){return P(y,-x);}
  P rotate(double t){double c=cos(t),s=sin(t);return P(c*x-s*y,s*x+c*y);}
  P reverseX(void){return P(-x,y);}
  P reverseY(void){return P(x,-y);}
  P unit(void){return (*this).norm()==0?P(0,0):(*this)/(*this).norm();}
  P floor(void){return P((int)x,(int)y);}
  double dot(const P&q){return x*q.x+y*q.y;}
  double det(const P&q){return x*q.y-y*q.x;}
  int sign(const P&q){double d = (*this).det(q); return (d>0)-(d<0);}
  static bool on_seg(P p1,P p2,P q){return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;}
  static P intersection(P p1,P p2,P q1,P q2){return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));}
};


int main()
{
  double x0,y0,x1,y1; cin>>x0>>y0>>x1>>y1;
  P p0 = P(x0,y0);
  P p1 = P(x1,y1);
  int q; cin >> q;
  REP(i,q)
  {
    double x,y; cin>>x>>y;
    P p2 = P(x,y);
    string str;
    int s = (p1-p0).sign(p2-p0);
    if(s>0) str = "COUNTER_CLOCKWISE";
    else if(s<0) str = "CLOCKWISE";
    else
    {
      if(P::on_seg(p0,p1,p2)) str = "ON_SEGMENT";
      else if(P::on_seg(p0,p2,p1)) str = "ONLINE_FRONT";
      else str = "ONLINE_BACK";
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 3256
#include <queue>
#include <cmath>
#include <list>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

bool check(const list<int> &lst){
  vector<int> v(lst.begin(), lst.end());
  REP(i,v.size()) if(i + 1 != v[i]) return false;
  return true;
}

int main(){
  while(const int n = getInt()){
    list<int> v;
    REP(i,n) v.push_back(getInt());

    if(check(v)){
      puts("0");
      continue;
    }
    REP(i,10000){
      int cnt = 0;

      for(list<int>::iterator it = v.begin();
          it != v.end();){
        cnt++;

        if(*it == 1){
          it = v.erase(it);
        }else{
          --*it++;
        }
      }

      v.push_back(cnt);

      if(check(v)){
        printf("%d\n", i + 1);
        goto end;
      }
    }
    puts("-1");
  end:;
  }
  return 0;
}

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

int main(){
  int N;cin>>N;
  int X[101];
  ll ans=M;
  rep(i,N) cin>>X[i];
  
  rep(i,100){
    ll cnt=0;
    rep(j,N){
      cnt+=(i-X[j])*(i-X[j]);
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ?"Yes":"No") << '\n';
}


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

int main() {
  int n;
  cin >> n;
  int ans = 1;
  while (n != 0) {
    n /= 2;
    ans *= 2;
  }
  cout << ans/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);
    vector<ll> L(N * 2);
    for (ll i = 0; i < N * 2; i++)
        scanf("%lld", &L[i]);

    sort(L.begin(), L.end());

    ll sum1 = 0, sum2 = L[0];
    for (ll i = 1; i < N * 2; i += 2)
    {
        sum1 += L[i - 1];
    }
    ll ans = 0;

    printf("%lld\n", max(sum1, sum2));
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        //Scanner scanner = new Scanner(System.in);
        String str = scanner.readLine();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        Integer n = Integer.parseInt(scanner.readLine());
        LinkedList<Character> list = new LinkedList<>();
        for (char ch : str.toCharArray())
            list.add(ch);
        boolean isR = false;
        for (int i = 0; i < n; i ++){
            String[] s1 = scanner.readLine().split(" ");
            if (s1[0].equals("1"))
                isR = !isR;
            else if (s1[0].equals("2")){
                if (s1[1].equals("1")){
                    if (isR)
                        list.add(s1[2].charAt(0));
                    else
                        list.addFirst(s1[2].charAt(0));
                }
                else if (s1[1].equals("2")){
                    if (isR)
                        list.addFirst(s1[2].charAt(0));
                    else
                        list.add(s1[2].charAt(0));
                }
            }
        }
        scanner.close();
        StringBuffer stringBuffer = new StringBuffer();
        for (char ch : list)
            stringBuffer.append(ch);
        if (isR) out.println(stringBuffer.reverse());
        else out.println(stringBuffer);
        out.flush();
    }
}


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

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

    vector<vector<int>> A(N, vector<int>(M));
    for (vector<int> &row : A)
    {
        for (int &a : row)
        {
            cin >> a;
            a--;
        }
    }

    int ans = N;
    vector<bool> hold(M, true);
    for (int i = 0; i < M; i++)
    {
        vector<int> count(M, 0);
        int tmp = 0;
        int next = N;
        for (int j = 0; j < N; j++)
        {
            for (int k = 0; k < M; k++)
            {
                int sport = A[j][k];
                if (hold[sport])
                {
                    count[sport]++;
                    break;
                }
            }
        }
        for (int j = 0; j < M; j++)
        {
            if (tmp < count[j])
            {
                tmp = count[j];
                next = j;
            }
        }
        ans = min(ans, tmp);
        hold[next] = false;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 a, b;
  std::cin >> a >> b;
  std::cout << a - (b < a ? 1 : 0) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<P> prime2;
    vector<P> prime1;
    
    int now=a[0]; int p1l=0;
    for(int i=2; i<=(int)sqrt(a[0])+1; i++){
        if(now%i==0){
            prime1.push_back(P(i,1));
            now/=i;
            p1l++;
        }
        while(now%i==0){
            prime1[p1l-1].second++;
            now/=i;
        }
    }
    if(now!=1) prime1.push_back(P(now,1));

    now=a[1]; int p2l=0;
    for(int i=2; i<=(int)sqrt(a[1])+1; i++){
        if(now%i==0){
            prime2.push_back(P(i,1));
            now/=i;
            p2l++;
        }
        while(now%i==0){
            prime2[p2l-1].second++;
            now/=i;
        }
    }
    if(now!=1) prime1.push_back(P(now,1));

    int pl=prime1.size();
    rep(i,prime2.size()){
        bool ex=false;
        rep(j,pl){
            if(prime2[i].first==prime1[j].first){
                prime1[j].second=max(prime1[j].second,prime2[i].second);
                ex=true;
                break;
            }
        }
        if(ex==false) prime1.push_back(prime2[i]);
    }

    vector<int> primes;
    rep(i,prime1.size()){
        rep(j,prime1[i].second) primes.push_back(prime1[i].first);
    }
    sort(all(primes));
    int prl=primes.size();
   //rep(i,prl) cout << primes[i] << endl;
    vector<int> check(prl,-1);
    rep(i,n){
        rep(j,prl){
            if(a[i]%primes[j]==0) a[i]/=primes[j];
            else if(check[j]==-1) check[j]=i;
            else check[j]=-2;
        }
    }

    int ans=1;
    rep(i,check.size()){
        if(check[i]==-1) ans*=primes[i];
    }
    int fac=1;
    rep(j,n){
        int tmp=1;
  	    rep(i,check.size()){
            if(check[i]==j) tmp*=primes[i];
        }
        fac=max(fac,tmp);
    }

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

//rate1379

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     MOD 1000000007
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;

// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll ans = 1;
    x%=m;
    while(y){
        if(y&1){
            ans=(ans*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return ans;
}

ll power(ll x, ll y){
    ll ans = 1;
    while(y){
        if(y&1){
            ans*=x;
        }
        y>>=1;
        x = x*x;
    }
    return ans;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}


// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    if(a.ff == b.ff){
        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

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


void solve(){
    ll n;
    cin>>n;
    vll v(n,0);
    map<ll,ll> mp,mp1;
    REP(i,n){
        cin>>v[i];
        mp[v[i]]++;
    }
    ll total = 0;
    for(auto item:mp){
        ll val = item.ss * (item.ss - 1)/2;
        mp1[item.ff] = val;
        total+=val;
    }
    // cout<<"to"<<total<<endl;
    REP(i,n){
        // total -= mp[v[i]];
        ll val = mp[v[i]]-1;
        ll ans = total - (mp1[v[i]]) + (val*(val-1))/2 ;
        cout<<ans<<endl;
    }

}


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


    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  VI xs(N);
  VI ys(M);
  cin >> xs >> ys;
  SORT(xs);
  SORT(ys);

  int z = max(X+1, xs.back()+1);
  bool ok = true;
  ok &= z <= ys[0] && z <= Y;

  cout << (ok ? "No War" : "War") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, a;
string s;

int main()
{
    cin >> N;
    vector<pair<string, pair<int, int>>> v;
    for (int i = 0; i < N; i++)
    {
        cin >> s >> a;
        auto p = make_pair(-1 * a, i);
        v.emplace_back(s, p);
    }
    sort(v.begin(), v.end());
    vector<int> ans(N);
    for (int i = 0; i < N; i++)
    {
        //cout << v[i].first << endl;
        ans[i] = v[i].second.second + 1;
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int A, B, C, D;
int imos[150];

signed main()
{
    string N;
    
    cin >> N;
    if (N.find('9') == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	char c;
	cin>>c;
	if(c-'a'<0) cout<<"A"<<endl;
	else cout<<"a"<<endl;
}		

Measured memory_bytes: 7024
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int A = NextInt();
        int B = NextInt();
        List<long> v = Enumerable.Range(0, N).Select(x => NextLong()).OrderByDescending(x => x).ToList();

        double ave = v.Take(A).Sum() / (A + .0);
        long n = v.Count(x => x == v[A - 1]);
        long ans = 0;
        if (v.Take(A).ToList().All(x => x == v[0]))
        {
            for (int i = A; i <= n && i <= B;i++) ans += nCr(n, i);
        }
        else
        {
            //そうでないならやりくりするしかない
            int count = 0;
            while (count < A && v[count] != v[A - 1]) count++;
            ans = nCr(n, A - count);
        }



        Console.WriteLine(ave.ToString("F30"));
        Console.WriteLine(ans);
    }
    public static long nCr(long n, long r)
    {
        long a = 1;
        long b = 1;
        for (long k = 0; k < r; k++)
        {
            a *= (n - k);
            b *= (k + 1);
            if (a % b == 0) { a /= b; b = 1; }
        }
        return (a / b);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    string s;cin >> s;
    for (int i = 0; i < 3; i++) {
        cout << (s[i]=='1'?9:1); 
    }
    cout << "\n";
    return 0;
}



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

#define pb push_back
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define beg begin()
#define en end()
#define rbeg rbegin()
#define ren rend()
#define sz size()
#define mem(a,b) memset(a,b,sizeof a)
#define mem0(a) memset(a,0,sizeof a)
#define mem1(a) memset(a,1,sizeof a)
#define memm(a) memset(a,-1,sizeof a)


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
//~ const int tam=1000;
const int inf=(int)1e9;

bool square(int x){
	int res=sqrt(x);
	if(res*res==x){
		return true;
	}
	++res;
	if(res*res==x){
		return true;
	}
	
	return false;
	
}


int main(){
	ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	auto val=a+b;
	int res = stoi(val);
	
	if(square(res)){
		cout<<"Yes";
	}else cout<<"No";
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PI 3.14159265358979
		#define EPS 1e-8
		#define mod  998244353
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"
			 
		const ll INF=1e15;	
		const int N=2e5+50;
		 

		 
		long long binpow(long long a, long long b, long long m) {
			a %= m;
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = res * a % m;
				a = a * a % m;
				b >>= 1;
			}
			return res;
		}
		
		ll modinverse(ll a,ll m)
		{
			return binpow(a,m-2,m);
		}
		
			
		
		
		int main()
		{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);cout.tie(0);
		
					
			ll h,w,n;
			cin>>h>>w>>n;
			
			ll r,c;
			cin>>r>>c;
			
			
			string s,t;
			
			ll l1=c,r1=c,u1=r,d1=r;
			ll l2=0,r2=0,u2=0,d2=0;
			
			ll f=1;
			
			cin>>s;
			cin>>t;
			for(ll i=0;i<s.length();i++)
			{
				if(s[i]=='D')
				{
					if(!u2)
						d1++;
					else
						u2--;
				}
				else if(s[i]=='R')
				{
					if(!l2)
						r1++;
					else
						l2--;
				}
				else if(s[i]=='L')
				{
					if(!r2)
						l1--;
					else
						r2--;
					
				}
				else
				{
					if(!d2)
						u1--;
					else
						d2--;
				}
				
				if(l1<=0 || u1<=0)
					f=0;
			
				if(d1>h || r1>w)
					f=0;
					
				if(t[i]=='D')
				{
					if(u1==r)
						d2++;
					else
						u1++;
					
					d2=min(d2,h-r);
				}
				else if(t[i]=='R')
				{
					if(l1==c)
						r2++;
					else
						l1++;
						
					r2=min(r2,w-c);
				}
				else if(t[i]=='L')
				{
					if(r1==c)
						l2++;
					else
						r1--;
						
					l2=min(l2,c-1);
				}
				else
				{
					if(d1==r)
						u2++;
					else
						d1--;
					
					u2=min(u2,r-1);
				}
			
			
			
			}
			
			if(f)
				cout<<"YES\n";
			else
				cout<<"NO\n";
		}
			
			
		


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

int n,c;
long long dp[100005];

 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>c;
	memset(dp,0x7f,sizeof dp);
	dp[0] = 0;
	
	for(int i=0;i<n;i++){
		int w,v;
		cin>>w>>v;
		for(int j=1e5;j>=v;j--){
			dp[j] = min(dp[j],dp[j-v]+w);
		}
	}
	
	long long ans = 0;
	for(int i=1;i<=1e5;i++){
		if(dp[i] <= c) ans = i;
	}
	
	cout<<ans;
	
	return 0;
}


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


int main() {
    int N; cin >> N;
    int p[N];
    for (int i=0; i<N; i++) cin >> p[i];
    sort(p,p+N);
    int sum = 0;
    for (int i=0;i<N;i++){
        if (i != N-1){
            sum += p[i];
        }
        else{
            sum += p[i]/2;
        }
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
//Contest ---Atcoder

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){

int n;

cin>>n;

int x,arr[100005];

for(int i=1;i<=n;i++){
   int x;
   cin>>x;
   arr[x]=i;
}
for(int i=1;i<=n;i++){
   cout<<arr[i]<<" ";
}
}

Measured memory_bytes: 1152
import numpy as np

a = [list(map(int, input().split(' '))) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
c = [[0 for i in range(3)] for j in range(3)]
f = False

for i in range(3):
	for j in range(3):
		if a[i][j] in b:
			c[i][j] = 1

for i in range(3):
	if c[i][0] + c[i][1] + c[i][2] == 3:
		f = True
		break
	elif c[0][i] + c[1][i] + c[2][i] == 3:
		f = True
		break
	elif c[2][0] + c[1][1] + c[0][2] == 3 or c[0][0] + c[1][1] + c[2][2] == 3:
		f = True
		break
if f:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 12264
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}

Measured memory_bytes: 256
def main():
  s = input().strip()
  if len(s) % 2 == 0:
    if s[0] == s[-1]:
      print('First')
    else:
      print('Second')
  else:
    if s[0] == s[-1]:
      print('Second')
    else:
      print('First')


if __name__ == '__main__':
  main()


Measured memory_bytes: 3316
N, M = tuple(int(i) for i in input().split(" "))
height = [int(i) for i in input().split(" ")]
road = []
for i in range(N):
    road.append([])
for i in range(M):
    temp = [int(j) - 1 for j in input().split(" ")]
    road[temp[0]].append(temp[1])
    road[temp[1]].append(temp[0])

goodH = [1 for i in range(N)]
ans = 0
for i in range(N):
    if goodH[i]:
        for j in road[i]:
            if height[i] > height[j]:
                goodH[j] = 0
            elif height[i] == height[j]:
                goodH[j] = 0
                goodH[i] = 0
                break
            else:
                goodH[i] = 0
                break
        else:
            ans += 1
print(ans)


Measured memory_bytes: 30156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    map<int,int> mp;
    rep(i,N) {
        int d; cin >> d;
        mp[d]++;
    }
    int M; cin >> M;
    bool flag = true;
    rep(i,M) {
        int t; cin >> t;
        if (mp[t] > 0) {
            mp[t]--;
        } else {
            flag = false;
            break;
        }
    }
    cout << (flag ? "YES" : "NO") << '\n';
    return 0;
}

Measured memory_bytes: 13004
n = int(input())
A = [int(input()) for _ in range(n)]

now = 0
cnt = 0
while A[now] != 2 and cnt <= n:
    now = A[now] - 1
    cnt += 1

if A[now] == 2:
    print(cnt + 1)
else:
    print(-1)


Measured memory_bytes: 12952
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    int ans = 0, N = S.size();
    for (int i = 0; i < N; i++) {
        int num = S[i] - '0';
        ans += num;
        ans %= 9;
    }
    if (ans == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3720