akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define MOD 1000000007
 
ll gcd(ll a, ll b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

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

int main(void){
    int N,M; cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	ll L = 0, R = n - 1;
	L = max(L, (b - a + c * (n - 1) + c + d - 1) / (c + d));
	R = min(R, (b - a + d * (n - 1)) / (c + d));
	
	cout << (L <= R ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  int cnt = 0;
  for(int i = 0; i < s.size() / 2; ++i){
    if(s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[200005];

ll ans;

int n;

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    for (int i = n, mx = -300000; i > 0; --i) {
    	if (arr[i] >= i) {
			printf("-1\n");
			return;    	
    	}

    	if (mx > arr[i] - i) {
    		printf("-1\n");
    		return;
    	}

    	mx = arr[i] - i;
    }    

    for (int l = 1, r; l <= n; l = r) {
		r = l + 1;

		while (r <= n && arr[r] == arr[r - 1] + 1) {
			++r;
		}
	    
	    ans += arr[r - 1];
    }

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

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    if(s.size()<4) {
        pl("No")
    } else {
        if(s.substr(0,4)=="YAKI"){
            pl("Yes")
        } else {
            pl("No")
        }
    }

    return 0;
}

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

namespace Minesweeper
{
    class Minesweeper
    {
        static void Main(string[] args)
        {
            string[] strInp = Console.ReadLine().Split(' ');

            int intH = int.Parse(strInp[0]);
            int intW = int.Parse(strInp[1]);

            // 入力テーブル
            string[,] strBoard = new string[intH,intW];

            for (int i = 0; i < intH; i++) {
                string strBuf = Console.ReadLine();

                for (int j = 0; j < strBuf.Length; j++) {
                    strBoard[i, j] = strBuf.Substring(j,1);
                }
            }

            // 探索補助テーブル 上下、左、右
            int[] intDx = new int[] { 0, 0, -1, -1, -1, 1, 1, 1 };
            int[] intDy = new int[] { -1, 1, 1, 0, -1, -1, 0, 1 };

            for (int i = 0; i < intH; i++) {

                for (int j = 0; j < intW; j++) {
                    if (strBoard[i, j] == "#") continue;

                    int intNum = 0;
                    for (int k = 0; k < 8; k++) {
                        int intWdy = i + intDy[k];
                        int intWdx = j + intDx[k];

                        if (intWdy < 0 || intWdy >= intH) continue;
                        if (intWdx < 0 || intWdx >= intW) continue;

                        if (strBoard[intWdy, intWdx] == "#") intNum++; // 「#」の探索

                    }

                    strBoard[i,j] = intNum.ToString();
                }

            }


            
            for (int i = 0; i < intH; i++)
            {
                string strOp = "";
                for (int j = 0; j < intW; j++)
                {
                    strOp += strBoard[i, j];
                }
                Console.WriteLine(strOp);
            }

            //return;
            
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
struct L : vector<P> {
    L(const P &a = P(), const P &b = P()) {
        emplace_back(a); emplace_back(b);
    }
};
using Polygon = vector<P>;
ostream &operator<<(ostream &os, P p) { return os << real(p) << " " << imag(p); }
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

enum CCW_RESULT { CCW = +1, CW = -1, BEHIND = +2, FRONT = -2, ON = 0 };
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return CCW;      // counter clockwise
    if (cross(b, c) < -eps) return CW;      // clockwise
    if (dot(b, c) < 0) return BEHIND;       // c--a--b on line
    if (norm(b) < norm(c)) return FRONT;    // a--b--c on line | a=b
    return ON;                              // on segment | a=c | b=c
}
#define curr(ps, i) ps[(i) % ps.size()]
#define next(ps, i) ps[(i + 1) % ps.size()]
#define prev(ps, i) ps[(i + ps.size() - 1) % ps.size()]
bool is_convex(const Polygon &ps) {
    for (int i = 0; i < ps.size(); i++) {
        if (ccw(prev(ps, i), curr(ps, i), next(ps, i)) == -1) return false;
    }
    return true;
}

#include <iostream>
#include <iomanip>
int main() {
    cout << fixed << setprecision(1);
    int n; cin >> n;
    Polygon ps;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        ps.emplace_back(x, y);
    }
    cout << is_convex(ps) << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> X(N), Y(N), Z(N);
    for (int i = 0; i < N ;i++)
        cin >> X[i] >> Y[i] >> Z[i];
    vector<vector<ll>> C = {X, Y, Z};

    ll res = -(1LL << 60);
    for (int i = 0; i < (1 << 3); i++) {
        vector<ll> sums;
        for (int j = 0; j < N; j++) {
            ll sum = 0;
            for (int k = 0; k < 3; k++) {
                if ((i >> k) & 1) {
                    sum += C[k][j];
                } else {
                    sum -= C[k][j];
                }
            }
            sums.push_back(sum);
        }
        sort(sums.begin(), sums.end(), greater<ll>());
        ll sum = 0;
        for (int j = 0; j < M; j++) {
            sum += sums[j];
        }
        res = max(res, sum);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char s[4];
  char S[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int i,n;
  scanf("%s",s);
  for (i=0; i<7; i++) {
    if (s[0] == S[i][0]&& s[1] == S[i][1]){
	  n=7-i;
    }  
  }
  printf("%d",n);
  return 0;
}

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

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

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    println!("{}", (a+b+1)/2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;


int main() {
  int N, K, R, S, P;
  string T;
  int num = 0;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  vector <char> res(N, '_');
  char old, next;
  REP(n,N){
    char target = T.at(n);
    
    if(n-K >= 0){
      old = res.at(n-K);
    }else{
      old = '_';
    }

    if(n+K < N){
      next = T.at(n+K);
    }else{
      next = '_';
    }

    if (target == 'r'){
      if (old != 'p'){
        res.at(n) = 'p';
        num += P;
      }else{
        if (next == 'p'){
          res.at(n) = 'r';
        }else{
          res.at(n) = 's';
        }
      }
    }else if(target == 's'){
      if (old != 'r'){
        res.at(n) = 'r';
        num += R;
      }else{
        if (next == 'r'){
          res.at(n) = 's';
        }else{
          res.at(n) = 'p';
        }
      }
    }else{
      if (old != 's'){
        res.at(n) = 's';
        num += S;
      }else{
        if (next == 's'){
          res.at(n) = 'p';
        }else{
          res.at(n) = 'r';
        }
      }
    }
  }

  cout << num << endl;

}

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




signed main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            if(s[i]=='0')ans++;
            else ans--;
        }else{
            if(s[i]=='0')ans--;
            else ans++;
        }
    }
    cout<<(s.length()-abs(ans))/2;
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(20000)
h= 0
w = 0
list1 = []

def dfs(x, y, f):
    list1[y] = list1[y][:x] + '1' + list1[y][x+1:]

    if y - 1 >= 0:
        if list1[y - 1][x] == f:
            dfs(x, y - 1, f)
    if y + 1 < h:
        if list1[y + 1][x] == f:
            dfs(x, y + 1, f)
    if x - 1 >= 0:
        if list1[y][x - 1] == f:
            dfs(x - 1, y, f)
    if x + 1 < w:
        if list1[y][x + 1] == f:
            dfs(x + 1, y, f)
    return

while True:
    h, w = list(map(lambda x: int(x),input().split(" ")))
    if 0 in (h, w):
        break
    n = 0
    for i in range(0, h):
        list1.append(input())
    for i in range(0, h):
        for j in range(0, w):
            if list1[i][j] != '1':
                dfs(j, i, list1[i][j])
                n+=1
    print(n)
    list1=[]

Measured memory_bytes: 15644
N, M = map(int, input().split())

H = list(map(int, input().split()))
F = [1 for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        F[b] = 0
    if H[a] <= H[b]:
        F[a] = 0
print(sum(F))


Measured memory_bytes: 84996
N=int(input())
A=list(map(int, input().split()))
if N<=2:
    print(1)
    exit()

now=0
ans=1
for i in range(1,N):
    if i==1:
        if A[i]-A[i-1]==0:
            now=0
        else:
            now=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if now>=1:
            plus=True
        elif now==0:
            plus=-1
        else:
            plus=False
            
    else:
        if A[i]-A[i-1]==0:
            nex=0
        else:
            nex=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if plus==-1:
            if nex>=1:
                plus=True
            elif nex<0:
                plus=False
        elif plus:
            if nex<0:
                plus=-1
                ans+=1
        else:
            if nex>0:
                plus=-1
                ans+=1

print(ans)



Measured memory_bytes: 84724
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned long long int ull;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=2e5;

int h,w;
vector<vector<char> > mz(50,vector<char>(50));
vector<vector<int> > d(50,vector<int>(50,INF));
int b=0;

int bfs(){
    queue<ii> que;
    que.push(make_pair(0,0));
    d[0][0]=1;
    while(!que.empty()){
        ii p=que.front();que.pop();
        int y=p.first,x=p.second;
        if(y==h-1&&x==w-1) break;
        for(int i=0;i<4;i++){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny>=0&&ny<h&&nx>=0&&nx<w&&mz[ny][nx]!='#'&&d[ny][nx]==INF){
                que.push(make_pair(ny,nx));
                d[ny][nx]=d[y][x]+1;
            }
        }
    }
    return d[h-1][w-1];
}

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>mz[i][j];
            if(mz[i][j]=='#') b++;
        }
    }
  int res=bfs();
  if(res==INF){
    cout<<-1<<endl;
    return 0;
  }
  cout<<h*w-b-res<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
static int N_MAX = 100;
 
void p(int n, int A[]) {
    for (int i = 0; i < n; ++i) {
        cout << A[i];
        if (i != n - 1) {
            cout << " ";
        }
    }
    cout << endl;
}
 
int main() {
    int n;
    int A[N_MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    p(n, A);
    for (int i = 1; i < n; ++i) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;
        p(n, A);
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> p(m), y(m);
	vector< vector<int> > d(n);
	for(int i = 0; i < m; ++i) {
		cin >> p[i] >> y[i];
		p[i]--;
		d[p[i]].push_back(y[i]);
	}
	
	for(int i = 0; i < n; ++i) {
		sort(d[i].begin(), d[i].end());
		d[i].erase(unique(d[i].begin(), d[i].end()), d[i].end());
	}
	
	for(int i = 0; i < m; ++i) {
		int x = p[i];
		int id = lower_bound(d[x].begin(), d[x].end(), y[i]) - d[x].begin();
		printf("%06d%06d\n", x + 1, id + 1);
	}
	
	return 0;
}


Measured memory_bytes: 9460
#include <stdio.h>
#include <set>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <queue>
#include <cctype>
using namespace std;
#define rep(i, a, b) for(register LL i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register LL i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
typedef long long LL;
#define inf (0x3f3f3f3f)
LL read() {
	LL x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}

const LL Maxn = (int)(1e7), Mod = (int)(1e9 + 7); 
LL n, f[Maxn], prefix[Maxn];
LL sum;
int main() {
	n = read();
	f[1] = n; f[2] = n * n % Mod;
	rep(i, 3, n) {
		f[i] = (f[i - 1] + sum) % Mod + (n - 1) * (n - 1) % Mod;
		f[i] = (f[i] + n - i + 2) % Mod;
		sum += f[i - 2];
	}
	printf("%lld\n", f[n]);
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
const int N = 1001;
int n; bool dp[N];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cin >> n;
  	for (int x = 6; x < N; x += 6)
      	dp[x] = true;
  	for (int x = 10; x < N; x += 10)
      	dp[x] = true;
	for (int a, i = 0; i < n; ++i)
		if (cin >> a, a%2 == 0 and not dp[a])
          	cout << "DENIED", exit(0);
  	cout << "APPROVED"; }

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int med3(int x, int y, int z)
{
  if (x < y)
  if (y < z) return y; else if (z < x) return x; else return z; else
  if (z < y) return y; else if (x < z) return x; else return z;
}

void QuickSort(int a[], int left, int right)
{
  if (left < right) {
    int i = left, j = right;
    int tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]);
    while (1) {
      while (a[i] < pivot) 
      i++;
      while (pivot < a[j])
      j--;
      if (i >= j) break;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
      i++;
      j--;
    }
    QuickSort(a, left, i - 1);
    QuickSort(a, j + 1, right);
  }
}

int main (void)
{
  int ar[200000];
  int len;
  scanf("%d", &len);
  for (int i = 0; i < len; i++){
    scanf("%d", &(ar[i]));
  }
  QuickSort(ar, 0, len - 1);
  for(int j = 0; j <= len - 2; j++){
    if (ar[j] == ar[j + 1]){
    puts("NO");
      exit(0);
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < b.length; i++) {
            b[i] = sc.nextInt();
        }
        long hunteredNumber = 0;
        for (int i = 0; i < b.length; i++) {
            long left = Math.min(a[i], b[i]);
            long right = Math.min(a[i + 1], b[i] - left);
            a[i + 1] -= right;
            hunteredNumber += left + right;
        }
        System.out.println(hunteredNumber);
        sc.close();
    }
}

Measured memory_bytes: 65172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
  	ll N;
  	cin >> N;
    ll sum = (N + 1) * N / 2;
  	cout << sum - N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++)cin>>a[i];
  int mx = 0;
  for(int i = 0; n > i; i++){
    if(mx > a[i]){
      cout << "No" << endl;
      return 0;
    }
    mx = max(mx,a[i]-1);
  }
  cout << "Yes" << endl;
    
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100000

typedef struct Ki{
  int p;
  int r;
  int l;
  int h;
}tree;

int n;
tree T[N];

void sibling(int i){
  int j;
  for(j=0;j<n;j++){
    if(T[i].p == -1){
      printf("-1");
      break;
    }
    else if(T[i].p==T[j].p&&i != j){
      printf("%d",j);
      break;
    }
    if(j==n-1)printf("-1");
      
  }
}



int depth(int i){
  int count=0,iNoOya;
  iNoOya=i;
  while(1){
    if(T[iNoOya].p==-1) break;
    iNoOya=T[iNoOya].p;
    count++;
    
  }
  return count;
}

void hantei(int i){
  if( T[i].p == -1)printf("root");
  else if(T[i].p!=-1 && T[i].h==0) printf("leaf");
  else printf("internal node");
  printf("\n");
}

int degree(int i){
  int j,count=0;
  for(j=0;j<n;j++){
    if(T[j].p==i) count++;
  }
  return count;
}

int height(int i){
  int j,left,right,a,b;
  if(T[i].h==-1){
    if(T[i].l==-1 && T[i].r==-1){
      T[i].h=0;
    }
    else{
      
      if(T[i].l!=-1){
	left = T[i].l;
	a = height(left);
      }
      
      else a = 0;
      
      if(T[i].r!=-1){
	right = T[i].r;
	b = height(right);
      }
      else b = 0; 
      
      if(a==b) T[i].h = a+1;
      if(a>b) T[i].h = a+1;
      if(a<b) T[i].h = b+1;
    }
  }
  return T[i].h;
}




int main(){
  int i,id,left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
    T[i].h = -1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].r = right;
    T[right].p = id;
    T[id].l = left;
    T[left].p = id;
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = ",i,T[i].p);
    sibling(i);
    printf(", degree = %d, depth = %d, height = %d, ",degree(i),depth(i),height(i));
    hantei(i);
  }
  return 0;
}
 

    

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t N;
int64_t dp[1000005];
int main(){
  cin>>N;
  dp[0]=1;dp[1]=1;
  int64_t sum=2;
  for(int i=2;i<=N;i++){
   dp[i]=(sum-dp[i-2]+mod)%mod;
    sum=(sum+dp[i])%mod;
  }int64_t ans=(dp[N]+dp[N-1]*(N-1))%mod;
  int64_t n=((N-1)*(N-1))%mod;
  for(int i=0;i<N-1;i++){
  ans=(ans+dp[i]*(n+i+1))%mod;
   }cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll  = long long;
using P = pair<int,int>;
using Pl = pair<ll ,ll >;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll >;
using vll = vector<vl>;
using vs = vector<string>;
const ll dx[] = {0,1,0,-1,1,1,-1,-1};
const ll dy[] = {1,0,-1,0,1,-1,-1,1};
const ll inf = (1<<30)-1;
const ll  infll = (1LL<<62)-1;
ll  ceil(const ll  a, const ll  b){return ((a)+(b)-1)/b;}

ll  n;

ll  dfs(ll m, bool ok) {
  if(m > n) return 0;
  ll res = 0;
  if(!ok) {
    ll copy = m;
    bool a, b, c;
    a = b = c = false;
    while(copy > 0) {
      if(copy%10 == 3) a = true;
      if(copy%10 == 5) b = true;
      if(copy%10 == 7) c = true;
      copy /= 10;
    }
    ok = (a && b && c);
  }
  res += ok;
  res += dfs(m*10+3, ok);
  res += dfs(m*10+5, ok);
  res += dfs(m*10+7, ok);
  return res;
}



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


  cin >> n;
  ll ans = 0;
  ans += dfs(3, false);
  ans += dfs(5, false);
  ans += dfs(7, false);
  cout << ans << endl;
}

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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	string s;	cin >> s;
	ll cnt = 0;

	if( s == "RSR" ){
		cnt = 1;
	}else{
		REP(i, 3){
			if( s[i] == 'R' )	cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int A,B,C,D;

void solve(){
    cout << max(0,min(B,D) - max(A,C)) << endl;
}

int main(){
    cin >> A >> B >> C >> D;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    string s;cin>>s;
    int ss=s.size();
    vvin dp(2,vin(2019));
    rep(i,2019)dp[0][i]=0;
    dp[0][s[0]-'0']++;
    int ans=0;
    rep(i,ss-1){
        int tmp=(i+1)%2;
        dp[tmp][s[i+1]-'0']++;
        rep(j,2019){
            dp[tmp][(10*j+(s[i+1]-'0'))%2019]+=dp[(tmp+1)%2][j];
        }
        ans+=dp[tmp][0];
        rep(i,2019)dp[(tmp+1)%2][i]=0;
    }
    cout<<ans<<endl;
}

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

int main()
{
    long N;
    long count = 0;
    cin >> N;
    for (size_t a = 1; a <= N; a++)
    {
        for (size_t b = 1; b <= N / a; b++)
        {
            if (N - a * b > 0)
            {
                count++;
            }
        }
    }
    cout << count;
}

Measured memory_bytes: 3188
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int x=sc.nextInt();
    int y=sc.nextInt();
    sc.close();
    int fee=0;

    if(n<=k){
      fee=x*n;
    }else{
      fee=x*k+y*(n-k);
    }
    System.out.println(fee);
  }
}

Measured memory_bytes: 21844
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		 while(true){
			 String input = in.readLine();
			 String[] numbers = input.split(" ");
			 Integer a = Integer.parseInt(numbers[0]);
			 Integer b = Integer.parseInt(numbers[1]);
			 if(a.equals(0) && b.equals(0)){
				 break;
			 }
			 if(a > b){
				 System.out.println(b + " " + a);
			 }
			 else{
				 System.out.println(a + " " + b);
			 }
		 }
	}

}

Measured memory_bytes: 24488
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int n,t;
double arr[10005],m,r,sum;
int main() {
	while(scanf("%d",&n)!=EOF&&n!=0)
	{
		sum=0,m=0;
		for(int i =0;i<n;i++)
		{
			cin>>t,m+=t,arr[i]=t; 
		}
		m=m/n;
		for(int i =0;i<n;i++)
		{
			sum+=pow(arr[i]-m,2); 
		}
		printf("%.8lf\n",sqrt(sum/n));
	}
}



Measured memory_bytes: 3228
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int count = 0;
      while (A[i] > 0) {
        if (A[i] % 2 == 0) {
          count++;
          A[i] /= 2;
        } else {
          break;
        }
      }
      list.add(count);
    }
    Collections.sort(list);
    System.out.println(list.get(0));
  }
}

Measured memory_bytes: 22736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String str = br.readLine();
		String[] s = str.split(" ");
		Arrays.sort(s);
		int maxcount=0, maxidx=0;
		for(int i = 0; i< s.length;){
			int dx=1;
			int count=1;
			while(true){
				if(i+dx==s.length)
					break;
				if(s[i].equals(s[i+dx])){
					count++;
					dx++;
				}
				else{
					break;
				}
				
			}
			if(maxcount < count){
				maxcount=count;
				maxidx = i;
			}
			i += dx;
		}
		System.out.print(s[maxidx] + " " );
		int maxlength=0;
		for(int i = 0; i < s.length;i++){
			if(maxlength < s[i].length()){
				maxlength = s[i].length();
				maxidx = i;
			}
		}
		System.out.println(s[maxidx]);
	}

}

Measured memory_bytes: 9128
#include <cstdio>

/* 配列の要素を順番に出力　*/
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 j, i, v;
    for (i=1; i<N; i++){
        v = A[i];
        j = i-1;
        while (j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    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: 2676
N, = map(int, input().split())
A = map(int, input().split())
f = True
for a in A:
    if a % 2:
        continue
    if (a % 3 == 0) or (a % 5 == 0):
        continue
    f = False
if f:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[]v = new double[n];

    for(int i=0; i<n; i++) {
    	v[i] =sc.nextInt();
    	}
    Arrays.sort(v);
    
    double kati = (v[0]+v[1])/2;
    for(int i=2; i<n; i++) {
    	kati = (kati + v[i])/2;
    }     	
    System.out.println(kati);
    }
}



Measured memory_bytes: 35892
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

// a -> 1
// aa -> 1
// aaa -> [a][aa] -> 2
// aaaa -> [a][aa][a] -> 3
// aaaaa -> [aa][a][aa] -> 3

// aabbaa -> [a][ab][b][aa] -> 4
//           [aa][b][ba][a] -> 4
// aabba -> [a][ab][b][a] -> 4
// abababa -> [a][b][a][b][a][b][a] -> 7
// abc -> [a][b][c] -> 3

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int out = 1;

    for(int sl = 1; sl <= 2; ++sl) {
        if(sl > n)
            continue;

        int cur = 1;
        string prev = s.substr(0, sl);
        for(int i = sl; i < n; ) {
            int len = 1;
            while(prev == s.substr(i, len) && i + len < n)
                ++len;

            string next = s.substr(i, len);
            if(next == prev)
                break;
            ++cur;
            out = max(out, cur);
            prev = next;
            i += len;
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int x;
		cin >> x;
		cout << !x << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n, x; cin >> n >> x;
    if(x == 2 * n - 1 || x == 1){
        cout << "No" << endl;
        return 0;
    }

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

    cout << "Yes" << endl;
    vector<int> a(2 * n - 1);
    vector<bool> used(2 * n);
    a[n - 1] = x;
    a[n - 2] = x - 1;
    a[n] = x + 1;
    used[a[n - 1]] = true, used[a[n]] = true, used[a[n - 2]] = true;
    if(x <= n)a[n - 3] = x + 2, used[x + 2]  = true;
    else a[n + 1] = x - 2, used[x - 2] = true;

    vector<int> num;
    for(int i = 1; i <= 2 * n - 1; i++) {
        if(used[i])continue;
        num.push_back(i);
    }
    for(int i = 0; i < 2 * n - 1; i++) {
        if(a[i])continue;
        a[i] = num.back();
        num.pop_back();
    }
    for(auto i : a)cout << i << endl;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>

char s[200001];

int main(void) {
    scanf("%s", s);
    int n = strlen(s);
    int b = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            b++;
        } else {
            ans += b;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
from fractions import gcd
t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    if b > d:
        print("No")
    elif a < b:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        if c < b-gcd(b, d)+ a%gcd(b, d):
            print("No")
        else:
            print("Yes")


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int avg = 0;
    rep(i, n){
        cin >> x[i];
        avg += x[i];
    }
    avg /= n;
    int best = 1000000000;
    for (int i = -1; i <= 1; i++){
        int dist = 0;
        rep(j, n){
            dist += pow(avg+i - x[j], 2);
        }
        if (dist < best) best = dist;
    }
    cout << best << endl;
    return 0;
}

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

int main(){
        int N,M,i,max=0;string s;
        map<string, int> mp;
        cin>>N;
        for(i=0;i<N;i++){
                cin>>s;
                mp[s]++;
        }
        cin>>M;
        for(i=0;i<M;i++){
                cin>>s;
                mp[s]--;
        }
        for(auto itr=mp.begin(); itr!=mp.end(); itr++) max=max<itr->second?itr->second:max;
        cout<<max;
}

Measured memory_bytes: 256
n = int(input())
a = list()
x = []
y = []
for i in range(n):
    A = int(input())
    a.append(A)
    x_ = []
    y_ = []
    for j in range(A):
        X,Y = map(int,input().split())
        x_.append(X)
        y_.append(Y)
    x.append(x_)
    y.append(y_)
mat = [0 for i in range(2**n)]
for i in range(2**n): #一つの可能性
    flag = True
    binary = format(i,"b")
    binary = (n-len(binary))*"0"+binary
    for j in range(n):#一人一人について正直者か見る
        if flag and  len(binary) > j and binary[j] =="1":
            for k in range(a[j]):#一人の証言について順に見ていく
                if flag and len(binary) > x[j][k]-1 and binary[x[j][k]-1] != str(y[j][k]):
                    flag = False
                    break
    if flag:
        mat[i] = 1
ans = 0
for i in range(2**n):
    if mat[i] == 1:
        binary =format(i,"b")
        count = 0
        for j in range(len(binary)):
            count += int(binary[j])
        ans = max(ans,count)
print(ans)

Measured memory_bytes: 3572
from bisect import *

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

r = [10**10] * N
index = -1
for i in range(N):
    j = bisect_right(r, -A[i])
    r[j] = -A[i]
    if j > index:
        index = j
print(index + 1)


Measured memory_bytes: 11036
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint cal(lint x,lint y){
	if(y%x==0) return x*(y/x*2-1);
	return cal(y%x,x)+x*2*(y/x);
}
int main()
{
	lint n,x;
	cin>>n>>x;
	if(x*2==n) cout<<x*3<<endl;
	else cout<<n+cal(min(x,n-x),max(x,n-x))<<endl;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {


			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var inputInfo = new List<Tuple<long, long>>();
			for (int i = 0; i < N; i++) {
				var input = retreiveLongArray();
				inputInfo.Add(new Tuple<long,long>(input[0],input[1]));
			}

			double sumDistance = 0;

			// i→jルートは何回使われるか=(N-1)!回　よってすべてのルートを計算して(N-1)!回かけてN!で割る
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					if (i==j) {
						continue;
					}
					var x = (inputInfo[i].Item1 - inputInfo[j].Item1);
					var y = (inputInfo[i].Item2 - inputInfo[j].Item2);
					sumDistance += Math.Sqrt(x * x + y * y);
				}

			}

			//答えの出力
			var ans = sumDistance/N;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 11348
def calc_formula(formula_list: list):
    operator = formula_list.pop()
    if formula_list[-1] in ['+', '-', '*']:
        back = calc_formula(formula_list)
    else:
        back = int(formula_list.pop())

    if formula_list[-1] in ['+', '-', '*']:
        front = calc_formula(formula_list)
    else:
        front = int(formula_list.pop())
    
    if operator == '+':
        return front + back

    if operator == '-':
        return front - back

    if operator == '*':
        return front * back

formula = input().split(' ')

res = calc_formula(formula)
print(res)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int x;
    cin >> x;
    int n = 100;
    int i = 0;
    while(1) {
        n += n / 100;
        i++;
        if(n >= x) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
package main
import "fmt"

func main() {
	var n int
	var s, t string
	fmt.Scan(&n)
	fmt.Scan(&s, &t)

	final := ""
	for i := 0; i < n; i++ {
		final = final + s[i:i+1]
		final = final + t[i:i+1]
	}
	fmt.Println(final)
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final String T = sc.next();

        s += s;
        
        out.println(s.contains(T) ? "Yes" : "No");
        
        out.flush();
    }
}

Measured memory_bytes: 23252
#include <algorithm>
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };

int main() {
    int n;
    cin >> n;
    ll dp[100100][3];
    vi a(n);
    vi b(n);
    vi c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i, n - 1) {
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1];
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1];
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

Measured memory_bytes: 3712
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    N, L = input_int_list()
    S = []
    for _ in range(N):
        S.append(input())
    S = sorted(S)
    print("".join(S))

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;
  int t=1;
  while(t*(t+1)/2<x) t++;
  cout << t << endl;
  return 0;
}


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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[][] arr = new int[n][2];
        for (int i=0; i<n; i++) {
            String[] s = br.readLine().split(" ");
            arr[i][0] = Integer.parseInt(s[0]);
            arr[i][1] = Integer.parseInt(s[1]);
        }

        int[] z = new int[n];
        for (int i=0; i<n; i++) z[i] = arr[i][0] + arr[i][1];
        int[] w = new int[n];
        for (int i=0; i<n; i++) w[i] = arr[i][0] - arr[i][1];

        Arrays.sort(z);
        Arrays.sort(w);

        System.out.print(Math.max(z[n-1]-z[0], w[n-1]-w[0]));
    }
}



Measured memory_bytes: 55912
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = [0] * (N-K+1)
#連続するK本のろうそくの選び方はN-K+1回だから計算量はo(N)
for i in range(N-K+1):
    xr = x[i+K-1]
    xl = x[i]
    lr = abs(xl) + abs(xr-xl)
    rl = abs(xr) + abs(xr-xl)
    ans[i] = min(lr,rl)
a = min(ans)
print(a)

Measured memory_bytes: 14380
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    string s; cin >> s;
    int Q; cin >> Q;

    deque<char> ans;
    for (auto v : s) ans.push_back(v);

    bool f = true;
    rep(i, Q) {
        int a, b;
        char c;

        cin >> a;
        if (a == 1) {
            f = !f;
        } else {
            cin >> b >> c;
            if (b == 1) {
                if (f) {
                    ans.push_front(c);
                } else {
                    ans.push_back(c);
                }
            } else {
                if (f) {
                    ans.push_back(c);
                } else {
                    ans.push_front(c);
                }
            }
        }
    }

    if (!f) {
        reverse(all(ans));
    }

    for (auto iter = ans.begin(); iter != ans.end(); iter++) {
        cout << *iter;
    }
    cout << endl;
}


Measured memory_bytes: 976
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		tsec, _ := strconv.Atoi(line)
		sec, remain := tsec%60, tsec/60
		min, remain2 := remain%60, remain/60
		hour := remain2 % 24
		fmt.Printf("%v:%v:%v\n", hour, min, sec)
	}

	if err := scanner.Err(); err != nil {
		// log.Println(err)
		return
	}
}



Measured memory_bytes: 1096