akhauriyash/Code-Regression huggingface dataset:
a = 5.times.map { gets.to_i }

last_i = 0
min_t = (a[0] % 10) == 0 ? 10 : a[0] % 10
a[1..-1].each_with_index do |x, i|
  t = (x % 10) == 0 ? 10 : x % 10
  if t < min_t
    min_t = t
    last_i = i + 1
  end
end

time = 0
a.each_with_index do |x, i|
  if i == last_i
    time += x
  else
    time += ((x / 10.0).ceil * 10).to_i
  end
end

puts time

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

int main(){
	int n, q;
    cin >> n >> q;
    vector<int> g[n+1];
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
    }
    int cntr[n+1] = {0};
    for(int i = 0; i < q; i++){
        int v, c;
        cin >> v >> c;
        // cout << v << " " << c << "\n";
        cntr[v] += c;
    }
    pair<int,int> root = {1, cntr[1]};
    stack<pair<int,int>> s;
    s.push(root);
    while(!s.empty()){
        root = s.top();
        int mycntr = root.second;
        int node = root.first;
        cntr[node] = mycntr;
        s.pop();
        for(int i : g[node]){
            s.push({i, mycntr + cntr[i]});
        }
    }
    for(int i = 1; i <= n; i++){
        cout << cntr[i] << " ";
    }
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m;
    string s;
    in>>n>>m>>s;
    vector<int> v(n+1);
    stack<int> ans;
    ifr(i,n+1){
        if(s[i]-'0') v[i]=v[i+1];
        else v[i]=i;
    }
    int c=n;
    while(c){
        if(c<m){
            ans.emplace(c);
            c=0;
            continue;
        }
        if(c==v[c-m]) return cout<<-1<<endl,0;
        ans.emplace(c-v[c-m]);
        c=v[c-m];
    }
    while(!ans.empty()) cout<<ans.top()<<" ",ans.pop();
    cout<<endl;
}

Measured memory_bytes: 1308
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int h,w ;
	cin >> h >> w ;
	vvc g(h+2,vc(w+2,'.')) ;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin >> g.at(i).at(j) ;
	bool ok = true ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(g.at(i).at(j)=='#'){
				if(g.at(i+1).at(j)=='#'||g.at(i-1).at(j)=='#'||g.at(i).at(j+1)=='#'||g.at(i).at(j-1)=='#'){
					continue ;
				}else{
					ok = false ;
				}
			}
		}
	}
	yorn(ok) ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define PDD pair<double, double>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
double dist(PDD &a, PDD &b){
   double ans =  sqrt((a.F-b.F)*(a.F-b.F) + (a.S-b.S)*(a.S-b.S));
   return ans;
}
int main(){
   int n;
   cin >> n;
   V<PDD> arr(n);
   loop(i,0,n){
      cin >> arr[i].F >> arr[i].S;
   }
   V<int> perm(n);
   loop(i,0,n){
      perm[i] = i;
   }
   double total = 0;
   double cnt = 0;
   do{
      cnt++;
      double tot = 0;
      loop(i,1,n){
         tot+=dist(arr[perm[i-1]],arr[perm[i]]);
      }
      total+=tot;
   }while(next_permutation(all(perm)));
   total/=cnt;
   printf("%.10f",total);
   return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cout.precision(16);

  li N;
  cin >>N;

  vi a(N);
  Input(a);
  li ans =0;
  Rep(i,N){
  	if(a[i]%2&&(i+1)%2)ans++;
  }

  cout<<ans;
}

Measured memory_bytes: 3612
def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, min(l+2019, r+1)):
        for j in range(l+1, min(l+2019, r+1)):
            if i < j:
                tmp = (i * j) % 2019
                #print(tmp)
                if tmp < ans:
                    ans = tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73388
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B;
  cin >> N >> A >> B;
  if (abs(A - B) % 2 == 1)
    cout << "Borys" << '\n';
  else
    cout << "Alice" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
  if(y==0) return x;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y){
  ll n = gcd(x,y);
  return x/n*y;
}

int main()
{
  int N;
  ll t[100];
  ll res=1;
  cin >> N;

  rep(i,N) cin >> t[i];

  rep(i,N){
    res = lcm(res, t[i]);
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define x first
#define y second
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define loopr(i, end, start) for(int i=end; i>=start; --i)
#define pb push_back
#define MOD 1000000007
#define mod(a) (a%MOD + MOD)%MOD
using namespace std;

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main() {   
    IOS;
	int n;
    cin >> n;
    int ans=0;
    loop(a, 1, n-1) {
        loop(b, 1, n-1) {
            if(a*b<n) ++ans;
            else break;
        }
    }
    cout << ans;
    //cerr << " Execution : " << (1.0*clock())/CLOCKS_PER_SEC << "s" << endl;
    return 0;
}

Measured memory_bytes: 3692
n = gets.to_i
s = gets.chomp.split("")

current = 0
see_w = s.map { |c|
  if c == "W"
    output = current
    current += 1
    output
  else
    current
  end
}

current = 0
see_e = s.reverse.map { |c|
  if c == "E"
    output = current
    current += 1
    output
  else
    current
  end
}.reverse

min = n
n.times do |i|
  min = [min, see_w[i] + see_e[i]].min
end
puts min


Measured memory_bytes: 36868
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x->left;
  }
  
  return x;
}

Node treeMaximum(Node x){
  
  while(x->right != NIL){
    x = x->right;
  }
  
  return x;
}

Node treeSearch(Node u, int k){
  
  while(u != NIL){
    if(u->key == k){
      return u;
    }else if(u->key < k){
      u = u->right;
    }else{
      u = u->left;
    }
  }
  
  return NIL;
}

Node treeSuccessor(Node x){//子の数を数える関数
  Node y;
  
  if(x->right != NIL){
    return treeMinimum(x->right);
  }

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  
  return y;
}

void treeDelete(Node z){
  Node y; 
  Node x; 

  if(z->left == NIL || z->right == NIL){
    y = z;//削除する関数にzを代入
  }else{
    y = treeSuccessor(z);
  }

  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y == y->parent->left){
      y->parent->left = x;
    }else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

void inorder(Node u){
  if(u->key == NIL) return;

  if(u->left != NIL){
    inorder(u->left);
  }
  
  printf(" %d",u->key);

  if(u->right != NIL){
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u->key == NIL) return;

  printf(" %d",u->key);

  if(u->left != NIL){
    preorder(u->left);
  }

  if(u->right != NIL){
    preorder(u->right);
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
      }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20480
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#define all(x) (x).begin(),(x).end()

int getDigit(ll num){
    int digit = 0;
    while(num != 0){
        digit++;
        num /= 10;
    }
    return digit;
}

void solve(string num, int d){

    ll sum = 0;
    int t[3] = {0};
    for (int i = 0; i < pow(2,d); i++){
        ll tmp = num[0]-'0';
        int x = i;
        for (int k = 0; k < d; k++){
            t[k] = x % 2;
            x /= 2;
        }
        for (int k = 0; k < d; k++){
            if (t[k] == 0){
                tmp *= 10;
                tmp += num[k+1]-'0';
            } else {
                sum += tmp;
                tmp = num[k+1]-'0';
            }
        }
        sum += tmp;
    }
    cout << sum << endl;
    //return ans;

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

    //solve(s,s.size()-1);
    int d = s.size()-1;
    string num = s;

    ll sum = 0;
    int t[3] = {0};
    for (int i = 0; i < pow(2,d); i++){
        ll tmp = num[0]-'0';
        int x = i;
        for (int k = 0; k < d; k++){
            t[k] = x % 2;
            x /= 2;
        }
        for (int k = 0; k < d; k++){
            if (t[k] == 0){
                tmp *= 10;
                tmp += num[k+1]-'0';
            } else {
                sum += tmp;
                tmp = num[k+1]-'0';
            }
        }
        sum += tmp;
    }
    //return ans;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<vector<ll> > dp(N, vector<ll> (4));
    dp[0][0] = 8;
    dp[0][1] = 1;
    dp[0][2] = 1;
    dp[0][3] = 0;
    for (ll i = 1; i < N; i++){
        dp[i][0] = (dp[i][0] + dp[i - 1][0] * 8) % 1000000007;
        dp[i][1] = (dp[i][1] + dp[i - 1][0] * 1) % 1000000007;
        dp[i][2] = (dp[i][2] + dp[i - 1][0] * 1) % 1000000007;
        dp[i][1] = (dp[i][1] + dp[i - 1][1] * 9) % 1000000007;
        dp[i][3] = (dp[i][3] + dp[i - 1][1] * 1) % 1000000007;
        dp[i][2] = (dp[i][2] + dp[i - 1][2] * 9) % 1000000007;
        dp[i][3] = (dp[i][3] + dp[i - 1][2] * 1) % 1000000007;
        dp[i][3] = (dp[i][3] + dp[i - 1][3] * 10) % 1000000007;
    }
    cout << dp[N - 1][3] << endl;
}


Measured memory_bytes: 73392
#include<bits/stdc++.h>
#define line cout<<endl;
#define space cout<<" ";
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238
typedef long long int ll;

using namespace std;

const int N = 1e9+7;

vector<ll> v(100005);
ll dp[100005];


ll findans(ll n,ll k)
{
    ll mini = INT_MAX;
    if(n==0)
    {
        return 0;
    }

    if(dp[n]!=-1)
        return dp[n];

    for(int i=n-1;i>=max(n-k,(ll)0);i--)
    {
      //   cout<<"n is: "<<n<<" "<<" i is: "<<i<<endl;
         mini = min(mini,abs(v[i]-v[n])+findans(i,k));
        // cout<<"mini in: "<<mini<<" n is: "<<n<<" "<<" is is: "<<i<<" v of i: "<<v[i]<<" v of n: "<<v[n]<<endl;
    }

    return dp[n] = mini;


}


void solve()
{
    memset(dp,-1,sizeof(dp));
    ll n,k;
    cin>>n;
    cin>>k;

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


    //ll ans = findans(n-1);
    ll ans = findans(n-1,k);
    cout<<ans;

}


int main()
{
   ll t;
   t = 1;
  // cin>>t;

   while(t--)
   {
       solve();
       cout<<endl;
   }




}














Measured memory_bytes: 12664
import math
from collections import Counter

n = int(input())
s = [Counter(list(input())) for _ in range(n)]
a = [math.inf] * 26
flag = [0] * 26
ans = ""
for i in s:
    ke = list(i.keys())
    val = list(i.values())
    for j, k in enumerate(ke):
        a[ord(k) - 97] = min(a[ord(k) - 97], val[j])
        flag[ord(k) - 97] += 1
for v in range(len(a)):
    if a[v] != math.inf and flag[v] >= n:
        ans += a[v] * chr(97 + v)
print(ans)

Measured memory_bytes: 9488
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[400000],b[400000];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)scanf("%d",&b[i]);
	int ans=0;
	rep(i,29){
		int d=1<<i;
		vector<int>v;
		rep(j,n){
			v.push_back(a[j]%(d<<1));
		}
		sort(v.begin(),v.end());
		ll cnt=0;
		rep(j,n){
			int e=b[j]%(d<<1);
			if(e<d){
				int f=d-e;
				int k=lower_bound(v.begin(),v.end(),f)-v.begin();
				int t=upper_bound(v.begin(),v.end(),(d<<1)-e-1)-v.begin();
				cnt+=t-k;
			}
			else{
				int F=(d<<1)-e-1;
				cnt+=upper_bound(v.begin(),v.end(),F)-v.begin();
				
				int f=(d<<1)-e+d;
				int k=lower_bound(v.begin(),v.end(),f)-v.begin();
				cnt+=n-k;
			}
		}
		if(cnt&1)ans+=d;
	}
	cout<<ans<<endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<string, int > Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;

int can[2000][200][2];

int main(){
	int n, m, a, h, p, q;
	while(cin >> n >> m >> a && (n || m || a)){
		memset(can, -1, sizeof(can));
		for(int i = 0; i < m; i++){
			cin >> h >> p >> q;
			can[h][p][1] = q;
			can[h][q][0] = p;
		}
		for(int i = 1000; i >= 0; i--){
			if(can[i][a][0] == -1 && can[i][a][1] == -1){}
			else if(can[i][a][0] != -1){
				a = can[i][a][0];
			}else if(can[i][a][1] != -1){
				a = can[i][a][1];
			}
		}
		cout << a << endl;
	}

	return 0;
}

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

bool vis[100001];
int arr[100001];
int main(){
	int n;
	cin>>n;

	for(int i=1;i<=n;i++) cin>>arr[i];

	int idx = 1;
	int cnt = 1;
	while(!vis[arr[idx]]){
		vis[idx] = 1;
		if(arr[idx] == 2) {
			cout<<cnt;
			return 0;
		}
		idx = arr[idx];
		cnt++;
	}
	cout<<-1;
}

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

int main()
{
  	int m,h,sstr;
  	string s;
  
 	cin >> s >> m;
   	
  	while(s != "-"){
      sstr = 0;
      for(int i = 0;i < m;i++){
        cin >> h;
        s += s.substr(sstr,h);
        sstr += h;
      }   
      cout << s.substr(sstr,s.length()) << endl;
      
      cin >> s >> m;
  	}
  
}


Measured memory_bytes: 3076
import java.util.*;

public class Main {
 
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int h = scan.nextInt();
    
   
    System.out.print((a+b)*h/2);
   
  }
  
}

Measured memory_bytes: 35792
import java.util.*;
public class Main {	
	String[] tile;
	boolean[][] board;

	void doIt() {
		Scanner stdIn =new Scanner(System.in);

		while(stdIn.hasNext()) {
			Queue<Integer> qx = new LinkedList<Integer>();
			Queue<Integer> qy = new LinkedList<Integer>();

			int width = stdIn.nextInt();
			int height = stdIn.nextInt();
			if(width + height == 0) break;
			tile = new String[height];
			board = new boolean[height][width];
			for(int r = 0; r < height; r++) {
				tile[r] = stdIn.next();
				for(int c = 0; c < width; c++) {
					if(tile[r].charAt(c) == '@') {
						qx.add(c);
						qy.add(r);
						board[r][c] = true;
					}
				}
			}

			int[] fdx = new int[]{1, -1, 0, 0};
			int[] fdy = new int[]{0, 0, -1, 1};
			int count = 1;//既に現在地は訪れているので含めておく
			while(!qx.isEmpty()) {
				int nowx = qx.poll();
				int nowy = qy.poll();
				for(int r = 0; r < fdx.length; r++) {
					int nextx = nowx + fdx[r];
					int nexty = nowy + fdy[r];
					if(!(nextx >= 0 && nexty >= 0 && nextx < width && nexty < height)) continue;
					if(tile[nexty].charAt(nextx) != '#' && !board[nexty][nextx]) {
						qx.add(nextx);
						qy.add(nexty);
						board[nexty][nextx] = true;
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
}

Measured memory_bytes: 34696
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        pq.push(x);
    }
    //take the most expensive and halve it
    for (int i = 0; i < m; i++) {
        int val = pq.top();
        pq.pop();
        pq.push(val / 2);
    }
    ll sum = 0;
    //remove all in pq and sum them
    while (!pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=3e3+5;
int arr[N];
int dp[N][N];
int n,S;

int32_t main()
{
    fast;
    cin>>n>>S;
    for(int i=1;i<=n;i++)
        cin>>arr[i];

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<N;j++)
            dp[i][j]=dp[i-1][j];

        dp[i][arr[i]]+=i,dp[i][arr[i]]%=BIG;
        for(int j=1;j<N;j++)
        {
            int sum=arr[i]+j;
            if(sum>=N)
                break;

            dp[i][sum]+=dp[i-1][j],dp[i][sum]%=BIG;
        }
    }

    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=dp[i][S],ans%=BIG;
    cout<<ans<<endl;

}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    map<ll,int> mp;
    REP(i,N) {
        ll a;
        cin>>a;
        if (mp.find(a)!=mp.end()) {
            mp[a]++;
        }
        else {
            mp[a] = 1;
        }
    }
    vector<ll> E;
    for (auto m:mp) {
        if (m.second >= 2) E.pb(m.first); 
        if (m.second >= 4) E.pb(m.first);
    }
    if (E.size() < 2) {
        cout<<0<<endl;
        return 0;
    }
    sort(ALL(E),greater<int>());
    cout<<E[0]*E[1]<<endl;
    return 0;
}

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

int main()
{
    cout << fixed << setprecision(18);
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    ll T;
    cin >> T;
    cout << (double)((double)ceil((double)T / (double)2.0) / (double)T);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e18;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const double pi=acos(-1);


int main(){
    //TB
    double a;
    cin>>a;
    a/=3;
    a=a*a*a;
    //cout<<a<<'\n';
    printf("%.10f\n",a);
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			IntStream.range(0, n).forEach(i -> {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				IntStream.range(0, number).forEach(j -> set.add(scanner.nextInt()));
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			});
			System.out.println(commonSet.size());
		}
	}
}


Measured memory_bytes: 26960
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define FOR(n) for(int i=0;i<n;i++)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]

int main()
{
	int a, b;
	cin >> a >> b;

	if (b == 1) 
	{
		cout << "0" << endl;
	}
	else
	{
		int count = 0;
		while (a < b)
		{
			count++;
			b = b - a + 1;
		}
		count++;

		cout << count << endl;
	}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H;
    cin >> H;

    ll n = 1;
    while((1LL<<n) <= H) ++n;
    PR((1LL<<n)-1);

    return 0;
}

/*



*/

Measured memory_bytes: 3604
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# N = int(input())
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

from itertools import *

N = int(input())
P = tuple([int(x) for x in input().split()])
Q = tuple([int(x) for x in input().split()])
li = list(permutations(list(range(1, N+1))))

for i in range(len(li)):
    if li[i] == P:
        p = i
    if li[i] == Q:
        q = i

print(abs(p-q))


Measured memory_bytes: 8052
b=True
l=[1,1,2,4]
def year(n):
  if n%3650==0:
    return n//3650
  else:
    return n//3650+1
while b==True:
  n=int(input())
  if n==0:
    b=False
    break
  else:
    if len(l)>n:
      pass
    else:
      while len(l)!=1+n:
        l.append(l[-1]+l[-2]+l[-3])
    print(year(l[n]))  


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

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

	bool f = true;

	for (int i = 1; i < s.size(); ++i) {
		if (s[i] == s[i - 1]) {
			f = false;
		}
	}

	cout << (f ? "yes" : "no") << endl;
}


Measured memory_bytes: 256
<?php
//$N = trim(fgets(STDIN));
list($N,$M) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));

$res=array();
$ac=array();
$wa=array();
for($i=0;$i<$M;$i++) {
  list($p,$S) =  explode(" ",trim(fgets(STDIN)));
  $p--;
  if ($S=="AC") $ac[$p]=1;
  if ($S=="WA" && !isset($ac[$p]))
  {
    if (!isset($wa[$p])) {
      $wa[$p]=1;
    }
    else {
       $wa[$p]+=1;
    }
  }
}
$wac=0;
foreach($ac as $k=>$a) {
  $wac += $wa[$k];
}
$account=count($ac);;
printf("%s %s\n",$account,$wac);


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

using namespace std;

int main(){

    int n,a;
    vector<int> life;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a;
        life.push_back(a);
    }

    sort(life.begin(),life.end());

    int tmp_min = life[0];
    int tmp_min_c = 0;
    
    while(tmp_min_c != tmp_min){
        tmp_min_c = tmp_min;
        for(int i = 0; i < life.size(); i++){
            int tmp = life[i] % tmp_min;
            if(tmp != 0 && tmp_min > tmp){
                tmp_min = tmp;
            }
        }
    }

    cout << tmp_min << endl;

}

Measured memory_bytes: 892
from functools import lru_cache
ans = ['IDENTICAL', 'DIFFERENT', 'CLOSE']

def compare(s1,s2):
    if s1 == s2:
        return 0
 
    l1,l2 = s1.split('"'),s2.split('"')
    if len(l1) != len(l2):
        return 1
 
    cnt = 0
    for i in range(len(l1)):
        if i%2 == 0:
            if l1[i] != l2[i]:
                return 1
        else:
            if l1[i] != l2[i]:
                cnt += 1
            if cnt > 1:
                return 1
    return 2

while True:
    str1 = input()
    if str1 == ".":
        break
    str2 = input()
    print(ans[compare(str1,str2)])



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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        char[] cs = s.toCharArray();
        Arrays.sort(cs);
        if (cs[0] == cs[2]) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    char a,b;cin>>a>>b;
    char c = '=';
    if(a<b)c = '<';
    else if(a>b) c = '>';
    out(c);
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define g 9.80
#define eps 1e-8
int top;

int n;
double v,xx,yy;
struct rectangle
{
       double l,r,b,t;
}rec[101];

bool judge(double a,double len )
{
     int i;
     double hh = a*xx*(xx-len);
     double hi = -a*len*len/4.0;//抛物&#32447;最高点的y坐&#26631; 
     if ( yy-hh>eps || yy-hi>eps ) return false;//抛物&#32447;&#39134;&#36807;pig下方 
     for ( i=1;i<=n;i++ )
     {
         if ( rec[i].l>xx ) break;//障碍物的左&#36793;界大于pig的x坐&#26631; 
         double h1 = a*rec[i].l*(rec[i].l-len );//左&#36793;界&#23545;&#24212;的高度 
         double h2 = a*rec[i].r*(rec[i].r-len );//右&#36793;界&#23545;&#24212;的高度 
         if ( h1>=rec[i].b && h1<=rec[i].t ) return false;
         if ( h2>=rec[i].b && h2<=rec[i].t ) return false;//撞上&#36793;界 
         if ( h1<rec[i].b && h2<rec[i].b ) //抛物&#32447;从矩形下方&#39134;&#36807; 
              if (  len/2-rec[i].l>eps && rec[i].r-len/2>eps && hi-rec[i].b>eps  ) 
                 return false;//抛物&#32447;最高点在矩形中或者高于矩形 
         if ( rec[i].l<=xx && rec[i].r>=xx  && rec[i].b>yy ) //pig 在一个矩形的下面 
             if ( hh>rec[i].t ) return false;
     }
     return true;
}


void solve()
{
     int i;
     double h,t,vx,vy,len;
     for ( i=1;i<=400000;i++ )
     {
           vy=double(i)/400000*v;
           vx=sqrt(v*v-vy*vy);
           t=vy/g;
           h = g*t*t/2;
           len = vx*2*t;
           if ( xx-len>eps ) continue;
           else
           {
               double a = (-2*vy*vy)/(g*len*len);
               if ( judge(a,len) )
               {
                    printf("Yes\n");
                    return ;
               }
           }
     }
     printf("No\n");
}

bool cmp(rectangle a,rectangle b)
{
     return a.l<b.l;
}

int main()
{
    int i;
    while ( scanf("%d %lf %lf %lf",&n,&v,&xx,&yy)!=EOF )
    {
          for ( i=1;i<=n;i++ )
          {
              scanf("%lf %lf %lf %lf",&rec[i].l,&rec[i].b,&rec[i].r,&rec[i].t);
              rec[i].r = min(xx,rec[i].r);
          }
          sort(rec+1,rec+n+1,cmp);
          solve();
    }
    return 0;
}
          
          
          
          

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

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

    int n;
    cin >> n;
    
    vector<ll> a(n);
    ll len_sum = 0;
    rep(i, n){
        ll len;
        cin >> len;
        len_sum += len;
        a[i] = len;
    }
    
    ll half_len = len_sum / 2;
    ll current = 0;
    ll left;
    ll right;
    rep(i, n){
        current += a[i];
        if(current >= half_len){
            right = current;
            left = current - a[i];
            break;
        }
    }

    cout << min(right - (len_sum - right), (len_sum - left) - left) << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  int dist[n][n], ans[n-1] = {}; // 1,2,...,n-1
  
  for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j)
      dist[i][j] = abs(i-j);
      
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      dist[i][j] = min(dist[i][j], dist[min(i, x)][max(i, x)] + 1 + dist[min(j, y)][max(j, y)]);
      ans[dist[i][j]-1]++;
    }
  }
  
  for (int i = 1; i < n; ++i)
    cout << ans[i-1] << '\n';
  return 0;
}

Measured memory_bytes: 15744
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read();

    let dd: Vec<_> = (0..n)
        .map(|_| read_cols!(i64, i64))
        .map(|(d1, d2)| d1 == d2)
        .collect();

    let ans = (0..n - 2).any(|i| dd[i] && dd[i + 1] && dd[i + 2]);

    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    ll a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    ll dp[1<<n];
    for(int s=1;s<1<<n;s++){
        ll p=0;
        for(int i=0;i<n;i++){
            if(((s>>i)&1)!=1)continue;
            for(int j=i+1;j<n;j++){
                if((s>>j)&1)p+=a[i][j];
            }
        }
        dp[s]=p;
    }
    for(int s=1;s<1<<n;s++){
        for(int t=(s-1)&s;t>0;t=(t-1)&s){
            dp[s]=max(dp[s],dp[s-t]+dp[t]);
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    string S;
    cin >> S;
    int T = 1;
    for ( int i = 0; i < N - 1; i++ ) {
        if ( S.at(i) != S.at(i+1) ){
            T += 1;
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define int long long

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;



signed main() {
	int N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	REP(k,N){
		if((ll)k*C-(N-1-k)*D<=B-A&&B-A<=(ll)k*D-(N-1-k)*C){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

char ch[100010];
int sSize;
string str[4] = {"dream", "dreamer", "erase", "eraser"};

int check(int id) {
	bool ok = true;
	int j = 0;
	for (int i = sSize - str[id].size(); i < sSize; i++) {
		if (i < 0) {
			return false;
		}
		if (ch[i] != str[id][j]) {
			return false;
		}
		j++;
	}
	return true;
}

signed main() {

	string S;
	cin >> S;

	sSize = S.size();

	rep(i, S.size()) {
		ch[i] = S[i];
	}

	while (sSize > 0) {
		bool ok = false;
		rep(i, 4) {
			if (check(i)) {
				sSize -= str[i].size();
				ok = true;
				break;
			}
		}
		if (!ok) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp11
{
    class MainClass
    {
        static void Main()
        {
            Dictionary<string, int> table = new Dictionary<string, int>();
            
            
            int N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                string str = Console.ReadLine();
                if (table.ContainsKey(str))
                    table[str] += 1;
                else
                    table.Add(str, 1);
            }
            int M = int.Parse(Console.ReadLine());
            for(int i = 0; i < M; i++)
            {
                string str = Console.ReadLine();
                if (table.ContainsKey(str))
                    table[str] -= 1;
                else
                    table.Add(str, -1);
            }
            int ans = table.Values.Max();
            Console.WriteLine(ans < 0 ? 0 : ans);
        }
    }
}


Measured memory_bytes: 13152
// glory be to the sky
#include<bits/stdc++.h> 


using namespace std;
	
typedef long long ll; 


map<ll, ll> M;

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, k;
	cin >> n >> k;
	ll a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		M[a] += b;
	}
	for (auto &x: M) {
		// cout << x.first << " " << x.second << " " << k << endl;
		if (k <= x.second) {
			cout << x.first << endl;
			return 0;
		}
		k -= x.second;
	}
	return 0;	
}


Measured memory_bytes: 4224
#include<stdio.h>
int main()
{
	int n,h[100000],i,c,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	c=0;
	a=0;
	for(i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			//printf("%d>=%d\n",h[i],h[i+1]);
			c++;
			//printf("c=%d\n",c);
			if(c>=a) a=c;
		}
		else {
			c=0;
			h[i]=h[i+1];
		}
	}
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>

typedef struct{
    int id;
    int parent;
    int sibling;
    int degree;
    int depth;
    int height;
}Tree;

int main(){
    int i,j,n,depmax=0,depth;
    int id,data;
    scanf("%d",&n);
    Tree T[n];
    for(i=0;i<n;i++){
        T[i].id=-1;
        T[i].parent=-1;
        T[i].sibling=-1;
        T[i].degree=0;
        T[i].depth=0;
        T[i].height=0;
    }
    
    
    for(i=0;i<n;i++){
        scanf("%d",&id);
        T[id].id=id;
        scanf("%d",&data);
        if(data!=-1){
            T[id].degree++;
            T[data].parent=id;
        }
        scanf("%d",&data);
        if(data!=-1){
            T[id].degree++;
            T[data].parent=id;
        }
    }
    
    //get status
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(T[i].parent==T[j].parent&&i!=j){
                T[i].sibling=j;
                T[j].sibling=i;
            }
        }
        data=i;
        depth=0;
        while(T[data].parent!=-1){
            depth++;
            data=T[data].parent;
            if(T[data].height<depth)T[data].height=depth;
        }
        T[i].depth=depth;
        
    }
    
    
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,T[i].parent,T[i].sibling,T[i].degree,T[i].depth,T[i].height);
        if(T[i].parent==-1)printf(" root\n");
        else if(T[i].degree==0)printf(" leaf\n");
        else printf(" internal node\n");
        
    }
    return 0;
}

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans;
  ans = (h2 * 60 + m2) - k - (h1 * 60 + m1);
  cout << ans << endl;
}

Measured memory_bytes: 3584
N,T = (int(i) for i in input().split())
c=[]
t=[]
for i in range(N):
    tmp1,tmp2 = (int(i) for i in input().split())
    c.append(tmp1)
    t.append(tmp2)

mincost = 1001
for i in range(N):
    if c[i]<mincost and T>=t[i]:
        mincost = c[i]

if mincost == 1001:
    mincost = 'TLE'
print(mincost)

Measured memory_bytes: 3064