akhauriyash/Code-Regression huggingface dataset:
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int dp[3];
//int mem[N];
vector<int>v;
/*int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	if (i + 1 < n)
		ret = min(ret, solve(i + 1) + abs(v[i] - v[i + 1]));
	if (i + 2 < n)
		ret = min(ret, solve(i + 2) + abs(v[i] - v[i + 2]));
	ret = ret == Mx ? 0 : ret;
	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	//cout << solve(0) << endl;;

	for (int i = 0; i < n; i++) {
		int& ret = dp[i % 3];
		ret = Mx;
		if (i - 1 >= 0)
			ret = min(ret, dp[(i - 1) % 3] + abs(v[i] - v[i - 1]));
		if (i - 2 >= 0)
			ret = min(ret, dp[(i - 2) % 3] + abs(v[i] - v[i - 2]));

		ret = ret == Mx ? 0 : ret;
	}

	cout << dp[(n - 1)%3] << endl;
	return Accepted;
}

Measured memory_bytes: 3560
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP(i, 1, n+1)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

void printv(vector<int> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}

int fact(int n){
    int res = 1;
    rep(i, n){ res *= i+1; }
    return res;
}

int perm(int n, int r){
    int res = 1;
    rrep(i,r){
        res *= n-i;
    }
    return res;
}

int comb(int n, int r){
    return perm(n, r) / fact(r);
}

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll N,M,K;

int main() {
    COMinit();
    
    cin>>N>>M>>K;
    
    ll res = 0;
    
    rep(i,K+1){
        // //K=0
        // M*pow(M-1,N-1)
        // //K=1
        // comb(N-1,1) * M*pow(M-1, N-2)
        //K=i
        //cout << "K:" << i << endl;
        //cout << "COM:" << COM(N-i,i) << endl;
        //cout << (COM(N-i,i) * M % MOD) * modpow(M-1, N-i-1,MOD)%MOD << endl;
        res += (COM(N-1,i) * M % MOD) * modpow(M-1, N-i-1,MOD)%MOD;
        res %= MOD;
    }
    cout << res << endl;
    //cout << M*modpow(M-1,N-1,MOD)%MOD;
}

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

int v[200005];

int main(){
	int n , m;
	cin >> n;
	for(int i=0;i<n - 1;i++){
		int a;
		cin >> a;
		v[a]++;
	}
	for(int i=1;i<=n;i++) cout << v[i] << '\n';
}

Measured memory_bytes: 4312
const memo = {}

const main = stdin => {
  const input = stdin.trim().split('\n')
  const [N] = input[0].split(' ').map(x => parseInt(x))
  const set = new Set()
  for (let i = 0; i < N; i++) {
    set.add(input[i + 1])
  }

  console.log(set.size)
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29588
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll n , m , k , i , j , t , q , cnt , cnt1 , cnt2 , cnt3;
ll cnt4 , cnt5 , ans , ans1 , ans2 , ans3 , sum , sum1 , sum2;
ll mini = 1e9 , maxi = -999;
int main(){
	sonic;
	cin >> n;
	for(i = 1 ; i <= n ; i *= 2){
	}
	i/=2;
	cout << i * 2 - 1;
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****
 
//   *  *  *****  *
//   * *     *    *
//   **      *    *
//   * *     *    *
//   *  *    *    ****
 
//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *

Measured memory_bytes: 256
H,W = map( int, input().split() )

x = []

for _ in range(H):
    row = list( input() )
    x.append(row)

blacks = []
count = 0

for i in range(H):
    for j in range(W):
        a = x[i][j]
        if a == '#':
            count += 1
            blacks.append((i,j))

result = 0
DIRS = [(0,1),(0,-1),(1,0),(-1,0)]

while count < H*W:
    result += 1
    new_blacks = []
    for black in blacks:
        for dir in DIRS:
            i = black[0]+dir[0]
            j = black[1]+dir[1]
            if i < 0 or i >= H:
                continue
            if j < 0 or j >= W:
                continue
            if x[i][j] == '.':
                new_blacks.append((i,j))
                x[i][j] = '#'
                count += 1
    blacks = new_blacks

print(result)

Measured memory_bytes: 125636
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e16+1);
const long long int MIN = (ll)(-1e16-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/
pll dp[3002][3002]; //1-> Max, 2->Min
vll a;

pll count(ll x, ll y){
    if(dp[x][y] != mp(MIN,MAX)) return dp[x][y];
    pll p1 = count(x+1,y);
    pll p2 = count(x,y-1);
    dp[x][y].first = max(p1.second+a[x] , p2.second+a[y]);
    dp[x][y].second = min(p1.first-a[x] , p2.first-a[y]);
    return dp[x][y];
}

int main(){
    _cin;
    cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    a.assign(n+1,0);
    fo(i,n) cin >> a[i+1];

    fo(i,3002) fo(j,3002) dp[i][j]={MIN,MAX};
    fo(i,n+1) dp[i][i]=(n%2) ? mp(a[i],a[i]) : mp(-a[i],-a[i]);
    dp[3001][3001]=mp(0,0);
    pll p = count(1,n);
    // repa(i,1,n+1){
    //     repa(j,i,n+1) cout << dp[i][j].first << ',' << dp[i][j].second << ' ';
    //     cout << endl;
    // }
    // cout << dp[1][1].first << endl;
    cout << p.first;

}
 return 0;      
}

Measured memory_bytes: 141312
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))

root = [1]
setroot = set(root)

for i in range(N):
    if A[root[-1]-1] in setroot:
        start = root.index(A[root[-1]-1])
        break
    setroot.add(A[root[-1]-1])
    root.append(A[root[-1]-1])

roop = root[start:]

if K <= start:
    print(root[K])
else:
    print(root[(K-start)%len(roop)+start])

Measured memory_bytes: 32300
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/









int main()
{
  //IOS; /* making cin faster */
  int N,i;
  CIN2(N,i);

  PRINTD(N-i+1);
  

  

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
      static List<int> a = new List<int>();
      static List<int> b = new List<int>();
      static List<int> c = new List<int>();
    static decimal result;
    static decimal N,K;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく


    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read1();
      result=decimal.MaxValue;
      K=(decimal)Math.Sqrt((double)N)+1;
      for(int i=1;i<=K;i++){
        decimal num=(N/i-1)+(i-1);
      if(N%i==0 && num<result){result=num;}
      }
      
        Console.WriteLine(result.ToString());

    }
  
    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = decimal.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
      for(int i=0;i<K;i++)
      {
        string[] tmp = Console.ReadLine().Split(' ');
        a.Add(int.Parse(tmp[0]));
        b.Add(int.Parse(tmp[1]));
        c.Add(0);
        string[] tmp2 = Console.ReadLine().Split(' ');
        for(int j=0;j<b[i];j++){c[i]+=(int)Math.Pow(2,int.Parse(tmp2[j])-1);}
      }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>


int main(){

int n, k, l[50], sum=0, max, x;
int i, j;

scanf("%d %d", &n, &k);

for(i=0;i<n;i++){
  scanf("%d", &l[i]);
}
for(i=0;i<k;i++){
  max=0;
  for(j=0;j<n;j++){
    if(max<l[j]){
      max=l[j];
      x=j;
    }
  }
  sum+=max;
  l[x]=0;
}
printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  string s;
  cin >> s;
  map<char, int> m;
  for (auto c : s) {
    m[c]++;
  }
  vector<int> q = {m['a'], m['b'], m['c']};
  if (*max_element(q.begin(), q.end()) - *min_element(q.begin(), q.end()) <= 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


Measured memory_bytes: 512
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var a = NextLong();
        var b = NextLong();
        var x = NextLong();

        var ans = 0L;
        ans += b / x;
        if (a == 0L) {
            ans++;
        } else {
            ans -= (a - 1) / x;
        }
        WriteLine(ans);
    }

    static long NextLong() {
        return long.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

	int main() {
		string s,t;
		int a = 0;
		cin >> s >> t;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == t[i]) {
				a++;
			}
		}cout << a << endl;
	}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<cassert>
#include<functional>
#include<string>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD(1e9+7);

int n, m;
char s[200011];
int main()
{
 scanf("%s %d", s, &m); n = strlen(s);
 int p = 0;
 while (m > 0 && p < n) {
  while (p < n && ((int('z') - s[p] + 1) > m || s[p] == 'a')) ++p;
  if (p >= n) break;
  m -= (int('z') - s[p] + 1);
  s[p++] = 'a';
 }

 if (m > 0) {
  s[n-1] = (int(s[n-1]) - int('a') + (m % 26)) % 26 + int('a');
 }

 s[n] = 0;
 puts(s);
 return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint a, b;
llint n, s, t;
llint distS[305], distT[305];
priority_queue<P, vector<P>, greater<P> > Q;
vector<llint> ans;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s >> t;
	
	llint res;
	for(int i = 1; i <= n; i++){
		cout << "? " << s << " " << i << endl;
		cin >> distS[i];
	}
	for(int i = 1; i <= n; i++){
		cout << "? " << t << " " << i << endl;
		cin >> distT[i];
	}
	
	llint D = distS[t];
	for(int i = 1; i <= n; i++){
		if(distS[i] + distT[i] == D) Q.push(make_pair(distS[i], i));
	}
	
	llint p = s;
	while(p != t){
		cout << "? " << p << " " << Q.top().second << endl;
		cin >> res;
		if(res == Q.top().first - distS[p]){
			ans.push_back(Q.top().second);
			p = Q.top().second;
		}
		Q.pop();
	}
	cout << "!";
	for(int i = 0; i < ans.size(); i++){
		cout << " " << ans[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 4668
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

struct point{
	Int j, i,step;
	point(Int i_, Int j_,Int s) :i(i_), j(j_),step(s){}
};

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

queue<point> que;
char tile[1001][1001];
int H, W;
bool ed[1001][1001];

point solve(char target)
{
	while (!que.empty()){
		point now(que.front());
		ed[now.i][now.j] = true;
		que.pop();
		REP(i, 4){
			int x = now.j + dx[i];
			int y = now.i + dy[i];

			if (x < 0 || y < 0 || x > W || y > H || ed[y][x])
				continue;

			if (tile[y][x] == target){
				return point(y, x,now.step+1);
			}

			if (tile[y][x] != 'X'){
				que.push(point(y, x, now.step + 1));
				ed[y][x] = true;
			}
		}
	}
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	int n(0);
	cin >> H >> W >> n;

	REP(i, 1001)REP(j, 1001){ tile[i][j] = 'X'; ed[i][j] = false; }

	REP(i, H)REP(j, W)cin >> tile[i][j];

	REP(i, H)REP(j, W){ if (tile[i][j] == 'S')que.emplace(i, j, 0); }

	for (int i = 0; i < n; ++i){
		REP(i_1, H + 1)REP(j_1, W + 1){ ed[i_1][j_1] = false; }
		point t = solve('1' + i);
		que = {};
		que.emplace(t);
	}

	cout << que.front().step << endl;

	return 0;
}

Measured memory_bytes: 3176
#coding:utf-8

N = int(input())
H = list(map(int, input().split()))
H.append(1000000000000000000000000000000)
dansa = 0
cnt = 0

for i in range(len(H)-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if cnt > dansa:
            dansa = cnt
        cnt = 0

print(dansa)

Measured memory_bytes: 14252
#!/usr/bin/python3r
# -*- coding:utf-8 -*-

from itertools import permutations

def main():
  n, m, nr = map(int, input().split())
  lr = list(map(lambda x:int(x)-1, input().split()))
  edges = [[10**9]*n for _ in range(n)]
  for i in range(n):
    edges[i][i] = 0
  for _ in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    edges[a][b] = edges[b][a] = c
    
  def wf():
    for k in range(n):
      for i in range(n):
        for j in range(n):
          edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j])
  wf()
          
  def calc_cost(path):
    cost = 0
    for i in range(nr-1):
      cost += edges[path[i]][path[i+1]]
    return cost
  
  print(min([calc_cost(path) for path in permutations(lr)]))

if __name__=='__main__':
  main()



Measured memory_bytes: 48856
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n;
    cin>>n;
    VI mr(n+1,0);
    for(int i=1;i<=sqrt(n);i++)
    for(int j=1;j<=sqrt(n);j++)
    for(int k=1;k<=sqrt(n);k++)
    {
        if(i*i+j*j+k*k+i*j+i*k+j*k<=n)
        mr[i*i+j*j+k*k+i*j+i*k+j*k]++;
    }
    for(int i=1;i<=n;i++)
    cout<<mr[i]<<endl;
}


return 0;
}





Measured memory_bytes: 3624
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
/*__________________
  I LOVE ORDERED_SET
  __________________
*/

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int n, k;
int a[101], dp[101010];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 0; i <= k; i++) {
		dp[i] = 1;
		for (int j = 1; j <= n; j++) {
			if(i - a[j] >= 0) dp[i] = min(dp[i], dp[i - a[j]]);
		}
		dp[i] = 1 - dp[i];
	}

	if(dp[k]) cout << "First";
	else cout << "Second";
}

Measured memory_bytes: 640
n = int(input())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
Dxy1, Dxy2, Dxy3 = 0, 0, 0
Dxyinf_list = []

for x, y in zip(x_list, y_list):
    Dxy1 += abs(x-y)
    Dxy2 += (abs(x-y))**2
    Dxy3 += (abs(x-y))**3
    Dxyinf_list.append(abs(x-y))

Dxy2 = Dxy2**(1/2)
Dxy3 = Dxy3**(1/3)
Dxyinf = max(Dxyinf_list)

print('{0:.6f}'.format(Dxy1))
print('{0:.6f}'.format(Dxy2))
print('{0:.6f}'.format(Dxy3))
print('{0:.6f}'.format(Dxyinf))


Measured memory_bytes: 5648
#include<stdio.h>

int main()
{
    int x,y;
    char op;
    int i;
    for(i=0;i<100;i++){
      scanf("%d %c %d",&x,&op,&y);
  if(op=='?')
      break;
        switch(op){
            case '+':printf("%d\n",x+y);break;
            case '-':printf("%d\n",x-y);break;
            case '*':printf("%d\n",x*y);break;
            case '/':printf("%d\n",x/y);break;   
        }
    }
    return 0;
}


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

typedef long long 			ll;
typedef unsigned long long 	ull;


int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b && b != c || a == c && b != c || b == c && a != c)
		return cout << "Yes" << endl, 0;
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {
			int N = Integer.parseInt(br.readLine());
			int[][] CSF = new int[N][3];
			for (int i = 0; i < N - 1; i++) {
				CSF[i] = Stream.of(br.readLine().split("[\\s]+")).mapToInt(Integer::parseInt).toArray();
			}
			int[] x = new int[N];
			for (int i = N - 2; i >= 0; i--) {
				int t = CSF[i][1];
				for (int j = i; j < N - 1; j++) {
					if (CSF[j][1] > t) {
						t = CSF[j][0] + CSF[j][1];
						continue;
					} else if (t % CSF[j][2] > 0) {
						t += CSF[j][2] - (t % CSF[j][2]);
					}
					t += CSF[j][0];
				}
				x[i] = t;
			}
			for (int i = 0; i < x.length; i++) {
				pw.println(x[i]);
			}
			pw.flush();
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 28116
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] input_num = input.Split(' ');
            int N = int.Parse(input_num[0]);
            int K = int.Parse(input_num[1]);
            int m = 1;  // Output
            if (N > K) { m += (N - K); }
            Console.WriteLine(m.ToString());
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

int main()
{
    long long m,n;
    std::cin>>m>>n;
    long long a;
    for (long long i=0;i<n;i++)
    {
        std::cin>>a;
        m-=a;
    }
    if (m<0)
    {
        std::cout<<"-1";
    }
    else
    {
        std::cout<<m;
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;
const int MAXN=1e5+7;
static int n,a[MAXN],dis[MAXN],ans;
inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]),dis[i]=abs(a[i]-a[i-1]);
	a[n+1]=0;++n;dis[n]=abs(a[n]-a[n-1]);
	Rep(i,1,n)ans+=dis[i];
	Rep(i,1,n-1)printf("%d\n",ans-dis[i]-dis[i+1]+abs(a[i+1]-a[i-1]));
}
inline void solve()
{
}
int main()
{
	init();
	solve();
	return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
 
int main(void)
{
    int i[1024], j;
    int n;
    int p[1024], q[1024], r[1024], c[1024];
    int pc, qc, rc, cc;
    int f;
     
    while (scanf("%d", &n), n != 0){
        for (j = 0; j < n; j++){
            scanf("%d %d %d %d", &i[j], &p[j], &q[j], &r[j]);
            c[j] = 4 * p[j] + 9 * q[j] + 4 * r[j];
        }
        scanf("%d %d %d %d", &pc, &qc, &rc, &cc);
        f = 0;
        for (j = 0; j < n; j++){
            if (pc >= p[j] && qc >= q[j] && rc >= r[j] && cc >= c[j]){
                printf("%d\n", i[j]);
                f = 1;
            }
        }
        if (f == 0){
            printf("NA\n");
        }
    }
     
    return (0);
}

Measured memory_bytes: 1060
from heapq import heappush, heappop

n, m = map(int, input().split())
a_list = input().split()
priority_queue = []
for a in a_list:
    heappush(priority_queue, (-int(a), 1))

for i in range(m):
    b, c = map(int, input().split())
    heappush(priority_queue, (-c, b))

res = 0
for i in range(n):
    c_, b = heappop(priority_queue)
    res += -c_
    b -= 1
    if b > 0:
        heappush(priority_queue, (c_, b))

print(res)

Measured memory_bytes: 84120
#include<stdio.h>

int main(){
    int h,m,s,S;
    scanf("%d",&S);
    
    s = S % 60;
    m = (S / 60) % 60;
    h = S / 3600;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}

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

int main()
{
    vector<int> n;
    vector<char> c;

    int a;
    char o;
    
    while( true )
    {
        cin >> a >> o;
        n.push_back(a);          //数
        c.push_back(o);     //演算部
        if( o == '=' )
            break;
    }

    int j = 0;
    for( int i = 0; i < n.size() - 1; i++ )
    {
        if( c[j] == '+' )
            n[i+1] = n[i] + n[i+1];
        else if( c[j] == '-' )
            n[i+1] = n[i] - n[i+1];
        else if( c[j] == '*' )
            n[i+1] = n[i] * n[i+1];
        else if( c[j] == '/' )
            n[i+1] = n[i] / n[i+1];
        else;
        j++;
    }
    cout << n[j] << endl;
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  string t; cin >> t;
  ll n = s.size();
  ll ans = 0;
  rep(i,n){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))

int main()
{
    int N, L;
    int ans = 0;
    
    scanf("%d %d", &N, &L);

    if(L >= 0){
        for(int i = 2; i <= N; i++){ans = ans + L + i - 1;}
    }

    else if(L < 0){
        if(abs(N) > abs(L)){
            for(int i = 1; i <= N;i++){ans = ans + L + i - 1;}                
        }
        else{
            for(int i = 1; i < N; i++){ans = ans + L + i - 1;}
        }
        
    }

    printf("%d", ans);
    
    return 0;
}


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

using namespace std;

typedef long long ll;

int N,M;
vector<vector<int>> to;
vector<bool> visited,used;
vector<int> ans,ans2;

void dfs(int a,int b){ 
  
  //今aにいて、記録済み
  
  for(auto ne : to[a] ){ 
    
    if(visited[ne]){ continue;}
    
    else{ 
      
      
     if( !used[ne] ){ 
      if( b == 0 ){ans.push_back(ne);}
      else{ ans2.push_back(ne);}
       used[ne] = true;
     }
      
      visited[ne] = true; dfs(ne,b); return;
    }
    
    //　aから繋がっていてかつ行ったことがない点がなくなるまでdfsを続ければ答えになるはず
    
  }
  
  return ;
}
    
  
  
  

int main(){
 
  cin >> N >> M;
  
  visited = vector<bool>(N,false);
  used = vector<bool>(N,false);
  to.resize(N);
  
  for(int i = 0; i < M; i++){ 
    int a, b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
    
  }
  
  int m = 1e9;
  
  int p;

  for(int i = 0; i < N; i++){ 
    
   if( m > (int)to[i].size() ){
     p = i;
     m = (int)to[i].size();
   }
    
  }

  if( m == 1 ){ 
    // p起点で進められるところまでを進める
    
    
    visited[p] = true;
    
     ans.push_back(p);
    
     used[p] = true;
  
    
    dfs(p,0);
     
    cout << (int)ans.size() << endl;
    
    for(auto ne : ans ){ 
      
      cout << ne+1 << " ";}
    
    cout << endl;
    
    
    
  }
  //if閉じ
  else{
    // 0を選んで両方向にやっていく
    
    visited[0] = true;
    
    ans2.push_back(0);
    
    
    dfs(0,0);
    dfs(0,1);
    
    reverse(ans.begin(),ans.end());
    
    cout << (int)ans.size() + (int)ans2.size() << endl;
    
    for(auto ne : ans){ 
      cout << ne+1 << " " ;
    }
  
    for(auto ne : ans2){
      cout << ne+1 << " ";
    }
    
    
  }
  
  return 0;
} 
  
    
    
   
     

Measured memory_bytes: 9976
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
    int a , b; string c;
    cin >> a >> c >> b;
    if(c == "+")  cout << a + b;
    else cout << a - b;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int dijkstra(int s, int g, int ticketNum, vector<vector<P>> &G){
    vector<vector<int>> dist(110, vector<int>(15, 1e9));
    priority_queue<T, vector<T>, greater<T>> que;
    dist[s][0] = 0;
    que.push(T(0, s, 0));

    while(!que.empty()){
        int ccost, cv, cticket;
        tie(ccost, cv, cticket) = que.top();
        que.pop();

        if(dist[cv][cticket] < ccost) continue;

        for(auto x : G[cv]){
            int nv = x.first;
            int ncost = x.second;
            if(dist[cv][cticket] + ncost < dist[nv][cticket]){
                dist[nv][cticket] = dist[cv][cticket] + ncost;
                que.push(T(dist[nv][cticket], nv, cticket));
            }
            if(cticket < ticketNum && dist[cv][cticket] + ncost / 2 < dist[nv][cticket+1]){
                dist[nv][cticket+1] = dist[cv][cticket] + ncost / 2;
                que.push(T(dist[nv][cticket+1], nv, cticket+1));
            }
        }
    }

    int ans=1e9;
    for(int i=0; i<=ticketNum; i++){
        chmin(ans, dist[g][i]);
    }

    return ans;
}

int main(){
    while(1){
        int c, n, m, s, d; cin>>c>>n>>m>>s>>d;
        s--, d--;
        if(c == 0) return 0;

        vector<vector<P>> G(110);
        for(int i=0; i<m; i++){
            int a, b, f; cin>>a>>b>>f;
            a--, b--;
            G[a].eb(P(b, f));
            G[b].eb(P(a, f));
        }

        cout << dijkstra(s, d, c, G) << endl;
    }
}


Measured memory_bytes: 3172
"use strict"

function Main(input) {
    const N = parseInt(input[0], 10);
    const V = input.slice(1).map(v => parseInt(v, 10));

    let result = 0;

    for (let i = 0; i < N; i++) {
        result += 1 / V[i];
    }

    console.log(1 / result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
<?php

$a = explode(' ', trim(fgets(STDIN)));
$numbers = explode(' ', trim(fgets(STDIN)));

$n = $a[0];
$m = $a[1];

$heap = new SplMaxHeap();

foreach ($numbers as $n) {
    $heap->insert((int)$n);
}

for ($i = 0; $i < $m; $i++) {
    $max = floor($heap->extract() / 2);
    $heap->insert($max);
}

$ans = [];
while ($heap->valid()) {
    $ans[] = $heap->extract();
}

echo array_sum($ans);

Measured memory_bytes: 20980
#include<bits/stdc++.h>
using namespace std;
       
#define ff              first
#define ss              second                            
#define int             long long
#define rep(i,j,k)      for(int i=(j); i<(int)k; ++i)
#define rrep(i,k,j)     for(int i=(int)k-1; i>=(j); --i)
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define endl            "\n"
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed << setprecision(y) << x
#define mk(arr,n,type)  type *arr = new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define PI              3.14159265358979323846264338327950L
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
       
       
       
       
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif  
}      
// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }    
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }  
//   int x1, y1;
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }   
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }   
// int fact(int n){
//   if(n==0) return 1 ;
//   else return n*fact(n-1); 
// }   

// bool isPrime(int x) {
//   for (int d = 2; d * d <= x; d++) if (x % d == 0) return false;
//   return true;
// }
double pi = 3.141592653589;

inline void solve() {
  int a[5];
  int c = 1;
  rep(i, 0, 5) {
   cin >> a[i];
   if (a[i] == 0) {
    cout << c;
    return;
   }
   c++;
  }
}    
int32_t main() {
 //c_p_c();
 //w(x)    
 solve();
 return 0;
}      

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int x, y;
  int k = 1;
  while(k != 0){
  scanf("%d %d",&x,&y);
  if(x == 0 && y == 0){
    break;
  }else if(x <= y) {
    printf("%d %d\n",x,y);
  }else if(x > y){
    printf("%d %d\n",y,x);
  }else
  k++;
  }
  return 0;
}

Measured memory_bytes: 600
import sys
 
primes = [1] * 500000
primes[0] = 0
 
for i in range(3, 1000, 2):
    if primes[i // 2]:
        primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])
 
for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)


Measured memory_bytes: 15012
#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A;
  cin >> B;
  int max = A + B;
  if(max < A-B){
    max = A-B;
  }
  if(max < A * B){
    max = A*B;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, Q, cnt = 0, tmp, ans = 0;
	string S;
	cin >> N >> Q >> S;
	vector<long long> l(Q), r(Q);
	for (int i = 0; i < Q; i++) {
		long long a, b;
		cin >> a >> b;
		l[i] = a - 1;
		r[i] = b - 1;
	}

	char pre = 'X';
	vector<long long> sum(N);
	for (int i = 0; i < N; i++) {
		if (pre == 'A' && S[i] == 'C') {
			cnt++;
		}
		sum[i] = cnt;
		pre = S[i];
	}

	for (int i = 0; i < Q; i++) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}


	char qq;
	cin >> qq;
	return 0;
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}
int a[27];
void solve(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        a[s[i]]++;
    }
    bool b = true;
    for(int i = 0; i < s.size(); i++){
        if(a[s[i]] % 2 == 1)
            b = false;
    }
    if(!b)
        cout << "No";
    else cout << "Yes";
}

// ."ww"w"".ww"""...ww"".

int main(){
    //freopen("lepus.in","r",stdin);
    //freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
    solve();
    //cout << endl;
    }
    //fclose(stdout);
}


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

int main() {

    int n;

    cin >> n;

    int count = 0;

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

        int num;

        cin >> num;

        if(i % 2 && num % 2)
            count++;

    }

    cout << count << endl;

    return 0;

}

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

int main(){
	int n;
	cin >> n;
	for(int rep=0; rep<n; rep++){
		string str[3];
		cin >> str[0] >> str[1];
		int ml = max(str[0].length(), str[1].length())+1;
		for(int i=0; i<2; i++){
			reverse(str[i].begin(), str[i].end());
			int len = str[i].length();
			for(int j=0; j<ml-len; j++){
				str[i] += "0";
			}
		}
		str[2] = "";
		int c=0;
		for(int i=0; i<ml; i++){
			int n = (str[0][i]-'0')+(str[1][i]-'0')+c;
			if(n>9) c=1;
			else c=0;
			str[2] += n%10 +'0';
		}
		if(str[2].back()=='0') str[2].pop_back();
		reverse(str[2].begin(), str[2].end());
		if(str[2].length() > 80){
			cout << "overflow" << endl;
		}else{
			cout << str[2] << endl;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;


int main()
{
    ios_base::sync_with_stdio(0);

    ll t, d;
    cin >> t >> d;

    int cnt = 0;

    while (t--) {
        ll x, y;
        cin >> x >> y;

        if (x*x + y*y - d*d <= 0)
            cnt++;

    }

    cout << cnt;


    return 0;
}



Measured memory_bytes: 3628
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline()).split())

n,y=nii()
for i in range(n+1):
  for j in range(n-i+1):
    num=n-i-j
    if 10000*i+5000*j+1000*num==y:
      print(i,j,num)
      exit()

print(-1,-1,-1)

Measured memory_bytes: 9192
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll

void solve(){
	while (true) {
		int t;
		cin >> t;
		if (t == 0) return;
		vector<int> inputs;
		REP(i, t) {
			int a;
			cin >> a;
			inputs.push_back(a);
		}
		int dp[101][50] = {};
		int cost[101] = {};
		REP(i, 101) {
			REP(q, 50) {
				dp[i][q] = 1e9;
			}
			cost[i] = 100;
		}
		int n;
		cin >> n;
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			a--;
			cost[a] = min(cost[a], b);
		}
		dp[0][0] = 0;
		for (int i = 0; i < 100; ++i) {
			for (int q = 0; q < t; ++q) {
				dp[i + 1][1] = min(dp[i + 1][1], dp[i][q] + 1);
				if (inputs[q] <= cost[i]) {
					dp[i + 1][(q + 1) % inputs.size()] = min(dp[i + 1][(q + 1) % inputs.size()], dp[i][q]);
				}
			}
		}
		int ans = 1e9;
		for (int q = 0; q < 50; ++q) {
			ans = min(ans, dp[100][q]);
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


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

a = X
s = set([a])
lst = [0]*M
lst[a] = 1
rlt = 0

j = 0
f = 1
for i in range(2,N+1):
  a = a**2 % M
  if a == 0:
    f = 2
    break
  elif a in s:
    j = lst[a]
    f = 0
    break
  else:
    lst[a] = i
    s.add(a)

if f > 0:
  print(sum(s))
else:
  t = 0
  k = i - j
  p = (N-j+1)//k
  r = (N-j+1)%k
  for u in range(1,M):
    if 0 < lst[u] < j:
      rlt += u
    elif lst[u] >= j:
      t += u
      if lst[u]-j+1 <= r:
        rlt += u
  rlt += t*p
  print(rlt)

Measured memory_bytes: 75468
#include<stdio.h>
#include<math.h>
#define pi 2*acos(0)
int main()
{
	int a,b,c,d;
	double s,x;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	x=0.5*abs(60*c-11*d);
	if(x>180) x=360-x;
	s=pi*x/180;
	s=cos(s);
	s=sqrt(a*a+b*b-2*a*b*s);
	printf("%.15lf\n",s);
	return 0;
}


Measured memory_bytes: 2600