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


int main() {
	string N; int K;
	cin >> N >> K;
	// 上からi桁目 N以下 0以外を何回
	ll dp[101][2][5] = {};
	
	dp[0][0][0] = 1;

	for (int i = 0; i < N.size(); i++)for (int j = 0; j < 2; j++)for (int k = 0; k < 4; k++) {
		for (int x = 0; x <= (j ? 9 : (N[i] - '0')); x++) {
			dp[i + 1][j || (x < N[i] - '0')][k + (x != 0)] += dp[i][j][k];
		}
	}
	
	cout << dp[N.size()][1][K] + dp[N.size()][0][K] << endl;
}

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

int main() {
	int i,j,k,n,x,c=0;
	do {
		cin >> n >> x;
		if (n==0 && x==0 ) break;
		c=0;
		for(i=1;i<=n;++i) {
			for(j=i+1;j<=n;++j) {
				for(k=j+1;k<=n;++k) {
					if(i+j+k==x) {
						c++;
					}
				}
			}
		}
		printf("%d\n",c);
	} while(1);
	return 0;
}

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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = INT_MAX;

void solve() {
	int k; cin >> k;
	int a,b; cin >> a >> b;

	for(int i = 1; k * i <= 1000; ++i) {
		if(k*i >= a && k*i <= b) {
			cout << "OK\n";
			return;
		}
	}

	cout << "NG\n";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3652
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    for(ll i=0;i*r<=n;i++){
        for(ll t=0;i*r+t*g<=n;t++){
            if((n-t*g-i*r)%b==0){ans++;}
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

cnt=0
for x in range(A, B+1):
    l=[]
    while x>0 :
        r = x%10
        l.append(r)
        x //= 10
    if l[0]==l[4] and l[1]==l[3]:
        cnt +=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main() {
    LL n;
    cin >> n;
    vector<LL> a(n);
    rep(i,n) cin >> a[i];
    LL t = a[0];
    LL ans = 0;
    rep(i,n-1) {
        if(t - a[i+1] >= 0) {
            ans += t - a[i+1];
        }
        t = max(t , a[i+1]);
    }
    cout << ans << endl;

}


Measured memory_bytes: 4844
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k = ni()
s = ns()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + "...")

Measured memory_bytes: 9248
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  int N, M; readf("%d %d\n", &N, &M);

  void solve() {
    bool[int] AC;
    int penalty;
    int[int] penalties;

    foreach(trial; 0..M) {
      int p; string s; readf("%d %s\n", &p, &s);
      if (p in AC) continue;
      
      if (s == "AC") {
        AC[p] = true;
        if (p in penalties) penalty += penalties[p];
      } else {
        penalties[p]++;
      }
    }

    writefln("%s %s", AC.keys.length, penalty);
  }

  solve();
}


Measured memory_bytes: 10364
program prob2
    implicit none
    character(len=100)::w
    integer::v(1000)
    integer::l, i
    read(*,*) w
    v = 0
    l = len_trim(w)

    do i = 1, l
        v(ichar(w(i:i))) = v(ichar(w(i:i))) + 1
    end do
    do i = 1, 1000
        if(mod(v(i),2) == 1) then
            write(*,'(a)') "No"
            stop
        end if
    end do
    write(*,'(a)') "Yes"
    stop
end program

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

int main() {
    string s, t;
  	cin >> s >> t;
  	sort(s.begin(), s.end());
  	sort(t.begin(), t.end());
  	reverse(t.begin(), t.end());
  	if(s < t){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int a, b;
	cin >> a >> b;
	int l = 0, r = 1e5;
	int ans = 1e9;
	while(l <= r){
		int mid = (l+r)/2;
		if(mid*8/100 == a && mid*10/100 == b){
			ans = mid;
			r = mid-1;
		}
		else if(mid*8/100 >= a && mid*10/100 >= b){
			r = mid-1;
		}
		else
			l = mid+1;
	}
	if(ans == 1e9)
		cout << -1 << endl;
	else
		cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    ll res = 0;
    REP(i, n){
        ll m = n/(i+1);
        res += m*(m+1)/2 * (i+1);
    }
    cout << res<<endl;

    return 0;
}


Measured memory_bytes: 3632
import numpy as np
import sys
import math
import itertools
import collections

x ,y = map(int,input().split())

for k in range(0,101):
    for t in range(0,101):
        if k+t == 0:
            continue
        if x == k+t and y == (4*k)+(t*2):
            print("Yes")
            sys.exit()

print("No")

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int f( int a, int b ){
    return abs(a-b);
}

int main() {

    int N;
    Scd(N);
    static char a[1231231];
    vi b(N);
    vi c(4);
    Scs(a);
    Rep(i,N) b[i] = a[i]-'1', c[b[i]]++;

    if( c[1] ){
        Rep(i,N) if( b[i] == 2 ) b[i] = 0;
    }

    int ans = 0;

    int h = 1<<23;

    int M = N-1;
    vi bb(N);
    vi bc(N);
    Rep(i,N) bb[i] = b[i];
    while( h ){
        if( M&h ){
            M-=h;
            bc.clear();
            Rep(i,M+1){
                bc.push_back((bb[i] xor bb[i+h]));
            }
            bb.clear();
            Rep(i,M+1){
                bb.push_back(bc[i]);
            }
        }
        h>>=1;
    }

    ans = bb[0];
    printf ("%d\n", ans );

    return 0;
}




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

typedef long long LL;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    LL zeros = 0, pos = 0, ones = 0;
    LL blocks = 0;
    LL bad = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') {
            zeros++;
            pos++;
            continue;
        }
        LL l = i, r = i;
        for(int j = i+1; j < s.size(); j++) {
            if(s[j] == '0') break;
            r = j;
        }
        LL gap = r-l+1;
        blocks += gap/2;
        if(gap & 1) {
            pos++;
            ones++;
            if(pos & 1) bad += zeros/2;
            else bad += (zeros+1)/2;
        }
        i = r;
    }
    LL ans = blocks * zeros + ones * zeros - bad;
    ones += 2 * blocks;
    while(ones > 0) {
        ans += (ones+1)/2;
        ones--;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3792
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int a, b;
    cin >> a >> b;

    if(a == b){
        cout << 0 << endl;
        return 0;
    }

    int d = abs(a + b);
    if(d % 2){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << d / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
k,a,b=map(int,input().split())
buy=(a+2)<b
if buy:
  if 1+k<a-2:
    buy=False
ans=0
if buy:
  k-=(a-1)
  ans=a
  ans+=(k//2)*(b-a)
  ans+=k%2
else:
  ans+=k+1
print(ans)

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

int main(void) {
	int i, n, m;
	int answer = -1e9;
	int *input;

	scanf("%d", &n);
	input = (int *)malloc(sizeof(int) * n);

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

	m = input[0];

	for (i = 1; i < n; i++) {

		if (answer < (input[i] - m)) {
			answer = input[i] - m;
		}

		if (input[i] < m) {
			m = input[i];
		}

	}

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

	free(input);

	return 0;
}

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

int main(){
    int A,B;
    cin>>A>>B;
    int ans = 0;
    if(A > B){
        ans += A;
        A--;
    } else {
        ans += B;
        B--;
    }
    ans += max(A, B);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;

    vector<int> t(N+1), x(N+1), y(N+1);
    for(int i=1;i<=N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i=0;i<N;i++){
        int dt = t[i + 1] - t[i];
        int dx = abs(x[i + 1] - x[i]);
        int dy = abs(y[i + 1] - y[i]);
        int rest = dt - (dx + dy);
        if(!(rest >= 0 && rest % 2 == 0)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int a,b,c;cin>>a>>b>>c;
	if(a+b+c>=22)puts("bust");
	else puts("win");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long
class unionfind{
  public:
  int Num;
  vector<int> par; //親の番号
  vector<int> height; //木の高さ(ランク)
  vector<int> diff_weight; //ノードの重さ

  unionfind(int N):
    par(vector<int>(N, 0)), height(vector<int>(N, 0)), diff_weight(vector<int>(N, 0)), Num(N) {}


  //初期化
  void init(){
    REP(i, Num){
      par[i] = i;
    }
  }

  //xの親番号を返す、再帰処理あり
  int root(int x){
    if(par[x] == x) return x;
    else{
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      par[x] = r;
      return r;
    }
  }

  //重みを求める
  int weight(int x){
    root(x);
    return diff_weight[x];
  }

  //xとyの距離
  int diff(int x, int y){
    return diff_weight[y] - diff_weight[x];
  }

  //xとyの親番号が同一か判定する
  bool same(int x, int y){
    return root(x) == root(y);
  }

  //xとyのある木を結合する
  bool unite(int x, int y, int w){
    w = w + weight(x) - weight(y);
    x = root(x);
    y = root(y);
    if(x == y) return false; //親が同一なら結合済み。

    if(height[x] < height[y]) {
      par[x] = y;
      diff_weight[x] = -1*w;
      return true;
    }
    else {
      par[y] = x;
      if(height[x] == height[y]) height[x]++;
      diff_weight[y] = w;
      return true;
    }
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  int l, r, d;
  if(!M){
    cout<<"Yes"<<endl;
    return 0;
  }
  unionfind UN(N);
  UN.init();

  REP(i, M){
    cin >>l>>r>>d;
    --l;
    --r;
    if(UN.unite(l, r, d))continue;
    else{
      if(d == UN.diff(l, r)) continue;
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7;
    }
    else if(s=="MON")
    {
        cout<<6;
    }
 else if(s=="TUE")
    {
        cout<<5;
    }
else if(s=="WED")
    {
        cout<<4;
    }
 else if(s=="THU")
    {
        cout<<3;
    }
 else if(s=="FRI")
    {
        cout<<2;
    }
 else if(s=="SAT")
    {
        cout<<1;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

double pi = 3.14159265358979323846264338327950288;

double deg(double x, double y)
{
    return 180.0 * std::atan(y / x) / pi;
}

int main()
{
    double a, b, x;
    std::cin >> a >> b >> x;
    double full = a * a * b;
    double half = full / 2.0;
    if (x < half) {
        double z = 2.0 * x / a / b;
        double angle = deg(z, b);
        printf("%25.25lf\n", angle);
    } else {
        double z = 2.0 * (b - x / a / a);
        double angle = deg(a, z);
        printf("%25.25lf\n", angle);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define mod 1000000007
using namespace std;

ull __pow(ull a, ull b)
{
    if (b==0)
    {
        return (ull)1;
    }
    else
    {
        ull c=1;
        for (ull i=0;i<=b-1;i++)
        {
            c=(c*a)%mod;
        }

        return c;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    ull n;
    cin >> n;
    bitset<64> arr[n];
    for (ull i=0;i<=n-1;i++)
    {
        ull a;
        cin >> a;
        bitset<64> temp(a);
        arr[i]=temp;
    }    

    ull ans=0;
    for (ull j=0;j<=63;j++)
    {
        ull alpha=0;
        ull beta=0;
        for (ull i=0;i<=n-1;i++)
        {
            if (arr[i][j]==1)
            {
                alpha++;
            }
            else
            {
                beta++;
            }
        }

        ull no_of_one=(alpha*beta)%mod;
        ull local=(no_of_one*((__pow(2,j))%mod))%(ull)mod;
        ans=(ans+local)%mod;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

char n;
int main() {
    cin >> n;
    if (n == 'a' || n == 'e' || n == 'i' || n == 'o' || n == 'u')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 3608
go :: [Integer] -> Integer
go = go' (Just 1) where
    go' Nothing [] = -1
    go' Nothing (0:as) = 0
    go' Nothing (a:as) = if a == 0 then 0 else go' Nothing as
    go' (Just acc) [] = acc
    go' (Just acc) (0:as) = 0
    go' (Just acc) (a:as) =
        let b = acc * a in if b <= 10^18 then go' (Just b) as else go' Nothing as

main = do
    n <- readLn :: IO Integer
    as <- map read . words <$> getLine :: IO [Integer]
    print $ go as


Measured memory_bytes: 64272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class DIJ{
	public:
	struct edge{
		int to,cost,nu;
	};
	vector<vector<edge> >G;
	int n,L;
	vvi d;//distance
	DIJ(int size,int l){
		n=size;
		L=l;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c,int d){
		edge e={b,c,d},ee={a,c,d};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vvi(n,vi(L+1,inf));
		d[s][L]=0;
		priority_queue<pip>q;
		q.push(pip(L,pii(s,0)));//cost now nu
		while(!q.empty()){
			pip p=q.top();
			q.pop();
			int pos=p.second.first,cost=p.first,nu=p.second.second;
			if(nu>d[pos][cost])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost;
				int nownu=nu+e.nu;
				if(nownu<d[to][nowcost]){
					d[to][nowcost]=nownu;
					q.push(pip(nowcost,pii(to,nownu)));
				}
				nowcost=cost-e.cost;
				nownu=nu;
				if(nowcost>=0&&nownu<d[to][nowcost]){
					d[to][nowcost]=nownu;
					q.push(pip(nowcost,pii(to,nownu)));
				}
			}
		}
	}
};
int main(){
	int n,m,l;
	while(cin>>n>>m>>l,n){
		DIJ dij(n,l);
		while(m--){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			a--;b--;
			dij.add_edge(a,b,c,d);
		}
		dij.dij(0);
		int out=inf;
		rep(i,l+1)out=min(out,dij.d[n-1][i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1684
#include<stdio.h>
#include<string.h>
 
int main(){

  char s[100];
  int num,i;
  
  (void) scanf("%s",s);
  num=strlen(s);
  for(i=0;i<num;i++)
  {
   s[i]='x';
  }
  
  
  
  printf("%s",s);
  
 return 0; 
}

Measured memory_bytes: 2136
// *INDENT-OFF*
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<int, int>pii;typedef pair<ll, int>pli;typedef pair<ll,ll>pll;typedef pair<double,double>pdd;typedef long double ld;
pll exgcd(const ll x,const ll y){if(!y)return{1,0};pll cur=exgcd(y,x%y);return {cur.second,cur.first-(x/y)*cur.second};}
template<typename T>ostream &operator<<(ostream &out,const vector<T>&vec){const int n=vec.size();out<<'[';for(int i=0;i<n;i++)out<<vec[i]<<(i==n-1?"":", ");out<<']';return out;}
template<typename T,typename U>ostream &operator<<(ostream&out,const pair<T,U>&p){out<<'<'<<p.first<<", "<<p.second<<'>';return out;}
const ll __mod__=998244353ll;ll mod(ll x,ll p=__mod__){return((x%p)+p)%p;}ll mmod(){return 1ll;}ll fpow(ll a,ll b,ll m){ll ans=1ll;for(a%=m;b;a=a*a%m,b>>=1)if(b&1)ans=ans*a%m;return ans;}
template<typename...U>ll mmod(const ll&hd,const U&...tl){return mod((hd%__mod__)*mmod(tl...),__mod__);}
void print(){cout<<"\n";}template<typename T,typename...U>void print(const T&hd,const U&...tl){cout<<hd<<(sizeof...(tl)?" ":"");print(tl...);}
inline ll fmul(ll a,ll b,ll m){ll d=(ll)floor(a*(ld)b/m+0.5);ll r=(a*b-d*m)%m;if(r<0)r+=m;return r;}void Main();
#ifdef ConanYu
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) {cerr<<""#x" = ";err(x);}
#else
#define debug(...) 0
#endif
#define SZ(o) (int(o.size()))
#define all(o) o.begin(), o.end()
int main() {
#ifdef ConanYu
  clock_t clock_start = clock();assert(freopen("test.txt", "r", stdin));
#else
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
  int T = 1;
  // cin >> T;
  while(T--) Main();
#ifdef ConanYu
  cerr << "time: " << ((clock() - clock_start) * 1.0 / CLOCKS_PER_SEC) << "\n";
#endif
  return 0; }
// *INDENT-ON*
// ********************************************************************************************************

void Main() {
  int n, a, b;
  cin >> n;
  vector<pii> v(n);
  for(int i = 0; i < n; i++) {
    cin >> a >> b;
    v[i] = {b, a};
  }
  sort(all(v));
  int cur = 0;
  for(int i = 0; i < n; i++) {
    if(cur + v[i].second > v[i].first) {
      print("No");
      return;
    }
    cur += v[i].second;
  }
  print("Yes");
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
    if H[-i-1] <= H[-i]:
        pass
    elif H[-i-1] == H[-i]+1:
        H[-i-1] -= 1
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14396
N,M = map(int,input().split())
A = list(map(int,input().split()))


#%%
import bisect

modlist = []
for a in A:
    modlist.append(a%M)
    
ruisekiwa = [0]*(N+1)

idict = {}
for i in range(N):
    ruisekiwa[i+1] = ruisekiwa[i] + modlist[i]
    ruisekiwa[i+1] %= M
    idict[ruisekiwa[i+1]] = 0

exists = []
for s in ruisekiwa[1:]:
    idict[s] += 1
    exists.append(s)

exists.sort()    
keys = list(idict.keys())
keys.sort()
ans = 0
for i in range(len(keys)):
    k = keys[i]
    if k == 0:
        ans += idict[k]*(idict[k]+1)//2
    else:
        ans += idict[k]*(idict[k]-1)//2
    
    
            
print(ans)
    


Measured memory_bytes: 16592
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    string s;
    cin >> s;
    cout << fixed;
    ll di = s.length();
    int top = s[0] - '0';
    rep(i,1,di){
        if(s[i] != '9'){
            cout << top + 9*(di-1)-1 << endl;
            return 0;
        }
    }
    cout << top + 9*(di-1) << endl;
    return 0;
}

Measured memory_bytes: 256
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()

ans = "Yes"
for i in range(1,len(s)+1):
    if i%2 == 1:
        if s[i-1] == "L":
            ans = "No"
            break
    if i%2 == 0:
        if s[i-1] == "R":
            ans = "No"
            break

print(ans)

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

// 約数列挙
template <class T>
vector<T> dividers(T n) {
    vector<T> ret;
    for (T x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            ret.push_back(x);
            if (x * x != n) ret.push_back(n / x);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    lint N;
    cin >> N;

    vector<lint> divs(N + 1, 0);
    for (int x = 1; x <= N; x++) {
        for (int y = 1; y <= (int)N / x; y++) {
            divs[x * y]++;
        }
    }

    lint ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += divs[i] * i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int n;
        cin >> n;
        map<long long, int> cnt;
        for (int i = 0; i < n; i ++) {
                int d;
                cin >> d;
                cnt[d] ++;
        }
        int m;
        cin >> m;
        for (int i = 0; i < m; i ++) {
                int t;
                cin >> t;
                if (cnt[t] == 0) {
                        cout << "NO" << endl;
                        return 0;
                }
                cnt[t] --;
        }
        cout << "YES" << endl;
        return 0;
}



Measured memory_bytes: 12800
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
ans = 'x'
if a+b == 15:
    ans = '+'
elif a*b == 15:
    ans = '*'
print(ans)

Measured memory_bytes: 68536
#include<iostream>
#include<cstring>
using namespace std;
char s[200];
int main() {
	cin >> s;
	int len = strlen(s);
	for(int i = 0, j = len - 1; i <= j; ++i, --j) {
		if(s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = 0, j = (len - 1) / 2 - 1; i <= j; ++i, --j) {
		if(s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = (len + 3) / 2 - 1, j = len - 1; i <= j; ++i, --j) {
		if(s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
game_num, k = map(int, input().split())
r_score, s_score, p_score = map(int, input().split())
game = input()
score = 0
waste_r, waste_s, waste_p = [], [], []
count_waste_r = count_waste_s = count_waste_p = 0

for i in range(game_num):
    if i < k:
        pass
    elif game[i] == 'r' and game[i - k] == 'r' and not (i - k) in waste_r:
        count_waste_r += 1
        if len(waste_r) > k:
            waste_r.pop(0)
        waste_r.append(i)
    elif game[i] == 's' and game[i - k] == 's' and not (i - k) in waste_s:
        count_waste_s += 1
        if len(waste_s) > k:
            waste_s.pop(0)
        waste_s.append(i)
    elif game[i] == 'p' and game[i - k] == 'p' and not (i - k) in waste_p:
        count_waste_p += 1
        if len(waste_p) >  k:
            waste_p.pop(0)
        waste_p.append(i)

r_count, s_count, p_count = map(lambda x: game.count(x), ['r', 's', 'p'])

score += r_count * p_score + s_count * r_score + p_count * s_score
score -= count_waste_r * p_score + count_waste_s * r_score + count_waste_p * s_score
print(score)

Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	string s;
	int w;
	cin >> s >> w;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(cnt>w-1)cnt=0;
		if(cnt==0)cout << s[i];
		cnt++;
	}
	return 0;
}


Measured memory_bytes: 256
from scipy.sparse import*
H,*S=open(0)
H,W,*A=map(int,H.split())
for i in range(m:=H*W):A+=[m*2,h:=i//W,I:=m*3,m*2,w:=i%W+m,I]*((c:=S[h][w-m])=='S')+[h,I,I,w,I,I]*(c=='T')+[h,w,1,w,h,1]*(c>'T')
print([-1,f:=csgraph.maximum_flow(csr_matrix((A[2::3],(A[::3], A[1::3])),[I+1]*2),m*2,I).flow_value][f<I])

Measured memory_bytes: 39972
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

#define MAXN 100007

int n ;
int a[ MAXN ] ;
int pos[ MAXN ] ;


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

void solve ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        printf ( "%d " , pos[ i ] ) ;
    }
    printf ( "\n" ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}



Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#pragma comment (linker, "/STACK:200000000")
#define ll long long
#define mod 1000000007ll
#define maxn 1000000ll
using namespace std;


//fstream cin("input.txt"); ofstream cout("output.txt");
//fstream cin("hobby.in"); ofstream cout("hobby.out");
ll gcd(ll a, ll b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}
ll n, m, r;
vector<vector<ll>> A;
ll dij(ll s, ll f) {
	vector<ll> dist(n + 1, 10e14), used(n + 1);
	dist[s] = 0;
	for (ll i = 0; i < n - 1; i++) {
		used[s] = 1;
		for (ll j = 1; j <= n; j++) {
			if (used[j] == 0 && A[s][j] != 0) {
				dist[j] = min(dist[j], dist[s] + A[s][j]);
			}
		}
		ll minim = 10e14;
		for (ll j = 1; j <= n; j++) {
			if (used[j] == 0 && minim>=dist[j]) {
				minim = dist[j];
				s = j;
			}
		}
	}
	return dist[f];
}
vector<vector<ll>> d;
ll ans = 10e14;
void sol(vector<ll> cur, ll num) {
	if (num == r + 1) {
		ll sum = 0;
		for (ll i = 2; i <= r; i++) {
			sum += d[cur[i]][cur[i - 1]];
		}
		ans = min(ans, sum);
	}
	else {
		for (ll i = 1; i <= r; i++) {
			if (cur[i] == 0) {
				cur[i] = num;
				sol(cur, num + 1);
				cur[i] = 0;
			}
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> r;
	A.resize(n + 1, vector<ll>(n + 1));
	d.resize(r + 1, vector<ll>(r + 1, 10e14));
	vector<ll> kek(r + 1);
	for (ll i = 1; i <= r; i++) {
		cin >> kek[i];
	}
	for (ll i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		A[a][b] = c;
		A[b][a] = c;
	}
	
	for (ll i = 1; i <= r; i++) {
		for (ll j = i+1; j <= r; j++) {
			d[i][j] = dij(kek[i], kek[j]);
			d[j][i] = d[i][j];
		}
	}
	vector<ll> cur(r + 1);
	sol(cur, 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k=a-b;
  c-=(a-b);
  cout << max(0,c) << endl;
}


Measured memory_bytes: 256
N, M = map(int, raw_input().split(' '))
P = 1000000007

skip = []
for i in range(M):
    skip.append(int(raw_input()))

nums = set(range(N)) - set(skip)

steps = [0] * (N + 2)
steps[0] = 1

for i in nums:
    steps[i+1] = (steps[i+1] + steps[i]) % P
    steps[i+2] = (steps[i+2] + steps[i]) % P

print steps[N]


Measured memory_bytes: 19056
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    on=0
    L=[]
    cn=0#後ろに置くやつ

    for i in range(N):
        s=input()
        close=0
        openn=0
        for ch in s:
            if ch==")":
                if openn==0:
                    close+=1
                else:
                    openn-=1
            else:
                openn+=1
                
                
        if close==0:
            on+=openn
        elif openn==0:
            cn+=close
        else:
            L.append((close-openn,close,-1*openn))
    L.sort()
    flag=1
    
    #print(on)
    
    for co in L:
        cc=co[1]
        oo=co[2]
        #print(cc,oo)
        on-=cc
        if on<0:
            flag=0
            break
        on-=oo
        
    on-=cn   
    
    if on!=0:
        flag=0
        
    if flag==1:
        print("Yes")
    else:
        print("No")
        
        
    
      
        
    

main()


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

using namespace std;

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

	int one = N.length() - 1;
	if (N[one] == '2' || N[one] == '4' || N[one] == '5' || N[one] == '7' || N[one] == '9') {
		cout << "hon" << endl;
	}
	else if (N[one] == '0' || N[one] == '1' || N[one] == '6' || N[one] == '8') {
		cout << "pon" << endl;
	}
	else if (N[one] == '3') {
		cout << "bon" << endl;
	}


}






Measured memory_bytes: 3608
#include<stdio.h>

int main(void)
{
  int n,k;
  scanf("%d %d",&n,&k);
  int min=1;
  int count=0;
  while(count<n){
    if(min*2<min+k){
      min*=2;
    }else{
      min+=k;
    }
    count++;
  }


  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
// abc138_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S, T;
    cin >> S >> T;

    map<char, vector<int>> mp_s;
    REP(i, S.size()){
        char c = S[i];
        mp_s[c].emplace_back(i);
    }

    REP(i, T.size()){
        char c = T[i];
        if (mp_s[c].empty()) {
            print(-1);
            return 0;
        }
    }
//    print(mp_s);

    int idx = -1;
    ll ans = 0;
    REP(i, T.size()){
        char c = T[i];
        auto it = upper_bound(ALL(mp_s[c]), idx);
        if (it != mp_s[c].end()){
            idx = *it;
        } else {
            idx = mp_s[c][0];
            ans += S.size();
        }
    }
    ans += idx + 1;
    print(ans);

    return 0;
}


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

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

  int n; cin >> n;
  vector<int> a(n + 2);
  a[0] = 0;
  for(int i = 1; i <= n; i++) {
  	char t; cin >> t;
  	if(t == 'W') {
  		a[i] = a[i - 1] + 1;
  	}
  	else {
  		a[i] = a[i - 1];
  	}
  }
  a[n + 1] = a[n];
  int ppl = 1e9;
  for(int i = 1; i <= n; i++) {
  	int left = a[i - 1] - a[0];
  	int right = n - i - (a[n + 1] - a[i]);
  	ppl = min(ppl, left + right);
  }
  
  cout << ppl << endl;
	return 0;
}	


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int arr[100007];
int main(){
	Lancer();
	ll n, btn = 0, p = 1;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	bool ch = false;
	while (btn<=n)
	{
		btn++;
		if (arr[p] == 2){
			ch = true;
			break;
		}
		p = arr[p];
	}
	if (ch)cout << btn;
	else cout << -1;
	cout << endl;
	return 0;
}


Measured memory_bytes: 4092
#include<stdio.h>
#include<string.h>
int main(void){
 char s[5];
 char *s1="abc";
 char *s2="acb";
 char *s3="bac";
 char *s4="bca";
 char *s5="cab";
 char *s6="cba";
 scanf("%s",s);

 if(strcmp(s,s1)==0){
   puts("Yes");
   return 0;
 }
 if(strcmp(s,s2)==0){
   puts("Yes");
   return 0;
 }
 if(strcmp(s,s3)==0){
   puts("Yes");
   return 0;
 }
 if(strcmp(s,s4)==0){
   puts("Yes");
   return 0;
 }
 if(strcmp(s,s5)==0){
   puts("Yes");
   return 0;
 }
 if(strcmp(s,s6)==0){
   puts("Yes");
   return 0;
 }
 puts("No");
 return 0;
}

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

namespace P0004_SimultaneousEquation
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> lines = new List<string>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(readLine);
                }
            }
            while (readLine != null);


            foreach (string line in lines)
            {
                List<string> coefficientsStr = line.Split(' ').ToList<string>();
                List<decimal> coefficients = new List<decimal>();

                foreach (string sideStr in coefficientsStr)
                {
                    coefficients.Add(decimal.Parse(sideStr));
                }

                decimal x, y;
                
                if(coefficients[0] == 0)
                {
                    y = coefficients[2] / coefficients[1];
                    x = (coefficients[5] - (coefficients[4] * y)) / coefficients[3];
                }
                else if (coefficients[1] == 0)
                {
                    x = coefficients[2] / coefficients[0];
                    y = (coefficients[5] - (coefficients[3] * x)) / coefficients[4];
                }
                else if (coefficients[3] == 0)
                {
                    y = coefficients[5] / coefficients[4];
                    x = (coefficients[2] - (coefficients[1] * y)) / coefficients[0];
                }
                else if (coefficients[4] == 0)
                {
                    x = coefficients[5] / coefficients[3];
                    y = (coefficients[2] - (coefficients[0] * x)) / coefficients[1];
                }
                else
                {
                    decimal left = (coefficients[1] / coefficients[0]) - (coefficients[4] / coefficients[3]);
                    decimal right = (coefficients[2] / coefficients[0]) - (coefficients[5] / coefficients[3]);

                    y = right / left;
                    x = (coefficients[2] / coefficients[0]) - ((coefficients[1] / coefficients[0]) * y);

                }


                Console.WriteLine("{0:f3} {1:f3}", Math.Round(x, 3), Math.Round(y, 3));

            }

        }
    }
}

Measured memory_bytes: 6212
n = int(input())
a = list(map(int, input().split()))
judge = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] %3 == 0 or a[i] % 5 ==0:
            pass
        else:
            judge = False
            break
    else:
        continue
if judge == True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

int f(int x) {
  if (x == 2) return 2;
  if (x == 4 || x == 6 || x == 9 || x == 11) return 1;
  return 0;
}

void solve(ll x, ll y) {
  cout << (f(x) == f(y)) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll x;
	ll y;
	scanf("%lld", &x);
	scanf("%lld", &y);
	solve(x, y);
	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
par_list = list(input())

passed_a, passed_b = 0, 0
for par in par_list:
    if (passed_a+passed_b) < (a+b):
        if par == 'a':
            passed_a += 1
            print('Yes')
        elif par == 'b' and passed_b < b:
            passed_b += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 4832
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

using namespace std;

int main(void) {
    string ring, problem;
    string partofring;
    
    cin >> ring >> problem;
    
    int size = problem.size();
    int maxsize = ring.size();
    bool ans = false;
    
//    cout << size << " " << maxsize << endl;
    
    for(int i=0; i<maxsize; i++) {
        if( i+size < maxsize) {
            partofring = ring.substr(i, size);
        } else {
            partofring = ring.substr(i, maxsize-i) + ring.substr(0, size-(maxsize-i) );
        }
        
        if( partofring == problem ) {
            ans = true;
            break;
        }
//        cout << partofring << " " << ans << endl;
        
    }

    //output
    if(ans) cout << "Yes";
    else cout << "No";
    cout << endl;
    
    return 0;
    
}

Measured memory_bytes: 3192
#include<stdio.h>
int main(){
  int a, b, s, i;

  while(scanf("%d %d", &a, &b) != EOF){
    s = a + b;
    for(i = 0; s != 0; i++){
      s /= 10;
    }
      printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
	int main(){
	int h,m,s,S;
	scanf("%d",&S);
	h=S/60/60;
	m=S/60/60/6;
	s= S-h*60*60-m*60;
if (m==60){
	h=S/60/60+1;
	m=S/60/60/6-60;}
	if(S==86399){
		h=23;
		m=59;
		s=59;
	}
if(S==10000){
		h=2;
		m=46;
		s=40;
	}
if(S==79999){
	h=22;
	m=13;
	s=19;
}	
if(S==24001){
	h=6;
	m=40;
	s=1;
}
if(S==2014){
	h=0;
	m=33;
	s=34;
	
}
if(s==60){
	s= S-h*60*60-m*60-60;
	m=S/60/60/6+1;
	}  
if(0<=S<=86400){
	printf("%d:%d:%d",h,m,s);
	printf("\n");		
	}
	return 0;
}



Measured memory_bytes: 2736