akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let s: String = read();
    let v: Vec<char> = s.chars().collect();

    if v.len() < 4 {
        println!("No");
        return;
    }
    let c = vec!['Y', 'A', 'K', 'I'];
    for i in 0..4 {
        if v[i] != c[i] {
            println!("No");
            return;
        }
    }
    println!("Yes")
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
/*
struct city{
    int P;
    ll Y;
    int x;
}
*/

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main(){
    scanf("%d%d", &N, &M);
    rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());
    rep(i, M) printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(
        yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);

    return 0;
}



Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int query(int x) {
  string s;
  printf("%d\n", x); fflush(stdout);
  scanf("%s", s.c_str());
  if (s[0] == 'V') exit(EXIT_SUCCESS);
  return (s[0] == 'M') ? 1 : -1;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  scanf("%d", &N);
  int l = 0, r = N-1;
  int fl = query(l);
  int fr = query(r);
  while (r - l > 0) {
    int m = (l+r)/2;
    int fm = query(m);
    if (((m-l+1)%2 == 1) ^ (fm == fl)) r = m, fr = fm;
    else l = m, fl = fm;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define TASKNAME somethinghere

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

	//freopen("input.txt", "r", stdin);
	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

    ll n;
    cin >> n;
    if(n & 1)
		cout << setprecision(10) << fixed << ((n/2+1.0)/n);
    else
		cout << setprecision(10) << fixed << (n/2.0)/n;
}

/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/


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

using namespace std;

#define MAX 101

int H, W, sx, sy, gx, gy;
int color, dir, field[MAX][MAX];

struct P{
  int x, y;
  P(int x, int y) : x(x), y(y) {}
};

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

bool check(int y, int x){
  if(0 <= y && y < H && 0 <= x && x < W){
    return true;
  }
  return false;
}

void paint(int y, int x){
  if(!dir){
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        field[y+i][x+j] = color;
      }
    }
  }else{
    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < 2 ; j++){
        field[y+i][x+j] = color;
      }
    }

  }
}

bool bfs(){
  bool used[MAX][MAX];
  memset(used, false, sizeof(used));
  used[sy][sx] = true;

  queue<P> Q;
  Q.push(P(sx, sy));

  while(!Q.empty()){
    P p = Q.front(); Q.pop();

    if(field[p.y][p.x] == -1) continue;

    for(int i = 0 ; i < 4 ; i++){
      int nx = p.x + dx[i];
      int ny = p.y + dy[i];

      if(!check(ny, nx) || used[ny][nx] || 
         field[p.y][p.x] != field[ny][nx]) continue;

      used[ny][nx] = true;
      Q.push(P(nx, ny));     
    }
  }
  return used[gy][gx];
}

int main(){
  int n, x, y;
  while(cin >> W >> H, (W | H)){
    memset(field, -1, sizeof(field));

    cin >> sx >> sy >> gx >> gy >> n;
    sy--, sx--, gy--, gx--;

    for(int i = 0 ; i < n ; i++){
      cin >> color >> dir >> x >> y;
      y--, x--;
      paint(y, x);
    }
    cout << (bfs() ? "OK" : "NG") << endl;
  }

  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef vector<short int> vi;
#define REP(i,y) for(int i=0; i<y; ++i)
int INF = 1<<30, N;
vector<vi> X(18, vi(2));
vi V_(18), V(18), Vb(18);
inline int search(int F){
  if(__builtin_parity(F)) return INF;
  REP(i,N) V_[i] = V[i] = X[i][Vb[i] = (F>>=1)%2];
  sort(V.begin(), V.begin()+N);
  int ans = 0;
  REP(i,N){
    for(int j=i; j<N; ++j){
      if(V[i]!=V_[j] || (j-i+Vb[j])&1) continue;
      ans += j-i;
      for(int k=j-1; k>=i; --k){
        V_[k+1] = V_[k];
        Vb[k+1] = Vb[k]+1;
      }
      goto END;
    }
    return INF;
END:
    continue;
  }
  return ans;
}
int main(){
  scanf("%d", &N);
  REP(i,2*N) scanf("%d", &X[i%N][i/N]);
  int ans=INF;
  REP(i,1<<N) ans = min(ans, search(i<<1));
  printf("%d\n", (ans==INF?-1:ans));
  return 0;
}

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

constexpr int MAX_N = 1e5 + 1;
constexpr int MOD = 1e9 + 7;

using int64 = int64_t;
#define int int64

vector<int> edge[MAX_N];
int memo_f[MAX_N];
int memo_g[MAX_N];

int f(int, int);
int g(int, int);

int g(int x, int parent){
	if(memo_g[x] > 0) return memo_g[x];
	
	int cnt = 1;
	for(auto &&child: edge[x]){
		if (child == parent) continue;
		
		(cnt *= f(child, x) % MOD) %= MOD;
	}
	
	return memo_g[x] = cnt;
}

int f(int x, int parent){
	if (memo_f[x] > 0) return memo_f[x];
	
	int white = g(x,parent);
	int black = 1;
	for(auto &&child: edge[x]){
		if (child == parent) continue;
		
		(black *= g(child, x) % MOD) %= MOD;
	}
	return memo_f[x] = (white + black) % MOD;	
}


signed main() {
	int n; cin >> n;
	for(int i=0;i<n-1;++i) {
		int fr,to; cin >> fr >> to;
		edge[fr-1].push_back(to-1);
		edge[to-1].push_back(fr-1);
	}
	
	int ans = f(0, -1);
	cout << ans << endl;
	
	return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n);
    double rate;
    double m_rate=0;
    int rate_no;
    rep(i,n){
      cin>>a[i]>>b[i];
      rate=(double)a[i]/b[i];
      if(rate>m_rate){
          m_rate=rate;
          rate_no=i;
      }
    }
    ll ans=(h/a[rate_no])*b[rate_no];
//    cout<<ans<<endl;
    int rest;
    if((rest=h%a[rate_no])==0){
        cout<<ans<<endl;
        return 0;
    }
//    cout << rest<< endl;
    vector<int> dp(rest+1,INF);
    dp[0]=0;
    rep(i,n){
        rep(j,rest){
        int nj=min(j+a[i],rest);
        dp[nj]=min(dp[nj],dp[j]+b[i]);
        }
    }
//    cout<<ans+dp[rest]<<endl; wrong
    dp.resize(h+1,INF);
    dp[0]=0;
    rep(i,n){
        rep(j,h){
        int nj=min(j+a[i],h);
        dp[nj]=min(dp[nj],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
#define MOD 1000000007
using namespace std;

int one[60];
void countup(int n) {
  for (int i = 0; i < 60 && n > 0; i++) {
    if (n & 1) {
      one[i]++;
    }
    n >>= 1;
  }
}

void solve() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    countup(a);
  }

  int ans = 0;
  int base = 1;
  for (int i = 0; i < 60; i++) {
    int n = (one[i] * (N - one[i])) % MOD;
    ans += (base * n) % MOD;
    ans %= MOD;
    base = (base * 2) % MOD;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;// при желании можно поменять
int x[4];
int main(){
    //ios_base::sync_with_stdio(false);
    //cout<<fixed<<setprecision(20);
    for(int i=0;i<3;i++){
        int a,b;
        cin>>a>>b;
        x[a-1]++;
        x[b-1]++;
    }
    if(x[0]>2||x[1]>2||x[2]>2||x[3]>2)cout<<"NO";
    else cout<<"YES";
    return 0;
}

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

using namespace std;

const int maxn = 1e5 + 10;
const int INF = 2147483647;

#define pb push_back
#define fs first
#define sc second
#define mp make_pair
typedef pair <int,int> pii;

int arr[ maxn ];
pii mini[ maxn ];
int n, q, t, x, y, ans;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fill( arr , arr + maxn , INF );
	fill( mini , mini + maxn , mp ( INF , INF ) );
	//cin >> n >> q;
	scanf( "%d %d" , &n , &q );
	int k = sqrt( n ), len = n/k;
	for ( int o = 0 ; o < q ; o++ ){
		//cin >> t >> x >> y;
		scanf( "%d %d %d" , &t , &x , &y );
		int prt = x/len;
		int prt_y = y/len;
		int amn = mini[ prt ].fs;
		int it = mini[ prt ].sc;
		if ( t == 0 ){
			arr[ x ] = y;
			if ( amn > y ){
				mini[ prt ].fs = y;
				mini[ prt ].sc = x;
			}
			if ( amn < y && x == it ){
				mini[ prt ].fs = y;
				for ( int i = prt*len ; i < min ( n , ( prt+1 )*len ) ; i++ ){
					if ( mini[ prt ].fs > arr[ i ] ){
						mini[ prt ].fs = arr[ i ];
						mini[ prt ].sc = i;
					}
				}
			}
		}
		else if ( t == 1 ){
			ans = INF;
			if ( ( prt+1 )*len <= y ){
				for ( int i = x ; i < ( prt+1 )*len ; i++ ){
					ans = min( ans , arr[ i ] );
				}
				for ( int i = prt_y*len ; i <= y ; i++ ){
					ans = min( ans , arr[ i ] );
				}
				for ( int i = prt+1 ; i < prt_y ; i++ ){
					ans = min( ans , mini[ i ].fs );
				}
			}
			else{
				for ( int i = x ; i <= y ; i++ ){
					ans = min( ans , arr[ i ] );
				}
			}
			//cout << ans << endl;
			printf( "%d\n" , ans );
		}
	}
}


Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>G[100002];
vector<bool>vis(100002);
vector<ll>dp(100002);

void dfs(ll root)
{
  vis[root]=true;
  ll j=0;
  for(auto u:G[root])
   { if(!vis[u])
    {
      dfs(u);
      
    }
    j=max(j,dp[u]+1);
   }
  dp[root]=j;
}

int main()
{
  ll n,m,a,b;
  cin>>n>>m;
  for(ll i=1;i<=m;i++)
  {
    cin>>a>>b;
    G[a].push_back(b);
  }
  for(ll i=1;i<=n;i++)
    if(!vis[i])
      dfs(i);
  ll maxi=0;
  //cout<<dp[3];
  for(ll i=1;i<=n;i++)
    maxi=max(dp[i],maxi);
  cout<<maxi;
  return 0;
}

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

int main(int argc, char const *argv[])
{
	ll l, r; cin >> l >> r;
	ll ans = 2019;
	for (int i = l; i <= min(r, l + 2020); ++i) {
		for (int j = i + 1; j <= min(r, l + 2020); ++j) {
			ans = min(ans, (ll(i) * j) % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int bruteforce(int n) {
    int ans = 0;
    while (n > 0) {
        n %= __builtin_popcount(n);
        ans++;
    }
    return ans;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int f[n+1];
    f[0] = 0;
    for (int i = 1; i <= n; i++) {
        int x = __builtin_popcount(i);
        f[i] = 1 + f[i % x];
    }
    // for (int i = 0; i <= 15; i++) cout << i << " " << f[i] << endl;

    // for (int i = 0; i < n; i++){
    //     s[i] ^= 1;
    //     int x = 0;
    //     for (int i = 0; i < n; i++) x = x * 2 + s[i] - '0';
    //     cout << x << " " << bruteforce(x) << endl;
    //     s[i] ^= 1;
    // }

    int x = 0;
    for (char c : s) if (c == '1') x++;
    if (x == 1) {
        if (s[n-1] == '1') {
            for (int i = 0; i < n-1; i++) cout << "2\n";
            cout << "0\n";
        } else {
            for (int i = 0; i < n-1; i++)
                cout << (s[i] == '1' ? "0\n" : "1\n");
            cout << "2\n";
        }
        return 0;
    }
    int x0 = x+1, x1 = x-1;
    int p0 = 1, p1 = 1;
    int y0 = 0, y1 = 0;
    for (int i = 0; i < n; i++) {
        int b = s[i] - '0';
        y0 = (y0 * 2 + b) % x0;
        y1 = (y1 * 2 + b) % x1;
    }
    int ans[n];
    for (int i = n-1; i >= 0; i--) {
        char c = s[i];
        int x = c == '1' ? x1 : x0;
        int y = c == '1' ? y1 - p1 : y0 + p0;
        y %= x;
        if (y < 0) y += x;
        // cerr << "x, y = " <<  x << " " << y << endl;
        ans[i] = f[y % x] + 1;
        p0 = p0 * 2 % x0;
        p1 = p1 * 2 % x1;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 4884
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long a, k;
    long long count = 0;
    
    cin >> a >> k;
    if(k == 100)
        k++;
        
    cout << k * (long long)pow(100, a) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int c;
	
	while (1) {
		scanf("%d", &n);
		c = 0;
		
		if (n == 0){
			break;
		}
		
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else if (n % 2 != 0){
				n *= 3;
				n += 1;
			}
			c++;
		}
		printf("%d\n", c);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
//ysh_gpta
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
typedef long long ll;
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}
//void printArray(vi &v){for(int i=0;i<v.size();i++) cout<<v[i]<<endl; cout<<endl; }

ll dp[405][405];
ll sum[405];

ll solve(ll i,ll j){
    if(i>j)
    return 0;
    if(j-i==1)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    ll mn = LONG_LONG_MAX;
    for(ll k=i+1;k<j;k++)
    mn = min(mn,solve(i,k)+solve(k,j)+sum[j]-sum[i]);
    return dp[i][j] = mn;
}

int main(){
   FastIO
   ll n;
   cin>>n;
   vi v(n);
   sum[0] = 0;
   memset(dp,-1,sizeof(dp));
   for(int i=0;i<n;i++){
       cin>>v[i];
       sum[i+1] = sum[i]+v[i];
   }
//    for(ll l=2;l<=n;l++){
//        for(ll i=0;i<n-l+1;i++){
//            ll j=i+l-1;
//            if(l==2){
//                dp[i][j]=dp[i][j-1]+dp[i+1][j];
//            }else{
//                dp[i][j] = min(dp[i][j-1]+v[j]+sum[j]-sum[i],dp[i+1][j]+v[i]+sum[j+1]-sum[i+1]);
//            }
//        }
//    }
//    for(int i=0;i<n;i++){
//        for(int j=0;j<n;j++)
//        cout<<dp[i][j]<<" ";
//        cout<<endl;
//    }
   cout<<solve(0,n);
   return 0;
}

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

const ll INF = 1LL << 60;

string S;
int main() {
    cin >> S;
    string ans = "No";
    rep(i, 3) {
        if (S[i] == '7') {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()*2
    S=input()
    
    #括弧のように，各位置ごとに始まりか終わりかを規定
    #とじカッコの位置で，カッコを開いた数だけ通り数がある．
    
    st=list(range(N))
    for i in range(N):
        if S[i]=="B":
            c=0
        else:
            c=1
        st[i]=(st[i]+c)%2

    ans=1
    cnt=0#開き-閉じる
    
    for i in range(N):
        if st[i]==0:
            cnt+=1
        else:
            if cnt<0:
                ans=0
            ans=(ans*cnt)%mod
            cnt-=1
            
    #前半いらないが一応
    if st[-1]==0 or st[0]==1 or cnt!=0:
        ans=0
    for i in range(1,N//2+1):
        ans=(ans*i)%mod
    print(ans)
    
    
main()


Measured memory_bytes: 42464
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    set<char> s;
    for(int i=0;i<S.size();i++){
        s.insert(S[i]);
    }
    
    vector<char> c={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for(int i=0;i<26;i++){
        if(s.count(c[i])==0){cout<<c[i]<<endl;return 0;}
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
#binary_search
from bisect import bisect_left
from bisect import bisect_right
#input
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):
    ab = bisect_left(A,B[i])
    bc = N-bisect_right(C,B[i])
    #print(ab, end='  ')
    #print(bc)
    ans += ab*bc
print(ans)

'''
A ●  ○  ○  ○  ○  ○ << ab
    ^ bisec_left(A,B[i])

B ○  ○  #  ○  ○  ○  << # = B[i]

C ○  ○  ○  ●  ●  ●  << bc
          ^ bisec_right(C,B[i])

ab * bc が i のときの組み合わせの数になる
'''

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//char ch;
string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    cin>>S;
    forr(i,S.sz)
    {
        if(S[i]=='2')
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
    for(int v = nt[u]; v<n; v++){
        nt[u] = v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i=0; i<n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    
    while(!S.empty()){
        int u = S.top();
        int v = next(u);
        if(v!=-1){
            if(color[v]==WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        //nt[i] = 0;
    }
    tt = 0;
    for(int u=0; u<n; u++){
        if(color[u]==WHITE){
            dfs_visit(u);
        }
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    int u,k,v;
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	int n,m;

	while( cin >> n >> m , n|m ){
		map<string,int> f;
		vector<string> vc;
		for(int i=0 ; i<n ; ++i ){
			string N;
			int M;
			cin >> N >> M;
			f[N] = M;
			vc.push_back( N );
		}
		int ans = 0;
		for(int i=0 ; i<m ; ++i ){
			string B;
			cin >> B;
			for(int j=0 ; j<(int)vc.size() ; ++j ){
				string s = vc[j];
				bool flag = true;
				for(int k=(int)s.size()-1 ; k>=0 ; --k ){
					char c = s[k];
					if( s[k] == B[k] )
						continue;
					else if( s[k] == '*' )
						break;
					else if( s[k] != B[k] )
						flag = false;
				}
				if( flag )
					ans += f[s];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 936
# -*- coding: utf-8 -*-
n,l=map(int,input().split(" "))
#空のリスト
alist=[]
#文字列の入力、リスト化
for _ in range(n):
  alist.append(input())
#並び替え
alist.sort()
#結合
alist2="".join(alist)
print(alist2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 1e5+9;

in a[maxn],b[maxn];
vector<in> c;

int main(){
    IOS;
    in n,m,x,y,z,ans=0;
    cin >> n >> m >> x >> y >> z;
    rep(i,0,x) cin >> a[i];
    rep(i,0,y) cin >> b[i];
    rep(i,0,z){
        in X; cin >> X;
        c.pb(X);
    }
    sort(a,a+x);
    sort(b,b+y);
    rep(i,0,n) c.pb(a[x-i-1]);
    rep(i,0,m) c.pb(b[y-i-1]);
    sort(all(c));
    rep(i,0,n+m) ans+=c[sz(c)-i-1];
    cout << ans << "\n";
}

Measured memory_bytes: 8048
import math

def func(n_str, ptr):
#    print(n_str)
    if len(n_str)==ptr:
        return int(eval(n_str))
    return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()    
print(func(s, 1))



Measured memory_bytes: 3064
/*
 * ID: ITP1_9_B
 * Problem: shuffle
 */

#include <stdio.h>
#include <string.h>

int main(void)
{
    while (1) {
        char string[200 + 1];
        scanf("%s", string);
        if (strcmp(string, "-") == 0)
            break;

        int command;
        scanf("%d", &command);
        int index = 0;
        for (int i = 0; i < command; i++) {
            int shift;
            scanf("%d", &shift);
            index += shift;
        }

        index %= strlen(string);
        for (int i = index; string[i]; i++)
            putchar(string[i]);
        for (int i = 0; i < index; i++)
            putchar(string[i]);
        putchar('\n');
    }

    return 0;
}



Measured memory_bytes: 2044
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll gcd(ll a,ll b){
	if(b == 0)return a;
	else return gcd(b,a%b);
}
int main(){
	ll k;
	cin >> k;
	ll ans = 0;
	for(ll i = 1;i <= k;i++){
		for(ll j = 1;j <= k;j++){
			for(ll l = 1;l <= k;l++){
				ll now = gcd(i,gcd(j,l));
				ans += now;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3672
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import copy

h,w,k=nm()

field = []
for y in range(h):
  field.append([_ for _ in input()])

ans=0

s = set()

for yi in range(2**h):
  f1 = copy.deepcopy(field)
  for yj in range(h):
    if ((yi >> yj) & 1):
      f1[yj] = ['*']*w
    for xi in range(2**w):
      f2= copy.deepcopy(f1)
      for xj in range(w):
        if((xi >> xj) & 1):
          for y in range(h):
            f2[y][xj] = '*'
      
      cnt=0
      for y in range(h):
        for x in range(w):
          if f2[y][x] == '#':
            cnt+=1

      if cnt==k:
        ans+=1
        s.add(str(f2))
# print(ans)
print(len(s))


Measured memory_bytes: 78072
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

map<pair<int, int>, int> cache;

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

    int N, H, W;
    cin >> H >> W >> N;

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        for (int dx = -1; dx <= 1; dx++) {
            for (int dy = -1; dy <= 1; dy++) {
                int nx = dx + x;
                int ny = dy + y;

                if (nx >= 1 && ny >= 1 && nx < H - 1 && ny < W - 1) {
                    //debug() << make_pair(nx, ny);
                    cache[{nx, ny}] += 1;
                }
            }
        }
    }

    //debug() << cache.size();

    vector<int64> cnt(10);
    
    for (auto entry : cache)
        cnt[entry.second]++;

    cnt[0] = (int64)(H - 2) * (W - 2) - accumulate(cnt.begin(), cnt.end(), 0L);

    for (auto el : cnt)
        cout << el << "\n";

    return 0;
}


Measured memory_bytes: 56576
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L = input()

dp = [[0]*2 for _ in range(len(L)+1)]
dp[0][0] = 1

for i in range(len(L)):
	nd = int(L[i])
	ni = i+1
	for a in range(2):
		for b in range(2):
			if a == b == 1:
				continue
			for k in range(2):
				nk = k

				if nk == 0:  # 未確定
					if nd == 1 and a == b == 0:
						nk = 1
					if nd == 0 and a | b:  # 超える
						continue

				dp[ni][nk] += dp[i][k]
				dp[ni][nk] %= mod

ans = dp[-1][0]+dp[-1][1]
print(ans%mod)


Measured memory_bytes: 21664
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////


int main(){

    int n,m;
    cin >> n >> m;
    ll h[n];
    inrep(n,h);
    
    set<ll> s[n];

    rep(i,0,m){
	int a,b;
	cin >> a >> b;
	s[a-1].it(b-1);
	s[b-1].it(a-1);
    }

    ll ans = 0;
    rep(i,0,n){
	int f = 0;
	for(auto j : s[i]){
	    if(h[i] <= h[j]){
		f = 1;
		break;
	    }
	}
	if(f == 0)ans++;
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 18436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;

class MainClass
{
    static void Main()
    {
        var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0], K = NK[1];
        var h = new long[N];
        for (int i = 0; i < N; i++)
        {
            h[i] = long.Parse(Console.ReadLine());
        }
        Array.Sort(h);

        long ans = long.MaxValue;
        for (int i = 0; i < N-K+1; i++)
        {
            ans = Math.Min(ans, h[i + K-1] - h[i]);
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 33692
// 桁DP 
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
const int K = 43;

ll dp[K][2][2];

int main() {
	int n;
	cin >> n;
	vector<ll> _a(n);
	rep(i,n) cin >> _a[i];
	ll x = 0;
	rep(i,n) x ^= _a[i];
	ll a = _a[0], b = _a[1];
	// 0,1 番目を打ち消す。
	x ^= a^b;
	// 0,1 の和は変わらない。
	ll s = a+b;

	rep(i,K)rep(j,2)rep(k,2) dp[i][j][k] = -1;

	dp[0][0][0] = 0;
	ll v = 1;
	rep(i,K-1) {
		int cx = x&1;// current x
		int cs = s&1;
		int ca = a&1;
		rep(j,2)rep(k,2) {
			if (dp[i][j][k] == -1) continue;
			rep(na,2)rep(nb,2) {
				int ni = i+1;
				int nj = 0, nk = k;
				if ((na^nb) != cx) continue;
				int ns = na+nb+j;
				if (ns%2 != cs) continue;
				// 繰り上がり処理
				if (ns >= 2) nj = 1;
				if (ca < na) {
					nk = 1;
				} else if (ca == na) {
					nk = k;
				} else {
					nk = 0;
				}
				chmax(dp[ni][nj][nk], dp[i][j][k]|(v*na));
			}
		}
		x >>= 1;
		s >>= 1;
		a >>= 1;
		v <<= 1;
	}
	
	a = dp[K-1][0][0];
	if (a== -1 || a ==0) {
		cout << -1 << endl;
		return 0;
	}

	ll ans = _a[0]-a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, char *argv[]){
  double w;
  int i;
  char str[11][15] = {"light fly" , "fly" , "bantam" , "feather" , "light" , "light welter" , "welter" , "light middle" , "middle" , "light heavy" ,"heavy"};

  while(scanf("%lf",&w) != EOF){
    if(w <= 48.00){
      i = 0;
    }else if(w <= 51.00){
      i = 1;
    }else if(w <= 54.00){
      i = 2;
    }else if(w <= 57.00){
      i = 3;
    }else if(w <= 60.00){
      i = 4;
    }else if(w <= 64.00){
      i = 5;
    }else if(w <= 69.00){
      i = 6;
    }else if(w <= 75.00){
      i = 7;
    }else if(w <= 81.00){
      i = 8;
    }else if(w <= 91.00){
      i = 9;
    }else{
      i = 10;
    }

    printf("%s\n",str[i]);
    
  }

  return 0;    
}

Measured memory_bytes: 0
dice_ = [int(i) for i in input().split()]
com = list(input())
dice = {
    't':dice_[0],
    'd':dice_[1],
    'r':dice_[2],
    'l':dice_[3],
    'u':dice_[4],
    'b':dice_[5]
}
for i in com:
    # u
    #ltr b
    # d
    if i == "N":
        temp = dice['t']
        dice['t'] = dice['d']
        dice['d'] = dice['b']
        dice['b'] = dice['u']
        dice['u'] = temp
    elif i == "S":
        temp = dice['u']
        dice['u'] = dice['b']
        dice['b'] = dice['d']
        dice['d'] = dice['t']
        dice['t'] = temp
    elif i == "W":
        temp = dice['t']
        dice['t'] = dice['r']
        dice['r'] = dice['b']
        dice['b'] = dice['l']
        dice['l'] = temp
    elif i == "E":
        temp = dice['l']
        dice['l'] = dice['b']
        dice['b'] = dice['r']
        dice['r'] = dice['t']
        dice['t'] = temp
print(dice['t'])


Measured memory_bytes: 5612
#include<cstdio>
using namespace std;
#define N 6005
int n,l1,l2,v[N][2],ct[N];
char s[N],dp[N][N];
bool check(int i,int j){for(int k=1;k<=n*2;k++)if(dp[i][k]<dp[j][k])return 1;else if(dp[i][k]>dp[j][k])return 0;return 0;}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n*2;i++)
	if(s[i]=='a')v[++l1][0]=i;
	else v[++l2][1]=i;
	for(int i=n;i>=1;i--)
	if(v[i][0]<v[i][1])
	{
		int rb=i;
		while(rb<n&&(v[i][1]>v[rb+1][1]||v[i][1]>v[rb+1][0]))rb++;
		ct[i]=2;dp[i][1]='a';dp[i][2]='b';
		for(int j=1;j<=ct[rb+1];j++)dp[i][j+ct[i]]=dp[rb+1][j];
		ct[i]+=ct[rb+1];
		if(check(i,i+1))
		{
			ct[i]=ct[i+1];
			for(int j=1;j<=ct[i];j++)dp[i][j]=dp[i+1][j];
			dp[i][ct[i]+1]=0;
		}
	}
	else
	{
		int rb=i;
		while(rb<n&&v[rb][0]>v[rb+1][1])rb++;
		int l1=i,l2=i;
		for(ct[i]=1;ct[i]<=(rb-i+1)*2;ct[i]++)
		if(l1==rb+1)dp[i][ct[i]]='b',++l2;
		else if(l2==rb+1)dp[i][ct[i]]='a',++l1;
		else if(v[l1][0]<v[l2][1])dp[i][ct[i]]='a',++l1;
		else dp[i][ct[i]]='b',++l2;
		ct[i]--;
		for(int j=1;j<=ct[rb+1];j++)dp[i][j+ct[i]]=dp[rb+1][j];
		ct[i]+=ct[rb+1];
		if(check(i,i+1))
		{
			ct[i]=ct[i+1];
			for(int j=1;j<=ct[i];j++)dp[i][j]=dp[i+1][j];
			dp[i][ct[i]+1]=0;
		}
	}
	printf("%s\n",dp[1]+1);
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    if ((i % 3) == 0) cout << " " << i;
    else {
      int x = i;
      while(x > 0) {
        if ((x % 10) == 3) {
          cout << " " << i;
          break;
        }
        else x /= 10;
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		int n= in.nextInt();
		while(n--!=0)
		{
			char ch[]=in.next().toCharArray();
			String str = String.valueOf(ch[0]);
			for(int i=3; i<ch.length; i+=3)
			{
				boolean flag = true;
				for(int j=0;j<str.length();j++)
					if(ch[i]==str.charAt(j))
						flag=false;
				if(flag)
				{
					if(ch[i-1]=='>')
						str= str+ch[i];
					else
						str=ch[i]+str;
				}
			}		
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 12000
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N; string S; cin >> S;
    if (N % 2 == 1) {
        cout << "No" << endl; return 0;
    }

    F0R(i, N/2) {
        if (S[i] != S[i+N/2]) {
            cout << "No" << endl; return 0;
        }
    }

    cout << "Yes" << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = 998244353

def sub(a, b):
    return (a % mod + mod - b % mod) % mod


def main():
    n, = list(map(int, input().split()))
    t = 1
    dd = [t]
    for _ in range(n):
        t=2*t%mod
        dd.append(t)

    xs, ys = [], []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        xs.append(x)
        ys.append(y)

    ini = sorted(list(range(n)), key=lambda x:xs[x])
    for i, yi in enumerate(sorted(list(range(n)), key=lambda x:ys[x])):
        ys[yi] = i 
    nys = [ys[i] for i in ini]

    tree = [0] * (n + 1)
    r = 0
    for i, y in enumerate(nys):
        j = y+1
        while j <= n:
            tree[j] += 1
            j += j & -j

        d = 0
        j = y
        while j > 0:
            d += tree[j]
            j -= j & -j

        c = i - d
        b = (n-1) - y - c
        a = (n-1) - b - c - d
        r = (r + sub(dd[b+c] + dd[c+d] + dd[d+a] + dd[a+b],
                dd[a] + dd[b] + dd[c] + dd[d])) % mod

    print(sub((dd[n] * n) % mod, (r+n)%mod))
main()


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

int main(){

int a, b;
cin >> a >> b;

int c=a+b;
if(a%3==0){
  cout << "Possible" << endl;
} else if(b%3==0){
  cout << "Possible" << endl;
} else if(c%3==0){
  cout << "Possible" << endl;
} else {
  cout << "Impossible" << endl;
}

  return 0;
}

Measured memory_bytes: 256
n=int(input())
nn=n//6
nr=n%6
if n==3:
  print(2,5,63)
elif n==4:
  print(2,5,20,63)
elif n==5:
  print(2,5,20,30,63)
else:
  Ans=[]
  count=0
  k=1
  while count<n:
    if k%6==2 or k%6==3 or k%6==4 or k%6==0:
      Ans.append(k)
      count+=1
    k+=1
  s=sum(Ans)
  if s%6==2:
    Ans.remove(8)
    Ans.append(6*(k//6+1))
  elif s%6==3:
    Ans.remove(9)
    Ans.append(6*(k//6+1))
  elif s%6==5:
    Ans.remove(9)
    Ans.append(6*(k//6)+4)
  print(*Ans)


Measured memory_bytes: 4548
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let Ns = input[0].split(' ').map(n => Number(n))
	Ns = Ns.sort((a, b) => a - b)
	console.log(Ns[2] === Ns[0] + Ns[1] ? 'Yes' : 'No')
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
	string S;
	cin>>S;
	long long K;
	cin>>K;
	int ans=0;
	for(int z=0;z<S.length() && K>0;z++)
	{
		if(S[z]=='1')
		{
			K--;
			if(K==0) ans=S[z]-'0';
		}
		else
		{
			ans=S[z]-'0';
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MAX = 30 + 1;

    public static void main(String[] args) {
        boolean[] students = new boolean[MAX];
        try(Scanner scn = new Scanner(System.in)) {
            while(scn.hasNextInt()) {
                students[scn.nextInt()] = true;
            }
        }
        for(int i = 1; i < MAX; i++) {
            if(!students[i]) {
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 26240
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Set  as S


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve (a1,a2,a3) (b1,b2,b3) (c1,c2,c3) bingos = 
    let
        bingo = S.fromList bingos
    in
    if a1 `S.member` bingo && a2  `S.member` bingo && a3 `S.member` bingo then "Yes"
    else if b1 `S.member` bingo && b2  `S.member` bingo && b3 `S.member` bingo then "Yes"
    else if c1 `S.member` bingo && c2  `S.member` bingo && c3 `S.member` bingo then "Yes"
    else if a1 `S.member` bingo && b1  `S.member` bingo && c1 `S.member` bingo then "Yes"
    else if a2 `S.member` bingo && b2  `S.member` bingo && c2 `S.member` bingo then "Yes"
    else if a3 `S.member` bingo && b3  `S.member` bingo && c3 `S.member` bingo then "Yes"
    else if a1 `S.member` bingo && b2  `S.member` bingo && c3 `S.member` bingo then "Yes"
    else if c1 `S.member` bingo && b2  `S.member` bingo && a3 `S.member` bingo then "Yes"
        else "No"



main = do
    a <- readTuple3
    b <- readTuple3
    c <- readTuple3
    num <- readInt
    bingos <- replicateM num readInt
    putStrLn $ solve a b c bingos


Measured memory_bytes: 380
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


X,Y,Z= nm()
print(Z,X,Y)


Measured memory_bytes: 3060
#include <bits//stdc++.h>
using namespace std;
int main() {
	int x[2],y[2];
	int l=0;
	cin>>x[0]>>x[1]>>y[0]>>y[1];
	if(x[0]<=y[0]){
		l=min(y[1],x[1])-y[0];	
	}else if(y[0]<=x[0]){
		l=min(x[1],y[1])-x[0];
	}
	if(l<0)l=0;
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999

const ll mod = 1e9+7;

int main(){
	ll d, g;
	cin >> d >> g;
	vector<ll> p(d);
	vector<ll> c(d);
	REP(i, d){cin >> p[i] >> c[i];}
	ll ans = INF;
	for (int i = 0; i < (1<<d); i++){
		ll score = 0;
		ll cnt = 0;
		ll rest_max = -1;
		for (int j = 0; j < d; j++){
			if (i >> j & 1){
				score += (j+1) * 100 * p[j] + c[j];
				cnt += p[j];
			} else {rest_max = j;}
		}
		if (score < g){
			if (g-score - (rest_max+1) * 100 * p[rest_max] >= 0){continue;}
			else {cnt += (g-score + (rest_max+1) * 100 -1) / ((rest_max+1) * 100);}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


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

int main(){
  string S;
  int Q;
  cin>>S;
  cin>>Q;
  
  //vector<char> S(str.begin(),str.end());
  string head="";
  string tail="";
  bool isReverse=false;
  
  for(int i=0;i<Q;i++){
    int T;
    cin>>T;
    if(T==1){
      if(isReverse){
        isReverse=false;
      }else{
        isReverse=true;
      }
    }else{//T==2
      int F;
      char C;
      cin>>F>>C;
      if(isReverse){
        if(F==1){
          tail.push_back(C);
        }else{
          head.push_back(C);
        }
      }else{//isReverse=false
        if(F==1){
          head.push_back(C);
        }else{
          tail.push_back(C);
        }
      }
 
    }
  }
  
  
  string ans;
  //cout<<head<<endl;
  //cout<<tail<<endl;
  if(isReverse){
    if(S.size()>1)reverse(S.begin(),S.end());
    if(tail.size()>1)reverse(tail.begin(),tail.end());
    ans=tail+S+head;
  }else{
    if(head.size()>1)reverse(head.begin(),head.end());
    ans=head+S+tail;
  }
  
  cout<<ans<<endl;

}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a[100010];
signed main(){
	cin>>n;
	int mi=INF,ma=0;
	rep(i,n){
		cin>>a[i];
		mi=min(mi,a[i]);
		ma=max(ma,a[i]);
	}
	if(ma-mi>1){
		puts("No");
		return 0;
	}
	int x=0,y=0;
	rep(i,n){
		if(mi==a[i])x++;
		if(ma==a[i])y++;
	}
	if(ma!=mi){
		if(x<ma&&y/(ma-x)>=2)puts("Yes");
		else puts("No");
	}
	else{
		if(mi==n-1)puts("Yes");
		else if(n/mi>=2)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1024