akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int dp[100009];
#define pb push_back
int vis[100009];
vector<int>adj[100009];
int n;
int call(int u)
{
    if(adj[u].size()==0)return 0;
    int mx=1;
    if(dp[u]!=-1)return dp[u];  
    for(int i=0;i<adj[u].size();i++)
    {
        int chi=adj[u][i];
        int val=call(chi)+1;
        mx=max(val,mx);
    }
    dp[u]=mx;
    return mx;
}
int main()
{
    int m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int val=call(i);
    //    cout<<"max from "<<i<<" = "<<val<<endl;
        ans=max(val,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, m, a[87][87], b[87][87], d[87][87][87 * 87 * 2], z = mod;

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[i][j];
    d[1][1][a[1][1] - b[1][1] + 87 * 87] = d[1][1][b[1][1] - a[1][1] + 87 * 87] = 1;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (i != 1 || j != 1) {
        for (int k = 0; k < 87 * 87 * 2; k++) {
            if (k - a[i][j] + b[i][j] >= 0 && k - a[i][j] + b[i][j] < 87 * 87 * 2) d[i][j][k] |= d[i - 1][j][k - a[i][j] + b[i][j]] | d[i][j - 1][k - a[i][j] + b[i][j]];
            if (k - b[i][j] + a[i][j] >= 0 && k - b[i][j] + a[i][j] < 87 * 87 * 2) d[i][j][k] |= d[i - 1][j][k - b[i][j] + a[i][j]] | d[i][j - 1][k - b[i][j] + a[i][j]];
        }
    }
    for (int i = 0; i < 87 * 87 * 2; i++) if (d[n][m][i]) z = min(z, abs(87 * 87 - i));
    cout << z;
}


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

int main(){
  int n,k,a[100000],p,o,cnt;
  int r=0,l;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
    r=max(r,a[i]);
  }
  l=1000000000;
  while(r<l){
    // cout<<r<<" "<<l<<endl;
    p=(r+l)/2;
    o=cnt=0;
    for(int i=0;i<n;i++){
      if((o+a[i])<=p) o+=a[i];
      else{
	o=0;cnt++;
	o+=a[i];
      }
    }
    cnt++;
    if(cnt<=k) l=p;
    else r=p+1;
  }
  p=(r+l)/2;
  cout<<l<<endl;
  return 0;
}



Measured memory_bytes: 3484
a,b,m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for i in range(m)]
ans = min(al)+min(bl)
for l in xyc:
    p = al[l[0]-1] + bl[l[1]-1] -l[2]
    ans = min(ans,p)
print(ans)

Measured memory_bytes: 38488
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    N := nextInt()
	max := 0
	min := 0
	for i := 0; i < N; i++{
		num := nextInt()
		if max < num{
			max = num
		}
		if i == 0{
			min = num
		}else if min > num{
			min = num
		}
	}
	fmt.Println(max-min)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length();
  string srev(s);reverse(ALL(srev));
  string s1=s.substr(0,(l-1)/2);
  string s1rev(s1);reverse(ALL(s1rev));
  string s2=s.substr((l+1)/2,(l-1)/2);
  string s2rev(s2);reverse(ALL(s2rev));
  if(s==srev&&s1==s1rev&&s2==s2rev) puts("Yes");else puts("No");
  return 0;
}

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

using ld = long double;
const ld eps = 1e-9;
struct aa {
	int now;
	int time;
};
struct edge {
	int from;
	int to;
	int w;
};
class Compare {
public:
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};	//aa?????????????????¶

vector<int>topo_sort(const vector<vector<int>>&edges) {
	int size_ = edges.size();
	vector<int>nums(size_);
	for (const auto& es : edges) {
		for (auto e : es) {
			nums[e]++;
		}
	}
	queue<int>que;
	for (int i = 0; i < size_; ++i) {
		if (!nums[i]) {
			que.push(i);
		}
	}
	vector<int>topo;
	while (!que.empty()) {
		int ver(que.front());
		topo.push_back(ver);
		que.pop();
		for (auto e : edges[ver]) {
			nums[e]--;
			if (!nums[e])que.push(e);
		}
	}
	if (topo.size() == size_)return topo;
	else return vector<int>();
}

int main() {
	while (1) {
		int N, M, P; cin >> N >> M >> P;
		if (!N)break;
		vector<vector<int>>edges(N),revedges(N);
		{
			vector<vector<edge>>dummyedges(N);
			for (int i = 0; i < M; ++i) {
				int a, b, w; cin >> a >> b >> w;
				dummyedges[a].push_back(edge{ a,b,w });
				dummyedges[b].push_back(edge{ b,a,w });
			}
			vector<int>memo(N,1e9);
			vector<vector<edge>>tos(N);
			memo[0] = 0;
			priority_queue<aa, vector<aa>, Compare>que;
			que.push(aa{ 0,0 });
			while (!que.empty()) {
				aa atop(que.top());
				que.pop();
				for (auto e : dummyedges[atop.now]) {
					const int nexttime = atop.time + e.w;
					if (memo[e.to] > nexttime) {
						memo[e.to] = nexttime;
						tos[e.to].clear();
						tos[e.to].push_back(e);
						que.push(aa{ e.to,nexttime });
					}
					else if (memo[e.to] == nexttime) {
						tos[e.to].push_back(e);
					}
				}
			}
			for (auto atos : tos) {
				for (auto e:atos) {
					edges[e.from].push_back(e.to);
					revedges[e.to].push_back(e.from);
				}
			}
		}
		vector<int>topo(topo_sort(edges));
		ld total;
		{
			vector<ld>fs(N, 0);
			fs[0] = 1;
			for (int i = 0; i < N; ++i) {
				int from = topo[i];
				for (auto to : edges[from]) {
					fs[to] += fs[from];
				}
			}
			total = fs[N - 1];
		}
		
		
		while (P--) {
			int a; cin >> a;
			vector<ld>fs(N);
			fs[0] = 1;
			for (int i = 0; i < N; ++i) {
				int from = topo[i];
				for (auto to : edges[from]) {
					if (from == a || to == a)continue;
					fs[to] += fs[from];
				}
			}
			ld ans = 1-fs[N - 1] / total;
			cout << fixed << setprecision(12) << ans << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>

int main(void) {
	int n;
	int i;
	int max, min,tmp;
	long long sum;
	sum = 0;
	max = -1000001;
	min = 1000001;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &tmp);
		sum += tmp;
		if (max < tmp) {
			max = tmp;
		}
		if (min > tmp) {
			min = tmp;
		}
	}
	printf("%d %d %lld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int H, W, CH, CW, DH, DW;
	cin >> H >> W >> CH >> CW >> DH >> DW;
	--CH; --CW; --DH; --DW;
	vector<string>s(H);
	cin >> s;
	deque<pair<int,int>>que;
	que.push_back({CH, CW});
	vector<vector<int>>dist(H, vector<int>(W, INF));
	dist[CH][CW] = 0;
	while(que.size()) {
		auto[i, j] = que.front();
		que.pop_front();
		FOR(ni, i - 2, i + 2 + 1) {
			FOR(nj, j - 2, j + 2 + 1) {
				if(!IN(0, ni, H) || !IN(0, nj, W)) continue;
				if(s[ni][nj] == '#') continue;
				if(abs(ni - i) + abs(nj - j) == 1) {
					if(CHMIN(dist[ni][nj], dist[i][j])) {
						que.push_front({ni, nj});
					}
				} else {
					if(CHMIN(dist[ni][nj], dist[i][j] + 1)) {
						que.push_back({ni, nj});
					}
				}
			}
		}
	}
	if(dist[DH][DW] == INF) out(-1);
	else out(dist[DH][DW]);
}

Measured memory_bytes: 13544
a = input()
b = input()
c = input()

d = 'A'
while True:
  if d == 'A':
    if len(a) == 0:
      break
    s = a[0]
    a = a[1:]
  elif d == 'B':
    if len(b) == 0:
      break
    s = b[0]
    b = b[1:]
  else:
    if len(c) == 0:
      break
    s = c[0]
    c = c[1:]
  if s == 'a':
    d = 'A'
  elif s == 'b':
    d = 'B'
  else:
    d = 'C'
print (d)


Measured memory_bytes: 9064
#include <iostream>

using namespace std;

int main()
{
    long int n;
    cin>>n;
    long int a[4]={0};
    string s;
    for(long int i=0;i<n;i++){
        cin>>s;
        if(s=="AC"){
            a[0]++;
        }
        else if(s=="WA"){
            a[1]++;
        }
        else if(s=="TLE"){
            a[2]++;
        }
        else if(s=="RE"){
            a[3]++;
        }
    }
    cout<<"AC x "<<a[0]<<"\n";
    cout<<"WA x "<<a[1]<<"\n";
    cout<<"TLE x "<<a[2]<<"\n";
    cout<<"RE x "<<a[3]<<"\n";
}

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

int N, M;
#define MAXN 100000
vector<int> adj[MAXN];
bool seen[MAXN];
deque<int> res;

void path1(int v) {
  seen[v] = true; res.push_front(v);
  for(int w : adj[v]) {
    if(!seen[w]) {
      path1(w); break;
    }
  }
}

void path2(int v) {
  seen[v] = true;
  for(int w : adj[v]) {
    if(!seen[w]) {
      res.push_back(w); path2(w); break;
    }
  }
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int A, B; cin >> A >> B; --A; --B;
    adj[A].push_back(B); adj[B].push_back(A);
  }
  path1(0); path2(0);
  cout << res.size() << endl;
  cout << res[0] + 1; res.pop_front();
  for(int v : res) cout << " " << v + 1;
  cout << endl;
  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w,m; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	ll x, y;
	cin >> x >> y;
	ll a, b;
	a = 0; b = 0;
	if ((-x + 2 * y) % 3 == 0 && (2 * x - y) % 3 == 0&& (-x + 2 * y)>=0&& (2 * x - y)>=0) {
		a = (-x + 2 * y) / 3;
		b = (2 * x - y) / 3;
	}
	else {
		cout << 0 << endl;
		return 0;
	}
	
	cout << Combination(a+b,min(a,b)) << endl;
}


Measured memory_bytes: 5504
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K, P[1005], ans;

int main(){
  scanf ("%d%d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", P + i);
  sort(P, P + N);

  for (int i = 0; i < K; i++) ans += P[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int ans = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        ans += s[i] - '0';
        ans %= 9;
    }
    cout << (ans ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	while(1) {

		string s[55];
		string t[55];

		int n; cin >> n;
		if(n == 0) break;
		rep(i, n) cin >> s[i];
		rep(i, n){
			t[i] += s[i][0];
			rep(j, s[i].size() - 1){
				if(s[i][j] == 'a' || s[i][j] == 'i' || s[i][j] == 'u' || s[i][j] == 'e' || s[i][j] == 'o'){
					t[i] += s[i][j + 1];
				}
			}
		}
		
		// rep(i, n) cout << t[i] << endl;
		int ans = -1;
		reps(k, 1, 51) {
			set<string> se;
			rep(i, n) se.insert(t[i].substr(0, k));
			// printf("se\n");
			// for(auto u : se) cout << u << endl;
			// printf("\n");
			if(se.size() == n) {
				ans = k; break;
			}
		}
		printf("%d\n", ans);
		
	}
	return 0;
}

Measured memory_bytes: 3312
import sys
input = sys.stdin.readline

n = int(input())
c = list(input())

ans = 0
l = 0
r = n - 1
while True:
    while c[l] != 'W' and l <= n - 1:
        l += 1
    if l >= r:
        print(ans)
        exit()
    while c[r] != 'R' and r >= 0:
        r -= 1
    if l >= r:
        print(ans)
        exit()
    c[l] = 'R'
    c[r] = 'W'
    ans += 1


Measured memory_bytes: 81252
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[400004], ne[400004], he[100001];
int kotae[100001], Q[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	int q = 0;
	Q[q++] = 1;
	kotae[1] = 1;
	rep(i, N) {
		int u = Q[i];
		for (int v = he[u]; v; v = ne[v]) {
			int To = to[v];
			if (!kotae[To]) {
				kotae[To] = u;
				Q[q++] = To;
			}
		}
	}
	printf("Yes\n");

	for (int i = 2; i <= N; i++) putint(kotae[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 7972
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let* ((n (read))
	   (m (read))
	   (c (read))
	   (b (loop repeat m collect (read))))
  (princ 
	(loop repeat n sum 
		  (if (> (+ c
					 (loop for i in (loop repeat m collect (read))
						   for j in b
						   sum (* i j)))
				  0)
			1
			0))))


Measured memory_bytes: 9404
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


//// C
int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> s = v;
    sort(s.rbegin(), s.rend());
    rep(i,n){
        int ans=s[0];
        if(s[0] == v[i]) ans = s[1];
        cout << ans << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while (a % 2 != 1) {
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
h,w = map(int,input().split(' '))
A = []
Ilist = [1]*w
for p in range(h):
    a=input()
    if '#' in a:
        A.append(a)
        i = 0
        while i < w:
            if a[i] == '#':
                Ilist[i] *= 0
            i += 1
#Ilist[k] = 1であるkを除外。
ans = ''
for a0 in A:
    k = 0
    while k < w:
        if Ilist[k] == 0:
            ans += a0[k]
        k += 1
    ans += '\n'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] || s[0] == s[2] && s[1] == s[3] && s[0] != s[1] || s[0] == s[3] && s[2] == s[1] && s[0] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<double> p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf", &p[i]);
  }
  vector<double> d(n + 1), e(n + 1);
  d[0] = 1;
  for (int i = 0; i < n; ++i) {
    fill(e.begin(), e.end(), 0);
    for (int j = 0; j <= i; ++j) {
      e[j + 1] += p[i] * d[j];
      e[j] += (1 - p[i]) * d[j];
    }
    swap(d, e);
  }
  double ret = 0;
  for (int i = 0; i <= n; ++i) {
    if (i > n - i) ret += d[i];
  }
  printf("%.10f\n", ret);
  return 0;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let a = v[0];
    let b = v[1];
    let c = v[2];

    for i in 0..b {
        if a * i % b == c {
            println!("YES");
            break;
        }
        if i == b - 1 {
            println!("NO");
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    //input
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    /*
    for(int i=0; i<n; i++){
        cout << "a[" << i << "] is " << a[i] << endl;
    }
    */
    
    //calculation
    int k=n; 
    for(int i=0; i<n; i++){
        //cout << "loop " << i << endl;
        double u = sqrt(a[i]);
        //cout << u << " for " << a[i] << endl;
        for(int j=2; j<= u; j++){
            if (j==a[i]){
                break;
            }
            if( a[i]%j==0){
                //cout << a[i] << " can be divided by " << j << endl;
                k--;
                break;
            }
        }
    }
    
    //output
    cout << k << endl;
}

Measured memory_bytes: 1196
import math

n = input().split()

A = int(n[0])
B = int(n[1])
H = int(n[2])
M = int(n[3])


m = M/5
h = H + (M/60)

x = abs(h-m)
kakudo = x*30

ans = (A**2) + (B**2) - (2*A*B*(math.cos(math.radians(kakudo))))
ans =math.sqrt(ans)
print(ans) 

Measured memory_bytes: 9528
from itertools import *

def nth(iterable, n, default=None):
    "Returns the nth item or a default value"
    return next(islice(iterable, n, None), default)

D, N = map(int, input().split())
delta = 100 ** D
ite = (x for x in count(delta, delta) if x % (delta * 100) != 0)
print(nth(ite, N - 1))

Measured memory_bytes: 3188
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
int a,b;
int ret,pool;
signed main(){
    I(n);
    pool = INT_MAX;
    REP(i,n){
        I(a); I(b);
        ret += a;
        if (a>b) pool = min(pool,b);
    }
    cout << (pool == INT_MAX ? 0 : ret - pool) << endl;
}

Measured memory_bytes: 256
num_of_nums = int(input())
nums = sorted(map(int, input().split(' ')))

d = {}

for num in nums:
	if num not in d:
		d[num] = [0, False]
	
	d[num][0] += 1


biggest_number = nums[-1]

for num in nums:
	if d[num][0] > 1:
		d[num][1] = True
	
	multiplier = 2
	product = num * multiplier
	
	while product <= biggest_number:
		if product in d:
			d[product][1] = True
		
		multiplier += 1
		product = num * multiplier

answer = 0
for key in d:
	if not d[key][1]:
		answer += d[key][0]

print(answer)
		
	

Measured memory_bytes: 136220
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			int i=int.Parse(Console.ReadLine());
			if(i==0)break;
			Sol mySol =new Sol(i);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		var d=rla();
		int N1=N/2;
		long trgt=0;
		for(int i=0;i<N;i++)trgt+=d[i];
		//trgt/=2;
		
		
		List<long> L1=new List<long>();
		long sum=0;
		for(int i=0;i<(1<<N1);i++){
			sum=0;
			for(int j=0;j<N1;j++){
				if(((i>>j)&0x1)>0)sum+=d[j];
			}
			L1.Add(sum);
		}
					
		List<long> L2=new List<long>();
		for(int i=0;i<(1<<N-N1);i++){
			sum=0;
			for(int j=0;j<N1;j++){
				if(((i>>j)&0x1)>0)sum+=d[j+N1];
			}
			L2.Add(sum);
		}
		
		long Min=(long)1e9;
		for(int i=0;i<L1.Count;i++){
			for(int j=0;j<L2.Count;j++){
				Min=Math.Min(Min,Math.Abs(2*L1[i]+2*L2[j]-trgt));
			}
		}
		
		Console.WriteLine(Min);
		
		
		
		
		
	}
	int N;
	public Sol(int n_){
		N=n_;
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5884
#include<iostream>
using namespace std;
void call(int n){
	int i=1, x;
	do{
		x = i;
		if(x % 3 == 0){
			cout << " " << i;
		}else{
			do{
				if(x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}while(x);
		}
	}while(++i <= n);
	cout << endl;
}
int main(){
	int n;
	cin >> n;
	call(n);
	
	return 0;	
}

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

int main(){

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

	int ans = 0;
	if(a <= 5){
		ans = 0;
	}
	else if(a <= 12){
		ans = b / 2;
    }
	else{
		ans = b;
	}

	cout << ans << endl;
	return 0;
}



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

#define NIL -1
#define MAX 100005

int getdep(int);
char* gettype(int);

typedef struct Node{
  int id;
  int k;
  int par;
  int dep;
  char* type;
  int* chi;
}Node;

Node T[MAX];
  
int main(){
  int n,i,j,u;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].id=NIL;
    T[i].par=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    T[u].id=u;
    scanf("%d",&T[u].k);
    if(T[u].k>0){
      T[u].chi=(int*)malloc(T[u].k*sizeof(int));
      for(j=0;j<T[u].k;j++){
	scanf("%d",&T[u].chi[j]);
	T[T[u].chi[j]].par=T[u].id;
      }
    }
  }

  for(i=0;i<n;i++){
    T[i].dep=getdep(i);
    T[i].type=gettype(i);
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",i,T[i].par,T[i].dep,T[i].type);
    if(T[i].k!=0){
      printf("%d",T[i].chi[0]);
      for(j=1;j<T[i].k;j++){
	printf(", %d",T[i].chi[j]);
      }
    }
    printf("]\n");
  }
  return 0;
}

int getdep(int u){
  int d=0;
  while(T[u].par != NIL){
    u=T[u].par;
    d++;
  }

  return d;
}

char* gettype(int u){
  if(T[u].par != NIL){
    if(T[u].k == 0)
      return "leaf";
    else
      return "internal node";
  }
  else
    return "root";
}
    



  

  
  
    
  



Measured memory_bytes: 5292
n = int(input())
h = [tuple(map(int, input().split())) for _ in range(n)]

# i日目の活動を３パターン考える
dp = [[-1]*3 for _ in range(n+1)]
dp[0][0] = dp[0][1] = dp[0][2] = 0
dp[1][0], dp[1][1], dp[1][2] = h[0][0], h[0][1], h[0][2]

for i in range(2, n+1):
    for j in range(3):
        h_max = 0
        for k in range(3):
            if j != k and h_max < dp[i-1][k] + h[i-1][j]:
                h_max = dp[i-1][k] + h[i-1][j]
        dp[i][j] = h_max

print(max(dp[n]))

Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll ans = 0ll;
string s;

int main()
{
    cin>>s;
    int size = s.size();
    REP(i, (1<<(size-1))) {
        ll tans = (s[0] - '0');
        FOR(j,1,size) {
            if ((i>>(j-1)) & 1 == 1) {
                ans += tans;
                tans = (s[j] - '0');
            } else {
                tans = tans * 10 + (s[j] - '0');
            }
        }
        ans += tans;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n, k;
    char s[50];
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    if (s[k - 1] == 'A')
        s[k - 1] = 'a';
    else if (s[k - 1] == 'B')
        s[k - 1] = 'b';
    else
        s[k - 1] = 'c';
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
class Rori:
  B1 = 1009
  B2 = 1007
  MOD1 = 10 ** 9 + 7
  MOD2 = 10 ** 9 + 9
  H1, H2 = None, None
  P1, P2 = None, None
  def __init__(s, L):
    n = len(L) + 1
    s.H1 = [0] * n
    s.H2 = [0] * n
    s.P1 = [1] * n
    s.P2 = [1] * n
    for i in range(n - 1):
      S = ord(L[i]) - ord('a') + 1
      s.H1[i + 1] = (s.H1[i] * s.B1 + S) % s.MOD1
      s.H2[i + 1] = (s.H2[i] * s.B2 + S) % s.MOD2
      s.P1[i + 1] = s.P1[i] * s.B1 % s.MOD1
      s.P2[i + 1] = s.P2[i] * s.B2 % s.MOD2
  def hashLR(s, l, r):
    t = (s.H1[r] - s.H1[l] * s.P1[r - l] + s.MOD1) % s.MOD1
    k = (s.H2[r] - s.H2[l] * s.P2[r - l] + s.MOD2) % s.MOD2
    return (t, k)


class AVL:
  import sys
  sys.setrecursionlimit(1000000)
  class Node:
    def __init__(s, k):
      s.k = k
      s.l = None
      s.r = None
      s.d = 1
  def __init__(s):
    s.x = None
  def l_rot(s, z):
    y = z.r
    t = y.l
    y.l, z.r = z, t
    z.d = s.get_depth(z)
    y.d = s.get_depth(y)
    return y
  def r_rot(s, z):
    y = z.l
    t = y.r
    y.r, z.l = z, t
    z.d = s.get_depth(z)
    y.d = s.get_depth(y)
    return y
  def depth(s, node):
    if not node:
      return 0
    else:
      return node.d
  def get_depth(s, node):
    return 1 + max(s.depth(node.l), s.depth(node.r))
  def add(s, k):
    s.x = s.add_sub(s.x, k)
  def add_sub(s, node, k):
    if not node:
      return s.Node(k)
    elif node.k == k:
      return node
    elif node.k > k:
      node.l = s.add_sub(node.l, k)
    else:
      node.r = s.add_sub(node.r, k)
    node.d = s.get_depth(node)
    bal = s.depth(node.l) - s.depth(node.r)
    if bal > 1:
      if node.l.k > k:
        return s.r_rot(node)
      else:
        node.l = s.l_rot(node.l)
        return s.r_rot(node)
    elif bal < -1:
      if node.r.k < k:
        return s.l_rot(node)
      else:
        node.r = s.r_rot(node.r)
        return s.l_rot(node)
    return node
  def check(s, k):
    return s.check_sub(k, s.x)
  def check_sub(s, k, node):
    if node == None:
      return False
    if node.k == k:
      return True
    if node.k > k:
      return s.check_sub(k, node.l)
    else:
      return s.check_sub(k, node.r)

def hersCode(n):
  ok = 0
  ng = n
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if nasu(mid):
      ok = mid
    else:
      ng = mid
  return ok

def nasu(n):
  L = [None] * (N - n + 1)
  for i in range(len(L)):
    L[i] = R.hashLR(i, i + n)
  T = AVL()
  T.add(L[0])
  for i in range(n, len(L)):
    if T.check(L[i]):
      return True
    T.add(L[i - n + 1])
  return False

def honya(x, y, n):
  for i in range(n):
    if S[x + i] != S[y + i]:
      return i
  return n

N = int(input())
S = input()

R = Rori(S)
print(hersCode(N))


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

using namespace std;
const int MAXN = 212345;
#define ll long long

ll n, a[MAXN], dp[MAXN];

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n;

	for (int i = 0; i < n; ++i) cin >> a[i];

	if (n == 2) cout << abs(a[1] - a[0]) << endl;
	
	else {

		dp[1] = abs (a[1] - a[0]);

		for (int i = 2; i < n; ++i) 
			dp[i] = min ( dp[i - 1] + abs(a[i] - a[i - 1]),  dp[i - 2] + abs (a[i] - a[i - 2]) );

		cout << dp[n - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	edges := make([]Edge, m)

	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		c := getNextInt64(scanner) * -1
		edges[i] = Edge{
			a:    a,
			b:    b,
			cost: c,
		}
	}

	cc := make([]int64, n)
	for i := 0; i < n; i++ {
		cc[i] = math.MaxInt64
	}

	cc[0] = 0

	for i := 0; i < n; i++ {
		for ii := 0; ii < m; ii++ {
			if cc[edges[ii].a] == math.MaxInt64 {
				continue
			}
			if cc[edges[ii].b] > edges[ii].cost+cc[edges[ii].a] {
				cc[edges[ii].b] = edges[ii].cost + cc[edges[ii].a]
				if i == n-1 && edges[ii].b == n-1 {
					fmt.Fprintln(writer, "inf")
					writer.Flush()
					return
				}
			}
		}
	}
	fmt.Fprintln(writer, -cc[n-1])
	writer.Flush()
}

type Edge struct {
	a, b int
	cost int64
}


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

using namespace std;
typedef long long unsigned int ll;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  b *= 1000;

  ll bb = (ll)b;
  ll ans = a * bb;
  ans /= 1000;
  cout << ans << '\n';
  return 0;
}



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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int ans = 0, p = 5;
    while (p <= n) {
      ans += n / p;
      p *= 5;
    }
    cout << ans << endl;
  }
  

  return 0;
}


Measured memory_bytes: 3172
X = int(input())

if 400 <= X and X <= 599:
    print(8)
if 600 <= X and X <= 799:
    print(7)
if 800 <= X and X <= 999:
    print(6)
if 1000 <= X and X <= 1199:
    print(5)
if 1200 <= X and X <= 1399:
    print(4)
if 1400 <= X and X <= 1599:
    print(3)
if 1600 <= X and X <= 1799:
    print(2)
if 1800 <= X and X <= 1999:
    print(1)
    

Measured memory_bytes: 9108
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


//------------------------------------------------------------------------------------------------------------------------------


int main() {

	INPUT_INT(N);
	INPUT_VECTOR_INT(H, N);

	int n = 0;
	int m = 0;
	REP(i, N-1) {
		if (H[i] >= H[i + 1]) {
			++n;
			if (n > m) m = n;
		} else {
			n = 0;
		}
	}

	OUTPUT(m);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;



int main(){
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    rep(i, N) cin >> A[i];

    rep(i, N){
        if(A[0] == A[i]){
            break;
        }
        if(i == N - 1){
            cout << 0 << endl;
        }
    }
    ll ans = MOD;
    for(ll i = -100; i <= 100; i++){
        ll tmp_ans = 0;
        rep(j, N){
            tmp_ans += (A[j] - i) * (A[j] - i);
        }
        ans = min(ans,tmp_ans);
    }
    cout << ans << endl;
}


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

using namespace std;
 
int main(){
    int d,n,m;
 
    while(cin >> d ,d){
	vector<int> cu,sh;
	int c,s;
	sh.push_back(0);
 
	cin >> n >> m;
	for(int i = 1 ; i < n ; i++){
	    cin >> s;
	    sh.push_back(s);
	}
	sh.push_back(d);
	for(int i = 0 ; i < m ; i++){
	    cin >> c;
	    cu.push_back(c);
	} 
	int sum = 0;  
	sort(sh.begin(),sh.end());
	sort(cu.begin(),cu.end());
	int pos = 1;
	for(int i = 0 ; i < m ; ){
	    if(sh[pos] >= cu[i]){
		sum += min(sh[pos]-cu[i],cu[i]-sh[pos-1]);
		i++;
	    }
	    else ++pos;
	}
	cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int N = S.size();

  cout << (S.substr(0,(N-1)/2)==S.substr((N+1)/2)? "Yes" : "No") << endl;

  return 0;
}


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

int main(void)
{
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);
    if (1 > N || 1 > A || 1 > B || N > 20 || A > 50 || B > 50)
    {
        exit(0);
    }
    else
    {
        int trainF = A * N;
        int taxiF = B;
        if (trainF < taxiF)
        {
            printf("%d",trainF);
        }
        else
        {
            printf("%d",taxiF);
        }
    }
}


Measured memory_bytes: 128
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
vector<ll>adj[200001];
vec order;
ll n,q;
// vec size(8,0);
// ll les=1;

// void dfstree(ll s)
// {

//     visit[s]=true;
//     size[s]=1;
//     order.pb(s);
//     for(auto u:adj[s])
//     {
//         if(visit[u])
//         {
//             continue;
//         }
//         dfstree(u);
//         size[s]+=size[u];

//     }
// }
// struct fenwicktree
// {
//     ll n;
//     vector<ll>bit;
//     fenwicktree(ll n)
//     {
//         this->n=n+1;
//         bit.assign(n+1,0);
//     }
//     void add(ll idx, ll val) {
//     for (idx; idx < n; idx += idx & -idx)
//         bit[idx] += val;
//     }

//     void range_add(ll l, ll r,ll val) {
//         add(l, val);
//         add(r + 1, -val);   
//     }

//     ll point_query(ll idx) {
//         ll ret = 0;
//         for (idx; idx > 0; idx -= idx & -idx)
//             ret += bit[idx];
//         return ret;
//     }


// };
ll xx,val,result[200001+1];

ll dist[500001];

queue<ll>q1;

void bfs(ll x)
{
  
  bool visits[500001]={false}; 
  visits[x]=true;

  q1.push(x);
  while(!q1.empty())
  {
      ll s=q1.front();
      q1.pop(); 
      for(auto u : adj[s])
      {
        if(visits[u])
          continue;
        visits[u]=true;
        q1.push(u);
        result[u]+=result[s];
      }

  }
}






int main() 
{

    fast();
      
  

        cin>>n>>q;
        ll i,x,y;
        f(i,0,n-1)
        {
         cin>>x>>y;
         adj[x].pb(y);
         adj[y].pb(x);  
    
        }
        f(i,0,q)
        {
            cin>>xx>>val;
            result[xx]+=val;
      
        }
        bfs(1);

        f(i,1,n+1)
        {
          
            cout<<result[i]<<" ";
           
        }
        


        
  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 


Measured memory_bytes: 20336
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>

using namespace std;
int sum(int i)
{
	int ret = i;
	while (i--) {
		ret += i;
	}
	return ret;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a)*b << "\n";
	
}

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

#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	long double n; cin >> n;
	n/=3;
	long double xd = n*n*n;
	
	cout << setprecision(9) << xd << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N,0);
    ll sum_=0;
    for(auto &a: A){
        cin >> a;
        sum_+=a;
    }

    ll dif=max(0LL,sum_-N*(N-1));
    ll cnt=0;
    priority_queue<ll, vector<ll>, less<ll> > que;
    for(int i=0; i<N; i++){
        cnt+=(A[i]+dif)/(N+1);
        A[i]=(A[i]+dif)%(N+1);
        if(cnt>dif){
            A[i]+=(cnt-dif)*(N+1);
            cnt=dif;
        }
        que.push(A[i]);
    }

    //cout_vec(A);

    ll tmp=0;
    while(que.top()+tmp>=N){
        ll top=que.top()+tmp;
        //cout << que.top() << ' '  << tmp << endl;
        que.pop();
        ll k=top/N;
        tmp+=k;
        que.push(top%N-tmp);
    }
    cout << dif+tmp << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long ans = 0;
	int c = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans += (x + c) / 2;
		c = x && (x + c) % 2 ? 1 : 0;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
### main

loop do
  n = gets.strip.to_i
  break if n == 0

  mtx = n.times.map{[]}
  shortests = n.times.map{[]}
  tallests  = n.times.map{0}

  for y in (0...n)
    mtx[y] = gets.strip.split(' ').map(&:to_i)
    minv = mtx[y][0]
    for x in (0...n)
      v = mtx[y][x]
      minv = v if minv > v
      tallests[x] = v if tallests[x] < v
    end
    shortests[y] = (0...n).map{|x| mtx[y][x] == minv}
  end

  h = 0

  for x in (0...n)
    tv = tallests[x]
    for y in (0...n)
      if shortests[y][x] && mtx[y][x] == tv
        h = tv
        break
      end
    end
  end

  puts h
end

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

typedef long long ll;

int main() {
	string s;
	ll k;
	cin >> s >> k;
	for (int i=0; i<min((ll) s.size(), k); i++)
		if (s[i] >= '2') {
			cout << s[i] << endl;
			return 0;
		}

	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
	n = int(raw_input())
	if n == 0:
		break
	dict = {}
	date = []
	for i in xrange(n):
		num,a,b = map(long,raw_input().split())
		if num in dict:
			dict[num] += a * b
		else:
			dict[num] = a * b
			date.append(num)
	
	judge = True
	for var in date:
		if dict[var] >= 1000000:
			print var
			judge = False
	
	if judge:
		print "NA"

Measured memory_bytes: 6552