akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 100000


ll N;

void cul(string S,char last) {
	if (S.length() == N) {
		cout << S << endl;
		return;
	}
	for (char k = 'a'; k <= last+1; k++) {
		cul(S + k, max(last,k));
	}
}



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


	cin >> N;

	cul("a", 'a');


	return 0;
}


Measured memory_bytes: 1536
x = int(input())

bin_x = format(x, '032b')
bin_x1 = format(~x & 0b11111111111111111111111111111111, '032b')
bin_x2 = format(x << 1 & 0b11111111111111111111111111111111, '032b')
bin_x3 = format(x >> 1 & 0b11111111111111111111111111111111, '032b')

print(bin_x)
print(bin_x1)
print(bin_x2)
print(bin_x3)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll n, m;
  cin >> n >> m;
  combination c(1e6);

  vl nums;
  ll mm = m;
  for(ll i = 2; i <= m / 2; i++) {
    if(mm == 1) break;
    ll num = 0;
    while(mm % i == 0) {
      mm /= i;
      num++;
    }
    if(num > 0) nums.push_back(num);
  }
  mint ans = 1;
  for(auto v : nums) ans *= c(v + n - 1, v);
  cout << ans.x << endl;
}

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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
template<class like_bool, class output> inline void negative(like_bool condition, output num){ if(condition)cout << -1 << endl; else cout << num << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

vector<int> parents;

int find_root(int now){
    if(parents[now] == now){
        return now;
    }else{
        return parents[now] = find_root(parents[now]);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    parents.resize(n);
    for(int i = 0; i < n; i++){
        parents[i] = i;
    }
    for(int i = 0; i < q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if(com){
            cout << (find_root(x) == find_root(y)) << endl;
        }else{
            parents[find_root(x)] = find_root(y);
        }
    }
}




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

//https://qiita.com/tubo28/items/e6076e9040da57368845
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 sx: i32 = read();
    let sy: i32 = read();
    let tx: i32 = read();
    let ty: i32 = read();

    //右からsへ
    let mut ans:String = "".to_string();
    for _i in 0..(tx - sx) {
        ans += "R";
    }
    for _i in 0..(ty - sy) {
        ans += "U";
    }

    //左からtへ
    for _i in 0..(tx - sx) {
        ans += "L";
    }
    for _i in 0..(ty - sy) {
        ans += "D";
    }

    //左からsへ
    ans += "L";
    for _i in 0..(ty - sy + 1) {
        ans += "U";
    }
    for _i in 0..(tx - sx + 1) {
        ans += "R";
    }
    ans += "D";
    
    //右からtへ
    ans += "R";
    for _i in 0..(ty - sy + 1) {
        ans += "D";
    }
    for _i in 0..(tx - sx + 1) {
        ans += "L";
    }
    ans += "U";

    println!("{}", ans);

}


Measured memory_bytes: 4352
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
        mut ab: [(usize, i64); n]
    }
    ab.sort();
    let mut que = BinaryHeap::new();
    let mut pos = 0;
    let mut ans = 0;
    for day in 1..=m {
        while pos < n && ab[pos].0 == day {
            que.push(ab[pos].1);
            pos += 1;
        }
        if let Some(money) = que.pop() {
            ans += money;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5852
import sys

def resolve():
    c = sys.stdin.readlines()
    c = list(map(lambda x: x.strip(), c))
    H, W, K = tuple(map(int, c[0].split(' ')))
    del c[0]
    ans = 0
    for hh in range(1<<H):
        for ww in range(1<<W):
            cnt = 0
            for h in range(H):
                for w in range(W):
                    if hh >> h & 1:
                        continue
                    if ww >> w & 1:
                        continue
                    if c[h][w] == '#':
                        cnt += 1

            if cnt == K:
                ans += 1

    print(ans)

resolve()

Measured memory_bytes: 73840
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

long long solve(long long n, vector<int> w, vector<int> v)
{
    vector<long long> dp(n+1, -1);

    dp[0] = n;
    for(int i = 0; i < 3; i++){
        if(v[i] <= 0){
            continue;
        }
        for(long long j = 0; j <= n; j++){
            if(dp[j] != -1){
                if(j+w[i] <= n){
                    dp[j+w[i]] = max(dp[j+w[i]], dp[j]+v[i]);
                }
            }
        }
    }
    long long maxValue = 0;
    for(long long i = 0; i <= n; i++){
        //printf("DDD %d\n", dp[i]);
        if(dp[i] > maxValue){
            maxValue = dp[i];
        }
    }

    return maxValue;
}

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


    vector<int> a;
    for(int i = 0; i < 3; i++){
        int tmp;
        cin >>tmp;
        a.push_back(tmp);
    }
    vector<int> b;
    for(int i = 0; i < 3; i++){
        int tmp;
        cin >>tmp;
        b.push_back(tmp);
    }

    vector<int> av;
    vector<int> bv;
    for(int i = 0; i < 3; i++){
        av.push_back(b[i] - a[i]);
        bv.push_back(a[i] - b[i]);
    }

    long long v = solve(n, a, av);
    long long ans = solve(v, b, bv);

    printf("%lld\n", ans);

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    string s; cin >> s;

    for (int i = 0;i < s.size()-1;i++){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;



int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout << fixed << setprecision(20);

   long n,a[100010],s=0,min_a=100000000,ans=0; 
   cin >> n;
   int p=0; bool flag=false;
   rep(i,0,n) {
   	cin >> a[i];
   	if(a[i]<0) {
   		a[i]*=-1;
   		p++;
   	}
   	else if(a[i]==0)flag=true;
   	s+=a[i];
   	min_a=min(min_a,a[i]);
   }
   if(p%2==0 or flag) ans=s;
   else ans = s-2*min_a;
   cout << ans << endl;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
constexpr int kN = int(3E5 + 10);
#define F first
#define S second
#define PB push_back

int cntx[kN], cnty[kN], x[kN], y[kN];
vector<int> v[kN];
set<pair<int, int>> s, ns;

int main() {
	int n, m, k, ans = 0;
	set<pair<int, int>> :: iterator u;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= k; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= k; i++) cntx[x[i]]++, cnty[y[i]]++;
	for (int i = 1; i <= k; i++) v[x[i]].PB(y[i]);
	for (int i = 1; i <= m; i++) s.insert({cnty[i], i});
	for (int i = 1; i <= n; i++) {
		for (int j : v[i]) s.erase({cnty[j], j});
		for (int j : v[i]) ns.insert({cnty[j], j});
		if (!s.empty()) {
			u = prev(s.end());
			ans = max(ans, cntx[i] + u -> F);
		}
		if (!ns.empty()) {
			u = prev(ns.end());
			ans = max(ans, cntx[i] + u -> F - 1);
		}
		for (int j : v[i]) ns.erase({cnty[j], j});
		for (int j : v[i]) s.insert({cnty[j], j});
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 38464
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll vis[100001]={0};
void dfs(ll node,vector<vector<ll>>&g)
{
  vis[node]=1;
  for(auto x:g[node])
  {
    if(!vis[x]) dfs(x,g);
  }
  return ;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    //compute();
    //Sieve();
    
   ll tests=1;
 // cin>>tests;
  ll t=1;
    while(tests--)
    {
      ll  n,i,k,ans=0;
      cin>>n>>k;
      ll mx,mn;
      vector<ll>dp(n+1,0);
      dp[1]=n;
      for(i=2;i<=n;i++)
      {
        dp[i]=dp[i-1]+n-(i-1);
      }
      for(i=k;i<=n;i++)
      {
        mn=((i-1)*i)/2;
        mx=dp[i];
        ans+=mx-mn+1;
        ans%=mod;
      }
      ans++;
      ans%=mod;
      cout<<ans;


        t++;
    }
    return 0;
   }

Measured memory_bytes: 15876
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG
    
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if(x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0)
        printf("Yes\n");
    else
    {
        printf("No\n");
    }

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        r[i]++;
    }
    vector<int> isprime(100001, 1);
    isprime[0] = 0, isprime[1] = 0;
    for (int i = 2; i < isprime.size(); i++) {
        if (!isprime[i]) continue;
            for (int j = i * 2; j < isprime.size(); j += i) {
                isprime[j] = 0;
            }
    }
    vector<int> a(100001, 0);
    for (int i = 0; i < a.size(); i++) {
        if (i % 2 == 0) continue;
        if (isprime[i] && isprime[(i + 1) / 2]) a[i] = 1;
    }
    vector<int> s(100002, 0);
    for (int i = 0; i < s.size(); i++) s[i + 1] = s[i] + a[i];
    for (int i = 0; i < q; i++) cout << s[r[i]] - s[l[i]] << '\n';
    return 0;
}

Measured memory_bytes: 2560
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int n;
    cin >> n;
    int a;
    deque<int> b;
    REP(i, n)
    {
        cin >> a;
        if (i % 2 == 0)
        {
            b.push_back(a);
        }
        else
        {
            b.push_front(a);
        }
    }
    REP(i, n)
    {
        cout << b[n % 2 == 0 ? i : n - 1 - i] << " ";
    }
    cout << endl;
    return 0;
}


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

const int DIM = 1e5 + 5;

int arr[DIM], aux[DIM];

int main( void ) {
    
    int n, x;
    cin >> n >> x;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i]; aux[i] = arr[i];
        
        if( i >= 2 )
            arr[i - 1] += arr[i];
    }
    
    long long ans = 0;
    for( int i = 1; i < n; i ++ ) {
        if( arr[i] > x ) {
            ans += arr[i] - x;
            arr[i + 1] -= min( arr[i] - x, aux[i + 1] );
            arr[i] = x;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = set()
for i in range(N):
  b.add(int(input()))

flag = 0

if (A1[0] in b) and (A1[1] in b) and (A1[2] in b):
  flag = 1

if (A2[0] in b) and (A2[1] in b) and (A2[2] in b):
  flag = 1

if (A3[0] in b) and (A3[1] in b) and (A3[2] in b):
  flag = 1

for col in range(3):
  n = 0
  if (A1[col] in b) and (A2[col] in b) and (A3[col] in b):
    flag = 1

if (A1[0] in b) and (A2[1] in b) and (A3[2] in b):
    flag = 1
if (A1[2] in b) and (A2[1] in b) and (A3[0] in b):
    flag = 1    

if flag:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	ll ans = 0;
	while (n > 0) {
		if (n % 10 == 2)++ans;
		n /= 10;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<vector>

using namespace std;
typedef long long Int;

int main(){
    Int n, m;
    cin >> n >> m;
    vector<Int> a(n), b(m);
    for(auto &x:a)cin >> x;
    for(auto &x:b)cin >> x;
    auto c = atcoder::convolution(a, b);
    for(auto elem:c){
        cout << elem << " ";
    }cout << endl;
}

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

int main() {
    int n, k;
    std::string s;
    std::cin>>n;
    std::cin>>s;
    std::cin>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    std::cout<<s<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}
 
  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
    {
      if(i>1&&i<a&&j<b&&j>1)printf(".");
      else printf("#");
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}


Measured memory_bytes: 2104
from collections import Counter
N = int(input())
*A, = map(int, input().split())
c = Counter(A)
ac = [(k, v) for k, v in c.items()]
ac.sort()
ac.reverse()

rest = 4
ans = 0
for k, v in ac:
    if v >= 4 and rest == 4:
        ans = k*k
        break
    elif v >= 2:
        rest -= 2
        if ans == 0:
            ans = -k
        else:
            ans *= -k
            break
print(max(ans, 0))


Measured memory_bytes: 107160
#include   <cstdio>
#include  <cstring>
#include <iostream>
using namespace std;

int n, a[5], tot, B, ans;
string s;

int main() {
	cin >> n >> s, s = " " + s;
	for (int i = 0; i <= 999; i++) {
		a[1] = i / 100, a[2] = i / 10 % 10, a[3] = i % 10, tot = 1, B = 0;
		for (int j = 1; j <= s.size() && !B; j++) {
			if (s[j] - '0' == a[tot]) tot++;
			if (tot > 3) B = 1;
		}
		if (B) ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  char ch;
  cin>>ch;
  int n=int(ch);
  char ch1=n+1;
  cout<<ch1<<endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
int n, ar[MAXn], cnt;
pair<int ,int> p[MAXn];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first;
		p[i].second = i;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++)
		if (p[i].second % 2 != i % 2)
			cnt++;
	cout << cnt/2;
}
		

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

int main() {
  string move;
  cin >> move;
  int a = 0;

  for(int i = 0; i < move.size(); i+=2){
      if(move[i] == 'L'){
        break;
      }
      else{
        a += 1;
      }     
    }
  for(int i = 1; i < move.size(); i+=2){
      if(move[i] == 'R'){
        break;
      }
      else{
        a += 1;
      }
    }
    if(a == move.size()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
g = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        g[i].append((x-1,y))
ans = 0
for bit in range(1<<n):
    f = True
    for i in range(n):
        if bit&(1<<i) and f:
            for x,y in g[i]:
                if y ==1 and bit&(1<<x):
                    continue
                elif y ==0 and bit&(1<<x)==0:
                    continue
                else:
                    f = False
                    break
    if f:
        ans = max(ans,bin(bit).count('1'))
print(ans)


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

int main(){
  int W,a,b;
cin >> W >> a >> b;
  if(a>b){
  if (b+W >a){
    cout << '0' << endl;
  }
  else {
    cout << a-b-W << endl;
  }}
    else{
   if (a+W >b){
    cout << '0' << endl;
  }
  else {
    cout << b-a-W << endl;
  }
  }
  
  }
    
    




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

int main() {
  int N=si(), Q=si();
  string S = ss();
  vector<int> ans(N+1);
  REP(i,N-1) {
    if (S[i]=='A'&&S[i+1]=='C') ans[i+1]++;
  }
  REP(i,N) ans[i+1]+=ans[i];
  while(Q--){
    int l=si()-1,r=si();
    int a=ans[r]-ans[l];
    if(r<N&&S[r-1]=='A'&&S[r]=='C')a--;
    pi(a);br();
  }
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    int ans = 0;
    while(N--){
        int x;
        cin >> x;
        ans += x - 1;
    }

    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    string str;
    cin>>str;

    int mx=0,cnt=0;
    for(int i=0;i<3;i++){
        cnt=0;
        if(str[i]=='R'){
            while(str[i]=='R' && i<3){
                cnt++;
                i++;
            }
            mx=max(cnt,mx);
        }
    }

    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int n;
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		
		System.out.println(n%2==0 ? n/2:(n/2)+1);

	}

}


Measured memory_bytes: 23636
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

#define RANGE 1000001

bool exist[RANGE];

int f(int n){
	if(n%2) return 3 * n + 1;
	else return n / 2;
}

int a(int s, int i){
	if(i == 1) return s;
	else return f(a(s, i-1));
}

int main(){
	int s;
	scanf("%d\n", &s);
	for(int i=0; i<RANGE; i++){
		exist[i] = false;
	}
	for(int i=1; i<RANGE+1; i++){
		if(exist[a(s,i)] == false) exist[a(s,i)] = true;
		else {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>

int main()
{
    int a, b;
    char op;

    while (1) {
        std::cin >> a >> op >> b;
        int result = 0;
        if (op == '+') {
            result = a + b;
        } else if (op == '-') {
            result = a - b;
        } else if (op == '*') {
            result = a * b;
        } else if (op == '/') {
            result = a / b;
        } else if (op == '?') {
            break;
        } else {
            std::cout << "ERROR! You input wrong operator." << std::endl;
        }
        std::cout << result << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

const int N = (int)1e5 + 5;
vector<ll>s;
vector<ll>cache(N,MOD);

ll res(ll top)
{
	if(top == 0)
	{
		return 0;
	}
	else if(top == 1)
	{
		if(cache[top] != MOD)
		{
			return cache[top];
		}
		ll ans = (abs(s[top] - s[top-1]));
		//ERR2(top, ans);
		return cache[top] = ans;
	}
	else
	{
		if(cache[top] != MOD)
		{
			return cache[top];
		}
		ll ans = min((abs(s[top]-s[top-1]) + res(top-1)), 
						(abs(s[top] - s[top-2]) + res(top - 2))
						);
		//ERR2(top, ans);
		return cache[top] = ans;
	}
}

int main()
{
	ll n,k;
	cin>>n>>k;
	s.resize(n);
	FOR(i,0,n) cin>>s[i];
	vector<ll>dp(N,MOD);
	dp[0] = 0;
	if(n == 1)
	{
		cout<<dp[0]<<endl;
		return 0;
	}
	FOR(i,0,n)
	{
		int j = i-1;
		while(j >= i-k && j>=0)
		{
			dp[i] = min(dp[i],
			abs(s[i] - s[j]) + dp[j]);
			j--;
		}		
	}	
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 5636
package main

import (
	"fmt"
	"strconv"
)

func month(s string) bool {
	i, _ := strconv.Atoi(s)
	if i > 0 && i <= 12 {
		return true
	}
	return false
}

func main() {
	var s string
	fmt.Scan(&s)

	first := s[:2]
	last := s[2:]

	if month(first) && month(last) {
		fmt.Println("AMBIGUOUS")
	} else if month(first) {
		fmt.Println("MMYY")
	} else if !month(last) {
		fmt.Println("NA")
	} else {
		fmt.Println("YYMM")
	}
}


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

#define ll long long
ll ara[405],prefsum[405],dp[405][405];
/**
Think this problem reversely. That means assume that initially all slimes r merged.
You have to make every slime separate with minimum cost. Cost of dividing a slime into
two part is the total value of the connected slime.
dp[i][j] means minimum cost to make every (j-i+1) slimes separate
**/

int main()
{
    ll i,j,k,n,ans;
    cin>>n;
    for(i=1 ; i<=n ; i++){
        cin>>ara[i];
        prefsum[i] = prefsum[i-1] + ara[i];
    }

    for(ll sz=2 ; sz<=n ; sz++){
        for(i=1 ; i<=n-sz+1 ; i++){
            j = i+sz-1;
            dp[i][j] = 1e18;
            ll cuttingcost = prefsum[j] - prefsum[i-1];
            for(k=i ; k<j ; k++)
                dp[i][j] = min(dp[i][j] , cuttingcost + dp[i][k] + dp[k+1][j]);
        }
    }
    cout<<dp[1][n]<<endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
//binary_search(all(p),x) bool型

int main(){

    int n;
    cin >> n;
    if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon" << endl;
    else if(n%10 == 3) cout << "bon" << endl;
    else cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループのノード数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans=0, w_cnt=0, e_cnt=0;
    if(S[0]=='W') w_cnt++;
    for(int i=1; i<N; i++){
        if(S[i]=='E') e_cnt++;
    }
    ans=e_cnt;
    for(int i=1; i<N; i++){
        if(S[i]=='E') e_cnt--;
        ans=min(ans, e_cnt+w_cnt);
        if(S[i]=='W') w_cnt++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 900
#include<iostream>
using namespace std;
 
int main()
{
    int Dice1[6];
    int Dice2[6];
    int tmp;
    int count=0;
    int i, j;
     
    for(i=0;i<6;i++){
        cin >> Dice1[i];
    }
     
    for(i=0;i<6;i++){
        cin >> Dice2[i];
    }
     
    for(i=0;i<5;i++){
        if(Dice1[i]==Dice2[i])
            count++;
    }
     
    for(i=0;i<4;i++){
        tmp=Dice2[0];
        Dice2[0]=Dice2[1];
        Dice2[1]=Dice2[5];
        Dice2[5]=Dice2[4];
        Dice2[4]=tmp;
        if(Dice2[1]==Dice1[1])
                break;
 
        else{
            for(j=0;j<4;j++){
                tmp=Dice2[0];
                Dice2[0]=Dice2[3];
                Dice2[3]=Dice2[5];
                Dice2[5]=Dice2[2];
                Dice2[2]=tmp;
                if(Dice2[0]==Dice1[1]){
                    tmp=Dice2[0];
                    Dice2[0]=Dice2[4];
                    Dice2[4]=Dice2[5];
                    Dice2[5]=Dice2[1];
                    Dice2[1]=tmp;
                    break;
                }
            }
        }
    }
    for(i=0;i<4;i++){
        tmp=Dice2[0];
        Dice2[0]=Dice2[3];
        Dice2[3]=Dice2[5];
        Dice2[5]=Dice2[2];
        Dice2[2]=tmp;
        if(Dice2[0]==Dice1[0]){
            if(Dice1[0]==Dice2[0]&&Dice1[1]==Dice2[1]&&Dice1[2]==Dice2[2]&&Dice1[3]==Dice2[3]&&Dice1[4]==Dice2[4]&&Dice1[5]==Dice2[5]){
                cout << "Yes" << endl;
                return 0;
            }
             
            else if(count!=4){
                cout << "No" << endl;
                return 0;
            }
        }
    }
     
}

Measured memory_bytes: 3100
N=int(input())
W=list(map(int,input().split()))
WR=list(reversed(W))

L=0
R=0
i=0
j=0
while i+j<N:
  if L<=R:
    L+=W[i]
    i+=1
  else:
    R+=WR[j]
    j+=1
print(abs(L-R))

Measured memory_bytes: 3064
n = int(input())
c = input()

# それぞれの色の数をカウント
w = c.count("W")
r = c.count("R")

ans = 0
for i in range(r): #　赤の数分文字列を確認する
  if c[i] == "W": ans += 1 # カウント
print(ans)

Measured memory_bytes: 9312
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    ll n,k,r;
    cin>>n>>k;
    r=n%k;
    cout<<min(r,k-r);
}

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

int main() {
    long N;
    long M;
    cin >> N >> M;
    long long ans;
    if(N==1 && M==1) cout << 1 <<"\n";
    else if(N==1) cout << M-2 <<"\n";
    else if(M==1) cout << N-2 <<"\n";
    else {
        ans = (N-2)*(M-2);
        cout << ans <<"\n";
    }

}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  if (a == b) {
    cout << a * 2 << endl;
  } else {
    cout << a * 2 - 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int main() {
  int K;
  int A;
  int B;
  cin >> K >> A >> B;
  int X = A / K;
  int Y = B / K;
  if(X < Y){
   cout << "OK" << endl;
  }
  else if(B % K == 0){
   cout << "OK" << endl;
  }
  else if(A % K == 0){
   cout << "OK" << endl;
  }
  else{
   cout << "NG" << endl;
  }
} 


Measured memory_bytes: 3596
#include<stdio.h>

int binarySearch(int A[], int n, int key){
    int l, r, m;

    l = 0;
    r = n; 
    
    while(l < r){
        m = (l + r) / 2;
        if(A[m] == key) return 1;
        else if(key < A[m]){
            r = m;
        }else{
            l = m + 1;
        }
    }

    return 0;
}

int main(){
    int n, A[100000 + 1], q, key;
    int i, res = 0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &key);
        res += binarySearch(A, n, key);
    }

    printf("%d\n", res);

    return 0;
}



Measured memory_bytes: 2100
#include<stdio.h>

void trace(int A[], int N){
  int i;
  
  for(i = 0 ; i < N ; i++){
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int i,j,key;
  
  for(i = 1 ; i < N ; i++){
    key = A[i];
    j = i - 1;
    
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    
    A[j+1] = key;
    trace(A,N);
  }
}


int main(){
  int i,j,N;
  int A[100];
  
  scanf("%d",&N);
  
  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }

  trace(A,N);
  insertionSort(A,N);
  
  return 0;
}



Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m;
	
	cin>>n>>m;
	
	if(n==m) cout<<0<<endl;
	
	else if(n>m) cout<<n-m<<endl;
	
	else cout<<m-n<<endl;
	
	return 0;
}	


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007

int main(){
  ll A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  if(A<B){
    ll x=A+V*T;
    ll y=B+W*T;
    if(x>=y){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }else{
    ll x=A-V*T;
    ll y=B-W*T;
    if(x<=y){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

public class Main{


    static int color[];
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	String str[]=br.readLine().split(" ");
	int n=Integer.parseInt(str[0]);
	int m=Integer.parseInt(str[1]);

        ArrayList<ArrayList<Integer>> edge=new ArrayList<>();
	color=new int[n];
	Arrays.fill(color,-1);

	for(int i=0;i<n;i++){
	    edge.add(new ArrayList<>());
	}

	for(int i=0;i<m;i++){
	    str=br.readLine().split(" ");
	    int a=Integer.parseInt(str[0]);
	    int b=Integer.parseInt(str[1]);

	    edge.get(a).add(b);
	    edge.get(b).add(a);
	}

	int c=1;
	for(int i=0;i<n;i++){
	    if(color[i]==-1)
		dfs(edge,n,i,c++);
	}
	
	int q=Integer.parseInt(br.readLine());
	for(int i=0;i<q;i++){
	    str=br.readLine().split(" ");
	    int s=Integer.parseInt(str[0]);
	    int g=Integer.parseInt(str[1]);

	    
	    if(color[s]==color[g]){
		System.out.println("yes");
	    }else{
		System.out.println("no");
	    }
	}
    }
    static void dfs(ArrayList<ArrayList<Integer>> edge,int n,int s,int c){
	Deque<Integer> stack=new ArrayDeque<>();

	color[s]=c;
	stack.add(s);
	while(!stack.isEmpty()){
	    int now=stack.poll();

	    for(int i:edge.get(now)){
		if(color[i]==-1){
		    color[i]=c;
		    stack.add(i);
		}
	    }
	}
    }
}



Measured memory_bytes: 74952
<?php
$line = fgets(STDIN); // 標準入力からの入力値を変数に代入
$array = explode(" ", $line); // 取得した入力値を半角スペースで分解

$i=1;
foreach ($array as $value){
 if($i==1){
    $a = $value;
 } else {
    $b = $value;
 }
 $i++;
}

$x = $a*$b - ($a + $b) +1;

echo $x;
?>

Measured memory_bytes: 3700
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define full(c) c.begin(), c.end()
typedef unsigned long long int ull;
using namespace std;

int main(){
	int k, i, n;
	string x, y;
	cin >> x;
	cin >> y;
	n = x.size();
	for (k = 0; k < n; k++){
		for (i = 0; i < n; i++){
			if (x[i] != y[(i + k)%n]) break;
		}
		if (i == n){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == T[i])
                {
                    ans += 1;
                }
            }
            Console.WriteLine(ans);
        }
    }

}


Measured memory_bytes: 13140
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        int n = s.nextInt();

        if(n == 1) {
            System.out.println("0");
        }
        int arr[] = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        int res = K;
        for(int i = 0; i < n; i++) {
            if(i == 0)
                res = Math.min(res, Math.min(arr[n-1]-arr[0], K-(arr[i+1] - arr[0])));
            else if(i == n-1)
                res = Math.min(res, Math.min(Math.abs(arr[n-1]-arr[0]), K - (arr[n-1] - arr[n-2])));
            else
                res = Math.min(res, Math.min(K - (arr[i] - arr[i-1]), K - (arr[i+1] - arr[i])));
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 65364
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//子の数が分かるUnionFind
struct UFT {
public:
	vector<int> par, rank;
	vector<int> c_n; //子の数
	void init(int n = 1) {
		par.resize(n); rank.resize(n); c_n.resize(n);
		for (int i = 0; i < n; i++)par[i] = i, rank[i] = 0, c_n[i] = 1;
	}
	void update(int x) {
		if (par[x] == x)return;
		else {
			int r = root(par[x]);
			c_n[par[x]] += c_n[x];
			par[x] = r;
			return;
		}
	}
	int root(int x) {
		if (par[x] == x)return x;
		else {
			int r = root(par[x]);
			return par[x] = r;
		}
	}
	UFT(int n = 1) {
		init(n);
	}
	int weight(int x) {
		return c_n[root(x)];
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)false;
		if (rank[x] < rank[y])swap(x, y);
		if (rank[x] == rank[y])rank[x]++;
		par[y] = x;
		update(y);
		return true;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UFT a(N+1);
	for (int i = 0; i < M; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		a.merge(x, y);
	}
	set<int> b;
	for (int i = 1; i <= N; i++)b.insert(a.root(i));
	cout << b.size() << endl;
}

Measured memory_bytes: 6144
from itertools import chain
import numpy as np
import networkx as nx

X = iter(open(0).readlines())
h, w = map(int, next(X).split())
C = np.zeros((10, 10), dtype=int)
for i in range(10):
    for j, c in enumerate(map(int, next(X).split())):
        C[i, j] = c
A = np.zeros((h, w), dtype=int)
for i in range(h):
    for j, a in enumerate(map(int, next(X).split())):
        A[i, j] = a

G = nx.DiGraph(C)
d = {-1:0}
for i in range(10):
    d[i] = nx.shortest_path_length(G, i, 1, weight='weight')
print(sum(d[a] for a in chain.from_iterable(A)))

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

using namespace std;

int main(){

  int a,b;
  cin>>a>>b;
  int result=0;
  string tmp;
  for(int i=a;i<=b;i++){
    tmp=to_string(i);
    if(tmp[0]==tmp[4]&&tmp[1]==tmp[3]){
      result++;
    }
    
  
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int W, a, b;
	cin >> W >> a >> b;
	if (a + W < b)
		cout << b - a - W << endl;
	else if (b + W < a)
		cout << a - b - W << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char next = 'a';
    int sa_idx = 0;
    int sb_idx = 0;
    int sc_idx = 0;
    while(1) {
        if ( next == 'a' && sa_idx >= sa.size() ) {
            cout << 'A' << endl;
            return 0;
        }
        else if ( next == 'b' && sb_idx >= sb.size() ) {
            cout << 'B' << endl;
            return 0;
        }
        else if ( next == 'c' && sc_idx >= sc.size() ) {
            cout << 'C' << endl;
            return 0;
        }
        if ( next == 'a' ) {
            next = sa[sa_idx];
            ++sa_idx;
        }
        else if ( next == 'b' ) {
            next = sb[sb_idx];
            ++sb_idx;
        }
        else if ( next == 'c' ) {
            next = sc[sc_idx];
            ++sc_idx;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
bool used[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string ans="";
  bool hog=true;
  vi A(n);
  ll mi=1;
  ll ma=0;
  for(int i=0;i<n;i++){
    cin>>A[i];
    ma=max(A[i],ma);
    used[A[i]]=true;
    if(A[i]==mi){
      for(int j=mi;j<=ma;j++)
	if(used[j]==false)hog = false;
      if(hog){
	string s="";
	for(int j=0;j<(ma-mi+1)*2;j++)s+='(';
	ll po=0;
	ll cnt=0;
	for(int j=mi-1;j<ma;j++){
	  for(int k=po;k<s.size();k++){
	    if(cnt<=A[j]-mi){
	      cnt++;
	    }else{
	      s[k]=')';
	      po=k+1;
	      break;
	    }
	  }
	}
	mi=ma+1;
	ma=0;
	ans+=s;
      }
    }
  }
  if(hog){
    cout<<ans<<endl;
  }else{
    cout<<":("<<endl;
  }
  return 0;
}



Measured memory_bytes: 4296
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> Tree(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		Tree[u - 1].push_back({ v - 1, w });
		Tree[v - 1].push_back({ u - 1, w });
	}
	vector<int> Color(N, -1);
	queue<int> Q;
	Q.push(0);
	Color[0] = 0;
	while (!Q.empty()) {
		int now = Q.front();
		Q.pop();
		for (const auto& p : Tree[now]) {
			if (Color[p.first] < 0) {
				Color[p.first] = (p.second % 2 == 0 ? Color[now] : 1 - Color[now]);
				Q.push(p.first);
			}
		}
	}
	for (int c : Color) cout << c << endl;
}


Measured memory_bytes: 6784