akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
int main() {
    int N;
    cin >> N;
    vector<long> v1;
    vector<long> v2;
    for(int i = 0; i < N+1; i++){
        int a;
        cin >> a;
        v1.push_back(a);
    }
    for(int j = 0; j < N; j++){
        int b;
        cin >> b;
        v2.push_back(b);
    }
     long count = 0;
    for(int k = 0; k < N; k++){
        if(v2[k]==0) continue;
        if(v1[k]-v2[k] >= 0){
            count += v2[k];
            continue;
        }
        if((v1[k]+v1[k+1]) >=v2[k]){
            count += v2[k];
            v1[k+1] -= (v2[k]-v1[k]);
            continue;
        }
        count += v1[k]+v1[k+1];
        v1[k+1] = 0;
    }
    cout << count << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if ( N == 1 ) {
    cout << "Hello World" << endl;
  }
  if ( N == 2 ) {
    int A,B;
    cin >> A >> B ;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
s = input()

num_A = 0
num_Z = 0

for i in range(len(s)):
    if s[i] == "A":
        num_A = i
        break

for i in range(len(s)-1, -1, -1):
    if s[i] == "Z":
        num_Z = i
        break

print(num_Z - num_A + 1)

Measured memory_bytes: 3516
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 
 
 int main()
 {
   int n,m;
   int d[200002];
   int t[200002];
   while(cin>>n)
   {
     for(int i=0;i<n;i++) cin>>d[i];
     cin>>m;
     for(int i=0;i<m;i++) cin>>t[i];
     if(m>n) cout<<"NO"<<endl;
     else
     {
       sort(d,d+n);
       sort(t,t+m);
       int cnt=0;
       int i=0;
       while(i<n&&cnt<m)
       {
         if(d[i]==t[cnt])
         {
           i++;
           cnt++;                  
         }       
         else
         {
           i++;    
         }   
       }    
       if(cnt==m) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
     }    
   }
   return 0;
 }
 

Measured memory_bytes: 1792
#include <iostream>
#include <cstdint>

int64_t mat[500][500];
int64_t area[500][500];

int main() {
	int H, h, W, w;
	std::cin >> H >> W >> h >> w;

	if ((H % h == 0 && W % w == 0) || (H == h && W == w)) {
		std::cout << "No" << std::endl;
		return 0;
	}
	std::cout << "Yes" << std::endl;

	const int64_t C = 999999999 / (h*w - 1);

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if ((i + 1) % h == 0 && (j + 1) % w == 0)
				mat[i][j] = -C * (h*w - 1) - 1;
			else
				mat[i][j] = C;
		}
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			std::cout << mat[i][j] << ' ';
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] cs;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        int score = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == 'p') {
                score--;
            } else {
                score++;
            }
        }
        System.out.println(score / 2);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main()
{
    string s;
    cin>>s;
    long long sum=0;
    for(int i=0; i<s.size(); i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)cout<<"Yes";
                        else cout<<"No";
    return 0;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<int> b(n + 1);
  int a = 0, na;
  rep(i, n) {
    cin >> na;
    b[i] = na - a;
    a = na;
  }
  b[n] = 0 - a;
  int sum = 0;
  rep(i, n + 1) sum += abs(b[i]);
  vector<int> c(n, sum);
  rep(i, n + 1) if(b[i + 1] * b[i] <= 0) c[i] -=
    2 * min(abs(b[i + 1]), abs(b[i]));
  rep(i, n) cout << c[i] << endl;

  return 0;
}

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

#ifdef DEBUG
#define LOG(...) fprintf(stderr, __VA_ARGS__)
#else
#define LOG(...) 
#endif // DEBUG

struct convert_list
{
    char from;
    char to;
    struct convert_list *next;
};
typedef struct convert_list CONVERT_LIST;


CONVERT_LIST* insert_list(CONVERT_LIST *list, char from, char to);
char search_list(CONVERT_LIST *head, char target);
void delete_list(CONVERT_LIST *list);

int main(void)
{
    
    while (1) {
        int num, convert_num;
        char from, to, target;
        int i;
        CONVERT_LIST *list_head;
        
        scanf("%d\n", &num);
        LOG("num = %d\n", num);

        if (num == 0) {
            break;
        }
        
        /* Make convert table */
        for (i = 0; i < num; i++) {
            scanf("%c %c\n", &from, &to);
            LOG("from = %c, to = %c\n", from, to);
            list_head = insert_list(list_head, from, to);
        }

        /* Convert */
        scanf("%d\n", &convert_num);
        LOG("convert_num = %d\n", convert_num);
        for (i = 0; i < convert_num; i++) {
            scanf("%c\n", &target);
            LOG("target = %c\n", target);

            printf("%c", search_list(list_head, target));
        }
        printf("\n");

        delete_list(list_head);
        list_head = NULL;
        
    }
    
    return 0;
}

CONVERT_LIST* insert_list(CONVERT_LIST *list, char from, char to) 
{
    CONVERT_LIST *head, *tail, *new_node;
    head = tail = list;

    if (tail != NULL) {
        for ( ; tail->next != NULL ; tail = tail->next) {
            /* NOP */
        }
    }
        
    new_node = (CONVERT_LIST*)malloc(sizeof(CONVERT_LIST));
    if (new_node == NULL) {
        /* malloc failed */
        return NULL;
    }

    memset(new_node, '\0', sizeof(CONVERT_LIST));
    new_node->from = from;
    new_node->to = to;
    new_node->next = NULL;

    if (tail != NULL) {
        tail->next = new_node;
    }
    else {
        head = new_node;
    }

    return head;

}

char search_list(CONVERT_LIST *head, char target) 
{
    CONVERT_LIST *tmp;
    tmp = head;
    if (head == NULL) {
        return target;
    }

    for ( ; tmp != NULL ; tmp = tmp->next) {
        if (tmp->from == target) {
            return tmp->to;
        }
    }

    return target;
    
}

void delete_list(CONVERT_LIST *list)
{
    CONVERT_LIST *tmp;
    tmp = list;
    if (list == NULL) {
        return ;
    }

    for ( ; list != NULL ; list = tmp) {
        tmp = list->next;
        free(list);
    }

    return ;


}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];

int main()
{
    ll N;
    cin >> N;
    ll max = 0;
    ll n = 0;
    REP(i, N)
    {
        cin >> A[i];
        max = std::max(max, A[i]);
    }

    ll sm = 0;
    REP(i, N)
    {
        if (A[i] == max)
            n++;
        else
            sm = std::max(sm, A[i]);
    }

    REP(i, N)
    {
        if (A[i] != max)
            cout << max << endl;
        else
        {
            if (n == 1)
                cout << sm << endl;
            else
                cout << max << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <unordered_map>


using namespace std;
using vi = vector<int>;
using vvi = vector <vi>;
using graph = vvi;


graph read_graph(int n_nodes, int n_edges, int off_set){
    graph g(n_nodes, vi());
    for (int i = 0; i != n_edges; ++i){
        int a, b;
        cin >> a >> b;
        g[a - off_set].push_back(b - off_set);
        g[b - off_set].push_back(a - off_set);
    }
    return g;
}

vi find_groups(graph g){
    int n_nodes = g.size();
    vi groups(n_nodes, 0);
    for (int i = 0; i != n_nodes; ++i) groups[i] = i;
    for (int v = 0; v != n_nodes; ++v){
        if (groups[v] != v) continue;
        vi stk(g[v]);
        while (not stk.empty()){
            int u = stk.back();
            stk.pop_back();
            groups[u] = v;
            for (auto w : g[u]){
                if (groups[w] != v) stk.push_back(w);
            }
        }
    }
    return groups;
}

int main() {
    ios::sync_with_stdio(false);
    int N, K, L;
    cin >> N >> K >> L;
    auto bus_routes = read_graph(N, K, 1);
    auto train_routes = read_graph(N, L, 1);
    auto bus_groups = find_groups(bus_routes);
    auto train_groups = find_groups(train_routes);
    vector<unordered_map<int, int>> counter(N);
    for (int v = 0; v != N; ++v){
        counter[bus_groups[v]][train_groups[v]] += 1;
    }
    for (int v = 0; v != N; ++v){
        cout << counter[bus_groups[v]][train_groups[v]] << (v == N - 1 ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 37532
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
inline ll read()
{
	ll x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 1000
#define MM 2000
struct edge{int x,y,w;}e[MM+5];
bool cmp(const edge&a,const edge&b){return a.w<b.w;}
int f[MN+5];mint ans;
int gf(int k){return f[k]?f[k]=gf(f[k]):k;}
int main()
{
	int n,m,i,j,s1=0,s2=1;ll s,x;
	n=read();m=read();x=read();
	for(i=1;i<=m;++i)e[i].x=read(),e[i].y=read(),e[i].w=read();
	sort(e+1,e+m+1,cmp);
	for(i=2;i<=m;++i)
	{
		memset(f,s=0,sizeof(f));
		if(gf(e[i].x)!=gf(e[i].y))f[gf(e[i].x)]=gf(e[i].y),s+=e[i].w;
		for(j=1;j<=m;++j)if(gf(e[j].x)!=gf(e[j].y))f[gf(e[j].x)]=gf(e[j].y),s+=e[j].w;
		if(s==x)++s1;if(s>x)++s2;
	}
	printf("%d",((mint(2)<<s1)-1)*(mint(2)<<s2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, K;
    cin >> N >> K;
    if (K > (N - 1) * (N - 2) / 2)
    {
        putout(-1);
        return 0;
    }
    vector<pair<ll, ll>> edges;
    loop(i, N - 1)
    {
        edges.push_back(make_pair(1, i + 2));
    }
    ll x = ((N - 1) * (N - 2) / 2) - K;
    if (x == 0)
        goto end;
    loop(i, N - 2)
    {
        ll now = i + 2;
        Loop(j, now + 1, N + 1)
        {
            edges.push_back(make_pair(now, j));
            x--;
            if (x == 0)
                goto end;
        }
    }
end:
    ll siz = edges.size();
    putout(siz);
    loop(i, siz)
    {
        cout << edges[i].first << " " << edges[i].second << endl;
    }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
ll n, k;
vector<ll> a;
bool solve(ll mid) {
  ll res = 0;
  rep(i, n) { res += (a[i] + mid - 1) / mid - 1; }
  return res <= k;
}
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> k;
  a = vector<ll>(n);
  rep(i, n) cin >> a[i];

  ll ok = INF;  //解が存在する値 [ok,ng) or (ng,ok]
  ll ng = 0;    // 解が存在しない値

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (solve(mid))
      ok = mid;
    else
      ng = mid;
  }

  cout << ok << endl;
  ret;
}


Measured memory_bytes: 4792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		for (int i=0; i<S.length(); i++) {
			char c = S.charAt(i);
			int cnt = 0;
			for (int j=0; j<S.length(); j++) {
				if (c == S.charAt(j)){
					cnt++;
				}
			}
			if (cnt != 2) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}


}

Measured memory_bytes: 21972
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
ans = 11
for i in range(1,int(math.sqrt(N))+1):
  if N%i==0:
    ans = len(str(N//i))

print(ans)

Measured memory_bytes: 39408
#include<cstdio>
char maze[2005][2005];
int sum1[2005][2005];
int sum2[2005][2005];
int pre1[2005][2005],pre2[2005][2005];
bool vis[2005][2005];
void dfs(int x,int y){
  if(vis[x][y])return;
  if(maze[x][y]!='1')return;
  vis[x][y]=true;
  dfs(x+1,y);dfs(x-1,y);dfs(x,y+1);dfs(x,y-1);
}
int main(){
  int n,m,q;scanf("%d%d%d",&n,&m,&q);
  for(int i=1;i<=n;++i)scanf("%s",maze[i]+1);
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
      if(maze[i][j]=='1')sum1[i][j]=1;
      if(maze[i][j]=='1'&&maze[i][j+1]=='1')sum2[i][j]++;
      if(maze[i][j]=='1'&&maze[i+1][j]=='1')sum2[i][j]++;
    }
  }
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
      sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1]+sum1[i][j];
      sum2[i][j]=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1]+sum2[i][j];
    }
  }
  for(int i=1;i<n;++i){
    for(int j=1;j<=m;++j){
      if(maze[i][j]=='1'&&maze[i+1][j]=='1')pre1[i][j]=1;
    }
    for(int j=1;j<=m;++j)pre1[i][j]+=pre1[i][j-1];
  }
  for(int j=1;j<m;++j){
    for(int i=1;i<=n;++i){
      if(maze[i][j]=='1'&&maze[i][j+1]=='1')pre2[i][j]=1;
    }
    for(int i=1;i<=n;++i)pre2[i][j]+=pre2[i-1][j];
  }
  int cnt=0;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
      if(maze[i][j]=='1'&&!vis[i][j])dfs(i,j),cnt++;
    }
  }
  int x1,y1,x2,y2;
  for(int i=1;i<=q;++i){
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

    printf("%d\n",(pre1[x2][y2]-pre1[x2][y1-1])+(pre2[x2][y2]-pre2[x1-1][y2])+(sum1[x2][y2]-sum1[x2][y1-1]-sum1[x1-1][y2]+sum1[x1-1][y1-1])-(sum2[x2][y2]-sum2[x2][y1-1]-sum2[x1-1][y2]+sum2[x1-1][y1-1]));
  }
  return 0;
}


Measured memory_bytes: 72960
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Measured memory_bytes: 13928
#include <stdio.h>

main()
{
	int money = 100000;
	int n;
	float a = 0.05;
	
	scanf("%d", &n);
	
	while (n != 0){
		money += money * a;
		if ((money % 1000) != 0){
			money -= money % 1000;
			money += 1000;
		}
		n--;
	}
	
	printf("%d\n", money);
	
	return (0);
}

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

int main() {
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; ++i){
        if(i*2 + ((x-i)*4) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int gcd(int a, int b) {
   int r;
   while((r = a % b) != 0)
   {
       a = b;
       b = r;
   }
   return b;
}

int main(void){
   int a, b, tmp;
   if (a < b){
       tmp = b;
b = a;
a = tmp;

   }
   while(cin >> a >> b) {
     int lcm = b/gcd(a,b)*a;
     cout << gcd(a,b) << " " << lcm << endl;
   }
   return 0;
}




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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int a=read(),b=read(),c=read()*2,x=read(),y=read();
	cout<<min({a*x+b*y,a*(x-min(x,y))+b*(y-min(x,y))+c*min(x,y),c*max(x,y)})<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;
int main(){
  string s;
  cin >> s;
  REP(i,s.size()){
    if(s[i]==','){
      s[i] = ' ';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n, l = map(int, input().split())
a = [0] * n
i = 0
s = 0
while i < n:
    a[i] = l + i  # a = azi
    s += a[i]  # s = sum
    i += 1
f = 1e9
ans = 0
i = 0
while i < n:
    if f > abs(a[i]):
        f = abs(a[i])
        ans = s - a[i]
    i += 1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int x;
    cin >> n >> x;
    if (x%1000>0)
    {
        cout << -1 <<' '<<-1<<' '<<-1;
        return 0;
    }
    x/=1000;
    int p1 = x;
    int p2 = 0;
    int p3 = 0;
    while(x>n &&p1>4&&x-4>=n)
    {
        x-=4;
        p1-=5;
        p2++;
    }
    while(x>n&&p2>1)
    {
        x--;
        p2-=2;
        p3++;
    }
       // cout << p3 <<' '<<p2<<' '<<p1;
    if (x!=n)
    {
        cout << -1 <<' '<<-1<<' '<<-1;
        return 0;
    }
    else
        cout << p3 <<' '<<p2<<' '<<p1;

}


Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(int, input().split()))
available = [i for i in range(10) if i not in D]

values = [0]
idx = 0
while True:
  base = values[idx] * 10
  for a in available:
    n = base + a
    if n >= N:
      print(n)
      quit()
    values.append(n)
  idx += 1

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

const string G = "GREATER";
const string E = "EQUAL";
const string L = "LESS";

int main() {
  
  string a,b;cin>>a>>b;
  string ans;
  if (a.size() > b.size()) {
    ans = G;
  } else if (a.size() < b.size()) {
    ans = L;
  } else {
    if (a > b) {
      ans = G;
    } else if (a < b) {
      ans = L;
    } else {
      ans = E;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

void printa(int *,int);

int main(){
  int a[N],i,j,v,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<n;i++){
    printa(a,n);
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
  }
  printa(a,n);
  return 0;
}

void printa(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    reverse(all(A));
    reverse(all(B));
    ll sum = 0;
    rep(i,N){
        A[i] += sum;
        if(A[i] % B[i]){
            if(A[i] < B[i]) sum += B[i] - A[i];
            if(A[i] > B[i]) sum += B[i] - (A[i] % B[i]);
        } 
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#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 vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>>pll(n);
  for(auto &a:pll)cin>>a.F>>a.S;
  vector<pair<ll,ll>>pll2(m);
  for(auto &a:pll2)cin>>a.F>>a.S;
  for(int i=0;i<n;i++){
    ll po = -1,num = llINF;
    for(int j=0;j<m;j++){
      ll dist = abs(pll[i].F-pll2[j].F)+abs(pll[i].S-pll2[j].S);
      if(dist < num){
	po = j+1;num = dist;
      }
    }
    cout<<po<<endl;
  }
  return 0;
}


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

int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  ll ans=0;
  if (X==D && K%2==0) ans = X;
  else if (X==D && K%2==1) ans = 0;
  else {
    ll wari = X/D;
    ll hiki = K-wari;
    if (hiki<=0) ans = X-K*D;
    else if (hiki%2==0) ans = X-wari*D;
    else ans = X-wari*D-D;
  }
  cout << abs(ans);
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
  #include<algorithm>
  #include<vector>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define float double
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define pb push_back
  int32_t main()
  { 
      IOS
      int n;
      cin>>n;
      vector<int> v(n);
      for(int i=0;i<n;i++)
      {
        cin>>v[i];
      }
      sort(v.begin(),v.end());
      double res=(v[0]+v[1])/2.0;
      
      for(int i=2;i<n;i++)
      res=(res+v[i])/2.0;
      cout<<res;
      //printf("%.12lf",res);
    
        return 0;
  }

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m=sc.nextInt();
        int d=sc.nextInt();
        String f[]=new String[n];
        String field[][]=new String[n][m];
        for (int i=0;i<n;++i) {f[i]=sc.next();}
        for (int i=0;i<n;++i)
        {
            for (int j=0;j<m;++j)
            {
                field[i][j]=f[i].substring(j,j+1);
            }
        }

        int ans=0;
        for (int i=0;i<n;++i)
        {
            int count=0;
            for (int j=0;j<m;++j)
            {
                if (field[i][j].equals("#")) { count=0;}
                else
                {
                    ++count;
                    if (d<=count) {++ans;}
                }
            }
        }

        for (int i=0;i<m;++i)
        {
            int count=0;
            for (int j=0;j<n;++j)
            {
                if (field[j][i].equals("#")) { count=0;}
                else
                {
                    ++count;
                    if (d<=count) {++ans;}
                }
            }
        }

        System.out.println(ans);
    }
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	string s;
	cin >> s;
	
	int n = s.size();
	vector<int> bc(n + 1, 0);
	for(int i = 1; i < n + 1; ++i){
		bc[i] = bc[i-1] + (s[i-1] == 'B' ? 1 : 0);
	}
	
	ll ans = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'W'){
			ans += bc[i+1];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
char cs[4010];
int as[4010], us[2010], vs[2010];
int memoW[4010][2010], memoB[4010][2010];
int dp[2010][2010];

int rec(int a, int b){
    if(a == N && b == N){
        return 0;
    }

    if(dp[a][b] != -1){
        return dp[a][b];
    }

    int res = 2001001001;
    
    if(a < N){
        int p = us[a + 1];
        res = min(res, p - memoW[p][a] - memoB[p][b] + rec(a + 1, b));
    }

    if(b < N){
        int p = vs[b + 1];
        res = min(res, p - memoW[p][a] - memoB[p][b] + rec(a, b + 1));     
    }

    return dp[a][b] = res;
}

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

    std::cin >> N;

    for(int i=0;i<2*N;++i){
        std::cin >> cs[i] >> as[i];
        if(cs[i] == 'W'){
            us[as[i]] = i;
        }else{
            vs[as[i]] = i;
        }
    }

    // White
    for(int i=0;i<2*N;++i){
        if(cs[i] == 'W'){
            int a = as[i];
            for(int j=1;j<a;++j){
                memoW[i][j] = (i > 0 ? memoW[i-1][j] : 0);
            }
            
            for(int j=a;j<=N;++j){
                memoW[i][j] = (i > 0 ? memoW[i-1][j] : 0) + 1;
            }
        }else{
            for(int j=1;j<=N;++j){
                memoW[i][j] = (i > 0 ? memoW[i-1][j] : 0);
            }
        }
    }

    // for(int i=0;i<2*N;++i){
    //     for(int j=1;j<=N;++j){
    //         std::cout << memoW[i][j] << " \n"[j==N];
    //     }
    // }
    

    // Black
    for(int i=0;i<2*N;++i){
        if(cs[i] == 'B'){
            int a = as[i];
            for(int j=1;j<a;++j){
                memoB[i][j] = (i > 0 ? memoB[i-1][j] : 0);
            }
            
            for(int j=a;j<=N;++j){
                memoB[i][j] = (i > 0 ? memoB[i-1][j] : 0) + 1;
            }
        }else{
            for(int j=1;j<=N;++j){
                memoB[i][j] = (i > 0 ? memoB[i-1][j] : 0);
            }
        }
    }

    // for(int i=0;i<2*N;++i){
    //     for(int j=1;j<=N;++j){
    //         std::cout << memoB[i][j] << " \n"[j==N];
    //     }
    // }
    
    memset(dp, -1, sizeof(dp));
    int res = rec(0, 0);
    std::cout << res << std::endl;
}


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

int main(){
  	string S; 
  	int N;
  	cin >> S;
  	N = S.size();
  	int a[26] = {0};
  	for (int i = 0; i < N; i++){
      	char p = S[i];
      	a[p - 'a']++;
    }
  	bool flag = false;
  	for (int i = 0; i < 26; i++){
      	if(a[i] == 0) {
          	cout << (char)(i + 'a') << endl;
          	flag = true;
          	break;
        }
    }
  	if (flag == false) cout << "None" << endl;
}


Measured memory_bytes: 512
//
// Created by RAJ SHAH on 18-08-2020.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0,c=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
            c+=1;
        else
            c=0;
        ans=max(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std ;
int main () {
  long long x ;
  cin >> x ;
  for (int i = -1000 ; i <= 1000 ; ++i) {
    for (int j = -1000 ; j <= 1000 ; ++j) {
      long long a = 1LL*i*i*i*i*i ;
      long long b = 1LL*j*j*j*j*j ;
      if (a - b == x) {
        cout << i << " " << j ;
        return 0 ;
      }
    }
  }
}


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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

	int x[5];
	for (int i = 0; i < 5; ++i) {
		cin >> x[i];
		if (x[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
ll n, a, b, c, d, ab;
int main(){
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	if(a > b) swap(a, b); n--; ab = b - a;
	for(int i = 0; i <= n; i ++){
		ll me = c * i, mf = d * i, ee = c * (n - i), ef = d * (n - i);
		ll mn = ee - mf, mx = ef - me;
		if(mn <= ab && ab <= mx){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, m, p;
	cin >> n >> m >> p;
	vector<tiii> g;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g.emplace_back(a, b, -(c - p));
	}

	vector<ll> d(n, LLONG_MAX);
	d[0] = 0;
	for (int i = 0; i < 2 * n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int a, b, c;
			a = get<0>(g[j]);
			b = get<1>(g[j]);
			c = get<2>(g[j]);
			if (d[a] < LLONG_MAX)
			{
				if (d[b] > d[a] + c)
				{
					if (i < n - 1)
					{
						d[b] = d[a] + c;
					}
					else
						d[b] = -inf;
				}

			}
		}
	}
	if (d[n - 1] <= -inf)
		cout << -1;
	else if (d[n - 1] >= 0)
		cout << 0;
	else
		cout << -d[n - 1];

		
	return 0;
}

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

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

int main() {
    int N, X; cin >> N >> X;
    vector<int> L(N, 0); rep(i, N) cin >> L[i];
    int cnt = 1, dis = 0;
    rep(i, N){
        dis += L[i];
        if(dis > X) break;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll solve(ll a) {
    return (a & 1 ? ((a + 1) >> 1) & 1 : ((a >> 1) & 1) | a);
}

int main() {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", solve(a - 1) ^ solve(b));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, x=0;

 cin >> N;

 int a[N]={0};

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

 for(int i=0;i<N;i++){
     x=a[x]-1;
    // cout << x << endl;
     if(x==1){
         cout<< i+1 <<endl;
         break;
     }
     else if(i>=N-1){
         cout << -1 << endl;
         break;
        }
 }

}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	REP(i, s.size()) {
		if (s.substr(i, n - i) + s.substr(0, i) == t) {
			cout << "Yes" << endl;

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

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

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            List<int> A = new List<int>();
            List<int> B = new List<int>();
            for(int i = 0; i < N; i++)
            {
                line = Console.ReadLine();
                string[] strs = line.Split(' ');
                A.Add(int.Parse(strs[0]));
                B.Add(int.Parse(strs[1]));
            }
            A.Sort();
            B = B.OrderByDescending(x => x).ToList();
            if (N % 2 == 0)
            {
                // Nが偶数 -> 中央が定まらない -> 2分の1単位で数える
                // N / 2 と N / 2 + 1の間？
                double MAX = (B[N / 2 - 1] + B[N / 2]);
                double MIN = (A[N / 2 - 1] + A[N / 2]);
                Console.WriteLine((MAX - MIN + 1));
            }
            else
            {
                // Nが奇数 -> 中央が定まる
                int MAX = B[N / 2];
                int MIN = A[N / 2];
                Console.WriteLine(MAX - MIN + 1);
            }
        }
    }
}


Measured memory_bytes: 46356
n,k = map(int,input().split())
a = list(map(int,input().split()))
arr = [0 for _ in range(n+1)]

for i in range(n):
    if arr[a[i]] == 0:
        arr[a[i]] = 1
    else:
        arr[a[i]] += 1

tmp = sorted(arr)[n-k+1:n+1]
print(n-sum(tmp))

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


int main() {
  ll N,K,R,S,P;
  string tt;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> tt;
  vector< ll > T(100005,0);
  REP(i,N) {
    ll ten;
    if ( tt[i] == 'r' )
      ten = P;
    else if ( tt[i] == 's' )
      ten = R;
    else
      ten = S;
    T[i] = ten;
  }
  ll ans = 0;
  REP(i,N) {
    if( (i >= K) && (tt[i-K] == tt[i]) ) {
      tt[i] = 'a';
      T[i] = 0;
    }
    ans += T[i];
//  cout << T[i][j] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>

bool isPrime(int num){
	if(num<2){
		return false;
	}
	for(int i{2};i*i<=num;++i){
		if(num%i==0){
			return false;
		}
	}
	return true;
}

int main(){
	const int MAX_NUM{1000000};
	int NUM{0};
	std::vector<bool> vPrime(MAX_NUM,false);
	for(int i{0};i<MAX_NUM;++i){
		vPrime[i]=isPrime(i);
	}

	while(std::cin >> NUM){
		int cntPrime{0};
		for(int i=0;i<=NUM;++i){
			if(vPrime[i]){
				++cntPrime;
			}
		}
		std::cout << cntPrime << std::endl;
		}
	return 0;
}

Measured memory_bytes: 1316
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w, k;
vector<vector<char>> c;

void solve() {
	cin >> h >> w >> k;
    c.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1<<h); ++ bit) {
        for(int bit1 = 0; bit1 < (1<<w); ++ bit1) {
            auto d = c;
            rep(i, h) {
                if(bit & (1<<i)) {
                    rep(j, w) {
                        d[i][j] = '?';
                    }
                }
            }
            rep(i, w) {
                if(bit1 & (1<<i)) {
                    rep(j, h) {
                        d[j][i] = '?';
                    }
                }
            }
            int cnt = 0;
            rep(i, h) {
                rep(j, w) {
                    if(d[i][j] == '#') {
                        ++ cnt;
                    }
                }
            }
            if(cnt == k) ++ ans;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#define INF 1e9
using namespace std;
int main(void) {
	int n, z, w; cin >> n >> z >> w;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	if (n >= 2) {
		cout << max(abs(a[n - 1] - a[n - 2]), abs(a[n - 1] - w)) << endl;
	}
	else {
		cout << abs(a[n - 1] - w);
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
d = readlines.map(&:split)

def zorome?(array)
  if array[0] == array[1]
    true
  else
    false
  end
end

count = 0
result = nil

d.each do |i|
  if zorome?(i)
    count += 1
  else
    count = 0
  end
  if count == 3
    result = true
  end
end

if result == true
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14388
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>h(n);
  rep(i,n)cin>>h.at(i);
  vector<int>a(m),b(m);
  rep(i,m) cin>>a.at(i)>>b.at(i);
  rep(i,m) a.at(i)--;
  rep(i,m) b.at(i)--;
//  rep(i,m) cout<<a.at(i)<<b.at(i)<<endl;
  vector<int>check(n);
  for(int i=0;i<m;i++){
    if(h.at(a.at(i)) > h.at(b.at(i)) ){
      check.at(b.at(i)) = 1;
    }
    else if(h.at(a.at(i)) < h.at(b.at(i)) ) {
      check.at(a.at(i)) = 1;
    }
    else{
      check.at(a.at(i)) = 1;
      check.at(b.at(i)) = 1;
    }
  }
  int count = 0;
  rep(i,n) if(check.at(i)==0)count++;
  cout << count << endl;
}

Measured memory_bytes: 4824
import copy

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
s=copy.deepcopy(l)
l.insert(0,[0,0,0])
for i in range(1,n+1):
    s[i-1][0]=l[i][0]-l[i-1][0]
    s[i-1][1]=l[i][1]-l[i-1][1]
    s[i-1][2]=l[i][2]-l[i-1][2]
    #print(s)
    if s[i-1][0]<abs(s[i-1][1])+abs(s[i-1][2]) or (s[i-1][0])%2!=(abs(s[i-1][1])+abs(s[i-1][2]))%2:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 48100