akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);


string S;
int getScore(int Xind) {
	int X = 0;
	REP(i, 3) {
		int n = S[Xind + i] - '0';
		X *= 10;
		X += n;
	}
	return abs(X - 753);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	int ans = INF;
	REP(i, SZ(S) - 2) {
		ans = min(ans,getScore(i));
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
using namespace std;

main(){
  set<int> Num;
  map<int,int> m;
  string in;
  while(getline(cin, in)){
    if(in.size()==0) break;
    int num=atoi(in.c_str());
    m[num]++;
  }
  while(getline(cin, in)){
    int num=atoi(in.c_str());
    if(m[num]>0){
      Num.insert(num);
      m[num]++;
    }
  }
  set<int>::iterator ite=Num.begin();
  while(ite!=Num.end()){
    cout << *ite << ' ' << m[*ite] << endl;
    ite++;
  }
  return 0;
}

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

using namespace std;

int main(void){
    int N, K, result;
    scanf("%d %d", &N, &K);
    vector<int> A(N);

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

    result = count_if(A.begin(), A.end(), [&K](int x) { return x >= K; });

    cout << result << endl;
}

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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> vec(55, vector<char>(55));
    REPS(i,h){
        REPS(j,w){
        cin >> vec.at(i).at(j);
        }
    }

    bool fumiya = true;
    REPS(i,h){
        REPS(j,w){
            if(vec.at(i).at(j) == '#' && vec.at(i-1).at(j) != '#' && vec.at(i+1).at(j) != '#' && vec.at(i).at(j-1) != '#' && vec.at(i).at(j+1) != '#'){
                fumiya = false;
            }
        }
    }
  	if(fumiya) cout << "Yes" << endl;
  	else cout << "No" << endl;

    return 0;
}



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, a;
	ll sum = 0;
	ll ans = 0;

	cin >> n;

	vector<ll> v;

	v.push_back(0);

	REP(i, n) {
		cin >> a;

		v.push_back(a);
	}

	v.push_back(0);

	FOR(i, 1, n + 2) {
		sum += abs(v[i] - v[i - 1]);
	}

	FOR(i, 1, n + 1) {
		if (v[i] >= v[i - 1] && v[i + 1] >= v[i]) {
			ans = sum;
		}
		else if (v[i] <= v[i - 1] && v[i + 1] <= v[i]) {
			ans = sum;
		}
		else {
			ans = sum - (abs(v[i] - v[i - 1]) + abs(v[i + 1] - v[i])) + abs(v[i + 1] - v[i - 1]);
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 2164
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]

c = Counter(A)
ans = []
for k, v in sorted(c.items(), reverse=True):
    if v > 3 and len(ans) == 0:
        ans.append(k)
        ans.append(k)
    elif v > 1:
        ans.append(k)
    if len(ans) == 2:
        break

if len(ans) == 2:
    print(ans[0] * ans[1])
else:
    print(0)

Measured memory_bytes: 21412
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo;}
  else return mpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll p = 37;
  ll n = p*p + p + 1, k = p + 1;
  vector<vector<int>> ans;
  rep(i,n){
    ans.push_back(vector<int>());
  }
  reps(i,p+1){
    ans[0].push_back(i);
    rep(j,p){
      ans[(i-1)*p + 1 + j].push_back(i);
    }
  }
  int num = k+1;
  int m = 0;
  rep(h, p){
      rep(b, p){
        ans[h + 1].push_back(num);
        rep(j,p){
          ans[1 + p + j*p + (b + m*j)%p].push_back(num);
        }
        num++;
      }
      m++;
  }

  cout<<n<<" "<<k<<endl;
  rep(i,n){
    rep(j,k){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 896
L,R,d = map(int,input().split())

if(R%d == 0):
  if(L%d == 0):
    print(int(R/d)-int(L/d)+1)
  else:
    print(int(R/d)-int(L/d))
else:
    print(int(R/d)-int(L/d))

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

const int MAX_N = 15;
const int INF = 1<<24;
vector<string> V;

int G[MAX_N][MAX_N];
int T[MAX_N][1<<MAX_N];

void press() {
  int n = V.size();
  bool erase[n];
  fill(erase, erase+n, false);
  for(int i = 0; i < V.size(); ++i) {
    for(int j = 0; j < V.size(); ++j) {
      if(i == j) continue;
      if(V[j].find(V[i]) != string::npos) {
	erase[i] = true;
	break;
      }
    }
  }
  vector<string> u = V;
  V.clear();
  for(int i = 0; i < n; ++i) {
    if(erase[i]) continue;
    V.push_back(u[i]);
  }
}

void make() {
  fill(G[0], G[MAX_N], -1);
  for(int i = 0; i < V.size(); ++i) {
    for(int j = 0; j < V.size(); ++j) {
      if(i == j) continue;
      G[i][j] = V[j].size();
      for(int c = 1; c < (int)V[i].size(); ++c) {
	string a = V[i].substr(c);
	string b = V[j].substr(0, a.size());
	if(a == b) {
	  G[i][j] = (int)V[j].size() - ((int)V[i].size() - c);
	  break;
	}
      }
    }
  }
}

int solve() {
  press();
  make();
  int N = V.size();
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < (1<<N); ++j) {
      if(j == (1<<i)) T[i][j] = V[i].size();
      else       T[i][j] = INF;
    }
  }
  for(int j = 0; j < (1<<N); ++j) {
    for(int i = 0; i < N; ++i) {
      for(int k = 0; k < N; ++k) {
	if(j & (1<<k)) continue;
	if(G[i][k] == -1) continue;
	T[k][j|(1<<k)] = min(T[k][j|(1<<k)], T[i][j] + G[i][k]);
      }
    }
  }
  int mini = INF;
  for(int i = 0; i < N; ++i) {
    mini = min(mini, T[i][(1<<N)-1]);
  }
  return mini;
}

void show() {
  for(int i = 0; i < V.size(); ++i) {
    for(int j = 0; j < V.size(); ++j) {
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
}

int main() {
  int N;
  while(cin >> N && N) {
    V.clear();
    for(int i = 0; i < N; ++i) {
      string str;
      cin >> str;
      V.push_back(str);
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////



int main(){
	bool sub = false;
	int plc = 0;
	string s,t,ans; cin >> s >> t;
	if(s.size() < t.size()){
	   cout << "UNRESTORABLE"; return 0;
	}
		
	for(int i=s.size()-1;i>=t.size()-1;i--){
		int st = i-t.size()+1;
		bool csub = true;
		if(s[i] == '?' || s[i] == t[t.size()-1]){
			for(int j=0;j<t.size();j++){
				if(s[st+j] != t[j] && s[st+j] != '?'){
					csub = false;
					break;
				}
			}
			if(csub == true){
				plc = st;
				sub = true;
				break;
			}
		}
	}

	if(sub){
		FOR(i,0,s.size()-1){
			if(plc <= i && i < plc+t.size()){
				ans[i] = t[i-plc];
			}else if(s[i] == '?'){
				ans[i] = 'a';
			}else{
				ans[i] = s[i];
			}
			//cout << ans[i];
		}
		cout << ans.c_str();
	}else{
		cout << "UNRESTORABLE";
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //昇順
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順

int main(){
  int n;
  cin >> n;
  vector<ll> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }

  ll pre = nums[0];
  bool down = true;
  bool up = true;
  bool first = true;
  int count = 0;
  r_rep_i(i, 1, n){
    if (pre < nums[i]){
      pre = nums[i];
      if(first){
        first = false;
        up = true;
        down = false;
        continue;
      }
      // if (up){
      //   down = false;
      //   continue;
      // }
      if(down){
        count += 1;
        first = true;
        continue;
      }
    }else if(pre > nums[i]){
      pre = nums[i];
      if(first){
        first = false;
        up = false;
        down = true;
        continue;
      }
      // if (up){
      //   down = false;
      //   continue;
      // }
      if(up){
        count += 1;
        first = true;
        continue;
      }
    }else{
      // if(first){
      // }
      continue;
    }
  }
  cout << count + 1 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int i,j,m,h,t,a;
int main(void){
    char s[201]={};
    for(;scanf("%s%d",s,&m),s[0]!='-';puts("")){
        a=strlen(s);
        for(i=t=0;i<m;scanf("%d",&h),t+=h,i++);
        for (i=0;i<a;i++){
            printf("%c", s[(t+i) % a]);
        }
    }
}

Measured memory_bytes: 1812
using System;

namespace A___Tak_and_Hotels__ABC_Edit_
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());
            var y = int.Parse(Console.ReadLine());
            var ans = 0;
            for(var i=1; i<=n; i++)
            {
                if(i<=k)
                {
                    ans += x;
                }
                else
                {
                    ans += y;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-

ABC = list(map(int, input().split()))

# ABCのどれなのかは関係ないので昇順ソートしとく
ABC.sort()
# まず、少ないやつを差が1になるまで+2していく
cnt = 0
while ABC[0] <= ABC[2] - 2:
	ABC[0] += 2
	cnt += 1
while ABC[1] <= ABC[2] - 2:
	ABC[1] += 2
	cnt += 1
# あとは3つのパターンから場合分け
if ABC[0] == ABC[1] == ABC[2]:
	print(cnt)
	exit()
elif ABC[0] == ABC[2] or ABC[1] == ABC[2]:
	cnt += 2
	print(cnt)
	exit()
elif ABC[0] == ABC[1]:
	cnt += 1
	print(cnt)
	exit()

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
string ans;

int main()
{
	string s;
	int n = 0;

	cin >> s;
	cin >> n;

	for (int i = 0; i < s.size(); ++i) {
		if (i == 0 || i % n == 0) {
			ans.push_back(s[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  string s; cin >> s;
  string t; cin >> t;
  t.pop_back();
  if(s == t) {
    print("Yes");
  }
  else {
    print("No");
  }
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int n, i, a[255], wa;
    // char a[255];
    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    wa = 0;
    // scanf("%d",a);
    // printf("%d\n",n);
    // printf("%d\n",a[2]);
    // for ( i = 0; i < n; i++)
    // {
    //    printf("%d\n",a[i]);
    // }
    for (i = 0; i < n; i++)
    {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
        {
            wa++;
        }
        
    }
    printf("%d\n",wa);
    return 0;

}

Measured memory_bytes: 1728
#include <iostream>

using namespace std;

class Card {
public:
	string suit;
	int value;
	int order;
	void setData(string card, int i);
};

void Card::setData(string card, int i) {
	suit = card[0];
	value = card[1] - '0';
	order = i;
}

void printa(Card card[], int len) {
	cout << card[0].suit << card[0].value;
	for (int i = 1; i < len; i++)
		cout << " " << card[i].suit << card[i].value;
	cout << endl;
}

void bsort(Card card[], int len) {
	for (int i = 0; i < len; i++)
		for (int j = len-1; j >= i+1; j--)
			if (card[j].value < card[j-1].value)
				swap(card[j], card[j-1]);
}

void ssort(Card card[], int len) {
	for (int i = 0; i < len; i++) {
		int mini = i;
		for (int j = i; j < len; j++)
			if (card[j].value < card[mini].value)
				mini = j;
		if (mini != i)
			swap(card[i], card[mini]);
	}
}

void isStable(Card sorted[], int len) {
	for (int i = 0; i < len-1; i++)
		if (sorted[i].value == sorted[i+1].value)
			if (sorted[i].order > sorted[i+1].order) {
				cout << "Not stable" << endl;
				return;
			}
	cout << "Stable" << endl;
}

int main() {
	int n;
	string t;
	Card *b, *s;
	cin >> n;
	b = new Card[n];
	s = new Card[n];
	for (int i = 0; i < n; i++) {
		cin >> t;
		b[i].setData(t, i);
		s[i].setData(t, i);
	}
	bsort(b, n);
	printa(b, n);
	isStable(b, n);
	ssort(s, n);
	printa(s, n);
	isStable(s, n);
}

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

int main()
{
    int n, k, l[50]{}, sum{};
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", l + i);
    
    std::sort(l, l + n);
    for (int i = 1; i <= k; i++)
        sum += l[n - i];

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

    return 0;
}

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

int helper(int *a, int i, int n, int *dp){
    if(i==n-1) return 0;

    if(dp[i]!=inf) return dp[i];
    int op1 =  helper(a, i+1, n, dp) + abs(a[i]-a[i+1]);
    int op2=inf;
    if(i+2<n) op2 =  helper(a, i+2, n, dp) + abs(a[i]-a[i+2]);
    return dp[i] = min(op1,op2);
}
int main() {
    int n;
    cin>>n;
    int a[n];
    int dp[n];
    
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) dp[i]=inf;
    cout<<helper(a,0,n,dp);
}


Measured memory_bytes: 13724
from collections import defaultdict
n=int(input())
d=defaultdict(int)

while n%2==0:
  n//=2
  d[2]+=1
f=3

while f*f<=n:
  if n%f==0:
    n//=f
    d[f]+=1
  else:
    f+=2
if n!=1:
  d[n]+=1
c=0
for k,v in d.items():
  i=1
  while v>=i:
    v-=i
    c+=1
    i+=1
print(c)
    

Measured memory_bytes: 9452
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define all(a) begin(a),end(a)
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define sz(x) ((int)x.size())
#define ins insert
#define rep(i,l,u) for(int i=l;i<=u;++i)
#define reb(i,l,u) for(int i=l;i>=u;--i)
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
main(){
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back

int main()
{
   int n;
   cin>>n;
   ll a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   ll mx=0;ll c=0;
   for(int i=0;i<n-1;i++)
   {
       if(a[i]>=a[i+1])
       c++;
       else
       {
           c=0;
       }
        mx=max(mx,c);
   }
   cout<<mx;
}



Measured memory_bytes: 1024
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<vector<int>> before(N+1, vector<int>(2, -INF));
    vector<vector<int>> after(N+1, vector<int>(2, -INF));
    before[0][0] = 0;
    after[0][0] = 0;

    for (int i = 0; i < N; i++) {
        int r = N-1-i;
        int l = i+1;
        int lower = N/2 - (int)ceil(1.0 * r / 2);
        int upper = (int)ceil(1.0 * l / 2);

        lower--;
        upper++;

        for (int a = lower; a <= upper; a++) {
            if (a < 0) continue;
            if (a >= N) continue;
            chmax(after[a+1][1], before[a][0] + A[i]);
            chmax(after[a][0], max(before[a][1], before[a][0]));
        }

        swap(before, after);
    }

    cout << max(before[N/2][0], before[N/2][1]) << endl;
    return 0;
}

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

int main(){
	// string st;
	// getline(cin, st);
	// transform(st.begin(), st.end(), st.begin(), ::toupper);
	// cout << st << endl;

	string str;
	getline(cin, str);

	char X = 'A' - 'a';
	for(int i = 0; i < str.size(); i++){
		if('a' <= str[i] && str[i] <= 'z') str[i] += X;
	}
	cout << str << endl;

	return 0;
}

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

using namespace std;

int main(void) {
	vector<int> hoge = vector<int>(10);
	for (int i = 0; i < 10;++i) {
		cin >> hoge[i];
	}
	sort(hoge.begin(), hoge.end(), greater<int>());
	for (int i = 0; i < 3;++i) {
		cout << hoge[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    int m; cin >> m;
    vint a(m); rep(i,m) cin >> a[i];
    ll sum = accumulate(all(a),0);
    if(sum > n) cout << -1 << endl;
    else cout << n-sum << endl;

    return 0;
}

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


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,K,Q;
    cin >> N >> K >> Q;
    vector<ll> A(Q);
    for(ll i = 0;i < Q;i++)
        cin >> A.at(i);

    map<ll,ll>mpa;
    for(ll i = 0;i < N;i++)
        mpa[i] = 0;

    for(ll i = 0;i < Q;i++){
        mpa[A.at(i) -1]++;
    }

    for(ll i = 0;i < N;i++){
        if((K+mpa[i]) - Q > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
} 

Measured memory_bytes: 10340
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	int n = s.size();
	if(n % 2 == 1) {
		cout << "No" << '\n';
		return 0;
	}
	for(int i = 0; i < n; i += 2) {
		if(s[i] != 'h' or s[i + 1] != 'i') {
			cout << "No" << '\n';
			return 0;
		}
	}
	cout << "Yes" << '\n';
	return 0;
}

Measured memory_bytes: 764
n = int(input())
ds = []
for i in range(n):
    a,b = map(int, input().split())
    ds.append((a+b, a, b))
ds.sort(reverse=True)
a = 0
b = 0
for i in range(0,n,2):
    a += ds[i][1]
for i in range(1,n,2):
    b += ds[i][2]

print(a-b)


Measured memory_bytes: 20996
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

var graph map[int]map[int]bool

func initGraph(x int) {
	graph = make(map[int]map[int]bool, x)
}

func add(from, to int) {
	if _, ok := graph[from]; !ok {
		graph[from] = make(map[int]bool)
	}
	graph[from][to] = true
}

func main() {
	n, m := scanInt(), scanInt()
	initGraph(n)
	for i := 0; i < m; i++ {
		a, b := scanInt(), scanInt()
		add(a, b)
		add(b, a)
	}

	seen := make([]int, n+1)
	for i := range seen {
		seen[i] = -1
	}
	ls := list.New()
	ls.PushBack(1)
	for ls.Len() > 0 {
		v := ls.Remove(ls.Front()).(int)
		for t := range graph[v] {
			if seen[t] > 0 {
				continue
			}
			seen[t] = v
			ls.PushBack(t)
		}
	}

	exist := true
	for _, v := range seen[2:] {
		if v == -1 {
			exist = false
			break
		}
	}
	var wr = bufio.NewWriter(os.Stdout)
	if exist {
		wr.WriteString("Yes\n")
		for _, v := range seen[2:] {
			wr.WriteString(strconv.Itoa(v) + "\n")
		}
	} else {
		wr.WriteString("No\n")
	}
	wr.Flush()
}


Measured memory_bytes: 37372
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll n,m;
char massiv[MAXN][MAXN];
ll dp[MAXN][MAXN];
ll mod=1000000007;

int main(){
FAST_READ;
cin>>n>>m;
for(ll i=1;i<=n;i++)
{
  for(ll j=1;j<=m;j++)
  {
	cin>>massiv[i][j];
  }
}
if(massiv[1][1]!='#')dp[1][1]=1;
for(ll i=1;i<=n;i++)
{
  for(ll j=1;j<=m;j++)
  {
	if(i==1 && j==1)continue;
	if(massiv[i][j]!='#')
	{
      if(i-1>=1)dp[i][j]+=dp[i-1][j];
      if(j-1>=1)dp[i][j]+=dp[i][j-1];
      dp[i][j]%=mod;
	}
  }
}
cout<<dp[n][m]%mod<<endl;






return 0;
} 


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

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = 2e5;
const ll INF = 1e11; 

int n;  
pair<ll, ll> x[MAXN];

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

    for (int i = 1; i <= n; i++) {                                     
        ll p, l;
        cin >> p >> l;
        x[i] = mp(p + l, p - l);
    } 

    sort(x + 1, x + n + 1);

    ll cnt = 1, r1 = x[1].fi;
               
    for (int i = 2; i <= n; i++) {
        ll l = x[i].se;
        if (l >= r1) {
            cnt++;
            r1 = x[i].fi;
        }                                                                                         
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1792
integer :: n, i, j, ans = 0, z(5000) = 0
character(5000) :: s
read*, n
read*, s
do i = 1, n-1
  z(i:n) = z_algorithm(s(i:n))
  do j = i+1, n
    ans = max(ans,min(j-i,z(j)))
  end do
end do

print"(I0)",ans

contains

function z_algorithm(s) result(z)
  character(*) :: s
  integer :: z(len_trim(s)), n, i, j, k
  z=0
  n=len_trim(S)
  z(1) = n
  i = 1
  j = 0
  do while (i < n)
    do while (i+j < n .and. s(j+1:j+1) == s(i+j+1:i+j+1))
      j = j+1
    end do
    z(i+1) = j
    if (j == 0) then
      i = i+1
      cycle
    end if
    k = 1
    do while (i+k < n .and. k + z(k+1) < j)
      z(i+k+1) = z(k+1)
      k = k+1
    end do
    i = i+k
    j = j-k
  end do
end function
end

Measured memory_bytes: 768
A, B, C = map(int, input().split())
ans = 0
while A%2 == 0 and B%2 == 0 and C%2 ==0:
    ans += 1
    a, b, c = A//2, B//2, C//2
    A = b+c
    B = a+c
    C = a+b
    if ans == 100: break
if ans == 100:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 3060
s = input()

first = s[:2]
second = s[2::]

if 1 <= int(first) <= 12:
    if 1 <= int(second) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(second) <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
vector<int> num, p, q, used;
int N, p1, q1, count, res;
int dfs(int i){
    int res = 0;
    if(i == N){
        if(num == p)p1 = count;
        if(num == q)q1 = count; 
        count++;
        if(p1 != -1 && q1 != -1) return abs(p1 - q1);
        else return 0;
    }
    for(int j = 0; j < N; j++){
        if(used[j] == 1){
            num[i] = j + 1;
            used[j] = 0;
            res = max(res, dfs(i + 1));
            used[j] = 1;
        }
    }
    return res;
}
int main(){
    cin >> N;
    p.resize(N);
    q.resize(N);
    num.resize(N);
    used.resize(N, 1);
    p1 = -1;
    q1 = -1;
    for(int i = 0; i < N; i++)cin >> p[i];
    for(int i = 0; i < N; i++)cin >> q[i];
    cout << dfs(0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

const int maxn=60;

struct edge
{
	int id, next;
};
struct sLink
{
	int u, v;
};

int n, m;
int h[maxn];
edge t[maxn*2];
sLink Link[maxn];
bool vis[maxn];
int ans;
int now;
int ban;

void join(int u, int v)
{
	t[now].id=v; t[now].next=h[u]; h[u]=now++;
	t[now].id=u; t[now].next=h[v]; h[v]=now++;
}
void read()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; ++i) h[i]=-1;
	for (int i=1; i<=m; ++i)
	{
		scanf("%d%d", &Link[i].u, &Link[i].v);
		join(Link[i].u, Link[i].v);
	}
}
void dfs(int cur)
{
	if (vis[cur]) return;
	vis[cur]=true;
	for (int i=h[cur]; i>-1; i=t[i].next)
		if (i!=ban && (i^1)!=ban)
			dfs(t[i].id);
}
void solve()
{
	for (int i=1; i<=m; ++i)
	{
		ban=(i-1)*2;
		memset(vis, false, sizeof(vis));
		dfs(Link[i].u);
		if (!vis[Link[i].v]) ++ans;
	}
	printf("%d\n", ans);
}
int main()
{
	read();
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i,m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].emplace_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;

  vector<vector<int>> dp(n, vector<int>(3, INF));
  queue<P> que;
  dp[s][0] = 0;
  que.push(make_pair(s, 0));
  while (!que.empty()) {
    auto e = que.front(); que.pop();
    int u = e.first;
    int cur = e.second;
    for (auto v : g[u]) {
      if (dp[v][(cur + 1) % 3] != INF) continue;
      dp[v][(cur + 1) % 3] = dp[u][cur] + 1;
      que.push(make_pair(v, (cur + 1) % 3));
    }
  }
  cout << (dp[t][0] == INF ? -1 : dp[t][0] / 3) << endl;
  return 0;
}


Measured memory_bytes: 14012
N,M,K=map(int,input().split())
As=list(map(int,input().split()))
Bs=list(map(int,input().split()))

a_sum=[0]
for i in range(N):
    a_sum.append(a_sum[-1]+As[i])

b_sum=[0]
for i in range(M):
    b_sum.append(b_sum[-1]+Bs[i])

j=M
ans=0
for i in range(N+1):
    if a_sum[i] > K:
        break

    while b_sum[j] > K - a_sum[i]:
        j-=1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47504
K = int(input())
A = [1,2,3,4,5,6,7,8,9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1,2):
            a = int(str(A[i]) + str(A[i]+j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = 10
L2 = len(A.copy())
for i in range(8):
    for i in range(L1,L2):
        B = A[i]
        if B % 10 == 0:
            A.append(int(str(B) + '0'))
            A.append(int(str(B) + '1'))
        elif B % 10 == 9:
            A.append(int(str(B) + '8'))
            A.append(int(str(B) + '9'))
        else:
            for j in range(-1, 2):
                a = int(str(B) + str((B % 10) + j))
                A.append(a)
    L1 = L2
    L2 = len(A.copy())
print(A[K-1])

Measured memory_bytes: 12864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[2]);
			if ("?".equals(str[1])) {
				break;
			}
			if ("+".equals(str[1])) {
				sb.append(Integer.toString(a + b)).append("\n");
			}
			if ("-".equals(str[1])) {
				sb.append(Integer.toString(a - b)).append("\n");
			}
			if ("*".equals(str[1])) {
				sb.append(Integer.toString(a * b)).append("\n");
			}
			if ("/".equals(str[1])) {
				sb.append(Integer.toString(a / b)).append("\n");
			}
		}
		System.out.print(sb);

	}

}

Measured memory_bytes: 24328
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 100003

int cnt[N];

int main(void)
{
  int n;
  cin>>n;
 
  for(int i=1;i<=n;i++) {
  	int x;
  	scan(x);
  	cnt[x]++;
  }
  int res = cnt[0] + cnt[1];
  for(int i=1;i<N-1;i++){
  	res = max(res , cnt[i-1] + cnt[i] + cnt[i+1]);
  }
  cout<<res;
  return 0;
}
 
 
void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

Measured memory_bytes: 640
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,it;
map<pair<int,int>,int>mp;
vector<pair<int,int> >g[606060];
bool vis[606060];
void lj(int a,int b,int c,int d)
{
	g[a].push_back(make_pair(b,c));
	g[b].push_back(make_pair(a,d));
}
int gd(int st,int c)
{
	if(mp.count(make_pair(st,c)))
	{
		return mp[make_pair(st,c)];
	}
	int now=it;
	it++;
	lj(st,now,1,0);
	mp[make_pair(st,c)]=now;
	return now;
}
int main()
{
	cin>>n>>m;
	it=n;
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		int x=gd(b,c),y=gd(a,c);
		lj(x,y,0,0);
	}
	priority_queue<pair<int,int> >q;
	for(int i=0;i<it;i++)
	{
		vis[i]=false;
	}
	q.push(make_pair(0,0));
	while(!q.empty())
	{
		pair<int,int>pp=q.top();
		q.pop();
		int ct=-pp.first,x=pp.second;
		if(x==n-1)
		{
			cout<<ct<<endl;
			return 0;
		}
		for(int i=0;i<g[x].size();i++)
		{
			if(!vis[g[x][i].first])
			{
				vis[g[x][i].first]=true;
				q.push(make_pair(-(ct+g[x][i].second),g[x][i].first));
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

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

namespace ALDS1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue<Process> processQueue = new Queue<Process>();
            int totalTime = 0;

            int[] tmpLine = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int countProcesses = tmpLine[0];
            Process.quantumTime = tmpLine[1];

            for (int i = 0; i < countProcesses; i++)
            {
                string[] tmpLine2 = Console.ReadLine().Split(' ');
                processQueue.Enqueue(new Process(tmpLine2[0], int.Parse(tmpLine2[1])));
            }

            while (processQueue.Count > 0)
            {
                Process tmpProcess = processQueue.Dequeue();
                totalTime += tmpProcess.RunProcess();
                if (tmpProcess.time > 0)
                {
                    processQueue.Enqueue(tmpProcess);
                }
                else
                {
                    Console.WriteLine(string.Format("{0} {1}", tmpProcess.name, totalTime));
                }
            }
            Console.ReadLine();
        }
    }

    class Process
    {
        public static int quantumTime;
        public string name { private set; get; }
        public int time { private set; get; }

        public Process(string name, int time)
        {
            this.name = name;
            this.time = time;
        }

        /// <summary>
        /// 最大でquantumTimeプロセスを実行し、実行時間を返す
        /// </summary>
        /// <param name="quantumTime"></param>
        /// <returns></returns>
        public int RunProcess()
        {
            if (this.time > Process.quantumTime)
            {
                this.time = this.time - Process.quantumTime;
                return Process.quantumTime;
            }
            else
            {
                int tmpTime = this.time;
                this.time = 0;
                return tmpTime;
            }
        }
    }
}



Measured memory_bytes: 24948
N = int(input())
A = list(map(int,input().split()))
#A1~An
cnt = 0
#conunt_trialを試行回す度に増やしていく
#奇数が出るまで割り続ける


def devision():
    global cnt
    for i in range(N):
        count = A[i]
        if count % 2 != 0:
            print(cnt)
            break
        else:
            count = count // 2
            A[i] = count

        if i == N-1:
            cnt += 1
            devision()

devision()


Measured memory_bytes: 2940
#include<stdio.h>

void visit(int i,int j);

int v[21][21],count,H,W;
char s[21][21];

int main(void){
  int i,j;
  
  while(1){

    for(i=0;i<21;i++){
      for(j=0;j<21;j++)
	s[i][j]='#';
}
    for(i=0;i<21;i++){
      for(j=0;j<21;j++)
	v[i][j]=0;
    }
    count=0;
    scanf("%d %d",&W,&H);
    if(W==0 && H==0)break;

    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	scanf(" %c",&s[i][j]);
      }
    }

    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(s[i][j]=='@'){
	  visit(i,j);
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

void visit(int i,int j){
  v[i][j]=1;
  count++;
  if(s[i+1][j]=='.' && i<H && v[i+1][j]==0)visit(i+1,j);
  if(s[i-1][j]=='.' && i!=0 && v[i-1][j]==0)visit(i-1,j);
  if(s[i][j+1]=='.' && j<W && v[i][j+1]==0)visit(i,j+1);
  if(s[i][j-1]=='.' && j!=0 && v[i][j-1]==0)visit(i,j-1);
}

Measured memory_bytes: 0
import math
N = int(input())
max_D = int(2 + math.sqrt(N))
count = []
ans = 1
for i in range(2, max_D):
   if N % i == 0:
      count.append(0)
      while N % i == 0:
         N = N // i
         count[-1] += 1
   if N < i:
      ans = 0
      break
l = len(count)
for i in range(l):
   E = 2*count[i]
   j = 0
   while j * (j + 1) <= E:
      j += 1
   ans += j - 1
print(ans)

Measured memory_bytes: 63460
def main(N, W, P):
    dp = [[0]*(W + 1) for _ in range(N)]
    for j in range(P[0][0], W+1):
        dp[0][j] = P[0][1]

    for i in range(1, N):
        for j in range(1, W + 1):
            if j - P[i][0] < 0:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
                continue

            dp[i][j] = max(dp[i-1][j-P[i][0]] + P[i][1],
                           dp[i-1][j])

    print(dp[N-1][W])

if __name__ == "__main__":
    N, W = map(int, input().split()) #N個の製品、Wの制限
    P = [tuple(map(int, input().split())) for _ in range(N)]
    main(N, W, P)

Measured memory_bytes: 146004
/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int t[1000],p;
	char w,bot,str1[1000],str2[1000],str3[1000];
	scanf("%s %s",str1,str2);
	strcpy(str3, str1);
	strcat(str1,str3);
	if ( strstr(str1, str2) == NULL ) printf("No\n");
	else printf("Yes\n");
	return 0;
}



Measured memory_bytes: 3160
#!/bin/bash

read in1
read in2
read in3
a=(${in2// / })
b=(${in3// / })
n=0
for ((i=0; i < $in1; i++)); do
  p=$((${a[$i]} - ${b[$i]}))
  if [ $p -gt 0 ]; then
    n=$(($n + $p))
  fi
done
echo $n

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

int main() {
  string S;
  cin >> S;
  string Sunny, Cloudy, Rainy;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
  
}


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

int  main(void) {
  ll n, k, s;
  cin >> n >> k >> s;

  vector<ll> ans;

  if (s == 1) {
    rep (i, k) ans.push_back(1);
    rep (i, n - k) ans.push_back(100);
    rep (i, n) cout << ans[i] << endl;
    return 0;
  }
  if (s == 2) {
    rep (i, k) ans.push_back(2);
    rep (i, n - k) ans.push_back(100);
    rep (i, n) cout << ans[i] << endl;
    return 0;
  }

  rep (i, k) ans.push_back(s);
  rep (i, n - k) ans.push_back(s - 1LL);

  rep (i, n) cout << ans[i] << endl;
   
  return 0;
}

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

bool pal(string x){
  int n = x.size() / 2;
  for (int i = 0; i < n; i++){
    if (x.at(i) != x.at(x.size() - i - 1)){
      return false;
    }
  }
  return true;
}
        
int main(){
  string s;
  cin >> s;
  
  int n = s.size() / 2;
  string s_1(n, 0);
  for (int i = 0; i < n; i++){
    s_1.at(i) = s.at(i);
  }
  
  if (pal(s) && pal(s_1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef vector<vector<int>> Tree;

int main() {
  int n; cin >> n;
  Tree t(n);
  for (int i = 0; i < n-1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }

  auto bfs = [&](int u, int d[]) {
    queue<int> que;
    que.push(u);
    d[u] = 1;
    while (!que.empty()) {
      int u = que.front(); que.pop();
      for (int v : t[u]) {
        if (d[v] == 0) {
          que.push(v);
          d[v] = d[u] + 1;
        }
      }
    }
  };

  int fd[n] = {}, sd[n] = {};
  bfs(0, fd);
  bfs(n-1, sd);

  int fc = 0, sc = 0;
  for (int i = 0; i < n; i++) {
    if (fd[i] <= sd[i]) fc++;
    else sc++;
  }

  cout << (fc > sc ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <limits>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
typedef long long ll;
const ll INF = 1e10;
int N, M, R;
ll d[203][203];

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

  cin >> N >> M >> R;
  vector<int> r(R);
  int u;
  rep(i, R){
    cin >> u;
    u--;
    r[i] = u;
  }

  rep(i, N){
    rep(j, N){
      if (i == j) d[i][j] = 0ll;
      else d[i][j] = INF;
    }
  }

  int a, b;
  ll t;
  rep(i, M){
    cin >> a >> b >> t;
    a--, b--;
    d[a][b] = t, d[b][a] = t;
  }
  rep(k, N){
    rep(i, N){
      rep(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
  sort(r.begin(), r.end());
  ll min_d = INF;
  do {
    ll distance = 0;
    rep(i, R-1) distance+=d[r[i]][r[i+1]];
    min_d = min(min_d, distance);
  } while ( next_permutation(r.begin(), r.end()));

  cout << min_d << endl;  
  
  return 0;
}

Measured memory_bytes: 640