akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace task1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(par => int.Parse(par)).ToArray();

            int temp = input[0];
            input[0] = input[1];
            input[1] = temp;

            temp = input[0];
            input[0] =  input[2];
            input[2] = temp;

            foreach (var item in input)
            {
                Console.Write(item+" ");
            }
        }
    }
}


Measured memory_bytes: 13268
#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 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
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
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);

  string S;
  cin >> S;

  cout << ((S[0]==S[1]&&S[1]==S[2])||(S[3]==S[1]&&S[1]==S[2])? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

ll invcomb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f1[n] * f0[k] % P * f0[n - k] % P;
}

struct Graph {
    struct Vertex { int n; int r; };
    struct Edge { int i, n; int r; int k; };
    Graph(int n, int m) : v(n, { -1, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n, 0, 0 };
        v[i].n = m;
        m++;
    }
    int dfs(int i, int p) {
        int k = 1;
        int *pk = nullptr;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) {
                pk = &o.k;
                continue;
            }
            k += o.k = dfs(o.i, i);
        }
        if (pk) *pk = n - k;
        return k;
    }
    int dfs0(int i, int p, int k) {
        ll r = 1;
        k--;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;

            o.r = dfs0(o.i, i, o.k);
            r = r * o.r % P * comb(k, o.k) % P;
            k -= o.k;
        }
        return r;
    }
    void dfs1(int i, int p, ll r, ll r1) {
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) {
                o.r = r1;
                r = r * o.r % P * comb(n - 1, o.k) % P;
                break;
            }
        }
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;

            int r0 = r * inv(o.r) % P * invcomb(n - 1, o.k) % P;
            dfs1(o.i, i, o.r, r0);
        }
        v[i].r = r;
    }
    void solve() {
        dfs(0, -1);
        int r = dfs0(0, -1, n);
        dfs1(0, -1, r, -1);

        for (int i = 0; i < n; i++) {
            cout << v[i].r << '\n';
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    init(n);

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.solve();

    return 0;
}

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

int main() {
    while(true) {
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) return 0;
        for(int i = 0; i < a; i++) {
            for(int j = 0; j < b; j++) {
                if(i == 0 || j == 0 || i == a - 1 || j == b - 1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}






Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include <cmath>
using namespace std;
int a, b, c;
int main() {
    cin >> a >> b >> c;
    if(c<=b) cout << "delicious" << endl;
    else if(c<=a+b) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
import copy
from collections import Counter

N,A,B=map(int, raw_input().split())
v=map(int, raw_input().split())
v.sort()
v.reverse()
c=Counter(v)

def C(n,r):
	bunshi=1
	bunbo=1
	for i in range(n,n-r,-1):
		bunshi*=i
	for i in range(1,r+1):
		bunbo*=i
	return bunshi/bunbo

ans=0
if A<=c[v[0]]:
	high=c[v[0]]
	for i in range(A,B+1):
		if i<=high:
			n=c[v[0]]
			r=i
			ans+=C(n,r)
	print v[0]
	print ans
	quit()
else:
	cnt=0
	t_sum=0
	cur=-1
	for i in v:
		cnt+=c[i]
		t_sum+=i*c[i]
		if cnt==A:
			n=A
			r=A
			break
		if cnt>A:
			n=c[i]
			r=A-(cnt-c[i])
			t_sum=t_sum-i*c[i]+i*r
			break

	print float(t_sum)/float(A)
	print C(n,r)



Measured memory_bytes: 3184
N=int(input())
A=[]
max=0
count=0
point=0
for i in range(N):
    x=int(input())
    A.append(x)
    if x>max:
        max=x
        count=0

    if x==max:
        count+=1
        point=i

A.sort(reverse=True)
if count==0:
    for i in range(N):
        print(max)
else:
    for i in range(N):
        if i!=point:
            print(max)
        else:
            print(A[1])

            

Measured memory_bytes: 12532
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;

//10  100 20

int main(){
	int n;
	cin>>n;
	std::vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	std::vector<int> dp(n,INT_MAX);
	dp[0] = {0};

	for (int i = 0; i < n; ++i)
	{
		for (auto x:{i+1,i+2})
		{
			//cout<<dp[x] <<" "<<dp[i] << " "<<abs(h[i]- h[x])<<" "<<(dp[i]+abs(h[i]-h[x]))<<" ";
			dp[x] = min(dp[x], dp[i] + abs(h[i]-h[x]));
			//cout<<dp[x] <<" ";
		}
		//cout<<dp[i]<<" "<<endl;
	}

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

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		System.out.println(singleOccurence(sc.next()));
		
		
		
	}
	
	public static int singleOccurence(String s)
	{
		int sum = 1;
	    StringBuilder sb = new StringBuilder();
	    if (s.length() > 0) {
	        char prev = s.charAt(0);
	        sb.append(prev);
	        for (int i = 1; i < s.length(); ++i) {
	            char cur = s.charAt(i);
	            if (cur != prev) {
	                sb.append(cur);
	                prev = cur;
	                sum++;
	            }
	        }
	    }
	    return sum;
	}
}

Measured memory_bytes: 25772
def main():
    n,m=map(int,input().split())
    ls=[list(map(int,input().split())) for i in range(m)]
    ans=[-1]*n
    
    flag=True
    for i in ls:
        idx,value=i[0]-1,i[1]
        tgt=ans[idx]
        if tgt!=value and tgt!=-1:
            flag=False
            break
        else:
            ans[idx]=i[1]
    
    if flag:
        if ans[0]==0:
            if n==1:
                print(0)
            else:
                print(-1)
        else:
            for i in range(n):
                if ans[i]==-1:
                    if n==1 and m==0:
                        ans[i]=0
                    elif i == 0:
                        ans[i]=1
                    else:
                        ans[i]=0
            print(int("".join(list(map(str,ans)))))
    else:
        print(-1)
main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define st first
#define nd second
#define ii pair<int,int>
#define orta ((bas+son)>>1)
#define pb push_back
#define N 200005
#define LOG 22
#define ll long long
#define MOD 998244353
using namespace std;

int n,k;
int a[N],sr[N];
bool flag;

bool ch(int l,int r) {

	bool res=sr[r]>l;

	flag|=(!res);

	return res;

}

int main() {

	scanf("%d %d",&n,&k);

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

		scanf("%d",a+i);

	}

	sr[1]=1;

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

		if(a[i]>=a[i-1]) sr[i]=sr[i-1];
		else sr[i]=i;

	}

	int ptr=0;
	int cnt=ch(1,k);

	multiset<int> s;

	for(int i=1;i<=n-k+1;i++) {

		while(ptr+1<=i+k-1) {

			++ptr;

			s.insert(a[ptr]);

		}

		if(!(i+k<=n) || (a[i]==*s.begin() && a[i+k]>*s.rbegin()));
		else cnt+=ch(i+1,i+k);

		s.erase(s.find(a[i]));

	}

	printf("%d",cnt+flag);

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,arr[1000],sum=0,m,p,x;
     cin>>t;
     for(int i=1;i<=t;i++)
     {
         cin>>arr[i];
         sum+=arr[i];
     }
     cin>>m;
     for(int i=0;i<m;i++)
     {
         cin>>p>>x;
         cout<<sum-arr[p]+x<<endl;
     }
}



Measured memory_bytes: 256
import itertools
import math
n = int(input())
xy = [[int(j) for j in input().split()] for i in range(n)]
x = [i[0] for i in xy]
y = [i[1] for i in xy]
sum = 0
ps = list(itertools.permutations(range(n), n))
for i in ps:
    for j in range(len(i)-1):
        tmp = math.sqrt((x[i[j]] - x[i[j+1]]) ** 2 + (y[i[j]] - y[i[j+1]]) ** 2)
        sum += tmp
print(sum / len(ps))


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

ll A,B,C;

int main()
{
	cin >> A >> B >> C;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0 << endl;
	}
	else{
		cout << min({A * B,B * C,C * A}) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
char M[9];
int main(){
	int T,P,R,t,p,s,m,i;
	for(;scanf("%d%d%d",&T,&P,&R),R;){
		map<int,map<int,int> >z;
		for(i=0;i<R;i++){
			scanf("%d%d%d%s",&t,&p,&s,M);
			if(*M=='W')z[t][p]-=1;else z[t][p]=s-z[t][p]*1200;
		}
		vector<pair<int,pair<int,int> > >v;
		for(i=1;i<=T;i++){
			for(p=s=0,R=1;R<=P;R++)if(z[i][R]>0)p++,s+=z[i][R];
			v.push_back(make_pair(-p,make_pair(s,i)));
		}
		sort(v.begin(),v.end());
		for(i=0;i<T;i++)printf("%d %d %d\n",v[i].second.second,-v[i].first,v[i].second.first);
	}
}

Measured memory_bytes: 0
#include<iostream>
#define mod 1000000007
using namespace std;
typedef long long ll;

ll factorial[200005];
ll H, W, A, B;

void init() {
    factorial[0] = 1;
    for (ll i = 1; i <= H + W; i++) factorial[i] = i;
    for (ll i = 2; i <= H + W; i++) {
        factorial[i] = ((factorial[i] % mod) * (factorial[i - 1] % mod)) % mod;
    }
    return;
}

ll _pow(ll x, ll y) {
    ll ans = 1, z = x;
    while (y > 0) {
        if ((y & 1) == 1) {
            ans = ((ans % mod) * (z % mod)) % mod; 
        }
        z = ((z % mod) * (z % mod)) % mod;
        y /= 2;
    }
    return ans;
}

ll comb(ll x, ll y) {
    if (x == 0 || y == 0) return 1;
    ll div_num = ((factorial[x - y] % mod) * (factorial[y] % mod)) % mod;
    return (factorial[x] * (_pow(div_num, mod - 2) % mod)) % mod;
}

int main() {
    ll count = 0;
    cin >> H >> W >> A >> B;
    init();
    for (ll i = 1; i <= W - B; i++) {
        ll sub_count = comb(H - A + B + i - 2, H - A - 1);
        ll subsub_count = comb(A + W - B - i - 1, A - 1);
        count =  (count +  (((sub_count % mod) * (subsub_count % mod)) % mod)) % mod;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	int edge[3];	// ??\????????????
	int max = 0;	// ???????????§???????????????????????????
	int sum = 0;	// ??????????????????
    int num;    // ????????????????????°
	int i,j;
    
    cin >> num; // ????????????????????°??????????????????
	for (j=0; j<num; j++) {
        
        // input 3 edges.
        for( i=0;i<3 ;){
            cin >> edge[i];
            // ?????¶ : 0 <= ???????????? <= 1000
            if(edge[i] < 0  ||  edge[i] > 1000){
                continue;
            }
            i++;
        }
        
        // ?????????????????§????????????
        for(i=1,max=0;i<3;i++){
            if(edge[i] > edge[max]){	max = i;    }
        }
        
        // ??????????????????????±??????????
        for(i=0,sum=0 ;i<3;i++){
            if(i != max){	sum += edge[i] * edge[i];   }
		}
        
        // output
        if(edge[max] * edge[max] == sum){	cout << "YES\n";	}
        else{	cout << "NO\n";	}
	}
    
	return 0;
}

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

const int SIZE = 200000;
using ll = long long;
ll N;
ll all = 0;
vector<ll> colors(SIZE), cnt(SIZE, 0), sub(SIZE, 0), ans(SIZE, 0);
vector<vector<ll>> T(SIZE);

ll f(ll x){
    return x * (x-1) / 2;
}

ll dfs(int node = 0, int p = -1){
    sub[node] = 1;
    ll bfr = cnt[colors[node]];
    for (ll i : T[node]){
        if (i == p) continue;
        ll pre = all - cnt[colors[node]];
        sub[node] += dfs(i, node);
        ll next = all - cnt[colors[node]];
        ans[colors[node]] -= f(next - pre);
    }
    cnt[colors[node]] = bfr + sub[node];
    all++;
    return sub[node];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> colors[i];
        colors[i]--;
        ans[i] += f(N);
    }

    for (int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b;
        a--;b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    dfs();
    for (int color = 0; color < N; color++)
        ans[color] -= f(N-cnt[color]);
    for (int i = 0; i < N; i++) ans[colors[i]]++;
    for (int i = 0; i < N; i++) cout << ans[i] << endl;
    
}

Measured memory_bytes: 35872
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	if ((a + b) % 2 != 0)
	{
		cout<<"IMPOSSIBLE";
	}
	else
	{
		cout << (a + b) / 2;
	}
	return 0;
}


Measured memory_bytes: 256
W = int(input())
ary = list(range(1, W + 1))
N = int(input())
for i in range(N):
    x,y = map(int,input().split(','))
    ary[x - 1], ary[y - 1] = ary[y - 1], ary[x - 1]
for i in ary:
    print(i)

Measured memory_bytes: 7556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  if(N.at(0)=='7' || N.at(1)=='7' || N.at(2)=='7'){
    
    cout << "Yes" << endl;
    
  }
  
  else {
    
   cout << "No" << endl;  
    
  }
  
}

Measured memory_bytes: 3520
N = input()
A = int(input())
n = int(N)
x = 0

if n > 100:
    x = int(N[-3])
    if x >= 5:
        x = x - 5

y = int(N[-2])
z = int(N[-1])
X = x * 100 + (y * 10) + z

if n <= A or X <= A:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

const mod = int(1e9 + 7)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if abs(n-m) > 1 {
		fmt.Println(0)
		return
	}
	ans := 1
	for i := n; i >= 1; i-- {
		ans *= i
		ans %= mod
	}
	for i := m; i >= 1; i-- {
		ans *= i
		ans %= mod
	}
	if n == m {
		ans *= 2
		ans %= mod
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1772
#include "bits/stdc++.h"

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

using namespace std;

int main() {
	string S;
	cin >> S;
	map<string, int> days;
	days["SUN"] = 0;
	days["MON"] = 1;
	days["TUE"] = 2;
	days["WED"] = 3;
	days["THU"] = 4;
	days["FRI"] = 5;
	days["SAT"] = 6;

	cout << 7 - days[S];
}

Measured memory_bytes: 256
A, B = map(int,input().split())

int(A)
int(B)
sum = 0

for i in range(2):
    if A > B:
        sum = sum + A
        A =  A - 1
    elif A < B:
        sum = sum + B
        B = B - 1
    else:
        sum = sum + A

print(sum)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

string s;
int ans;
int main() {
    cin>>s;
    bool up=false;
    RREP(i,1,s.size()){
       if(s[i]-'0'<9 || up){
           up=true;
       }
        ans+=9;
    }
    if(up) ans+=s[0]-'0'-1;
    else ans+=s[0]-'0';
    p(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m,d;
  cin>>n>>m>>d;
  string str[n];
  for(int i=0;i<n;i++)
    cin>>str[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m-d+1;j++){
      int flag=1;
      for(int k=0;k<d;k++){
	if(str[i][j+k]=='#'){
	  flag=0;
	}
      }
      if(flag)
	ans++;
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n-d+1;j++){
      int flag=1;
      for(int k=0;k<d;k++){
	if(str[j+k][i]=='#'){
	  flag=0;
	}
      }
      if(flag)
	ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3176
#! env/bin/local python3
# -*- coding:utf-8 -*-

# -- submit ----

# --- fetch input ---
inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---
n, m = (int(i) for i in inputs[0].split())
heights = [int(h) for h in inputs[1].split()]
paths = [[int(p) for p in path.split()] for path in inputs[2:]]

tours = {n: h for n, h in zip(range(1, n+1), heights)}
tours_neighbor = {n: [] for n in range(1, n+1)}

for path in paths:
    tours_neighbor[path[0]].append(path[1])
    tours_neighbor[path[1]].append(path[0])

counter = 0
for tour, neighbor in tours_neighbor.items():

    checker = True

    for n in neighbor:
        if tours[tour] <= tours[n]:
            checker = False

    if checker:
        counter += 1

print(counter)


Measured memory_bytes: 68592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll a[2002][2002],b[2002][2002];
string s[2002];
int main() {
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<h;i++){
		ll cnt=0;
		for(int j=0;j<w;j++){
			if(s[i][j]!='#'){
				cnt++;
				a[i][j]=cnt;
			}
			else{
				cnt=0;
			}
		}
	}
	for(int i=0;i<w;i++){
		ll cnt =0;
		for(int j=0;j<h;j++){
			if(s[j][i]!='#'){
				cnt++;
				b[j][i]=cnt;
			}
			else{
				cnt=0;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=w-2;j>=0;j--){
			if(a[i][j]==0){
				continue;
			}
			a[i][j]=max(a[i][j],a[i][j+1]);
		}
	}
	for(int i=0;i<w;i++){
		for(int j=h-2;j>=0;j--){
			if(b[j][i]==0){
				continue;
			}
			b[j][i]=max(b[j][i],b[j+1][i]);
		}
	}
	ll ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ll now=a[i][j]+b[i][j]-1;
			ans=max(now,ans);
		}
	}
	cout <<ans;
}

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

typedef long long int ll;

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

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i,n) cin >> a[i];
  double s = 0;
  rep(i,n) s += a[i];
  s = s / n;
  int ans = 0;
  rep(i,n) {
    if (abs(s - a[ans]) > abs(s - a[i]) + 0.0001) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
int main()
{
	int a,b,x,y,z;
	while(scanf("%d%d",&a,&b),a)
	{
		b-=a;
		z=b/1000;
		b%=1000;
		y=b/500;
		x=b%500/100;
		printf("%d %d %d\n",x,y,z);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
 #include <math.h>

 #define PI 3.14159265358979323846264338327950L

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

long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
 }

Measured memory_bytes: 2576
from collections import deque
n,m = map(int,input().split())
path = [set() for _ in range(n)]
for _ in range(m):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    path[u].add(v)

s,t = map(int,input().split())

que = deque([(s-1,0)])
d = [[float('inf')]*n for _ in range(3)]
d[0][s-1] = 0
while que:
    p,i = que.popleft()
    j = (i+1)%3
    for to in path[p]:
        if d[j][to] == float('inf'):
            d[j][to] = d[i][p] + 1
            que.append((to,j))
if d[0][t-1] == float('inf'):
    d[0][t-1] = -3
print(d[0][t-1]//3)


Measured memory_bytes: 81824
#include <iostream>

using namespace std;

void solve()
{
	int Num = 0;
	double mass = 0;
	double height = 0;
	while(~scanf("%d,%lf,%lf/n", &Num, &mass, &height))
	{
		if(mass / (height * height) >= 25.0)
		{
			cout << Num << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0
def check(a):
    global ans
    tmp = 0
    for i in range(H):
        for j in range(W):
            if a[i] and a[H+j] and C[i][j] == "#":
                tmp += 1
    ans += 1 if tmp == K else 0

def dfs(a):
    if len(a) == H+W:
        check(a)
        return
    for i in range(2):
        dfs(a+[i])

dfs([])
print(ans)


Measured memory_bytes: 76184
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<stack>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

signed main() {
	Int a,b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    ll X;
    cin >> X;

    ll cnt = 0;
    ll now = 100;
    while(!(now >= X)) {
        now *= 1.01;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3592
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

// i 枚目まで使って j 円にするときの最小枚数
int dp[13][101010];
const vector<int> money = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

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

  int n; cin >> n;

  for (int i = 0; i < 13; ++i) {
    for (int j = 0; j < 101010; ++j) {
      dp[i][j] = INF;
    }
  }

  for (int i = 0; i < 13; ++i) {
    dp[i][0] = 0;
  }

  for (int i = 0; i < 12; ++i) {
    for (int j = 0; j < 101010; ++j) {
      if (j < money[i]) {
        dp[i + 1][j] = dp[i][j];
      }
      else {
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - money[i]] + 1);
      }
    }
  }

  cout << dp[12][n] << '\n';

  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI               \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double
#define endl "\n"

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int spf[10 * N];

void sieve()
{
   for (int i = 1; i < 10 * N; i++)
      spf[i] = i;
   for (int i = 2; i < 10 * N; i++)
   {
      for (int j = i; j < 10 * N; j += i)
         spf[j] = min(spf[j], i);
   }
}

set<int> query(int n)
{
   set<int> res;
   while (n > 1)
   {
      res.insert(spf[n]);
      n /= spf[n];
   }
   return res;
}
int32_t main()
{
   AB_BHI_NI_DEGI
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
   //cout.precision(20);
   //cout << fixed;
   int T = 1;
   //cin >> T;
   int cnt = 1;
   sieve();
   while (T--)
   {
      int n;
      cin >> n;
      int a[n];
      for (int i = 0; i < n; i++)
         cin >> a[i];
      map<int, int> mp;
      int g = 0;
      for (int i = 0; i < n; i++)
      {
         g = __gcd(g, a[i]);
         if (a[i] == 1)
            continue;
         set<int> s = query(a[i]);
         for (auto j : s)
            mp[j]++;
      }
      bool f = 1;
      for (auto it : mp)
      {
         if (it.S > 1)
         {
            f = 0;
            break;
         }
      }
      if (f)
      {
         cout << "pairwise coprime\n";
         return 0;
      }
      if (g == 1)
      {
         cout << "setwise coprime\n";
         return 0;
      }
      cout << "not coprime\n";
   }
   return 0;
}

Measured memory_bytes: 24180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n,m,B[2000],a,z,c,ans=0;
    cin>>n>>m>>c;
    rep(i,m) cin>>B[i];
    rep(i,n){
        z=0;
        rep(j,m) cin>>a,z+=a*B[j];
        if(z+c>0) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
import math
n=int(input())
rootn=int(math.sqrt(n))
ketamin=12
for i in range(1,rootn+2):
    if n%i==0:
        fab=max(i,n//i)
        fabstr=str(fab)
        keta=len(fabstr)
        if ketamin>keta:
            ketamin=keta
print(ketamin)



Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, m;
	vector<int> move(3);
	cin >> n >> m >> move[0] >> move[1] >> move[2];
	SORT(move);
	vector<vector<int>> route(n + 1);

	REP(i, m){
		int a, b;
		cin >> a >> b;
		route[a].push_back(b);
	}
	int ans = -1;
	vector<vector<vector<bool>>> step(n + 1, vector<vector<bool>>(n + 1, vector<bool>(3, false)));
	FOR(i, 1, n){
		vector<int> now;
		now.push_back(i);
		REP(j, move[2]){
			int ns = now.size();
			vector<int> now2;
			set<int> si;
			REP(k, ns){
				REP(l, route[now[k]].size()){
					if (si.find(route[now[k]][l]) == si.end()){
						now2.push_back(route[now[k]][l]);
						si.insert(route[now[k]][l]);
					}
				}
			}
			now = now2;
			if (j == move[0] - 1)
				REP(k, now.size())
				step[i][now[k]][0] = true;
			if (j == move[1] - 1)
				REP(k, now.size())
				step[i][now[k]][1] = true;
			if (j == move[2] - 1)
				REP(k, now.size())
				step[i][now[k]][2] = true;
		}
	}
	vector<vector<int>> goalto(n+1,vector<int>(3,10000));
	goalto[n][0] = 0;
	goalto[n][1] = 0;
	goalto[n][2] = 0;
	queue<pair<int,int>> qii;
	qii.push({ 0,n });
	while (!qii.empty()){
		pair<int,int> num = qii.front(); qii.pop();
		REP(i,n){
			REP(j,3){
				if (step[i][num.second][j]){
					if (goalto[i][j] ==10000){
						goalto[i][j] = num.first + 1;
						if (goalto[i][0] != 10000 && goalto[i][1] != 10000 && goalto[i][2] != 10000){
							qii.push({ max(goalto[i][0], max(goalto[i][1], goalto[i][2])), i });
						}
					}
				}
			}
		}
	}

	REP(i,3){
		if (goalto[1][i] == 10000){
			ans = -1;
			break;
		}
		ans = max(ans, goalto[1][i]);
	}
	if (ans != -1)
		cout << ans << endl;
	else
		cout << "IMPOSSIBLE" << endl;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

#define int long long

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int pw(int a, int n) {
    int re = 1;
    a %= MOD;
    while (n > 0) {
        if (n & 1) {
            re = re * a % MOD;
            n--;
        } else {
            a = a * a % MOD;
            n >>= 1;
        }
    }
    return re;
}

int inv(int x) {
    return pw(x, MOD - 2);
}

int n, k, fact[N], a[N];

int f(int nn, int kk) {
    return fact[nn] * inv(fact[kk]) % MOD * inv(fact[nn - kk]) % MOD;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * i % MOD;
    int ans = 0;
    for (int i = k - 1; i < n; i++) {
        int x = a[i];
        if (x < 0) x += MOD;
        ans = (ans + x * f(i, k - 1) % MOD) % MOD;
    }
    for (int i = k - 1; i < n; i++) {
        int x = -a[n - i - 1];
        if (x < 0) x += MOD;
        ans = (ans + x * f(i, k - 1) % MOD) % MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int s[100];
int top;

void push(int x){
  top++;
  s[top]=x;
}
int pop(){
  top--;

  return s[top+1];
}



int main(){
  int n;

  top=0;
  while(scanf("%d",&n)!=EOF){
    if(n==0) printf("%d\n",pop());
    else push(n);
  }

  return 0;
}

Measured memory_bytes: 600
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var d = make(map[int]int)

	for i := 0; i < n; i++ {
		var k int
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var food int
			fmt.Scan(&food)
			d[food]++
		}
	}

	var cnt int
	for _, v := range d {
		if v == n {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int n, i;
    int r = 0, w = 0;
    char c[200000];

    scanf("%d", &n);
    getchar();

    for (i = 0; i < n; i++) {
        c[i] = getchar();
        if (c[i] == 'R')
            r++;
    }

    for (i = 0; i < r; i++) {
        if (c[i] == 'W')
            w++;
    }

    printf("%d\n", w);

    return 0;
}

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

using namespace std;
int main(){
  int n;
   cin >>n;
  
  vector<int> a(n);
  int max1=0;
  int max2=0;

  for(int i=0;i<n;i++){
   cin >> a[i];
  if(a[i]>=max1) {max2=max1; 
               max1=a[i];
              }
  else if(a[i]>=max2)  {
    max2=a[i];
  }
    
  }
  
  for(int i=0;i<n;i++){

  if(a[i]==max1) cout << max2 << endl;  
  else cout << max1 << endl;  
  } 
  
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    int a[n];
    rep(i,0,n-1)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    repA(i,1,n)
    cout<<mp[i]<<endl;
}


Measured memory_bytes: 13756
import math

n=int(input())
s=input()
ng=len(s)
r=[]
g=[]
b=[]

for i in range(ng):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)

kihon=math.factorial(n)%998244353
combo=0
list1=[]
list2=[]
list3=[]

deka=[]
tibi=[]

for i in range(n):
    moto=[r[i],g[i],b[i]]
    jun = sorted([r[i],g[i],b[i]])
    list1.append(jun[0])
    list2.append(jun[1])
    list3.append(jun[2])
    deka.append(moto.index(jun[2]))
    tibi.append(moto.index(jun[0]))

dekalist=[1]
tibilist=[1]
for i in range(n-1):
    next=max(1, dekalist[-1]-1)
    if i+next<n:
        while deka[i]==deka[i+next] and list3[i]>=list2[i+next]:
            next+=1
            if i+next==n:
                break
    dekalist.append(next)
    
    next2=max(1, tibilist[-1]-1)
    if i+next2<n:
        while tibi[n-1-i]==tibi[n-1-i-next2] and list1[n-1-i]<=list2[n-1-i-next2]:
            next2+=1
            if i+next2==n:
                break
    tibilist.append(next2)


for dl in dekalist:
    kihon=(kihon*dl)%998244353
for tl in tibilist:
    kihon=(kihon*tl)%998244353

print(kihon%998244353)

Measured memory_bytes: 27692
N=int(input())
H=list(map(int,input().split()))
c=0
ans=0
for i in range(N-1):
    if H[i] >= H[i+1]: c+=1
    else: ans=max(ans,c); c = 1 if H[i] > H[i+1] else 0
print(max(ans,c))

Measured memory_bytes: 14252
#include<cstdio>
#include<algorithm>
#define MAXN 2000
int N,K;
int memo[MAXN+1][MAXN+1];
 
void Add(int x, int y, int x2, int y2)
{
	++memo[x][y];
	--memo[x][y2+1];
	--memo[x2+1][y];
	++memo[x2+1][y2+1];
}
 
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++)
	{
		int x, y; char c;
		scanf("%d %d %c", &x, &y, &c);
		x %= 2*K; y %= 2*K;
 
		if (((x < K && y < K) || (x >= K && y >= K)) == (c == 'B'))
		{
			int x_ = x % K, y_ = y % K;
			
			Add(0, 			0, 			x_		 , y_		);
			
			Add(x_ + K + 1, 0, 			2 * K - 1, y_		);
			Add(0, 			y_ + K + 1, x_		 , 2 * K - 1);
			
			Add(x_ + K + 1, y_ + K + 1, 2 * K - 1, 2 * K - 1);
			Add(x_ + 1	  , y_ + 1	  , x_ + K	 , y_ + K	);
		}
		else
		{
			int x_ = x % K, y_ = y % K;
 
			Add(x_ + 1	  , 0		  , x_ + K	 , y_		);
			Add(x_ + 1	  , y_ + K + 1, x_ + K	 , 2 * K - 1);
 
			Add(0		  , y_ + 1	  , x_		 , y_ + K	);
			Add(x_ + K + 1, y_ + 1	  , 2 * K - 1, y_ + K	);
		}
	}
 
	for (int i = 0; i < 2001; i++)
		for (int j = 1; j < 2001; j++)
	{
			memo[i][j] += memo[i][j - 1];
	}
	for (int i = 1; i < 2001; i++)
		for (int j = 0; j < 2001; j++)
	{
		memo[i][j] += memo[i - 1][j];
	}
	int max = 0;
	for (int i = 0; i < 2*K; i++)
		for (int j = 0; j < 2*K; j++)
			max = std::max(max, memo[i][j]);
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 15744
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
#define WHOLE(x) x.begin(),x.end()
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

#define aise akdj

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	string s;
  cin>>s;
  SORT(s);
	if (s[0] == s[1] && s[2] == s[3]&&s[0]!=s[2])COUT("Yes");
	else COUT("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100009];
ll n,x;
vector<ll>v;
ll frog(ll pos)
{
    if(pos<=0)
        return 0;
    if(pos==1)
        return abs(v[0]-v[1]);
        if(dp[pos]==-1)
        {
            dp[pos]= min(abs(v[pos]-v[pos-1])+frog(pos-1),abs(v[pos]-v[pos-2])+frog(pos-2));
        }
    return dp[pos];
}

int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    cout<<frog(n-1)<<endl;
}


Measured memory_bytes: 7116
#include <bits/stdc++.h>
 
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;
 
#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long
 
// n개중에서 k 를 고르는 Combination table을 미리 세팅한다.
// C[n][k] -> nCk
ULL Comb[51][51];
void combination_table(int n)
{
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
        {
            if(j == 0 || j == i)
                Comb[i][j] = 1ll;
            else
                Comb[i][j] = Comb[i - 1][j - 1] + Comb[i - 1][j];
        }
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int N, A, B;
    cin >> N >> A >> B;
 
    VL items(N, 0);
    REP(i, 0, N) cin >> items[i];
 
    combination_table(N);
    sort(items.begin(), items.end(), greater<LL>());
 
    double max_avg = (double)accumulate(items.begin(), items.begin() + A, 0ll) / A;
    
    LL smallest = items[A - 1];
    int numSmallest = count(items.begin(), items.end(), smallest);

	cout.precision(10);
    cout << fixed << max_avg << endl;

    LL cnt = 0ll;
    // 1. items[0] == items[A - 1] 인 경우    
    if(items[0] == smallest)
        cnt += accumulate(Comb[numSmallest] + A, Comb[numSmallest] + B + 1, 0ll);
    else {
        int numSub = count(items.begin(), items.begin() + A, smallest);
        cnt += Comb[numSmallest][numSub];
    }
 
    cout << cnt << endl;
 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
HOU = []
for i in range(n):
    tmp = int(input())
    for _ in range(tmp):
        x, y = (map(int, input().split()))
        HOU.append([i, x - 1, bool(y)])

anssum = 0
for i in range(2 ** n):
    flag = True
    for j in range(len(HOU)):
        if (i >> HOU[j][0]) & 1:
            if HOU[j][2] == i >> HOU[j][1] & 1:
                continue
            else:
                flag = False
                break
        else:
            if not (i >> HOU[j][0]) & 1:
                continue
            else:
                flag = False
                break


    if flag:
        anssum = max(anssum,str(bin(i)).count('1'))

print(anssum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  int N; cin >> N;
  vector<vector<P>> mem(N);
  rep(i,N) {
    int a; cin >> a;
    rep(j,a) {
      int x,y; cin >> x >> y;
      mem[i].push_back(make_pair(x,y));
    }
  }
  int ans = 0;
  // bit全探索 0:不親切, 1:正直
  for (int bit = 0; bit < (1<<N); ++bit) {
    vector<int> S(N, 0);
    for (int i = 0; i < N; i++) {
      if (bit & (1<<i)) {
        S[i] = 1;
      }
    }
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (S[i]==1) {
        for (int j=0; j<mem[i].size(); j++) {
          P m = mem[i][j];
          // cout << m.first << " " << m.second << endl;
          // cout << "test " << m.first-1 << ' ' << m.second << endl;
          if (S[m.first-1] != m.second) flag=false;
          // break;
        }
      }
    }
    int tmp = 0;
    if(flag) {
      // cout << "S ";
      // rep(i,N) cout << S[i] << ' ';
      rep(i,N) if(S[i]==1) tmp++;
    }
    // cout << endl;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;
ll n, t, sum, mx, mn, m;

void solve(){
	cin >> n >> m;
	if(n % m) {
		cout << n / m + 1;
	}
	else cout << n / m;
}

int main()
{
	t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

const uint32_t MOD = 1000000007;

uint32_t COMB[2005][2005] = {1};

void comb_init(uint32_t N)
{
  for (int n=1; n<=N; ++n) {
    for (int r=0; r<=N; ++r) {
      if (n==r || r==0)
	COMB[n][r] = 1;
      else
	COMB[n][r] = (COMB[n-1][r-1]+COMB[n-1][r])%MOD;
    }
  }

}

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

  comb_init(N);

  for (int k=1; k<=K; ++k)
    cout << ((uint64_t)COMB[N-K+1][k]*COMB[K-1][k-1])%MOD << endl;

  return 0;
}


Measured memory_bytes: 15872
n = int(input())
a = [input() for i in range(n)]
for i in range(n):
    num  = a.count(a[i])
    if num > 1:
        print('No')
        exit()
for i in range(n-1):
    if a[i][-1] == a[i+1][0]:
        continue
    else:
        print('No')
        exit()
print('Yes')


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int sum_num(int a)
{
    int s = 0;
    while (a)
    {
        s += a % 10;
        a /= 10;
    }
    return s;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));

    int ans = 0;
    rep(i, n)
    {
        ans += (i & 1) ? -a[i] : a[i];
    }

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


Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;

long long f(long long n){
	if(n == 1)
		return 1;
	if(n == 0)
		return 0;
	long long x = f(floor(n/2));
	return 1 + x + x;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long x;
    cin >>x;
    cout <<f(x);
    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;

  cout << (a+b+1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 3624
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    counter = defaultdict(int)
    for _ in range(M):
        A, B = map(lambda x: int(x) - 1, input().split())
        counter[A] += 1
        counter[B] += 1
    is_valid = True
    for v in counter.values():
        if v % 2 == 1:
            is_valid = False
            break
    if is_valid:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


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

int main() {
    int h,w;cin>>h>>w;
    
    rep(i,w+2)cout<<'#';
    cout<<endl;
    
    rep(i,h){
        string tmp;cin>>tmp;
        cout<<'#'<<tmp<<'#'<<endl;;
    }
    rep(i,w+2)cout<<'#';
    cout<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>

using namespace std;

const int N = 200005;

int n, K, C, f[N], g[N];

char s[N];

int main() {
	scanf("%d%d%d%s", &n, &K, &C, s + 1);
	int v = 0;
	for (int i = 1; i <= n; i++) {
		f[i] = f[i - 1];
		if (s[i] == 'x') continue;
		if (i - C - 1 >= 1) v = max(v, f[i - C - 1]);
		f[i] = max(f[i], v + 1);
	}
	v = 0;
	for (int i = n; i; i--) {
		g[i] = g[i + 1];
		if (s[i] == 'x') continue;
		if (i + C + 1 <= n) v = max(v, g[i + C + 1]);
		g[i] = max(g[i], v + 1);
	}


	for (int i = 1; i <= n; i++)
		if (f[i - 1] + g[i + 1] < K) printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 3200