akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <string>
    #include <math.h>
    #include<algorithm>
    using namespace std;
     
    int main(){
      int N;
      cin >> N;
      int a[N];
      for(int i=0;i<N;i++){
       cin >> a[i];
      }
      int n4=0;
      int n2=0;
      for(int i=0;i<N;i++){
       if(a[i]%4==0)n4=n4+1;
        else if(a[i]%2==0)n2=n2+1;
      }
      if(n2>0){
       if(n4*2+n2>=N){
        cout << "Yes" << endl; 
       }
       else{
        cout << "No" << endl; 
       }
      }
      else{
       if(2*n4+1>=N){
        cout << "Yes" << endl; 
       }
        else{
         cout << "No" << endl; 
        }
      }
        return 0;}

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


int main()
{
    int a, b;
    int count, tmp;

    while (std::scanf("%d %d", &a, &b) != EOF) {

        count = 0;
        tmp= a + b;

        while(tmp != 0) {
            count++;
            tmp /= 10;
        }

        std::cout << count << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
static const int MAX_N = 40;
static const ll INF = 1 << 30;

int n;
ll w[MAX_N], v[MAX_N];
ll W;

pair<ll, ll> ps[1 << (MAX_N / 2)];

void solve(){
	int n2 = n / 2;
	for(int i = 0; i < 1 << n2; i++){
		ll sw = 0, sv = 0;
		for(int j = 0; j < n2; j++){
			if(i >> j & 1){
				sw += w[j];
				sv += v[j];
			}
		}
		ps[i] = make_pair(sw, sv);
	}
	sort(ps, ps + (1 << n2));
	int m = 1;
	for(int i = 1; i < 1 << n2; i++){
		if(ps[m - 1].second < ps[i].second){
			ps[m++] = ps[i];
		}
	}

	ll res = 0;
	for(int i = 0; i < 1 << (n - n2); i++){
		ll sw = 0, sv = 0;
		for(int j = 0; j < n - n2; j++){
			if(i >> j & 1){
				sw += w[n2 + j];
				sv += v[n2 + j];
			}
		}
		if(sw <= W){
			ll tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1) -> second;
			res = max(res, sv + tv);
		}
	}

	printf("%lld\n", res);
}

int main(){
	scanf("%d %lld", &n, &W);
	for(int i = 0; i < n; i++){
		scanf("%lld %lld", &v[i], &w[i]);
	}
	solve();
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());

    queue<ll> q;
    q.push(a[1]);
    q.push(a[1]);
    ll cnt = 2;

    ll ans = a[0];

    while (cnt != n) {
        ll t = a[cnt];

        ll q1 = q.front();
        q.pop();

        ans += q1;
        q.push(t);
        q.push(t);

        cnt++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    pii p1, p2, a = make_pair(0, 0);
    cin >> p1.first >> p1.second >> p2.first >> p2.second;
    a.first = p1.second - p2.second;
    a.second = p2.first - p1.first;
    cout << p2.first + a.first << " " << p2.second + a.second << " "
         << p1.first + a.first << " " << p1.second + a.second << endl;
    return 0;
}


Measured memory_bytes: 256
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int seen[4];
int main() {
    string S;
    cin >> S;

    int i;
    for (i = 0; i < S.size(); i++) {
        if (S[i] == 'N') seen[0] = 1;
        else if (S[i] == 'S') seen[1] = 1;
        else if (S[i] == 'W') seen[2] = 1;
        else seen[3] = 1;
    }
    if ((seen[0] != seen[1]) || (seen[2] != seen[3])) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");

    return 0;
}



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

public class Main {
    char[] cs;

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

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == '0' || cs[i] == '1') {
                sb.append(cs[i]);
            } else {
                if (sb.length() > 0) {
                    sb.setLength(sb.length() - 1);
                }
            }
        }
        System.out.println(sb);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		(new Solver()).Solve();
	}	
}


public class Solver
{
	private int N;
	private int Q;
	private string s;
	private char[] t;
	private char[] d;

	public Solver()
	{
		N = GetInt();
		Q = GetInt();
		s = "\0" + GetString();
		t = new char[Q];
		d = new char[Q];
		for(int i = 0; i < Q; i++)
		{
			t[i] = GetString()[0];
			d[i] = GetString()[0];
		}
	}

	public void Solve()
	{
		int lbl = 0;
		int ubl = N + 1;
		while(lbl + 1 < ubl)
		{
			int mid = (lbl + ubl)/2;
			if(move(mid) == 0)
				lbl = mid;
			else
				ubl = mid;
		}

		int lbr = 0;
		int ubr = N + 1;
		while(lbr + 1 < ubr)
		{
			int mid = (lbr + ubr)/2;
			if(move(mid) == N + 1)
				ubr = mid;
			else
				lbr = mid;
		}

		Console.WriteLine(ubr - ubl);
	}

	private int move(int x)
	{
		if((x == 0) || (x == N + 1))
			return x;

		int currentX = x;
		for(int i = 0; i < Q; i++)
		{
			if(s[currentX] != t[i])
				continue;

			if(d[i] == 'L')
			{
				if(currentX == 1)
					return 0;
				else	
					currentX--;
			}
			else
			{
				if(currentX == N)
					return N + 1;
				else
					currentX++;
			}
		}

		return currentX;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 17756
n,m=[int(val) for val in input().split()]
matrix=[[int(val) for val in input().split()]for val in range(m)]
#print(n,m,matrix)
ee=[[val[0]-1, val[1]-1] for val in matrix]

cnt=0
k=0
for L in range(m):
    xx=[i for i in range(n)]
    for j in range(m):
        if j!=k:
            val1=xx[ee[j][1]]
            val2=xx[ee[j][0]]
            for i in range(len(xx)):
                if xx[i]==val1:
                    xx[i]=val2
#    print(xx)
    if len(set(xx))>1:
        cnt+=1
    k+=1
    
print(cnt)


Measured memory_bytes: 3064
// Hint: Don't look, No need, Let'em Play.

#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

// #define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

using hr_clock = chrono::high_resolution_clock;

struct Timer_ {
    private: chrono::time_point<hr_clock> start_;
    public: Timer_(); ~Timer_();
}_;

#define single_test

const int N = 1e7 + 4;

int a[N];

void solve() {
    for (int i = 1; i < N; ++i) {
        for (int j = i; j < N; j += i) {
            ++a[j];
        }
    }
    long long ans = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        ans += 1ll * i * a[i];
    }
    cout << ans << '\n';
}

signed main() {
    fast;
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    while (t--) {
        // Timer_ _;
        solve();
    }

    return 0;
}

Timer_::Timer_() {
    start_ = hr_clock::now();
}

Timer_::~Timer_() {
    #ifdef bhupixb
    cerr << "took: " << chrono::duration_cast<chrono::microseconds>(hr_clock::now() - start_).count() / 1000 << " ms\n";
    #endif
}


Measured memory_bytes: 42744
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MAX_A = 1000000000000000000LL;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  bool succ = true;
  ll ans = 1;
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) succ = false;
  }
  if (!succ) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = 0; i < N; i++) {
    if (A[i] <= MAX_A / ans) {
      ans *= A[i];
    } else {
      succ = false;
      break;
    }
  }
  if (!succ) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define all(v)                   v.begin(),v.end()
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define t_c(t)                          for(int z=1;z<=t;z++)
#define p_c                             printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define MX                       100005
#define inf                      10000000000000000+7
#define M                        1000000002
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};

int main()
{
   int n,i,j;
   cin>>n;
   int a[n+5],b[n+5],c[n+5],ans=0;
   map<int,int>mm1,mm2;
   for(i=0;i<n;i++){cin>>a[i];
   }
   for(i=0;i<n;i++)
   {
       cin>>b[i];
   }
   for(i=0;i<n-1;i++)
   { cin>>c[i];
       if(mm2[i+1]==1)ans+=c[i];
   }
   for(i=0;i<n;i++)
   {
       ans+=b[a[i]-1];
       if(i<(n-1))
       {
           if(a[i+1]-a[i]==1)
           {
               ans+=c[a[i]-1];
           }
       }
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3564
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int[] A = in.ii(N);
        Arrays.sort(A);
        int max = A[A.length - 1];
        int ans = 0;
        boolean[] b1 = new boolean[max + 1];
        boolean[] b2 = new boolean[max + 1];
        for (int i = 0; i < A.length; i++) {
            if (!b1[A[i]]) {
                if (b2[A[i]]) {
                    b1[A[i]] = true;
                    ans--;
                } else {
                    for (int j = 2; ; j++) {
                        int x = A[i] * j;
                        if (b1.length <= x) {
                            break;
                        }
                        b1[x] = true;
                    }
                    b2[A[i]] = true;
                    ans++;
                }
            }
        }

        // int ans = 0;
        // for (int i = 0; i < A.length; i++) {
        //     if (!b1[A[i]]) {
        //         ans++;
        //     }
        // }
        out.println(ans);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 39840
#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
long long int a[100009],b[100009],c[100009];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	long long int cur=0;
	for(int i=n-1;i>=0;i--){
		a[i]+=cur;
		c[i]=b[i]-a[i]%b[i];
		if(a[i]%b[i]==0)c[i]=0;
		cur+=c[i];
	}
	cout<<cur<<endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  n++;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

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

  ll next_branch = 1;  
  ll ans = 0;
  for(int i = 0; i < n; ++i)
  {
    b[i] = min(b[i], next_branch);
    next_branch = min((next_branch - a[i]) * 2, (1LL << 62));
    if (next_branch < 0){
      cout << -1;
      return;
    }
    ans += b[i];
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string a,b,c;
   cin >> a >> b >> c;
   cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
 }

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N, K;
vector<ll> G[101010];
vector<ll> val(101010, 0);

void dfs(ll now, ll par, ll one, ll two){
	val[now] = max(K - one - two, 0ll);
	ll cnt = 0;
	REP(i, G[now].size()){
		ll next = G[now][i];
		if(next == par) continue;
		dfs(next, now, 1, one+cnt);
		cnt++;
	}
	return;
}

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

    cin >> N >> K;
    REP(i, N-1){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }

    dfs(0, -1, 0, 0);

    ll res = 1;
    REP(i, N){
    	res *= val[i];
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12416
from collections import deque
N, Q = map(int, input().split())  # N頂点の木, Q回の操作
tree = [[] for _ in range(N)]  # N頂点の木を構築する
visited = [False]*N
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)
counter = [0]*N  # その頂点がもともと持っている力
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    counter[p] += x
# print(counter)
# exit()
q = deque([0])
visited[0] = True
while len(q):
    v = q.pop()
    for e in tree[v]:  # 親の値を伝播させていく
        if visited[e]:
            continue
        visited[e] = True
        counter[e] += counter[v]
        q.append(e)

print(*counter)


Measured memory_bytes: 106772
#include <bits/stdc++.h>
#define N 6001
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<P> G[N];
int n,m,cap,ls[N];
void add_edge(int a,int b,int d){
  G[a].push_back(P(b,d));
  G[b].push_back(P(a,d));
}

int dijkstra(){
  vector<vector<int> >D(cap+1,vector<int>(n,INF));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(cap,0)));
  D[cap][0]=0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int d=t.first,c=t.second.first,pos=t.second.second;

    if(pos==1) return d;
    if(ls[pos])c=cap;
    if(D[c][pos]<d)continue;
    
    
    for(int i=0;i<G[pos].size();i++){
      int nd=d+G[pos][i].second;
      int nx=G[pos][i].first;
      int nc=c-G[pos][i].second;
      if(nc>=0&&D[nc][nx]>nd)Q.push(PP(nd,P(nc,nx))),D[nc][nx]=nd;
    }
  }
  return -1;
}


int main(){
  while(1){
    cin>>n>>m>>cap;cap*=10;
    if(!n&&!m&&!cap)break;
    for(int i=0;i<N;i++)G[i].clear(),ls[i]=0;
    
    map<string,int> M;
    string a,b;
    cin>>a>>b;
    M[a]=0,M[b]=1;
    int _n=2;
    for(int i=0,d;i<n;i++){
      cin>>a>>b>>d;
      if(!M.count(a)) M[a]=_n++;
      if(!M.count(b)) M[b]=_n++;
      add_edge(M[a],M[b],d);
    }
    n=_n;
    for(int i=0;i<m;i++) {cin>>a;if(M.count(a))ls[M[a]]=1;}
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 52180
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	double ans;
	ans = (double)((N + 1) / 2) / (double)N;
	printf("%.12f", ans);


	return 0;
}

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

using namespace std;

int calc(int v) {
    int cnt = 0;
    for (int i = 1; i <= v; i++) {
        cnt += v % i == 0;
    }
    return cnt;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        ans += calc(i) == 8;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,K; cin >> N >> K;
    VI l(N); REP(i,N) cin >> l[i];
    SORT(l);
    reverse(l.begin(), l.end());
    int ans = 0;
    REP(i,K) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def mi(): return map(int,input().split())
def lmi(): return list(map(str,input().split()))
def ii(): return int(input())
def isp(): return input().split()

n=ii()
dic_s={}
for i in range(n):
  s_=list(input())
  s__=sorted(s_)
  #print(s__)
  s=''.join(s__)
  if s in dic_s.keys():
    dic_s[s]+=1
  else:
    dic_s.setdefault(s,1)

  
cnt=0
#print(dic_s)
for i in dic_s.values():
  if i>1:
    cnt+=i*(i-1)//2

print(cnt)


Measured memory_bytes: 22112
#include <iostream>
#include <string>

using namespace std;

int main(){
	int H, W;
	string *a = NULL;
	string sharp;

	sharp = "#";

	cin >> H >> W;

	a = new string[H];

	for(int i = 0; i < H; i++){
		cin >> a[i];
	}

	while((int)sharp.length() < W+2){
		sharp += "#";
	}

	for(int i = 0; i < H; i++){
		a[i].insert(0, "#");
		a[i] += "#";
	}

	cout << sharp << endl;
	for(int i = 0; i < H; i++){
		cout << a[i] << endl;
	}

	cout << sharp << endl;

	delete[] a;

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0;
  } else {
    vector<int> X(M);
    for (int i = 0; i < M; i++) {
      cin >> X.at(i);
    }
    sort(X.begin(), X.end());
    int range = X.at(M - 1) - X.at(0);
    priority_queue<int> dist;
    for (int i = 0; i <= M - 2; i++) {
      dist.push(X.at(i + 1) - X.at(i));
    }
    for (int i = 1; i <= N - 1; i++) {
      range -= dist.top();
      dist.pop();
    }
    cout << range;
  }
}

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


void solve(long long X){
    int mx = 0;
    for (int i=2; i<ceil(sqrt(X)); i++) {
        int tmp = 1;
        while (tmp <= X) {
            tmp *= i;
        }
        mx = max(mx, tmp / i);
    }
    if (X == 1) {
        mx = 1;
    }
    cout << mx << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string mt[200];
int used[200][200];

int main() {
	int h,w;
	while(~scanf("%d %d\n",&h,&w),h){
		int x,y;
		for(y=0;y<h;y++){
			cin>>mt[y];
		}
		memset(used,0,sizeof(used));
		pint pos(0,0);
//cout<<"hoge"<<endl;
//cout<<mt[0][0]<<endl;
//cout<<'>'<<endl;
		while(mt[pos.second][pos.first]!='.'){
//cout<<pos.first<<" "<<pos.second<<endl;
			if(used[pos.second][pos.first]==1)break;
			used[pos.second][pos.first]=1;
			if(mt[pos.second][pos.first]=='>'){
				pos.first++;
			}else if(mt[pos.second][pos.first]=='<'){
				pos.first--;
			}else if(mt[pos.second][pos.first]=='v'){
				pos.second++;
			}else{
				pos.second--;
			}
		}
		if(mt[pos.second][pos.first]!='.')cout<<"LOOP"<<endl;
		else cout<<pos.first<<" "<<pos.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int search(int,int);
int n;
int A[20];

int main(){
    int i,q,m,ans;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&m);
        ans=search(0,m);
        if(ans==1)printf("yes\n");
        else printf("no\n");
    }
    return 0;
    }

    int search(int i,int m){
        int a;
        if(m==0) return 1;
        if(i>=n)return 0;
        a=search(i+1,m)||search(i+1,m-A[i]);
        return a;
    }


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
// #define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/
#define int64_t long long
#define int long long

struct Combination
{
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
  {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }
  
  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};


signed main(){
  ll H, W, A, B;
  Combination cmb(200002, 1000000007);
  const ll mod = 1000000007;
  cin >> H >> W >> A >> B;

  ll ans = 0;
  for(ll i = B + 1; i <= W; i++){		      
    ans = (ans + cmb.C(i  - 1+ H - A - 1, i - 1) * cmb.C(W - i  + A - 1, A - 1)) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
program dividing_chocolate
  implicit none
  integer :: h, w, k, a(10,1000) = 0, i, j, l, m, c(10), d(10), u, x = 1e9, y
  character(1000) :: s
  read(*,*) h, w, k
  do i = 1, h
    read(*,'(a)') s
    do j = 1, w
      if (s(j:j) == "1") a(i,j) = 1
    end do
  end do
  if (h == 1) then
    write(*,'(i0)') sum(a(1,1:w))/k
    stop
  end if
  u = lshift(1,h-1)
  do l = 0, u-1
    c = 0
    d = 0
    y = popcnt(l)
    do j = 1, w
      m = 1
      do i = 1, h
        if (i /= 1 .and. btest(l,i-2)) m = m+1
        c(m) = c(m)+a(i,j)
      end do
      if (any(c > k)) then
        y = y+1
        c = c-d
        if (any(c > k)) goto 100
      end if
      d = c
    end do
    x = min(x,y)
100 end do
  write(*,'(i0)') x
end program dividing_chocolate

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){ 
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> A(N,vector<int> (N-1));
  rep(i,N){
    rep(j,N-1){
      cin >> A[i][j];
      A[i][j]--;
    }
    reverse(A[i].begin(),A[i].end());
  }
  vector<P> q;
  auto check = [&](int i){
    if(A[i].size()==0) return;
    int j = A[i].back();
    if(A[j].size()==0) return;
    if(i == A[j].back()){
      if(i > j) swap(i,j);
      P p(i,j);
      q.push_back(p);
    }
  };
  rep(i,N){
    check(i);
  }
  int day = 0;
  while(q.size() > 0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> pre;
    swap(pre,q);
    for(P p: pre){
      int i=p.first,j=p.second;
      A[i].pop_back();
      A[j].pop_back();
    }
    for(P p: pre){
      int i=p.first,j=p.second;
      check(i);
      check(j);
    }
  }
  rep(i,N){
    if(A[i].size() != 0){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 4224
data = input()
length = len(data)

between = length - 1
num = 0
for i in range(2**between):
    list_data = list(data)
    for j in range(between):
        if ((i >> j) & 1):
            list_data[between - j] = '+'+list_data[between - j]
    hoge = ''.join(list_data).split('+')
    for k in hoge:
        num += int(k)

print(num)

Measured memory_bytes: 9152
from fractions import gcd


N, K = map(int, raw_input().split())
A = sorted(list(map(int, raw_input().split())))


if K > A[-1]:
    print('IMPOSSIBLE')
else:
    flag = True
    tmp = reduce(gcd, A)
    if tmp != 1:
        flag = False
    for a in A:
        if a == K or (K - a) % tmp == 0:
            flag = True
            break
    if flag:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')


Measured memory_bytes: 12600
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");

        int max = 0;
        boolean onCheck = false;
        int cl = 1; // current length

        for(String x : input){
            if(x.equals("1")){
                cl++;
                onCheck = true;
            }else if(onCheck){
                max = Math.max(cl,max);
                cl = 1;
                onCheck = false;
            }
        }

        max = Math.max(cl,max);

        System.out.println(max);
    }
}


Measured memory_bytes: 24540
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

class union_find_tree
{
    private:
        int *par;
        int *rank;
    public:
        union_find_tree(int n);
        int root(int x);
        void unite(int x, int y);
        bool same(int x, int y);
};

union_find_tree::union_find_tree(int n)
{
    par = new int[n];
    rank = new int[n];
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rank[i] = 0;
    }
}

int union_find_tree::root(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = root(par[x]);
    }
}

void union_find_tree::unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y) {
        return;
    }
    if (rank[x] < rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank[x] == rank[y]) {
            rank[x]++;
        }
    }
}

bool union_find_tree::same(int x, int y) {
    return root(x) == root(y);
}

int main(void)
{
    int n, q;
    cin >> n >> q;
    union_find_tree uft(n);
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uft.unite(x, y);
        } else {
            cout << uft.same(x, y) << endl;
        }
    }
    return 0;
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

ll h[500000];
int main() {
   ll i,j,k;
    ll n,ans=0;
    vector<ll> hp;
    cin >>n>>k;

    for(i=0; i<n; i++)
    {
      cin >>h[i];
      hp.push_back(h[i]);
    }

    sort(hp.begin(),hp.end());
    reverse(hp.begin(),hp.end());

    
    for(i=k; i<n; i++)
    {
      ans+=hp[i];
    }
  cout << ans << endl;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n; cin >> n;
    ld A[n+1];
    for(int i = 1;i <= n; i++)
        cin >> A[i];

    ld dp[n+1][n+1];
    memset(dp , 0 , sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1 ;i <= n ;i++){
        for(int j = 0; j <= n ; j++){
            if(j)
            dp[i][j] += A[i]*dp[i-1][j-1];
            dp[i][j] += (1-A[i])*dp[i-1][j];
            
        }
    }
    ld ans = 0;
    for(int i = n ;i >= 0 ; i--){
        if(i > n-i)
            ans += dp[n][i];
    }
    printf("%0.9lf\n" , ans);
    return 0;
}

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

int main() {
  long long n;
  cin >> n;
  if(n % 2 != 0){
    cout << 0;
    return 0;
  }
  vector<long long> a(25);
  long long wa = 5;
  for(int i = 0; i < 25; i++){
    a.at(i) = (n / 2) / wa;
    wa *= 5;
  }
  long long out = 0;
  for(int i = 0; i < 25; i++){
    out += a.at(i);
  }
  cout << out;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int dp[50001];

int main () {
  int n, m, tmp;
  vector<int> c;
  cin>>n>>m;
  for (int i=0; i<m; ++i) {
    cin>>tmp;
    c.push_back(tmp);
  }

  for (int i=1;i<=n;++i){
    dp[i] = 1<<29;
  }

  for (int i=0;i<m;++i) {
    for (int j=c[i];j<=n;++j) {
      dp[j] = min(dp[j], dp[j-c[i]]+1);
    }
  }

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


Measured memory_bytes: 3372
from collections import deque

def solve(k):
    que = deque()
    que.append((1, 1))
    dp = {1: 1}
    while que:
        x, c = que.pop()
        y = (x + 1) % k
        if (not y in dp) or (dp[y] > c + 1):
            dp[y] = c + 1 
            que.appendleft((y, c+1))
        z = (10 * x) % k
        if (not z in dp) or (dp[z] > c):
            dp[z] = c
            que.append((z, c))
    return dp[0]

k = int(input())
print(solve(k))

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	string s; cin >> s;

	int arr[40] = {0};

	for (int i = 0; i < s.size(); ++i)
		{
			arr[s[i]- 'a'] ++;
		}
	// so now I have an array of all 

		// for(auto i : arr)
			// cout << i << endl;


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

		int temp = arr[i];
		if(temp%2 == 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3672
s = input()
d = {}
for i in range(4):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
if d[s[0]] == d[s[1]] == d[s[2]] == d[s[3]] == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            int a = int.Parse(s);
            s = Console.ReadLine();
            int b = int.Parse(s);
            s = Console.ReadLine();
            int c = int.Parse(s);
            s = Console.ReadLine();
            int x = int.Parse(s);

            int ans = 0;
            for (int i=0; i<=a; i++)
            {
                for (int j=0; j<=b; j++)
                {
                    for (int k=0; k<=c; k++)
                    {
                        int price = i * 500 + j * 100 + k * 50;
                        if (price == x)
                        {
                            ans++;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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


int main(){
  string str;
  cin >> str;
  vector<char> vec(4);
  for (int i = 0; i < 4; i++){
    vec.at(i) = str.at(i);
  }

  sort(vec.begin(), vec.end());
  if (vec.at(0) == vec.at(1) && vec.at(2) == vec.at(3) && vec.at(0) != vec.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	int ans = 0;
	cin >> str;
	for (auto& c : str)
	{
		ans += c == '+' ? 1 : -1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    rep(i,n) {
        char c;
        cin>>c;
        if(c=='Y') {
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int r,D,x2000,i;
	cin>>r>>D>>x2000;
	int x=x2000;
	for (i=0;i<10;i++){
		x=r*x-D;
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int a[5];
  int x, ans = 0, mini = 10, n = 0;
  rep(i,5) {
    cin >> x;
    if (x % 10 == 0){
      ans += x;
    }
    else {
      mini = min(mini, x % 10);
      a[n] = x;
      n++;
    }
  }
  int w = 0;
  rep(i,n){
    if(a[i] % 10 == mini && w == 0){
      ans += a[i];
      w++;
    }
    else{
      ans = ans + ((a[i] / 10) + 1) * 10;
    }
  }
    
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
//
static const long long INFTY = (1LL << 50);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n;
static const int MAX = 100000;
vector<pair<ll, ll>> adj[MAX];

ll d[MAX];
ll p[MAX];
void dijkstra(int s) {
	priority_queue<pair<ll, ll>>PQ;
	int color[MAX];

	rep(i, n) {
		d[i] = INFTY;
		color[i] = WHITE;
		p[i] = 0;
	}

	d[s] = 0;
	p[s] = -1;
	PQ.push(make_pair(0, s)); // ?reverse?
	color[s] = GRAY;

	while (!PQ.empty()) {
		pair<ll, ll> f = PQ.top(); PQ.pop();
		ll u = f.second;

		color[u] = BLACK;

		if (d[u] < f.first * (-1)) continue;

		rep(j, adj[u].size()) {
			ll v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				p[v] = u;
				color[v] = GRAY;
			}
		}
	}
	//rep(i, n) cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	//rep(i, n) cout << i << " " << (p[i] == INFTY ? -1 : p[i]) << endl;
}

vector<int> get_path(int t) {
	vector<int> path;
	for (; t != -1; t = p[t])path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}

int main()
{
	cin >> n;

	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		adj[a - 1].push_back(make_pair(b - 1, c));
		adj[b - 1].push_back(make_pair(a - 1, c));
	}

	int Q, K;
	cin >> Q >> K;

	vector<ll> v;
	dijkstra(K - 1);
	rep(i, Q) {
		int x, y;
		cin >> x >> y;

		ll k_shortest = d[x - 1];
		ll  y_shortest = d[y - 1];

		v.push_back(k_shortest + y_shortest);
	}

	for (vector<ll>::iterator it = v.begin(); it != v.end(); it++) {
		cout << *it << endl;
	}
	return 0;
}

Measured memory_bytes: 12272
L,R=map(int,input().split())
if R-L>2019:
  result=0
else:
  kotae=[]
  for i in range(L,R+1):
    kotae.append(i%2019)
  kotae.sort()
  kaitou=[]
  for j in range(len(kotae)-1):
    for k in range(j+1,len(kotae)):
      kaitou.append((kotae[j]*kotae[k])%2019)
  result=min(kaitou)

print(result)

Measured memory_bytes: 75440
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    cout<<(a+b+2-1)/2<<endl;
}


Measured memory_bytes: 256