akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	bool e=true;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]>a[i+1])
		{
			e=false;
			break;
		}
	}
	if(e==false)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				int temp;
				temp=b[i];
				b[i]=b[j];
				b[j]=temp;
				e=true;
				for(int i=0;i<n-1;i++)
				{
					if(b[i]>b[i+1])
					{
						e=false;
						break;
					}
				}
				if(e==true)
				{
					cout<<"YES";
					return 0;
				}
				else
				{
					for(int l=0;l<n;l++)
					{
						b[l]=a[l];
					}
				}
			}
			
		}
	}
	if(e==true)
	{
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
	return 0;
}

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

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

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define INF 0x3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define pair pair<int,int>
#define C(a) cout<<a<<endl;
#define CY cout<<"YES"<<endl;
#define CN cout<<"NO"<<endl;
#define Cy cout<<"Yes"<<endl;
#define Cn cout<<"No"<<endl;
#define ull unsigned long long
#define me(a) memset(a,0,sizeof(a));
#define my(a,b) memcpy(a,b,sizeof(b));
#define cio ios::sync_with_stdio(false)
ll mod=1e9+7;
ll gcd(ll a,ll b){return (a%b==0) ? b : gcd(b,a%b);}
char s[200005];
inline void solve(int n){
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='R')cnt++;
	}
	for(int i=1;i<=cnt;i++){
		if(s[i]=='W')ans++;
	}
	cout<<ans<<endl;
}
int main()
{
	int n;
	cin>>n;
	scanf("%s",s+1);
	solve(n);
 	return 0;
}

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

using namespace std;

typedef unsigned long long ll;

const ll mod = 1e9 + 7;
int n, dict[70][2];
ll a[300010], ans = 0;

ll inv(ll x)
{
	ll res = 1;
	for (ll b = mod - 2; b; b /= 2)
	{
		if (b % 2)
			res = (res * x) % mod;
		x = (x * x) % mod;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		ll t = a[i];
		for (int j = 1; j <= 61; j++)
		{
			dict[j][t % 2]++;
			t /= 2;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		ll o = 1;
		for (int j = 1; j <= 61; j++)
		{
			int f = a[i] % 2;
			ans = (ans + dict[j][!f] * o) % mod;
			a[i] /= 2;
			o = o * 2 % mod;
		}
	}
	cout << ans * inv(2) % mod << endl;

	return 0;
}

Measured memory_bytes: 2560
/** 
 *  Author : Parth Prajapati
 *  Institute : Pandit Deendayal Petroleum University
 *  Problem : Longest Common Subsequence
 *  Time complexity : O(len1*len2)
 *  Space complexity : O(len1*len2)
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    string s1, s2;
    cin>>s1>>s2;
    int len1, len2, i, j;
    len1 = s1.length();
    len2 = s2.length();
    vector<vector<int>> dp(len1+1,vector<int>(len2+1));
    for(i=0;i<len1+1;++i)
    {
        for(j=0;j<len2+1;++j)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(s1[i-1] == s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    i = len1; j = len2;
    string lcs;
    while(i > 0 && j > 0)
    {
        if(s1[i-1] == s2[j-1])
        {
            lcs += s1[i-1];
            i--; j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            --i;
        else
            --j;
    }
    reverse(lcs.begin(),lcs.end());
    cout<<lcs;
    return 0;
}


Measured memory_bytes: 35584
from itertools import product

n, m = map(int, input().split())

xyzs = [[int(x) for x in input().split()] for _ in range(n)]

multipliers = product((-1, 1), repeat=3)

def max_sum(multiplier):
    sums = (sum(a*mul for a, mul in zip(xyz, multiplier)) for xyz in xyzs)
    top_m = sorted(sums, reverse=True)[:m]
    return sum(top_m)

print(max(max_sum(multiplier) for multiplier  in multipliers))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define maxn ((int)1e5+10)
using namespace std;
int n;
long long c,k,res=0,r;
vector<pair<long long,long long> > v;
bool vis[maxn];
void dfs(int pos,int y)
{
	if(v[pos].first>y||r==c)
		return ;
	++r;
	vis[pos]=true;
	if(pos==n-1)
		return ;
	dfs(pos+1,y);
}
int main()
{
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)
	{
		long long x;
		cin>>x;
		v.push_back(make_pair(x,x+k));
	}
	sort(v.begin(),v.end());
	memset(vis,false,sizeof(vis));
	for(int i=0;i<n;i++)
		if(!vis[i])
		{
			r=0;
			++res;
			dfs(i,v[i].second);
		}
	cout<<res<<endl;
	return 0;
}

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

int main(){
  int x,a;
  cin>>x>>a;
  if(x<a){
    cout<<0<<endl;
  }
  else{
    cout<<10<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

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

int main(){

  ll n = in();
  ll m = in();
  ll k = in();
  vector<string> s(n);
  REP(i, n){
    s[i] = stin();
  }
  
  auto isin = [&](ll y, ll x){
    return 0 <= y && y < n && 0 <= x && x < m;
  };

  auto add = [&](ll y, ll x){
    return (min({y, x, n-1-y, m-1-x}) + k - 1) / k;
  };
  
  ll si = -1;
  ll sj = -1;
  ll ans = INFLL;
  REP(i, n){
    REP(j, m){
      if(s[i][j] == 'S'){
        si = i;
        sj = j;
        if(i == 0 || j == 0 || i == n-1 || j == m-1){
          ans = 0;
        }
      }
    }
  }
  assert(si != -1);
  assert(sj != -1);

  vector<vector<ll>> dist(n, vector<ll>(m, INFLL));
  dist[si][sj] = 0;
  
  using pl = pair<ll, ll>;
  queue<pl> que;
  que.emplace(si, sj);
  while(!que.empty()){
    ll y = que.front().fi;
    ll x = que.front().se;
    que.pop();
    REP(i, 4){
      ll ny = y + dy[i];
      ll nx = x + dx[i];
      if(isin(ny, nx) && s[ny][nx] != '#' && dist[ny][nx] == INFLL){
        dist[ny][nx] = dist[y][x] + 1;
        que.emplace(ny, nx);
      }
    }
  }

  REP(i, n){
    REP(j, m){
      if(dist[i][j] <= k){
        chmin(ans, add(i, j) + 1);
      }
    }
  }

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


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <string>

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    a -= b;

    while (a >= c)
    {
        a -= c;
    }

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  ll N; cin >> N;
  ll sum = 0;
  rep(i, N){
    ll num = i + 1;
    if(num % 3 == 0 || num % 5 == 0)
    {

    }
    else{
      sum += num;
    }
  }

  cout << sum << endl;
}  


Measured memory_bytes: 3628
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.array;

void main() {
	auto Q = readln.chomp.to!int;
	foreach (i; 0..Q) {
		auto input = readln.split.map!(to!int).array;
		//??????CAN?????°????±??????????CAN?????°??????min(C, A, N)????????????
		int can = min(input[0], input[1], input[2]);
		input[] -= can;
		//?¬????CCA?????°????±??????????CCA?????°??????
		int cca;
		if (input[0] > input[1] * 2) cca = input[1];
		else cca = input[0] / 2;
		input[0] -= cca * 2;
		int ccc = input[0] / 3;
		writeln(can + cca + ccc);
		
	}
}

Measured memory_bytes: 2472
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 2333
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m;
char c[maxn];
signed main() {
	scanf("%s", c);
	if(c[1] == 'R') puts("ABC");
	else puts("ARC");
	return 0;
}

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

int main(){
	int n;cin >> n;
	string s, str;
	map<string, int> m;
	for(int i = 0;i < n;i++){
		cin >> s >> str;
		if(s[0] == 'i'){
			m[str] = 1;
		}else{
			if(m[str])cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define X real()
#define Y imag()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, x = -1;
	cin >> a >> b;
	for(int k = 10; k <= 1280; ++k) {
		if(int(k * 0.1) == b && a == int(k * 0.08)) {
			x = k;
			break;
		}
	}
	cout << x << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (ceil((float)c / b) <= ceil((float)a / d)) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,k,q,a[114514]={};
	cin>>n>>k>>q;
	for(int i=0;i<n;i++)a[i]=k-q;
	for(int i=0;i<q;i++){
		ll x;
		cin>>x;
		a[x-1]++;
	}
	for(int i=0;i<n;i++){
		if(a[i]>0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
	int a,b,c;
	char x,y;
	cin>>a>>x>>b>>y>>c;
	if(b<=4){
		cout<<"Heisei"<<endl;
	}else{
		cout<<"TBD"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 1 << 19;
typedef long long ll;
const int mod = 924844033;
const int inv2 = (mod + 1) >> 1;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
typedef int AI[maxn];
AI wn, rev, fac, ifac, inv;
int lim,invlim;
inline void init(int len) {
	for(lim = invlim = 1;lim < len;lim <<= 1) invlim = (ll) invlim * inv2 % mod;
	for(int i = 1;i < lim;++i) rev[i] = rev[i >> 1] >> 1 | (i % 2 * lim / 2);
}
inline void fft(int * a,int type) {
	typedef unsigned long long ll;
	static ll t[maxn];
	for(int i = 0;i < lim;++i) t[i] = a[rev[i]];
	for(int mid = 1;mid < lim;mid <<= 1) for(int i = 0;i < lim;i += mid + mid) for(int j = 0;j < mid;++j) {
		const int x = (ll) t[i + j + mid] * wn[mid + j] % mod;
		t[i + j + mid] = mod - x + t[i + j]; t[i + j] += x;
	}
	for(int i = 0;i < lim;++i) a[i] = t[i] % mod;
	if(!type) {
		for(int i = 0;i < lim;++i) a[i] = (ll) a[i] * invlim % mod;
		std::reverse(a + 1,a + lim);
	}
}
int n;
struct T{ int to, nxt; } way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y) {
	way[++num] = {y, h[x]},h[x] = num;
	way[++num] = {x, h[y]},h[y] = num;
}
int a[maxn], b[maxn];;
inline int dfs0(int x,int f = 0) {
	int size = 1;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != f) {
		int t = dfs0(way[i].to, x);
		++ a[t], size += t;
	}
	return ++ a[n - size], size;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for(int i = 2;i < maxn;++i) {
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (ll) fac[i - 1] * i % mod;
		ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
	}
	for(int mid = 1;mid < maxn;mid <<= 1) {
		const int W = pow(5,mod / mid / 2); wn[mid] = 1;
		for(int i = 1;i < mid;++i) wn[mid + i] = (ll) wn[mid + i - 1] * W % mod;
	}
	cin >> n;
	for(int i = 1, x, y;i < n;++i) cin >> x >> y, link(x, y);
	dfs0(1);
	init(n + n + 1);
	for(int i = 0;i <= n;++i) { 
		a[i] = (ll) a[i] * fac[i] % mod;
		b[i] = ifac[n - i];
	}
	fft(a, 1), fft(b, 1);
	for(int i = 0;i < lim;++i) a[i] = (ll) a[i] * b[i] % mod;
	fft(a, 0);
	for(int i = 1;i <= n;++i) {
		std::cout << ((ll) n * fac[n] % mod * ifac[i] % mod * ifac[n - i] + (ll) a[i + n] * (mod - ifac[i])) % mod << '\n';
	}
}


Measured memory_bytes: 30336
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int a, b, ab, c = 0;


	while (cin >> a >> b) {
		ab = a + b;
		for (ab; ab > 0; ab /= 10) {
			c++;
		}
		cout<<c<<endl;
		c = 0;
	}
	return 0;
}


Measured memory_bytes: 3092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	if sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(tmp[0])
		b, _ := strconv.Atoi(tmp[1])
		c, _ := strconv.Atoi(tmp[2])

		var cnt int

		for i := a; i <= b; i++ {
			if c%i == 0 {
				cnt++
			}
		}

		fmt.Println(cnt)
	}
}



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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long N, std::vector<std::string> W) {
  bool ok = true;
  unordered_set<string> S;
  char last = W[0][0];
  rep(i,N){
    if(S.find(W[i])!=S.end()){ ok = false; break; }
    S.insert(W[i]);
    if(last!=W[i][0]){
      ok = false; break;
    } else {
      last = W[i][W[i].size()-1];
    }
  }
  yesno(ok);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  std::vector<std::string> W(N);
  for (int i = 0; i < N; i++) {
    std::cin >> W[i];
  }
  solve(N, std::move(W));
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;



int main(){
  int N;
  char s1[50];
  cin >> N;

  if(N % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0;i<N/2;i++){
    cin >> s1[i];
  }

  for(int i=0;i<N/2;i++){
    char c;
    cin >> c;
    if(s1[i] != c){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <deque>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void paint_color(const vector<vector<int>> &T, vector<pair<int, int>> &mass_color, int v, int prev, int who, int cost = 0)
{
    if(mass_color[v].second > cost)
    {
        mass_color[v].first = who;
        mass_color[v].second = cost;
    }
    for(int i = 0; i < T[v].size(); i++)
    {
        int u = T[v][i];
        if(u == prev) continue;
        paint_color(T, mass_color, u, v, who, cost + 1);
    }
}

void solve()
{
    int n; cin >> n;
    vector<vector<int>> T(n);
    for(int i = 0; i < n - 1; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }

    vector<pair<int, int>> mass_color(n, make_pair(-1, INF));
    paint_color(T, mass_color, 0, -1, 0);

    // for (int i = 0; i < n; i++)
    //     cout << mass_color[i].first << " : " << mass_color[i].second << endl;
    paint_color(T, mass_color, n - 1, -1, 1);

    // for(int i = 0; i < n; i++)
    //     cout << mass_color[i].first << " : " << mass_color[i].second << endl;

    int fennec = 0, snuke = 0;
    for(int i = 0; i < n; i++)
    {
        if(mass_color[i].first == 0) fennec++;
        else snuke++;
    }

    if(fennec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 14336
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string a[19];
int main()
{
	int h,w,num=0;
	cin>>h>>w;
	rep(i,h) cin>>a[i];
	rep(i,h) rep(j,w){
		if(a[i][j]=='#') num++;
	}
	if(num==h+w-1) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 764
# coding: utf-8
# Your code here!

N = int(input())
arr = list(map(int, input().split()))
ctr = 0

for i in range(N):
    while True:
        if arr[i] % 2 == 0:
            ctr += 1
            arr[i] = arr[i] // 2
        else:
            break
print(ctr)

Measured memory_bytes: 4148
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

R, C, M = map(int, raw_input().split())
S = []
t_cost = []
on_cost = []
off_cost = []

for loop in range(R):
    hoge = raw_input()
    S.append(hoge)

for loop in range(R):
    hoge = map(int, raw_input().split())
    t_cost.append(hoge)

for loop in range(R):
    hoge = map(int, raw_input().split())
    on_cost.append(hoge)

for loop in range(R):
    hoge = map(int, raw_input().split())
    off_cost.append(hoge)

m = {}
used = {}

for y in range(R):
    for x in range(C):
        m[(x, y)] = []

def func(x, y, gx, gy, step):
    if x < 0 or y < 0 or x >= C or y >= R:
        return False
    if (x, y) in used:
        return False
    used[(x, y)] = step
    if S[y][x] == '#':
        return False
    if x == gx and y == gy:
        m[(x, y)].append(step)
        return True
    ret = False
    ret = (ret or func(x - 1, y, gx, gy, step + 1))
    ret = (ret or func(x + 1, y, gx, gy, step + 1))
    ret = (ret or func(x, y - 1, gx, gy, step + 1))
    ret = (ret or func(x, y + 1, gx, gy, step + 1))
    if ret:
        m[(x, y)].append(step)
    return ret

sy, sx = map(int, raw_input().split())
cnt = 0
for loop in range(M - 1):
    gy, gx = map(int, raw_input().split())
    used = {}
    func(sx, sy, gx, gy, cnt)
    cnt = m[(gx, gy)].pop()
    sx, sy = gx, gy
m[(gx, gy)].append(cnt)

ans = 0
for y in range(R):
    for x in range(C):
        t = t_cost[y][x]
        on = on_cost[y][x]
        off = off_cost[y][x]

        lst = m[(x, y)]
        if len(lst) > 0:
            ans += on + off
        for i in range(len(lst) - 1):
            t1 = lst[i]
            t2 = lst[i + 1]
            ans += min(on + off, t * (t2 - t1))
#print m
print ans



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

int main() {
    // your code goes here
    ll n,i,x[100005],l[100005],a,b,c,d,ans=1;
    vector<pair<ll,ll>> v;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i] >> l[i];
        v.push_back({x[i]-l[i],x[i]+l[i]-1});
    }
    sort(v.begin(),v.end());
    a=v[0].first; b=v[0].second;
    for(i=1;i<n;i++){
        c=v[i].first; d=v[i].second;
        if(c>b){
            ans++;
            a=c; b=d;
        } else {
            if(d<b){
                a=c; b=d;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define d 100000000
using namespace std;int main(){long long int n,a=0,count=0;cin>>n;for(int i=0;i<d;i++){a+=7;a%=n;a*=10;count++;if(a==0){break;}}if(a==0)cout<<count;else cout<<-1;}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T 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;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int x = 1; x <= sqrt(N) + 2; x++) {
    if (N % x == 0) {
      if ((N / x) - 1 > x) {
        ans += (N / x) - 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[101];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 200000000;
    for(int i = -100; i <= 100; i++){
        int wa = 0;
        for(int j = 0; j < n; j++){
            wa += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, wa);
    }
    cout << ans << endl;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

bool srt(pii a , pii b){
	return a.ff-a.ss>b.ff-b.ss;
}

bool cmp(pii x , pii y){
	return x.ff+x.ss>y.ff+y.ss;
}

int32_t main() {
	aryan_pandeya();
	FIO;

	int n ;
	cin>>n ; 
	pii a[n];
	for(int i = 0 ; i<n ; i++){
		cin>>a[i].ff>>a[i].ss;
	}
	sort(a,a+n,cmp);
	int op1 = abs(a[n-1].ff-a[0].ff)+abs(a[n-1].ss-a[0].ss);
	sort(a,a+n,srt);
	int op2 = abs(a[n-1].ff-a[0].ff)+abs(a[n-1].ss-a[0].ss);
	cout<<max(op1,op2);	


	return 0;
}


Measured memory_bytes: 6800
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int key;

        string[] inpt;

        while (true)
        {
            inpt = Console.ReadLine().Split(' ');
            if (inpt[0].StartsWith("en"))
            {
                break;
            }
            if (inpt[0].StartsWith("i"))
            {
                key = int.Parse(inpt[1]);
                this.Insert(key);
            }
            else
            {
                Console.WriteLine(this.Extract());
            }
            
        }
    }

    private const int MAX = 2000000;

    private int H = 0;
    private int[] A = new int[MAX + 1];

    private void MaxHeapify(int i)
    {
        int l;
        int r;
        int largest;
        l = 2 * i;
        r = 2 * i + 1;

        if (l <= this.H && this.A[l] > this.A[i])
        {
            largest = l;
        }
        else
        {
            largest = i;
        }
        if (r <= this.H && this.A[r] > this.A[largest])
        {
            largest = r;
        }

        if (largest != i)
        {
            int tmp = this.A[i];
            this.A[i] = this.A[largest];
            this.A[largest] = tmp;
            this.MaxHeapify(largest);
        }
    }

    private int Extract()
    {
        int maxv;
        if (this.H < 1)
        {
            return int.MinValue;
        }
        maxv = this.A[1];
        this.A[1] = this.A[H--];
        this.MaxHeapify(1);
        return maxv;
    }

    private void IncreaseKey(int i, int key)
    {
        if (key < this.A[i])
        {
            return;
        }
        this.A[i] = key;
        while (i > 1 && this.A[i / 2] < this.A[i])
        {
            int tmp = this.A[i];
            this.A[i] = this.A[i / 2];
            this.A[i / 2] = tmp;
            i = i / 2;
        }
    }

    private void Insert(int key)
    {
        this.H++;
        this.A[this.H] = int.MinValue;
        this.IncreaseKey(this.H, key);
    }

    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 24148
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.next();
		String t=scan.next();
		scan.close();
		char sc[] = s.toCharArray();
		char st[] = t.toCharArray();

		Arrays.sort(sc);
		Arrays.sort(st);
		int min=Math.min(st.length, sc.length);
		int check=0;
		int cnt=0;
		for(int i=0;i<min;i++) {

			if(sc[i] < st[st.length-1-i]) {
				check=1;
				break;
			}
			if(sc[i] == st[st.length-1-i])cnt++;
			if(cnt==min)check=-1;
		}
		if(check==-1) {
			if(sc.length < st.length)check=1;
			else check=0;
		}

		System.out.println((check==1)? "Yes":"No");
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;

const int N = 1e9 ;
const int P = 1e9 + 7;

ll quickPower(ll a, ll b) {
    ll res = 1;
    a %= P;
    while (b) {
        if (b & 1)res = (res % P) * (a % P) % P;
        a = (a % P) * (a % P) % P;
        b >>= 1;
    }
    return res;
}
ll inv(ll x) {//x关于p的逆元，p为素数
    return quickPower(x, P - 2);
}
ll qpow(ll x, ll n) {
    ll res = 1;
    x %= P;
    while (n) {
        if (n & 1) res = res * x % P;
        x = x * x % P;
        n >>= 1;
    }
    return res;
}
ll C(ll n, ll m) {
    if (m > n)return 0;
    ll up = 1, down = 1;//分子分母;
    for (int i = n - m + 1; i <= n; i++)
        up = up * i % P;
    for (int i = 1; i <= m; i++)
        down = down * i % P;
    return up * inv(down) % P;
}
ll Lucas(ll n, ll m) {
    if (m == 0)return 1;
    return C(n % P, m % P) * Lucas(n / P, m / P) % P;
}
int comb(int n,int m){
     if(n-m<m)m=n-m;
     if(m==0)return 1;
     return comb(n-1,m-1)*n/m;
}
int main(){
    IOS;
    ll n,a,b;
    cin>>n>>a>>b;
    ll res=0;
    res+=qpow(2,n);
    res=(res-1+P+P-Lucas(n,a)-Lucas(n,b)+P)%P;
    cout<<res;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(int i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    vector<bool>v1(100001, false),v2(100001, false);
    vector<int>v2cnt(100001);
    rep(i, 2, 100001){
        int cnt = 0;
        sqrep(j, 1, i){
            if(i%j==0){
                cnt++;
                if(j*j!=i)cnt++;
            }
        }
        if(cnt==2)v1[i]=true;
        if(v1[i]&&v1[(i+1)/2])v2[i]=true;
    }
    int p = 0;
    rep(i, 0, 100001){
        if(v2[i])p++;
        v2cnt[i] = p;
    }
    int q;
    cin >> q;
    vector<int>ans(q);
    rep(i, 0, q){
        int l, r;
        cin >> l >> r;
        ans[i]=v2cnt[r]-v2cnt[l-1];
    }
    rep(i, 0, q)cout << ans[i] << endl;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int ans;
int main(){
        cin>>s1>>s2;
        int len1=s1.size();
        for (int i=0; i<len1; i++) {
                if (s1[i]!=s2[i]) ans++;
        }
        cout<<ans<<endl;
        return 0;
}


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

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int i = 0;
	while (a + b * i <= x) {
		i++;
	}
	i--;
	int ans = x - (a + b * i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x=input().split()
longestWord= ""
mostWord=0
currentCount=0
THEmostWord=""

for r in range (len(x)):
    if len(x[r])> len(longestWord):
        longestWord=x[r]

for j in range (len(x)):
    currentCount=x.count(x[j])
    if currentCount > mostWord:
        mostWord= currentCount
        THEmostWord=x[j]

print(THEmostWord, longestWord)

Measured memory_bytes: 7340
A,B,C,X,Y = map(int,input().split())
C *= 2
ax = 0
bx = 0
num = 0
while ax < X or bx < Y:
  if ax < X and bx < Y:
    if A+B < C:
      num += A+B
    else:
      num += C
    ax += 1
    bx += 1
  elif ax < X:
    if A < C:
      num += A
    else:
      num += C
    ax += 1
  else:
    if B < C:
      num += B
    else:
      num += C
    bx += 1
print(num)

    

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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> PQ;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		PQ.push(a);
	}
	while (m--) {
		int a = PQ.top();
		PQ.pop();
		PQ.push(a / 2);
	}
	
	long long ans = 0;
	while (!PQ.empty()) {
		ans += PQ.top();
		PQ.pop();
	}
	cout << ans << '\n';
	
	return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin>>a>>b>>c;
    if((a == b and a != c) or (a == c and b != a) or (b == c and a != b))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
l = int(input())
a = []
for i in range(0, l):
    a.append(int(input()))

left = [0] * (l + 1)
start= [0] * (l + 1)
goal = [0] * (l + 1)
right = [0] * (l + 1)
last = [0] * (l + 1)

for i in range(1, l + 1):
    left[i] = left[i - 1] + a[i - 1]
    
for i in range(1, l + 1):
    c = 0
    if a[i - 1] == 0:
        c = 2
    elif a[i - 1] % 2 == 1:
        c = 1
    start[i] = min(left[i], start[i - 1] + c)

for i in range(1, l + 1):
    c = 0
    if a[i - 1] % 2 == 0:
        c = 1
    goal[i] = min(start[i], goal[i - 1] + c)
    
for i in range(1, l + 1):
    c = 0
    if a[i - 1] == 0:
        c = 2
    elif a[i - 1] % 2 == 1:
        c = 1
    right[i] = min(goal[i], right[i - 1] + c)
    
for i in range(1, l + 1):
    last[i] = min(last[i - 1] + a[i - 1], right[i])
    
print(last[-1])

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

int main() {
  string N, ans ="No";
  cin >> N;
  
  for(int i = 0;i < 2;i++){
    if(N[i] == N[i+1] && N[i+1] == N[i+2]){
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

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

int main(){
    bool nonprime[100001] = {};
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i < 100001; i++){
        if(!nonprime[i]){
            for(int j = i+i; j < 100001; j+=i){
                nonprime[j] = true;
            }
        }
    }

    int sum[100001] = {};

    for(int i = 1; i < 100001; i++){
        sum[i] = sum[i-1];
        if(!nonprime[i] && !nonprime[(i+1)/2])  sum[i]++;
    }

    int q;
    scanf("%d\n", &q);

    int l, r;
    for(int i = 0; i < q; i++){
        scanf("%d %d\n", &l, &r);
        int ans = sum[r] - sum[l-1];
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;


int main(){
    //bool ans=false;
    string ans;

    string s,t;

    cin>>s>>t;

    ans=t+s;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>

using namespace std;

namespace {

const size_t kHashSize = 244140624;

class Dictionary {
 public:
  Dictionary() : table_(new int[kHashSize]) {}
  ~Dictionary() { delete[] table_; }

  void insert(const char* k, size_t n) {
    const size_t i = Encode(k, n);
    table_[i] = 1;
  }

  bool find(const char* k, size_t n) const {
    return table_[Encode(k, n)] > 0;
  }

 private:
  static int Id(char c) {
      switch (c) {
        case 'A':
          return 1;
        case 'C':
          return 2;
        case 'G':
          return 3;
        case 'T':
          return 4;
      }
      // should not reach here.
      return 0;
  }

  size_t Encode(const char* k, size_t n) const {
    size_t h = 0;
    size_t p = 1;
    for (size_t i = 0; i < n; ++i) {
      h += p * Id(k[i]);
      p *= 5;
    }
    return h;
  }

  int* table_;
};

} // namespace

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

  Dictionary d;
  char op[7];
  char str[13];
  for (int i = 0; i < n; ++i) {
    scanf("%s ", op);
    scanf("%s", str);
    const char c = op[0];
    const size_t len = strnlen(str, 13);
    if (c == 'i') {
      d.insert(str, len);
      continue;
    }

    if (d.find(str, len)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 40596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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



int main() {
    int s,w;
    cin >> s >> w;
    if(s > w) {
        cout << "safe" << endl;
    }
    else{
        cout << "unsafe" << endl;
    }
}


Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let helix: String = read();

    match helix.as_str() {
        "A" => println!("T"),
        "T" => println!("A"),
        "C" => println!("G"),
        "G" => println!("C"),
        _ => panic!()
    }
}

Measured memory_bytes: 4352
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = list(map(int, input().split()))
root = []
for i in range(M):
    x = list(map(int, input().split()))
    root.append(x)
uf = UnionFind(N)
for i in range(M):
    a, b = root[i]
    a, b = a - 1, b - 1
    uf.union(a, b)
gc = uf.group_count()
print(gc - 1)

Measured memory_bytes: 29432
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] ary = new long[n];
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            ary[i] = a;
        }
        long ans = 0;
        long cnt = 0;
        for (int i = 0; i < n - 1; i++) {
            if (ary[i] >= ary[i + 1]) {
                cnt++;
            } else {
                if (ans < cnt) {
                    ans = cnt;
                }
                cnt = 0;
            }
        }
        if (ans < cnt) {
            ans = cnt;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48356
a, b, c, x = [int(input()) for _ in range(4)]
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50 == x:
                count+=1
            if i*500+j*100+k*50 > x: break
print(count)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import itertools
import numpy as np


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    H, W, K = list(map(int, input().split()))
    c = []
    for h in range(H):
        c.append(input())

    return H, W, K, c


def main(H: int, W: int, K: int, c: list) -> None:
    """
    メイン処理.

    Args:\n
        H (int): 行数（1 <= H <= 6）
        W (int): 列数（1 <= W <= 6）
        K (int): 正の整数（1 <= K <= HW）
        c (list): マスの色
    """
    # "." = 0, "#" = 1の配列に変換
    l = np.zeros(shape=(H, W))
    for h, w in itertools.product(range(H), range(W)):
        l[h, w] = (c[h][w] == "#")

    # 求解処理
    ans = 0
    for h_bit, w_bit in itertools.product(range(1 << H), range(1 << W)):
        l_copy = l.copy()
        for h in range(H):
            if h_bit & (1 << h):
                l_copy[h, :] = [0]
        for w in range(W):
            if w_bit & (1 << w):
                l_copy[:, w] = [0]
        ans += (np.sum(l_copy) == K)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    H, W, K, c = get_input()

    # メイン処理
    main(H, W, K, c)


Measured memory_bytes: 27064
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
int x=0,y=0,z=0,w=0,n=0;
string b;
std::cin >> x;
int a[x+1];
rep(i,x+1){
  a[i]=i;
}
std::cin >> y;
rep(i,y){
scanf("%d,%d",&z,&w);
swap(a[z],a[w]);
}
repone(i,x+1){
  std::cout << a[i] << '\n';
}
}



Measured memory_bytes: 3164
//私はずっとC問題の実行ファイルを動かし、動かねえと嘆いていました。
//とても... とても... 悔しいです。
//編入終わったら、ちゃんとAtCoderをやります。
#include <algorithm>
#include <iostream>

using namespace std;
#define ll long long
// Google大好き！！！
int main(void) {
  int n;
  cin >> n;

  ll ans = 1;
  const ll m = 1e18;
  bool flag = false;
  ll a[100010];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if ((m) / ans < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4348