akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// ABC002-D, Expected 1405, 9:50, First AC
	/*int n, m; cin >> n >> m;
	vector<vector<int>> g(n);
	rep(i, m) {
		int x, y; cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans = 0;
	rep(i, 1 << n) {
		bool ok = true;
		rep(j, n) {
			if (i >> j & 1) {
				rep(k, n) {
					if (i >> k & 1 && j != k) {
						bool ok2 = false;
						rep(l, g[j].size()) {
							if (g[j][l] == k) ok2 = true;
						}
						if (!ok2) {
							ok = false; break;
						}
					}
				}
				if (!ok) break;
			}
		}
		int tmpCount = 0;
		rep(j, n) tmpCount += i >> j & 1;
		if (ok) ans = max(ans, tmpCount);
	}
	cout << ans << endl;
	*/

	// Square869120Contest #4 B, 19:08, First AC
	/*int n, k; cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = llINF;
	rep(i, 1 << n) {
		int c = 0;
		rep(j, n) c += i >> j & 1;
		if (c != k) continue;
		ll tmpMax = -1;
		ll tmpAns = 0;
		rep(j, n) {
			if (i >> j & 1) {
				tmpAns += max(0ll, tmpMax - a[j] + 1);
				tmpMax = max(tmpMax + 1, a[j]);
			}
			else {
				tmpMax = max(tmpMax, a[j]);
			}
		}
		ans = min(ans, tmpAns);
	}
	cout << ans << endl;
	*/

	// ABC145-C, 297, 17:15, First AC
	/*int n; cin >> n;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(ALL(p));
	double ans = 0;
	int num = 0;
	do {
		num++;
		double dist = 0;
		rep(i, n) {
			if (i == 0) continue;
			dist += sqrt((p[i].first - p[i - 1].first) * (p[i].first - p[i - 1].first) + (p[i].second - p[i - 1].second) * (p[i].second - p[i - 1].second));
		}
		ans += dist;
	} while (next_permutation(p.begin(), p.end()));
	cout << setprecision(15) << ans / num << endl;
	*/

	// ABC077-C, 1096, 24:50, First AC(難しかったけど面白かった)
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll ans = 0;
	rep(i, n) {
		if (b[i] <= a[0]) continue;
		if (c[n - 1] <= b[i]) continue;
		
		int up, down;
		auto upitr = lower_bound(ALL(a), b[i]);
		if (upitr == a.begin()) continue;
		up = upitr - a.begin();

		auto downitr = upper_bound(ALL(c), b[i]);
		if (downitr == c.end()) continue;
		down = downitr - c.begin();
		
		/*
		int l, r, m, up, down;
		l = -1;
		r = n;
		while (l + 1 < r) {
			m = (l + r) / 2;
			if (a[m] < b[i]) l = m;
			else r = m;
		}
		up = l;

		l = -1;
		r = n;
		while (l + 1 < r) {
			m = (l + r) / 2;
			if (c[m] <= b[i]) l = m;
			else r = m;
		}
		down = r;
		*/

		ans += ll(up) * ll(n - down);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4560
from collections import deque

n,m = map(int, input().split())
P = [0]+list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n+1)]
for x, y in XY:
    G[x].append(y)
    G[y].append(x)

q = deque()
vis = [False]*(n+1)
ans = 0
for i in range(1,len(G)):
    set_x, set_px = set(), set()
    q.append(i)
    while q:
        x = q.popleft()
        if vis[x]: continue
        vis[x] = True
        set_x.add(x)
        set_px.add(P[x])
        for y in G[x]:
            if vis[y]: continue
            q.append(y)
    ans += len(set_x & set_px)
print(ans)


Measured memory_bytes: 54880
#include <stdio.h>

int main(){
  char a[3];
  scanf("%s",a);
 
  if(a[2]=='\0'){
    printf("%s",a);
  }else{
    char u = a[0];
    a[0] = a[2];
    a[2] = u;
    printf("%s",a);
  }  
}

Measured memory_bytes: 128
#include<stdio.h> 
int main(){ 
 int a, b,c,cnt=0; 
 scanf("%d %d %d",&a, &b, &c); 
 for (int i = a; i <= b; ++i) { 
  if (c%i == 0) ++cnt; 
 } 
 printf("%d\n", cnt); 
 return 0; 
} 


Measured memory_bytes: 2104
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		try {
			int time_sec = sc.nextInt();

			int hour = time_sec / 3600;
			int minute = time_sec % 3600 / 60;
			int second = time_sec % 60;

			System.out.println(hour + ":" + minute + ":" + second);
		} catch(InputMismatchException ex) {
			ex.printStackTrace();
		} finally {
			sc.close();
		}
	}
}



Measured memory_bytes: 26352
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct P
{
	int l, r;
	bool operator<(const P& p)
	{
		return r != p.r ? r < p.r : l < p.l;
	}
};

P Ps[100010];

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

	int N, M;
	cin >> N >> M;
	rep(i, 0, M)
	{
		cin >> Ps[i].l >> Ps[i].r;
	}

	sort(Ps, Ps + M);

	int r = 0;
	int ans = 0;
	rep(i, 0, M)
	{
		if (r <= Ps[i].l)
		{
			ans++;
			r = Ps[i].r;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
from bisect import bisect_left
A, B, Q = map( int, input().split())
S = [ int( input()) for _ in range(A)]
T = [ int( input()) for _ in range(B)]
X = [ int( input()) for _ in range(Q)]
for i in range(Q):
    q = X[i]
    ANS = []
    # jinja kara
    JP = []
    s = bisect_left(S, q)
    if s == 0:
        JP.append(S[0])
    elif s == A:
        JP.append(S[A-1])
    else:
        JP.append(S[s])
        JP.append(S[s-1])
    while JP:
        f = JP.pop()
        z = abs(f-q)
        t = bisect_left(T, f)
        if t == 0:
            ANS.append( z + abs(f - T[0]))
        elif t == B:
            ANS.append( z + abs(f - T[B-1]))
        else:
            ANS.append( z + abs(f - T[t]))
            ANS.append( z + abs(f - T[t-1]))
    # tera kara
    TP = []
    t = bisect_left(T, q)
    if t == 0:
        TP.append(T[0])
    elif t == B:
        TP.append(T[B-1])
    else:
        TP.append(T[t])
        TP.append(T[t-1])
    while TP:
        f = TP.pop()
        z = abs(f-q)
        s = bisect_left(S, f)
        if s == 0:
            ANS.append( z + abs(f - S[0]))
        elif s == A:
            ANS.append( z + abs(f - S[A-1]))
        else:
            ANS.append( z + abs(f - S[s]))
            ANS.append( z + abs(f - S[s-1]))
    print( min(ANS))

Measured memory_bytes: 16116
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define REP(x,b) for(int x=0;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main( int argc, const char* argv[] )
{
    string s;
    cin >> s;
    REV(s);
    FORSIZE(i, s) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1172
/*
======================================================
                    BunGee_Gum
======================================================
*/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x,y,t,k;
pair<char,char>p;
set< pair<char,char> >s;
int main()
{
    ios::sync_with_stdio(0);
    string s,s2;

    cin>>n>>x>>y;

    t=n-x;
    k=y-t;
    if(k<0)
        k=0;
    cout<<k<<endl;



    return 0;
}


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

using namespace std;

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

typedef long long int ll;


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

	int n,k;
	int arr[100000];
	cin >> n >> k;

	rep(i,n)
		cin >> arr[i];
	
	int count = 0;
	rep(i,n)
	{
		if(arr[i] >= k)
			count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
int n,a[20][20];
void solve(int i,int j,int c){
  if(n*n+1==c) return;
  if(i>n) return solve(1,j,c);
  if(j>n) return solve(i,1,c);
  if(i<1) return solve(n,j,c);
  if(j<1) return solve(i,n,c);
  if(!a[i][j]){
    a[i][j]=c;
    return solve(i+1,j+1,c+1);
  }
  if(a[i][j]) solve(i+1,j-1,c);
}
int main(void){
  for(;;){
    scanf("%d",&n);
    if(!n) break;
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++) a[i][j]=0;
    }
    solve(n/2+2,n/2+1,1);
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++) printf("%4d",a[i][j]);
      puts("");
    }
  }
}


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

using namespace std;

int main()
{
    string S,T;;
    cin>>S>>T;
    bool ans = false ;
    for ( int i = 0; i < S . size (); ++ i )
    {
        if ( S == T )
        {
            ans = true ;
            break ;
        }
        S = S . back () + S . substr (0, S . size () -1);
    //cout<<S<<endl;
    }
    if (ans)
    {
        cout <<"Yes"<< endl ;
    }
    else
    {
        cout <<"No"<< endl ;
        return 0;
    }
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k % 2 == 1) cout << b-a << endl;
  else cout << a-b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(b<c)
   {
       cout<<0<<endl;

   }
   else if(d<a)
   {
       cout<<0<<endl;
   }
   else if(c<=a && b<=d)
   {
       cout<<b-a<<endl;
   }
   else if(a<=c && d<=b)
   {
       cout<<d-c<<endl;
   }
   else if(a<c)
   {
       cout<<b-c<<endl;
   }
   else
   {
       cout<<d-a<<endl;
   }
}


Measured memory_bytes: 256
d1 = int(input())
d2 = int(input())
d3 = int(input())
d4 = int(input())
d5 = int(input())
sa = int(input())
data = sorted([d1, d2, d3, d4, d5])
if data[-1] - data[0] > sa:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll cnt = 0;
  ll A[200200];
  rep(i, N) cin >> A[i];
  if(A[0] != 0) {
    cout << -1 << "\n"; return 0;
  }
  rep1(i, N - 1) {
    if(A[i] == 0) continue;
    else if(A[i] == A[i - 1] + 1) {
      cnt ++;
    }
    else if(A[i] <= A[i - 1] && A[i] <= i) {
      cnt += A[i];
    }
    else {
      cout << -1 << "\n"; return 0;
    }
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);
  printf("%td\n", std::min_element(a.begin(), a.end())-a.begin()+1);
}



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

 int main() {
   vector<char> S(3);
   for(int i = 0;i < 3;i++){
     cin >> S.at(i);
   }
   sort(S.begin(), S.end());
   
     if(S.at(0) == 'a' && S.at(1) == 'b' && S.at(2) == 'c'){
       cout << "Yes" << endl;
     }else{
       cout << "No" << endl;
     }                            
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);
  string S;
  cin >> S;
  u32 R = 0, B = 0;
  for (u32 i = 0; i < S.size(); ++i) {
    if (S[i] == '0') R++;
    if (S[i] == '1') B++;
  }
  cout << ((R < B) ? R * 2 : B * 2) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define chmax(x,y) x = max(x, y)

int main() {
    string n ;
    cin >> n ;
    int k = n.size() ;
    ll tot = 0 ;
    rep(i, k){
        char f = n[i] ;
        int a = f - '0' ;
        tot += a ;
    }
    if(tot % 9 == 0){
        cout << "Yes" << endl; 
    }
    else {
        cout << "No" << endl; 
    }
} 

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S, T;
    cin >> S >> T;
    string ans;
    ans = S + T[S.length()];
    if(ans == T){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;
int main()
{
    /*
    cin>>x;
    cout<<x<<endl;
    */
    int n,m,i,j,ans;
    cin>>n;
    vector<int> k(n);
    for(i=0;i<n;i++){
        cin>>k[i];
    }
    ans=k[0];
    for(i=1;i<n;i++)
        ans=__gcd(ans,k[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 998244353
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

/*
  階乗計算（MODで割った余りで返す）
*/

class Factorial {
    private:
        vector<long long> fac;
    public:
        Factorial();
        Factorial(long long n_max);
        void initialization(long long n_max);
        long long getFactorial(long long n);
};

Factorial::Factorial() {}
Factorial::Factorial(long long n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (long long i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
void Factorial::initialization(long long n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (long long i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
long long Factorial::getFactorial(long long n) {
    return fac[n];
}

/*
  MOD計算
*/
// 割り算のための逆元を求める（mod m での a の逆元）
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u % m;
}

/*
    順列と組み合わせ (P, C, H)
*/

class PCH {
    private:
        Factorial fact;
    
    public:
        PCH(long long n_max);
        long long P(long long n, long long r);
        long long C(long long n, long long r);
        long long H(long long n, long long r);
};
PCH::PCH(long long n_max) {
    fact.initialization(n_max);
}
long long PCH::P(long long n, long long r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD;
}

long long PCH::C(long long n, long long r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

long long PCH::H(long long n, long long r) {
    return C(n - 1 + r, r);
}

int main() {

    long long N, M, K;
    cin >> N >> M >> K;

    vector<long long> count(N + 1, 0);
    count[1] = M;
    for (int i = 2; i <= N; i++) {
        count[i] = count[i - 1] * (M - 1) % MOD;
    }
    long long ans = 0;

    PCH pch(N);

    for (int i = 0; i <= K; i++) {
        long long x;
        x = count[N - i];
        x = x * pch.C(N - 1, i) % MOD;
        ans += x;
        ans %= MOD;
    }

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

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

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int main() {
  vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;
  int k = find(v.begin(), v.end(), s) - v.begin();
  cout << 7 - k << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
	"sort"
)

func main() {
	sc := NewScanner()

	arr := make([]int, 5)
	n := make([]int, 5)
	for i := 0; i < 5; i++ {
		tmp := sc.NextInt()
		n[i] = tmp
		arr[i] = tmp % 10
	}

	sort.Ints(arr)
	ans := 0
	first := true
	for i := 0; i < 5; i++ {
		if arr[i] == 0 {
			continue
		}
		if first {
			first = false
			continue
		}
		ans += 10 - arr[i]
	}
	//	fmt.Printf("%+v\n", ans) // output for debug

	for i := 0; i < 5; i++ {
		ans += n[i]
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

#define MAX 7368792

int main() {
	int m, n;
	while (cin >> m >> n, m) {
		vector<bool> used(MAX);
		int ans = m;
		for (int i = 0; i < n; ++i) {
			for (int j = ans; j < MAX; j += ans) used[j] = true;
			while (used[ans]) ++ans;
		}
		cout << ans << endl;
	}

	return 0;
}


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

int mod = 1000000007;

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
   
    vector<int> A(N, 1); //数列A

    vector<vector<int>> list(Q, vector<int>(4));
    for (int i = 0; i < Q; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cin >> list[i][j];
        }
        list[i][0]--;
        list[i][1]--;
    }

    int score;
    int ans = 0;
    int k = N - 1;
    while (true)
    {
        score = 0;
        for (int i = 0; i < Q; i++)
        {
            if (A[list[i][1]] - A[list[i][0]] == list[i][2])
                score += list[i][3];
        }
        ans = max(ans, score);

        if (A[k] != M)
            A[k]++;
        else
        {
            while (A[k] == M)
                k--;
            if (k == -1)
                break;
            else
            {
                A[k]++;
                for (int i = k + 1; i < N; i++)
                    A[i] = A[k];

                k = N - 1;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3604
def insertionSort(A, n, g, cnt):
	for i in range(g, n):
		v = A[i]
		j = i - g
		while (j >= 0) and (A[j] > v):
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v
	return cnt

def shellSort(A, n, m, G):
	cnt = 0
	for i in range(m):
		cnt = insertionSort(A, n, G[i], cnt)
	return cnt

n = int(input())
A = []
for i in range(n):
	A.append(int(input()))

h = 1
p = 1
G = []

if n < 2:
	G = [1]
	p = 2
else:
	while h < n: 
		G.append(h)
		h = 3 ** p + h
		p += 1

G.reverse()
cnt = shellSort(A, n, p - 1, G)
print(p - 1)
print(" ".join(map(str, G)))
print(cnt)
for i in range(n):
	print(A[i])


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int now = 1;
    for (int i = 0; i < n; i++){
        if (a[i] ==  now) now++;
    }
    if (now == 1) cout << - 1 << endl;
    else cout << n - now + 1 << endl;
}

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

bool dp[2][8192][16384] = {};

int main(void) {
  int x, y, n;
  string s;
  vector<int> f[2];
  
  cin >> s >> x >> y;
  
  n = s.size();
  int zohe = 0;
  
  f[0].push_back(0);
  f[1].push_back(0);
  
  for (auto c : s) {
    if (c == 'F')
      f[zohe % 2].back()++;
    if (c == 'T') {
      f[zohe % 2].push_back(0);
      zohe++;
    }
  }
  
  dp[0][0][f[0][0] + n] = true;
  dp[1][0][f[1][0] + n] = true;
  dp[1][0][-f[1][0] + n] = true;

  for (int i = 0; i < 2; i++) {
    for (int j = 1; j < f[i].size(); j++) {
      for (int k = 0; k <= n * 2; k++) {
        int d = f[i][j];
        if (k - d >= 0 && dp[i][j - 1][k - d])
          dp[i][j][k] = true;
        if (k + d <= n * 2 && dp[i][j - 1][k + d])
          dp[i][j][k] = true;
      }
    }
  }
  
  cout << (dp[0][f[0].size() - 1][x + n] && dp[1][f[1].size() - 1][y + n] ? "Yes" : "No") << endl; 
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

  COMinit();

  long long int ans = 0;

  for(int i=1;i<=h-a;i++) {
    ans = (ans + COM(b+i-2, i-1) * COM(w-b+h-i-1, w-b-1)) % MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 12160
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
const char *body = "Sabcde";
char s[10][11];
bool vis[10][10][1<<8][10];
bool bad[10][10];

int main() {
	int H, W, N;
	scanf("%d%d%d", &H, &W, &N);
	rep(i, H) scanf("%s", s[i]);
	int inithist = 0, sy = -1, sx = -1;
	rep(i, H) rep(j, W) if(s[i][j] == 'S') {
		int y = i, x = j;
		rep(k, 4) {
			rep(d, 4) {
				int yy = y + dy[d], xx = x + dx[d];
				if(yy<0||yy>=H||xx<0||xx>=W) continue;
				if(s[yy][xx] != body[k+1]) continue;
				y = yy, x = xx;
				inithist |= d << (k * 2);
				break;
			}
		}
		sy = i, sx = j;
//		cerr << sy << ", " << sx << endl;
	}

	int t = 0;
	mset(vis, 0);
	mset(bad, 0);
	vector<int> q, next;
	vis[sy][sx][inithist][0] = true;
	next.pb(inithist | (sy << 8) | (sx << 12) | (0 << 16));
	while(!next.empty()) {
		q.swap(next);
		while(!q.empty()) {
			int ss = q.back(); q.pop_back();
			int hist = ss & 255;
			int y = ss >> 8 & 15, x = ss >> 12 & 15;
			int num = ss >> 16;
//			cerr << y << ", " << x << ", " << hist << ", " << num << ": " << t << endl;
			if(num == N) {
				printf("%d\n", t);
				return 0;
			}
			{	int yy = y, xx = x;
				rep(k, 4) {
					int d = hist >> (k*2) & 3;
					yy += dy[d], xx += dx[d];
					bad[yy][xx] = true;
				}
			}
			rep(d, 4) {
				int yy = y + dy[d], xx = x + dx[d];
				if(yy<0||yy>=H||xx<0||xx>=W) continue;
				if(s[yy][xx] == '#' || bad[yy][xx]) continue;
#define NEXT(y, x, h, n)\
	if(!vis[y][x][h][n]) {\
		next.pb(h | (y << 8) | (x << 12) | (n << 16));\
		vis[y][x][h][n] = true;\
	}
				int newhist = ((hist << 2) & ~(3 << 8)) | (d ^ 2);
				NEXT(yy, xx, newhist, (num + (s[yy][xx] == '1' + num)));
			}
			{	int yy = y, xx = x;
				rep(k, 4) {
					int d = hist >> (k*2) & 3;
					yy += dy[d], xx += dx[d];
					bad[yy][xx] = false;
				}
			}
		}
		t ++;
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 1492
N = int(input())
a = list(map(int,input().split()))

def solve(N):
    fac = 0
    for i in a:
        while True:
            if i % 2 == 0:
                fac = fac + 1
                i = i//2
            else:
                break
    return fac

print(solve(N))


Measured memory_bytes: 4152
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    int a = 0;
    int b = 0;
    rep(i, n) {
        string s, t;
        cin >> s >> t;
        if (s == t) {
            a++; b++;
        } else if (s < t) {
            b += 3;
        } else {
            a += 3;
        }
    }
    cout << a << " " << b << endl;
}



Measured memory_bytes: 3160
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main(){
  string S;
  cin>>S;
  int l=(int)S.length();
  vector<int> vS(l);
  for(int i=0;i<l;i++){
    if(S[i]=='1')	vS[i]=1;
    if(S[i]=='0')	vS[i]=0;
    //cout<<vS[i];
  }
  int res=0;
  int sum=0;
  int tmp=!vS[0];
  for(int i=0;i<l;i++){
    if(vS[i]==tmp){
      vS[i]=!vS[i];
      sum++;
    }
    tmp=vS[i];
    //cout<<vS[i];
  }
  for(int i=0;i<l;i++){
    if(S[i]=='1')	vS[i]=1;
    if(S[i]=='0')	vS[i]=0;
    //cout<<vS[i];
  }
  //int res=0;
  int sum2=0;
  int tmp2=vS[0];
  
  for(int i=0;i<l;i++){
    if(vS[i]==tmp2){
      vS[i]=!vS[i];
      sum2++;
    }
    tmp2=vS[i];
    //cout<<vS[i];
  }
  if(sum<=sum2)	res=sum;
  if(sum>sum2)	res=sum2;
  //top=10;
  //cout<<l<<endl;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	ll n;
	cin>>n;
	ll sum=n*(n+1)/2;
	sum-=3*(n/3)*(n/3+1)/2;
	sum-=5*(n/5)*(n/5+1)/2;
	sum+=15*(n/15)*(n/15+1)/2;
	cout<<sum<<endl;

}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
    int a,b,c,diviser;
    
    scanf("%d%d%d",&a,&b,&c);
    
    while(a<=b){
        if(c%a==0){
            diviser++;
        }
        a++;
    }
    printf("%d\n",diviser);
    
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

//using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
//typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const i64 mod = 1000000007LL ;

#define maxn 500005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

int main()
{
    int n , k ;
    scanf("%d %d",&n,&k) ;
    printf("%d\n",n-k+1) ;

    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint p=1e9+7;

int main(){
  vector<string> A={"A","G","C","T"};
  map<string,lint> m1,m2;
  for(auto e:A)m1[e]=1;
  int N;
  cin>>N;
  REP(i,N-1){
    for(auto& e:m1){
      e.second%=p;
      for(auto c:A){
        bool f=true;
        REP(j,4){
          string S=e.first+c;
          if(j!=0)swap(S[j],S[j-1]);
          if(S.find("AGC")!=S.npos){
            f=false;
            break;
          }
        }
        if(f){
          string S=e.first+c;
          if(S.size()<=3)m2[S]+=e.second;
          else m2[S.substr(1)]+=e.second;
        }
      }
    }
    m1=m2;
    m2.clear();
  }
  lint ans=0;
  for(auto e:m1){
    ans+=e.second%p;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main()
{
  using namespace std;
  string a_str,b_str;
  while(cin>>a_str){
    cin>>b_str;
    int num,i=3;
    while(--i>=0)
      if(a_str[i]==b_str[i])
         num++;
         cout<<num<<endl;
  }
         return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import math

def main():
    N = int(input())

    max_k = 0
    if N < 0:
        min_n = 0
        for k in range(1, 32, 2):
            min_n += (-2) ** k
            if min_n <= N:
                max_k = k
                break
    else:
        max_n = 0
        for k in range(0, 32, 2):
            max_n += 2 ** k
            if N <= max_n:
                max_k = k
                break

    t = 0
    for k in range(1, max_k + 1, 2):
        t += 2 ** k

    n = N + t
    n ^= t

    print(bin(n)[2:])


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  vector<ll>A(N);
  ll B=0;
  for(ll i=0;i<N;i++){
    cin>>A[i];
    B^=A[i];
  }
  for(ll i=0;i<N;i++){
    cout<<(B^A[i])<<" ";
  }
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct tri{
  ll f,s,t;
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;ll K;cin >> N >> K;
  vector<PII> v(N);
  ll b;
  b = K+2*N-1;
  int index = 0;
  repp(x,K,K+N){
    if((x&1)==0)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }
  repp(x,K,K+N){
    if(x&1)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }

  sort(all(v));
  ll c = K+2*N;
  queue<tri> que;
  rep(i,N){
    if(v[i].first>c){
      cout << -1 << endl;
      return 0;
    }
    que.push({v[i].second,v[i].first-v[i].second,c});
    ++c;
  }
  while(!que.empty()){
    tri t = que.front();que.pop();
    cout << t.f SP t.s SP t.t << endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    string s;
    ci >> s;

    map<char, int> m;

    rep(i, 0, 4) {
	if(!m[s[i]]) m[s[i]] = 1;
	else m[s[i]]++;
    }

    if(m[s[0]] == 2 && m[s[1]] == 2 && m[s[2]] == 2 && m[s[3]] == 2) co << "Yes" << en;
    else co << "No" << en;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  ll sum = 0;
  ll ans1 = 0;
  
  //正負の順
  for(int i=0,s=1;i<n;i++,s*=-1){
    sum += a[i];
    if(sum * s <= 0){
      ans1 += abs(sum - s);
      sum = s;
    }
  }
  sum = 0;
  ll ans2 = 0;
  
  //負正の順
  for(int i=0,s=-1;i<n;i++,s*=-1){
    sum += a[i];
    if(sum * s <= 0){
      ans2 += abs(sum - s);
      sum = s;
    }
  }
  
  cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>

#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

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

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll INF = (ll)1e18;
ll MOD;

ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 2000100;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    
    ld p, ans = 0;
    ll x;
    cin >> x >> p;
    
    p /= 100;
    if (x % 2 == 0) {
        ans = x / 2 / p;
    }
    else {
        ans = 1 + (x + 1) * (1 - p) / 2 / p + (x - 1) / 2;
    }
    cout << setprecision(10) <<  ans << endl;
    
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;

int main()
{
	unsigned long long n;
	char s[20];
	cin >> n;
	sprintf(s, "%llu", n);
	int m = strlen(s);
	unsigned long long k = (m - 1) * 9, h = 0, maxx = 0;
	for (int i = 0; i < m - 1; i++)
		h = h * 10 + 9;
	for (int i = 0; i < 10; i++) {
		unsigned long long hh = (unsigned long long)(i * pow(10, m - 1)) + h;
		//cout << hh << endl;
		if (hh <= n)
			maxx = max(maxx, k + i);
	}
	cout << maxx << endl;
	return 0;
}


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

int main() {
    cout<< fixed << setprecision(1000);
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << sqrt((a - c) * (a - c) + (b - d) * (b - d)) << endl;
}



Measured memory_bytes: 3292
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

template <typename T> T mod_pow(T n, T r, T m) {
	T ret = 1;
	T tmp = n;
	while (r != 0) {
		if (r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}

int main() {
	ull mod = 998244353;
	
	uint N;
	cin >> N;
	
	vector<uint> Ds(N, 0);
	uint m = 0;
	uint d;
	
	for(uint n=0; n<N; n++) {
		cin >> d;
		if(n == 0 && d != 0) {
			cout << 0;
			return 0;
		} else if(d == 0 && n != 0) {
			cout << 0;
			return 0;
		}
		Ds[d]++;
		m = max(m, d);
	}
	
	ull ans = 1;
	for(uint i=1; i<=m; i++) {
		ans = ans * mod_pow((ull)Ds[i-1], (ull)Ds[i], mod) % mod;
	}
	
	cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  ll a = 60 * h1 + m1;
  ll b = 60 * h2 + m2;
  ll ans = b - a - k;
  if(ans<0){
    print(0);
  }
  else{
    print(ans);
  }
}

Measured memory_bytes: 3636
nk=list(map(int,input().split()))
s=input()
L=[]
R=[]
lr="a"
for i in range(nk[0]):
    if lr=="L":
        if s[i]=="R":
            lr="R"
            R.append(1)
        else:
            L[-1]+=1
    elif lr=="R":
        if s[i]=="L":
            lr="L"
            L.append(1)
        else:
            R[-1]+=1
    else:
        lr=s[0]
        if lr=="L":
            L.append(1)
        else:
            R.append(1)
L.sort(reverse=True)
R.sort(reverse=True)
lsum=sum(L[:nk[1]])
rsum=sum(R[:nk[1]])
if len(L)<=nk[1] or len(R)<=nk[1]:
    print(nk[0]-1)
else:
    if lsum+sum(R)>rsum+sum(L):
        rmerge=sum(R[:nk[1]+1])+lsum
        R=R[nk[1]:]
        if R!=[]:
            R[0]=rmerge
        else:
            R=[rmerge]
        L=L[nk[1]:]
        ans=sum(R)-len(R)+sum(L)-len(L)
    else:
        lmerge=sum(L[:nk[1]+1])+rsum
        L=L[nk[1]:]
        if L!=[]:
            L[0]=lmerge
        else:
            L=[lmerge]
        R=R[nk[1]:]
        ans=sum(L)-len(L)+sum(R)-len(R)
    print(ans)


Measured memory_bytes: 4664
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n;
int main() {
	cin >> n;
	LL ans = 1e18;
	for (LL i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			LL j = n / i;
			ans = min(ans, abssl(i - 1) + abssl(j - 1));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256