akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    char S[4];
    int i;
    for(i=0;i<3;i++)
    scanf("%c",&S[i]);
    
     if(S[0]=='a'&&S[1]=='b'&&S[2]=='c')printf("Yes");
      else if(S[0]=='a'&&S[1]=='c'&&S[2]=='b')printf("Yes");
   else if(S[0]=='b'&&S[1]=='a'&&S[2]=='c')printf("Yes");
   else if(S[0]=='b'&&S[1]=='c'&&S[2]=='a')printf("Yes");
     else if(S[0]=='c'&&S[1]=='a'&&S[2]=='b')printf("Yes");
  else if(S[0]=='c'&&S[1]=='b'&&S[2]=='a')printf("Yes");
  else{printf("No");}
  
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;

    return 0;
}


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

using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

#define rep(i,a,b) for(int i =(a);i<(int)(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

typedef long long ll;

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

    ll ans = 0;
    ll pos, step, dist; 
    cin>>pos>>step>>dist;

    pos = abs(pos);
    ll val = pos/dist;
   
    if(val>= step){
        ans = pos- step*dist;
    }
    else{
        ans = pos - val*dist;
        step = step - val;
        if(step&1ll){
            ans = min(abs(ans- dist), abs(ans+dist));
        }
    }

    cout<<ans<<endl;


    return 0 ;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll K, N;
    cin>>K>>N;
    vector<ll> A(N);
    ll Sh=0;
    rep(i, N){
        cin>>A[i];
        if(i>0){
            Sh=max(Sh, A[i]-A[i-1]);
        }
    }
    ll V=A[0]+K-A[N-1];
    Sh=max(Sh, V);
    cout<<K-Sh<<endl;


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, ans;
    cin >> A >> B;
    ans = A%B>0?1:0;
    cout << ans<< endl;
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A%2==1 && B%2==1)
    // 	puts("Yes");
    // else
    // 	puts("No");
	
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <climits>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
ll MODULAR_INVERSE(ll a , ll MOD) {
    return MODULAR_POWER(a , MOD - 2 , MOD);
}
int spf[N + 1];
void sieve() {
    spf[1] = 1;
    for(int i = 2 ; i < N ; i++) spf[i] = i;
    for(int i = 4 ; i < N ; i += 2) spf[i] = 2;
    for (int i = 3 ; i * i < N ; i++) {
        if (spf[i] == i) {
            for (int j = i * i ; j < N ; j += i) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
}
map < ll , ll > getFactorization(ll x) {
    map < ll , ll > ret;
    while (x != 1){
        ret[spf[x]]++;
        x = x / spf[x];
    }
    return ret;
}
ll f[123456];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    long long n , m;
    cin >> n >> m;
    sieve();
    map < ll , int > ans;
    f[0] = 1;
    const ll kk = 123455;
    rep(i , 1 , kk) {
        f[i] = i * f[i - 1];
        f[i] %= mod;
    }
    if(m == 1) {
        cout << 1 << endl;
        return 0;
    }
    rep(i , 2 , N - 1) {
        if(spf[i] == i) {
            while(1) {
                if(m % spf[i] != 0) {
                    break;
                }
                ans[spf[i]]++;
                m /= spf[i];
            }
        }
    }
    if(m != 1) {
        ans[m]++;
    }
    ll answer = 1;
    for(auto j : ans) {
        ll fi = j.first;
        ll se = j.second;
        answer *= f[se + n - 1];
        answer %= mod;
        answer *= MODULAR_INVERSE(f[se] , mod);
        answer %= mod;
        answer *= MODULAR_INVERSE(f[n - 1] , mod);
        answer %= mod;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;
using ld = long double;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;
constexpr int M = 1e9 + 7;

constexpr int N = 301;
ld E[N][N][N];

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

	int n, c[3] = {0, 0, 0}; cin >> n;
	rep(i, 0, n) { int a; cin >> a; ++c[--a]; }
	rep(k, 0, n + 1)
		rep(j, 0, n + 1)
			rep(i, 0, n + 1) {
				int s = i + j + k;
				if (n < s) break;
				if (s == 0) continue;
				auto &x = E[i][j][k];
				x = n;
				if (i) x += i * E[i - 1][j][k];
				if (j) x += j * E[i + 1][j - 1][k];
				if (k) x += k * E[i][j + 1][k - 1];
				x /= s;
			}
	cout << fixed << setprecision(18) << E[c[0]][c[1]][c[2]];
}

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

int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  a[0] += 'A' - 'a';
  b[0] += 'A' - 'a';
  c[0] += 'A' - 'a';

  cout << a[0] << b[0] << c[0] << endl;
}


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

int main(){
  int a,b,c;
  string ans;
  cin >> a >> b >> c;
  if(c>=a && b>=c){
    ans="Yes";
  }
  else {
    ans="No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
N, L, T = map(int, input().split())
 
ants = []
for i in range(N):
    x, w = map(int, input().split())
    ants.append((x, w))
 
# After T
ants2 = []
for ant in ants:
    ants2.append((ant[0] + T * (3 - 2 * ant[1])) % L)
 
st = 0
for i in range(N):
    if ants2.count(ants2[i]) == 1:
        break
    st += 1
 
# Number of collision for Ants[st]
cl = 0
for i in range(N):
    if ants[i][1] == ants[st][1]:
        continue  # same direction
    else:
        if ants[st][1] == 1:
            if ants[i][0] > ants[st][0]:
                fc = (ants[i][0] - ants[st][0]) / 2
            else:
                fc = ((L - ants[st][0]) + ants[i][0]) / 2
            cl += (2 * (T - fc)) // L + 1
        else:
            if ants[i][0] > ants[st][0]:
                fc = ((L - ants[i][0]) + ants[st][0]) / 2
            else:
                fc = (ants[st][0] - ants[i][0]) / 2
            cl -= (2 * (T - fc)) // L + 1
 
stant = ants2[st]
ants2.sort()
idx = ants2.index(stant) - int(cl) - st
 
for i in range(N):
    print(ants2[(i + idx) % N])

Measured memory_bytes: 18472
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string ans;
	switch(n%10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			ans="hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			ans="pon";
			break;
		case 3:
			ans="bon";
			break;
		default:
			break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    string a;
    cin>>a;
    f(i,0,a.length()){
        cout<<"x";
    }
    cout<<endl;
    
    
    


   

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int alp[26]={};
    char al;
    while(cin >> al){
        al = tolower(al);
        int num = al-'a';
        alp[num]++;

    }
    for(int i=0;i<26;i++){
        cout << char(i+'a') << " : " << alp[i] << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;

int u[N], v[N], w[N], f[N];
bool vis[N];

int find(int x){
	if (f[x] == x) return x;
	return f[x] = find(f[x]);
}

int main(){
	int n, q; long long m;
	scanf("%d%lld%d", &n, &m, &q);
	for (int i = 1; i <= n; i++) f[i] = i;
	int n1 = n;
	for (int i = 1; i <= q; i++){
		scanf("%d%d%d", &u[i], &v[i], &w[i]); u[i] ++; v[i] ++;
		if (w[i] == 0){
			if (find(u[i]) == find(v[i])) continue;
			n1 --;
			f[find(u[i])] = find(v[i]);
		}
	}

	int num = 0;
	for (int i = 1; i <= q; i++){
		if (w[i] == 1){
			if (find(u[i]) == find(v[i])) return 0 * printf("No");
			num = 1;
		}
	}
	if (num > 0 && n1 < 3) return 0 * printf("No");
	long long m1 = n - 1;
	if (num > 0) m1 ++;
	long long m2 = 1LL * n1 * (n1 - 1) / 2 + n - n1;
	if (m >= m1 && m <= m2) return 0 * printf("Yes");
	else return 0 * printf("No");
	return 0;
}

Measured memory_bytes: 1792
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0

for i in range(N):
    b = B[i]
    a = bisect.bisect_left(A, b)
    c = N - bisect.bisect_right(C, b)
    ans += a*c
print(ans)


Measured memory_bytes: 23240
// Marcin Knapik
#include<bits/stdc++.h>
#include<unistd.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
 
typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define boost                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define REP(i, a, b)            for (int i = (a); i <= (b); i++)
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define TRAV(i, n)              for(auto&i:n)
#define beg(x)                  (*(x.begin()))
#define re(x)                   int x; cin >>x;   
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
 
const ll T = 1 << 20;
const int INF = 1e9 + 7;
// const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll  N = 1e6+7;
const int LOG = 17;
 
ll n, m, q;

int koszt[N];
int otw[N];

int dp[1<<12][1007];

signed main(){
	boost;
	cin >> n >> m;
	FOR(i, m){
		cin >> koszt[i+1];
		int temp;
		cin >> temp;
		int maska = 0;
		FOR(j, temp){
			int pom;
			cin >> pom;
			pom--;
			maska |= (1<<pom);
		} 
		otw[i+1] = maska;
	}
	for(int j = 0 ; j < (1<<12); j++){
		for(int i = 0 ; i< 1007; i++){
			dp[j][i] = INF;
		}
	}
	dp[0][0] = 0;
	for(int i = 1; i <= m; i++){
		for(int j = 0; j < (1<<n); j++){
			if((otw[i]&j) == otw[i]){
				int pop = j^otw[i];
				int mini = INF;
				for(int k = 0; k < i; k++){
					setmin(mini, dp[pop][k]);
				}
				dp[j][i] = min(INF, mini+koszt[i]);
			}
		}

		for(int j = (1<<n) -1; j>= 0; j--){
			for(int k = j; k >= 0; k = (k-1)&j){
				dp[k][i] = min(dp[k][i], dp[j][i]);
				if(k == 0)
					break;
			}
		}
	}
	int mini = INF;
	for(int i = 0; i <= m; i++){
		setmin(mini, dp[(1<<n)-1][i]);
	}
	cout << (mini!=INF?mini:-1) << '\n';

}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> rate(n);
  int sum =0;
  bool zero = true;

  rep(i,n){
    cin >> rate.at(i);
    if(rate.at(i)%10!=0) zero = false;
    sum += rate.at(i);
  }

  if(zero){
    puts("0");
    return 0;
  }

  sort(all(rate));

  if(sum%10!=0){
    cout << sum << endl;
    return 0;
  }

  rep(i,n){
    if((sum-rate.at(i))%10==0) continue;
    else {
      cout << sum-rate.at(i) << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int copy;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println(a + " " + b + " " + c);
			}else{
				System.out.println(a + " " + c + " " + b);
			}
		}else if(a > b){
			if (b > c){
				System.out.println(c + " " + b + " " + a);
			}else{
				System.out.println(b + " " + c + " " + a);
			}
		}
		}
}


Measured memory_bytes: 26220
/* Low Elements */

#include <iostream>
#define N 1000000000
using namespace std;

int main(){
  int n;
  cin >> n;
  int p[n];
  int min=N;
  int cnt=0;
  for(int i=0;i<n;i++){
    cin >> p[i];
    if(p[i]<min){
      min=p[i];
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 1e5 + 5;

int dp[N][4];

signed main() {
    accell();
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
        cout << "Alice";
    else
        cout << "Borys";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; ++i)

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

if((b-a)%2==0) cout << "Alice" << endl;
else cout << "Borys" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll N, A, B, C;
vector<ll> L;

ll rec(ll used, ll a, ll b, ll c) {
    if (used == N) {
        if (a < 1 || b < 1 || c < 1) return 1LL<<60;
        else return abs(a-A) + abs(b-B) + abs(c-C);
    }

    ll res = rec(used+1, a, b, c);
    chmin(res, rec(used+1, a+L[used], b, c) + (a > 0 ? 10 : 0));
    chmin(res, rec(used+1, a, b+L[used], c) + (b > 0 ? 10 : 0));
    chmin(res, rec(used+1, a, b, c+L[used]) + (c > 0 ? 10 : 0));

    return res;
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    rep(i, N) cin >> L[i];
    cout << rec(0, 0, 0, 0) << endl;
}

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

int main() {

  long long N;
  scanf("%lld", &N);
  long long W;
  scanf("%lld", &W);
  vector<ll> w(N);
  vector<ll> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &w[i], &v[i]);
  }
  auto w0 = w[0];
  map<ll, vector<ll>> m;
  for (int i = 0; i < N; i++) {
    m[w[i] - w0].push_back(v[i]);
  }
  ll s[4][N+1];
  for (int i = 0; i < 4; i++) {
    sort(m[i].begin(), m[i].end(), greater<>());
    s[i][0] = 0;
    for (int j = 0; j < m[i].size(); j++) {
	s[i][j+1] = s[i][j] + m[i][j];
    }
  }
  ll maxVal = 0;
  for (int i = 0; i <= m[0].size(); i++) {
    for (int j = 0; j <= m[1].size(); j++) {
      for (int k = 0; k <= m[2].size(); k++) {
        for (int l = 0; l <= m[3].size(); l++) {
          if (w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3)*l <= W) {
	      maxVal = max(maxVal, s[0][i] + s[1][j] + s[2][k] + s[3][l]);
          }
        }
      }
    }
  }
  cout << maxVal << endl;
}


Measured memory_bytes: 256
#include <string>

#include <vector>
#include <iostream>

#include <algorithm>
#include <functional>

using namespace std;

int main() {
	int N, K;
	cin >> N >>K;
	vector<int> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), greater<int>());
	int min = A.back();
	for (auto i : A) {
		if (i == min)A.pop_back();
	}
	A.push_back(min);
	int size = A.size();
	int ans = 0;
	while (true) {
			size -= K;
			ans++;
			if (size <= 0) break;
			size++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    char c;
    cin >> c;
    if (
            c == 'a' ||
            c == 'e' ||
            c == 'i' ||
            c == 'u' ||
            c == 'o'
            ) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define PPB pop_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define loop(i,start,end) for(ll i=start; i<end; i++)
#define rloop(j,start,end) for(ll j=start-1; j>=end; j--)

int main()
{   
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" ,stdin);
    freopen("output.txt", "w" ,stdout);
    #endif

    ll n,k;
    cin>>n>>k;

    ll a[n];
    loop(i,0,n)
        cin>>a[i];

    ll dp[k+1]={0};

    loop(i,1,k+1)
        loop(j,0,n)
        {
            if(a[j]>i)
                break;

            else if(dp[i-a[j]]==0)
            {
                dp[i]=1;
                break;
            }
        }

    if(dp[k]==1)
        d1("First");
    else
        d1("Second");
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  double num = (a + b) / 2.0;
  //cout << num << endl;
  int inum = (a + b) / 2;
  
  if(num > inum) cout << inum + 1 << endl;
  else cout << inum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 22;
const ll mod = 1e9 + 7;
bool matrix[maxn][maxn];
ll dp[maxn][1<<maxn];
int n;

ll recursion(int i, int mask) {
    if(dp[i][mask] != -1) return dp[i][mask];
    if(i == n) {
        if(mask == (1<<n)-1) return dp[i][mask] = 1LL;
        else return dp[i][mask] = 0LL;
    }

    dp[i][mask] = 0LL;
    for(int j=0;j<n;j++) {
        if(matrix[i][j] && (mask&(1<<j))==0) {
            dp[i][mask] += recursion(i+1, mask|(1<<j));
            dp[i][mask] %= mod;
        }
    }
    return dp[i][mask];
}

int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>matrix[i][j];
        }
    }

    memset(dp,-1,sizeof(dp));
    cout<<recursion(0, 0);
    return 0;
}

Measured memory_bytes: 721152
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt=0,ans=s.size();
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='S') {
      cnt++;
    }
    else if(s[i]=='T'&&cnt>0) {
      ans-=2;
      cnt--;
    }
  }
  cout << ans << "\n";
}

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

const int  mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}//xをカッコないで初期化している
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;//thisはこの構造体を指している
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll get_ans(ll l, ll m){
    mint upper=1;
    mint downer=1;
    for(ll i=1;i<=l+m;i++){
        upper*=i;
    }
    for(ll i=1; i<=l;i++){
        downer*=i;
    }
    for(ll i=1;i<=m;i++){
        downer*=i;
    }
    mint ans=upper/downer;
    return ans.x;
}

int main(void){
    ll x, y;
    cin>>x>>y;
    if((2*x-y)%3==0&&(-x+2*y)%3==0){
        ll l=(2*x-y)/3;
        ll m=(-x+2*y)/3;
        if(l<0||m<0) {
            cout<<0<<endl;
            return 0;
        }
        ll ans=get_ans(l, m);
        cout<<ans<<endl;
        return 0;
    }
    cout<<0<<endl;
    return 0;

}

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

int main() {
   int N;
   cin >> N;
   string A,B;
   cin >> A >> B;
   string C;
   C = A + B;
   rep(i,N){
     C.at(2*i)=A.at(i);
     C.at(2*i+1)=B.at(i);
   }
   cout << C << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int MAX = 1e5;
struct edge {int to, cost;};
vector<vector<edge> > T(MAX);
int n;
ll pass[MAX];

void dfs(ll x, ll d){
    pass[x] = d;
    for (const auto &e : T[x]){
        if (pass[e.to]) continue;
        dfs(e.to, d + e.cost);
    }
}
int main(){
    int a, b, c; sc(n)
    for (int i = 0; i < n - 1; i++){
        sc(a) sc(b) sc(c)
        a--; b--;
        T[a].push_back((edge){b, c});
        T[b].push_back((edge){a, c});
    }
    int q, k, x, y;
    sc(q) sc(k)
    fill(pass, pass + n, 0);
    dfs(--k, 1);
    for (int i = 0; i < q; i++){
        sc(x); sc(y);
        cout << pass[--x] + pass[--y] - 2ll << endl;
    }
    return 0;
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	string s=to_string(n);
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='2' || s[i]=='4' || s[i]=='7' || s[i]=='9'|| s[i]=='5')
		{
			cout<<"hon"<<endl;
			break;
		}
		else if(s[i]=='3')
		{
			cout<<"bon"<<endl;
			break;
		}
		else if(s[i]=='0' || s[i]=='1' || s[i]=='6' || s[i]=='8')
		{
			cout<<"pon"<<endl;
			break;
		}
	
	}

	
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll h, w, k, ans = 0, black = 0;
string c[10];

int main() {
	cin >> h >> w >> k;
	rep(i, h) {
		cin >> c[i];
		rep(j, w) {
			if (c[i][j] == '#')black++;
		}
	}
	rep(i, 1 << h) {
		rep(j, 1 << w) {
			ll cnt = 0;
			rep(l, h) {
				rep(m, w) {
					if ((i >> l & 1 || j >> m & 1) && c[l][m] == '#')
						cnt++;
				}
			}
			if (black - cnt == k)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
    static final int max=1000000;
    public static void main(String[] args) {
        boolean p[]=new boolean[max+1];
        for(int i=0;i<max;i++)p[i]=true;
        p[0]=false;p[1]=false;
        for(int t=2;t<max;t++){
            if(p[t]){
                for(int i=t*2;i<max;i+=t){
                    p[i]=false;
                }
            }
        }
        Scanner n = new Scanner(System.in);
        while(n.hasNext()){
            long in = n.nextLong();
            int cnt=0;
            for(int i=2;i<=in;i++){
                if(p[i])cnt++;
            }
            System.out.println(cnt);
        }
    }
}

Measured memory_bytes: 27360
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    if(n == 3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }

    vector<int> ans;
    ll sum=0;
    for(int i=2; i<=30000; i++){
        if(i % 2 == 0 || i % 3 == 0){
            ans.push_back(i);
            sum += i;
        }

        if(ans.size() == n-2){
            break;
        }
    }

    for(int i=30000; i>=2; i--){
        if(!(i % 2 == 0 || i % 3 == 0)) continue;
        for(int j=30000; j>=2; j--){
            if(i == j) continue;
            if(!(j % 2 == 0 || j % 3 == 0)) continue;
            if(i == *lower_bound(ans.begin(), ans.end(), i)) continue;
            if(j == *lower_bound(ans.begin(), ans.end(), j)) continue;
            
            if((sum + i + j) % 6 == 0){
                ans.push_back(i);
                ans.push_back(j);
                goto END;
            }
        }
    }

    END:;

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int dig(long x){
  string s=to_string(x);
  return s.size();
}

int F(long a,long b){
  return max(dig(a),dig(b));
}

int main() {
  long N;cin>>N;
  int m=9999;
  for(long i=1;i<=sqrt(N);i++){
    if(N%i==0)m=min(m,F(i,N/i));
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1000000];
long long b[1000000];
signed main(){
  for(int i=0;i<4;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<4;i++){
    if(a[i]==1){
      cout<<6000*b[i]<<"\n";
    }
    if(a[i]==2){
      cout<<4000*b[i]<<"\n";
    }
    if(a[i]==3){
      cout<<3000*b[i]<<"\n";
    }
    if(a[i]==4){
      cout<<2000*b[i]<<"\n";
    }
  }
  return(0);
}


Measured memory_bytes: 3116
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int cnt = 0;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  for(int i=0;i<n;i++){
    //cout << sum << " " << a[i]*4 << endl;
    if(sum<=a[i]*4*m){
       cnt++;
    }
  }
  if(cnt>=m)  cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;

class Program
{
    static void Main(string[] args)
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        BigInteger ans = 1;
        int color = input[1] - 1;
        for (int i = 0; i < input[0] - 1; i++)
        {
            ans *= color;
        }
        Console.WriteLine(ans * input[1]);
    }
}

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

int main() {
	int loop;
	char st[] = "CODEFESTIVAL2016" ;
	char sg[17];
	int ans = 0;

	scanf("%s", sg);

	for (loop = 0; loop < 17; loop++)
		if (st[loop] != sg[loop])ans++;

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
X = int(input())
def price(n):
  if n == 1:
    return False
  for i in range(2, int(n**0.5)+1):
    if n%i == 0:
      return False
  return True

while(1):
  if price(X):
    print(X)
    break
  else:
    X += 1

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

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t=1;
    while (t--) {
        string s;
        cin >> s;
        if(s.back() != 's') {
            cout <<s+'s' << "\n";
        } else {
            cout << s+"es" << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#modの掛け算

def modmal(a,b,mod): #a*bをmodを法にして求める

    return a * b % mod


#modの割り算

def moddiv(a,b,mod): #a/bをmodを法にして求める

    return (a * pow(b,mod-2,mod)) % mod


#逆元

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod

"""
とある二つのxのみに着目すると
距離0になるのは N * M * (M-1)通り
距離xになるのは (N-x) * M * M 通り
すべての場合において他の駒のおき方が (N*M-2)! / (N*M-K)! 通りある
駒を区別しないので駒の割り当て方→K!でわる

110 1
101 2
011 1
"""

N,M,K = map(int,input().split())
mod = 10**9+7

fac,inv = modfac(N*M+1,mod)


ansx = 0

for dis in range(N):

    if dis == 0:
        ansx += N*M*(M-1) * dis
    else:
        ansx += 2 * (N-dis) * M * M * dis

    ansx %= mod

ansx *= fac[N*M-2] * inv[N*M-K]
ansx %= mod
ansx *= modnCr(K,2,mod,fac,inv)
ansx *= inv[K]

ansy = 0
for dis in range(M):

    if dis == 0:
        ansy += M*N*(N-1) * dis
    else:
        ansy += 2 * (M-dis) * N * N * dis

    ansy %= mod

ansy *= fac[N*M-2] * inv[N*M-K]
ansy %= mod
ansy *= modnCr(K,2,mod,fac,inv)
ansy *= inv[K]

print ((ansx+ansy)%mod)    

Measured memory_bytes: 54128
#include <iostream>

using namespace std;

int main(){
     long long ans=0,num1=1,num2=1,n,m;
     cin >> n >> m;
    // if (m<=n-1) cout << 0;
    //     else {
    //          for (int i=1;i<=m;i++)
    //             num1=num1*i % (1000000007);
    //          for (int i=1;i<=n;i++)
    //             num2=num2*i % (1000000007);
    //          for (int i=1;i<=m-n+1;i++)
    //             num3=num3*i % (1000000007);
    //          for (int i=1;i<=n+1;i++)
    //             num4=num4*i % (1000000007);
    //          for (int i=1;i<=2*n-m;i++)
    //             num5=num5*i % (1000000007);
    //          ans=(((num1*num2 %1000000007)*num4 %1000000007)/num3  %1000000007)/num5  %1000000007;
    //          cout << ans;
    //     }
    if (m==n+1 || m==n-1) {
         for (int i=1;i<=m;i++)
                 num1=num1*i % (1000000007);
             for (int i=1;i<=n;i++)
                num2=num2*i % (1000000007);
            cout << num1*num2 % 1000000007;
    }
        else if (m==n){
             for (int i=1;i<=m;i++)
                 num1=num1*i % (1000000007);
             for (int i=1;i<=n;i++)
                num2=num2*i % (1000000007);
            cout << 2*num1*num2 % 1000000007;
        }
        else cout << 0;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3000][2];
pair<int, int> arr[3001];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, t;
	cin >> n >> t;
	for(int i=1; i<=n; i++) {
		cin >> arr[i].first >> arr[i].second;
	}
	for(int i=1; i<=n; i++) {
		for(int j=0; j<t; j++) {
			dp[i][j][0] = dp[i-1][j][0];
			dp[i][j][1] = max(dp[i-1][j][1], dp[i-1][j][0]+arr[i].second);
			int jp = j-arr[i].first;
			if(jp >= 0) {
				dp[i][j][0] = max(dp[i][j][0], dp[i-1][jp][0]+arr[i].second);
				dp[i][j][1] = max(dp[i][j][1], dp[i-1][jp][1]+arr[i].second);
			}
		}
	}
	int ans = 0;
	for(int i=0; i<t; i++) {
		ans = max(ans, dp[n][i][1]);
	}
	cout << ans;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int s[200100];
inline bool reach(int a,int b){
	for(int i=a;i<b;i++){
		if(s[i]&&s[i+1]){
			return false;
		}
	}
	return true;
}
int main(){
	int a,b,c,d,n;
	cin>>n>>a>>b>>c>>d;
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		c=='.'?s[i]=0:s[i]=1;
	}
	s[0]=1;
	s[n+1]=1;
	if(c<d){
		if(reach(a,c)&&reach(b,d)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		int f=0;
		for (int i = b; i <=d; i++) {
            if ((!s[i-1])&&(!s[i])&&(!s[i+1])) {
                f=1;
            }
        }
        if(f){
        	cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int n[30]={0},i,k;
	for(i=0;i<28;i++){
		scanf("%d",&k);
		n[k-1]=k;
	}
	for(i=0;i<30;i++)if(n[i]==0)printf("%d\n",i+1);
	return 0;
}


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

int main() {
    string s1, s2;
    int cnt, mmax = 0;
    cin >> s1 >> s2;
    for (int i = 0; i <= s1.size() - s2.size(); i++) {
        cnt = 0;
        for (int j = 0; j < s2.size(); j++) {
            if (s1[i + j] == s2[j]) {cnt++;}
        }
        mmax = max(cnt, mmax);
    }
    cout << s2.size() - mmax << endl;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N%2==0){
      System.out.println(N/2) ;
      return;
    }else{
      System.out.println((N+1)/2) ;
      return;
    }
  }
}



Measured memory_bytes: 21204
#include <iostream>
#include <map>

using namespace std;

const int W = 4, H = 5;
int ans;
map<string, int> memo;

inline int next(int pos, int dy, int dx)
{
    if (dy == 0 && dx == 0)
        return -1;
    int x = (pos % W) + dx, y = (pos / W) + dy;
    if (x < 0 || y < 0 || x >= W || y >= H)
        return -1;
    return y * W + x;
}

int Rec(string s)
{
    if (memo.end() != memo.find(s))
        return memo[s];

    int res = s.size();

    for (int i = 0; i < s.size(); ++i) {
        for (int dy = -1; dy <= 1; ++dy) {
            for (int dx = -1; dx <= 1; ++dx) {
                int nx = next(i, dy, dx);
                if (nx == -1 || nx >= s.size())
                    continue;
                if (s[i] != s[nx])
                    continue;

                string tmp;
                for (int l = 0; l < s.size(); ++l)
                    if (l != i && l != nx)
                        tmp.push_back(s[l]);

                res = min(res, Rec(tmp));
            }
        }
    }

    memo.insert(map<string, int>::value_type(s, res));
    return res;
}

int main()
{
    int N;

    cin >> N;
    while (N--) {
        // Input
        char ch;
        string card;

        for (int i = 0; i < H * W; ++i) {
            cin >> ch;
            card += ch;
        }
        // Solve
        ans = H * W;
        cout << Rec(card) << endl;
    }

    return 0;
}

Measured memory_bytes: 1576
from sys import stdin


def main():
    S = input()
    count = 1
    ans = 0

    for s in S:
        if count % 2 == 1:
            if s == "R" or s == "U" or s == "D":
                ans += 1
        else:
            if s == "L" or s == "U" or s == "D":
                ans += 1
        count += 1

    if len(S) == ans:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int N = in.nextInt();
            Integer A[] = in.nextIntArray(N);
            Integer B[] = in.nextIntArray(N);
            Integer C[] = in.nextIntArray(N - 1);
            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += B[A[i] - 1];
                if (i > 0 && A[i] - A[i - 1] == 1) {
                    sum += C[A[i - 1] - 1];
                }
            }
            out.printLine(sum);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

        public Integer[] nextIntArray(int size) {
            Integer array[] = new Integer[size];
            for (int i = 0; i < size; i++) {
                array[i] = nextInt();
            }
            return array;
        }

    }

    static class OutputWriter {
        PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define OO -1
using namespace std;

int dp[100*1000];
vector<int> graphe[100*1000];

int plus_long(int noeud)
{
    if (dp[noeud] != -1) return dp[noeud];
    dp[noeud] = 0;
    for (int voisin : graphe[noeud])
        chmax(dp[noeud], plus_long(voisin) + 1);
    return dp[noeud];
}

signed main()
{
    int nb_sommets, nb_chemins;
    cin >> nb_sommets >> nb_chemins;
    
    for (int i=0;i<nb_sommets;++i)dp[i] = -1;
    for (int i=0;i<nb_chemins;++i)
    {
        int x, y;
        cin >> x >> y;
        --x;--y;
        graphe[x].push_back(y);
    }
    int m = 0;
    for (int i=0;i<nb_sommets;++i)
        chmax(m, plus_long(i));
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    double n;
    cin>>n;
    cout<<2*pi*n;   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main() {
	string S;
	ll K;

	cin >> S >> K;

	int SLen = S.size();
	ll count = 0;
	
	vector<pair<char, int>>vector;
	char now = ' ';
	int index = -1;

	for (int i = 0; i < SLen; i++) {
		if (now != S[i]) {
			now = S[i];
			index++;
			vector.push_back(make_pair(now, 1));
		} else {
			vector[index].second++;
		}
	}

	int VLen = vector.size();

	if (VLen == 1) {
		cout << (K*vector[0].second) / 2 << endl;
	} else {
		//頭と尾っぽが一緒
		if (vector[0].first == vector[VLen - 1].first) {
			if (vector[0].second % 2 == 1 && vector[VLen - 1].second % 2 == 1) {
				for (int i = 0; i < VLen; i++) {
					count += vector[i].second / 2;
				}
				count *= K;
				count += K - 1;
				cout << count << endl;
			} else {
				for (int i = 0; i < VLen; i++) {
					count += vector[i].second / 2;
				}
				count *= K;
				cout << count << endl;
			}

		//頭と尾っぽがべつ
		} else {
			for (int i = 0; i < VLen; i++) {
				count += vector[i].second / 2;
			}
			count *= K;
			cout << count << endl;
		}

	}			
}

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

using static Input;
using static Util;
class Program
{
    static int N;
    static int[][] ABC;
    static void INPUT()
    {
        N = NextInt();
        ABC = new int[N][];
        for (int i = 0; i < N; i++)
        {
            ABC[i] = LineInt();
        }
    }

    static void OUT()
    {
        var dp = new int[N + 1, 3];
        for (int i = 1; i <= N; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                dp[i, j] = Math.Max(dp[i - 1, (j + 1) % 3], dp[i - 1, (j + 2) % 3]) + ABC[i - 1][j];
            }
        }

        var max = 0;
        for (int i = 0; i < 3; i++)
        {
            max = Math.Max(dp[N, i], max);
        }

        Console.WriteLine(max);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

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

class Util
{

}




Measured memory_bytes: 26164