akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll X, K, D;
    cin >> X >> K >> D;

    if(X>0) X *= -1;
    ll pos = abs(X)/D;
    pos = min(K, pos);
    ll res = 0;
    if(pos>=K){
       res = abs(X + pos*D);
    }else{
        ll r = K-pos;
        if(r&1){
            res = abs(X + pos*D + D); 
        }else{
            res = abs(X + pos*D); 
        }
    }
     cout << res << endl;

    return 0;
}

Measured memory_bytes: 3648
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="?":
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(a//b)


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

int main() {
	while(true){
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) return 0;

		int d = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++)
					if (i + j + k == x) d++;
			}
		}

		cout << d << endl;
	}
	return 0;
}

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

void maxHeapify(int a[],int i,int n){
    int l=i*2,r=i*2+1;
    int largest=i;

    if(r<=n){
        if(a[r]>a[largest]){
            largest=r;
        }
        if(a[l]>a[largest]){
            largest=l;
        }
    }
    else if(l<=n){
        if(a[l]>a[largest]){
            largest=l;
        }
    }

    if(largest!=i){
        int tmp=a[largest];
        a[largest]=a[i];
        a[i]=tmp;
        maxHeapify(a,largest,n);
    }
    return;
}

void buildMaxHeap(int a[],int n){
    int m=n/2;
    for(;m>0;m--){
        maxHeapify(a,m,n);
    }
    return;
}

void insert(int a[],int key,int n){
    a[n]=key;
    while(key>a[n/2]){
        a[n]=a[n/2];
        a[n/2]=key;
        n/=2;
    }
    return;
}

int extractMax(int a[],int n){
    int ret=a[1];
    a[1]=-1;
    maxHeapify(a,1,n);
    return ret;
}

int main(void){
    int n=0,key;
    int a[2000001];
    a[0]=2100000000;
    string order="kkkk";
    
    while(order[2]!='d'){
        if(order[0]=='i'){
            cin>>key;
            n++;
            insert(a,key,n);
        }
        else if(order[1]=='x'){
            printf("%d\n",extractMax(a,n));
            while(a[n]==-1){
                n--;
            }
        }
        cin>>order;
    }

    return 0;
}


Measured memory_bytes: 8828
import heapq as hq

N = int(input())
c = []
for i in range(N):
  x, y = map(int, input().split())
  c.append((i, x, y))

cx = sorted(c, key=lambda x: x[1])
cy = sorted(c, key=lambda x: x[2])

edge = [set() for i in range(N)] # edge[from][to] = weight

for i in range(1, N):
  edge[cx[i-1][0]].add((cx[i][1]-cx[i-1][1], cx[i][0]))
  edge[cx[i][0]].add((cx[i][1]-cx[i-1][1], cx[i-1][0]))

  edge[cy[i-1][0]].add((cy[i][2]-cy[i-1][2], cy[i][0]))
  edge[cy[i][0]].add((cy[i][2]-cy[i-1][2], cy[i-1][0]))
  
for i in range(N-1):
  edge[cx[i][0]].add((cx[i+1][1]-cx[i][1], cx[i+1][0]))
  edge[cx[i+1][0]].add((cx[i+1][1]-cx[i][1], cx[i][0]))

  edge[cy[i][0]].add((cy[i+1][2]-cy[i][2], cy[i+1][0]))
  edge[cy[i+1][0]].add((cy[i+1][2]-cy[i][2], cy[i][0]))
  

q = [(0, 0)]
used = [False] * N
un = 0
r = 0

while q and un < N:
  w, prev = hq.heappop(q)

  if used[prev]: continue
  
  used[prev] = True
  un += 1
  r += w
  
  for w, to in edge[prev]:
    if not used[to]:
      hq.heappush(q, (w, to))
print(r)

Measured memory_bytes: 90576
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    ans = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9232
N = int(input())
p = [int(i) for i in input().split()]
count = 0
i = 0
while i < N:
    if p[i]-1==i:
        if i+1 != N:
            if p[i+1]-1==i+1:
                i += 1
                count += 1
            else:
                count += 1
        else:
            count += 1
    i += 1

print(count)

Measured memory_bytes: 52908
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 998244353;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int K;
    cin >> K;
    K--;
    char d = s[K];
    rep(i,N){
        if(s[i] != d){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int L[N];
    REP(i, N) cin >> L[i];

    sort(L, L + N);

    int count = 0;
    FOR(i, 0, N - 2) {
        FOR(j, i + 1, N - 1) {
            int target = L[i] + L[j];
            int *id = lower_bound(L + j + 1, L + N, target);
            int idx = (int)(id - (L + j + 1));
            count += idx;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;

namespace ndifix{

}

int main(){
    int n;cin>>n;
    vector<int> a(n),b(n),c(n);for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    vector<vector<int>> dp(n);for(int i=0;i<n;i++)dp[i].resize(3);
    dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];

    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][2]+b[i],dp[i-1][0]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }

    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>

int main(int argc, const char *argv[]) {
    double a, b, c, d, e, f, x, y, det;
    for ( ; std::cin >> a >> b >> c >> d >> e >> f; ) {
        det = a * e - b * d;
        x = (e * c - b * f) / det;
        y = (a * f - d * c) / det;
        if (-0.0005 < x && x < 0.0005) x = 0.0001;
        if (-0.0005 < y && y < 0.0005) y = 0.0001;
        std::cout << std::fixed << std::setprecision(3) << x << " " << y << std::endl;
    }
    return 0;
}

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

const int mod = 1e9 + 7;

template <typename T> inline bool chmax(T &a, const T &b) {
    if(a >= b) {
        return false;
    }
    a = b;
    return true;
}
template <typename T> inline bool chmin(T &a, const T &b) {
    if(a <= b) {
        return false;
    }
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int ac = 0, pe = 0, n, m, p;
    cin >> n >> m;
    bool ok[100009] = {};
    
    int num[100009] = {};
    string s;
    rep(i, m) {
        cin >> p >> s;
        if(!ok[p]) {
            if(s == "AC") {
                ac++;
                pe += num[p];
                ok[p] = 1;
            } else
                num[p]++;
        }
    }
    cout << ac << " " << pe << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {
	
	int k;
	string s;

	cin >> k >> s;

	string ans = s;

	if (s.length() > k) {
		ans = s.substr(0, k) + "...";
	}

	cout << ans << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for (int i = 0;i < n;i++) cin >> a[i];
  for (int i = 0;i < n;i++) cin >> b[i];
  for (int i = 0;i < n-1;i++) cin >> c[i];
  int beforefood = 100;
  int ans = 0;
  for (int i = 0;i < n;i++) {
    ans += b[i];
    if (a[i] == beforefood + 1) ans += c[a[i]-2];
    beforefood = a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

class Graph{
	private:
	int GV,GE;
	vvi List;
	void bridgefunc(int x,vb& used,vi& disc,vi& low,vi& par){
		static int time=0;
		used[x]=1;
		disc[x]=low[x]=++time;
		for(int i=0;i<List[x].size();i++){
			int v=List[x][i];
			if(!used[v]){
				par[v]=x;
				bridgefunc(v,used,disc,low,par);
				low[x]=min(low[x],low[v]);
				if(low[v]>disc[x]){
					if(v<x) br.push_back(P(v,x));
					else br.push_back(P(x,v));
				}
			}
			else if(v!=par[x]) low[x]=min(low[x],disc[v]);
		}
	}
	public:
	vp br;
	Graph(int v,int e){
		GV=v;
		GE=e;
		List=vvi(v);
	}
	void add_edge(int x,int y){
		List[x].push_back(y);
		List[y].push_back(x);
	}
	void bridge(){
		vb used(GV);
		vi disc(GV),low(GV),par(GV,-1);
		for(int i=0;i<GV;i++){
			if(!used[i]) bridgefunc(i,used,disc,low,par);
		}
	}
};

int V,E;

int main(){
	cin>>V>>E;
	Graph gra(V,E);
	int s,t;
	for(int i=0;i<E;i++){
		cin>>s>>t;
		gra.add_edge(s,t);
	}
	gra.bridge();
	sort(gra.br.begin(),gra.br.end());
	for(int i=0;i<gra.br.size();i++){
		cout<<gra.br[i].first<<' '<<gra.br[i].second<<endl;
	}
}

Measured memory_bytes: 2928
def main():
    n, k, q = map(int, input().split())
    point = [0]+[k-q]*n
    point_add = [0]*(n+1)
    for a in range(q):
        a = int(input())
        point[a] += 1

    result = [x + y for (x, y) in zip(point, point_add)]

    for i in result[1:]:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 54244
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vector<int> line(n);
	int max_ai = 0;
	foreach(i, line){
		cin >> i;
		chmax(max_ai, i);
	}
	vector<int> cnt(max_ai+1, 0);
	foreach(i, line){
		if(max_ai/2>i){
			cout << "Impossible" << endl;
			return 0;
		}
		chmin(i, max_ai-i);
		if(cnt[i]){
			++cnt[max_ai-i];
		}else{
			++cnt[i];
		}
	}
	bool flag = true;
	foreach(i, cnt){
		if(i==0){
			flag = false;
		}
	}
	if(max_ai&1){
		flag &= cnt[max_ai/2] == 1 && cnt[max_ai/2+1] == 1;
	}else{
		flag &= cnt[max_ai/2] == 1;
	}
	if(flag){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

string s;
int year,month,day;
inline void solve(){
  IN(s);
  year=stoi(s.substr(0,4));
  month=stoi(s.substr(5,2));
  day=stoi(s.substr(8,2));
  if(year<=2018)OUT("Heisei");
  else if(month<=4)OUT("Heisei");
  else OUT("TBD");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

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

up2 = int(s[:2])
end2 = int(s[2:])

if (0<up2<13) and (0<end2<13):
    ans = "AMBIGUOUS"
elif 0<up2<13:
    ans = "MMYY"
elif 0<end2<13:
    ans = "YYMM"
else:
    ans = "NA"
# ans = YYMM, MMYY, AMBIGUOUS, NA
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
import sys
n = int(input())
bottun = [int(input()) for i in range(n)]
i = 0
cnt = 0
while 1:
  if bottun[i] == 0:
    print(-1)
    sys.exit()
  if bottun[i] == 2:
    print(cnt+1)
    sys.exit()
  temp = bottun[i] - 1
  bottun[i] = 0
  i = temp
  cnt += 1

Measured memory_bytes: 49712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll calc(ll x,ll y,ll z){
  ll A=x*x*x+y*y*y;
  return (A<=z*z*z) ? A:0;
}
 
int main(){
  ll z;
  while(cin>>z,z){
 
    ll mx=0;
    for(int i=1;i<2000;i++)
      for(int j=1;j<2000;j++)mx=max(mx,calc(i,j,z));
    cout<<z*z*z-mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 2944
N = int(input())
Si = [""] * N

for n in range(N):
  Si[n] = input()
Si = sorted(Si)

newSi = ["",0]*N
cnt = 0
newSi[0] = [Si[0],1]
maxnum = 1
for n in range(1,N):
  if Si[n] == newSi[cnt][0]:
    newSi[cnt][1] = newSi[cnt][1] + 1
    if newSi[cnt][1] > maxnum: maxnum = newSi[cnt][1]
  else:
    cnt = cnt+1
    newSi[cnt] = [Si[n],1]

for c in range(cnt+1):
  if newSi[c][1] == maxnum: print(newSi[c][0])

Measured memory_bytes: 40664
#include<iostream>
#include<map>
using namespace std;
long long ret,sum;
map <long long,int> mp;
int main(){
int n;
cin >> n;
mp[0]++;
for(int i=0;i<n;i++){
long long a;
cin >> a;
sum+=a;
ret+=mp[sum];
mp[sum]++;
}
cout << ret;
//system("pause");
return 0;
}

Measured memory_bytes: 12800
a, b, c, d, e, f = map(int,input().split())
 
suger_max = int(f * e/(100+e))
 
water, suger = [], [] 
 
for i in range(f//(a*100) + 1):
    for j in range(f//(b*100) + 1):
        temp = a * 100 * i + b * 100 * j
        if temp <= f and 0 < temp:
            water.append(temp)

for p in range(suger_max//c + 1):
    for q in range(suger_max//d + 1):
        if c * p + d * q <= suger_max:
            suger.append(c * p + d * q) 

z = [0, 0, 0]
for x in suger:
    for y in water:
        temp = x / (x + y) 
        if temp <= e/(100+e) and x + y <= f:
            if z[0] <= temp:
                z[0] = temp
                z[1] = x + y
                z[2] = x

print(*z[1:3])

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

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<" "<<2*(a+b)<<endl;
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();

    if (N % 500 <= A) {
      System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 35596
#include <stdio.h>
int main(){
  int i,ib;
  char a,s[100];
  while(1){
    i=0;
    scanf("%c",&a);
    if(a=='.')break;
    else if(a=='('){
      s[i]='(';
      i++;
    }else if(a==')'){
      s[i]=')';
      i++;
    }else if(a=='['){
      s[i]='[';
      i++;
    }else if(a==']'){
      s[i]=']';
      i++;
    }
    while(1){
      scanf("%c",&a);
      if(a=='.'){
	if(i==0){
	  printf("yes\n");
	  break;
	}else {
	  printf("no\n");
	  break;
	}
      }else if(a=='('){
	s[i]='(';
	i++;
      }else if(a==')'){
	if(s[i-1]=='(')i--;
	else {
	  s[i]=')';
	  i++;
	}
      }else if(a=='['){
	s[i]='[';
	i++;
      }else if(a==']'){
	if(s[i-1]=='[')i--;
	else {
	  s[i]=']';
	  i++;
	}
      }
    }
    scanf("%c",&a);
  }
  return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define f  first
#define s  second
#define fora(var, start, end) for(int var = start; var < end; var++)

int main()
{
  inp(n);
  std::vector<int> a(n),b(n),c(n);
  fora(i,0,n)
  {
    cin>>a[i]>>b[i]>>c[i];

  }
  std::vector<int> dpa(n),dpb(n),dpc(n);
  fora(i,0,n)
  {
    if(i==0)
      {dpa[i]=a[i];dpb[i]=b[i];dpc[i]=c[i];}
    else
    {
        dpa[i]= a[i]+ max(dpb[i-1],dpc[i-1]);
        dpb[i]= b[i]+ max(dpa[i-1],dpc[i-1]);
        dpc[i]= c[i]+ max(dpa[i-1],dpb[i-1]);
    }
  }
  print(max(dpb[n-1],max(dpa[n-1],dpc[n-1])));
  
  return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int a,b,c,d, A[100], B[100], C[100][100], D[100][100][100];
string s, t, r;




int main(){
	cin >> a;
	b = inf, c = -inf;
	for(int i = 0; i < a; i++){
		cin >> A[i];
		b = min(b, A[i]);
		c = max(c, A[i]);
	}
	cout << abs(b-c) << endl;


	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int len, ans = 0;

	cin >> S;
	len = S.length();

	rep(i, len / 2) {
		if (S[i] != S[len - 1 - i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string s;
    std::cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])std::cout<<"Yes";
    else std::cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main(void){
    while(1){
    int v=0;
    cin>>a;
    if(a[0]=='0') break;
    for(int i=0;i<a.length();i++){
        v+=a[i]-'0';
    }
    cout<<v<<endl;
    }
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using graph=vector<vector<int>>;

void add_directed_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
}

vector<int> topological_order(const graph& D){
	int n=D.size();
	vector<int> deg(n);
	rep(u,n) for(int v:D[u]) deg[v]++;

	vector<int> res;
	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		res.emplace_back(u);
		for(int v:D[u]) if(--deg[v]==0) Q.emplace(v);
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	m+=n-1;
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		add_directed_edge(G,u,v);
	}

	vector<int> dp(n);
	for(int u:topological_order(G)){
		for(int v:G[u]) dp[v]=max(dp[v],dp[u]+1);
	}

	vector<int> ans(n,-1);
	rep(u,n) for(int v:G[u]) if(dp[v]==dp[u]+1) ans[v]=u;
	rep(u,n) printf("%d\n",ans[u]+1);

	return 0;
}


Measured memory_bytes: 10088
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();

        int maxlen = 0;
        int i = 0;
        while (i < N) {
            int len = 0;
            char ch = S.charAt(i);
            while (i < N && (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')) {
                len++;
                maxlen = Math.max(len, maxlen);

                i++;
                if (i < N) ch = S.charAt(i);
            }
            i++;
        }

        System.out.println(maxlen);

        return;
    }

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char > > a;
  vector<char > tmp(W, ' ');
  bool onlydot = true;
  REP(i, H){
    onlydot = true;
    REP(j, W){
      cin >> tmp[j];
      if(tmp[j] != '.'){
	onlydot = false;
      }
    }
    if(!onlydot){
      a.push_back(tmp);
    }
  }
  
  // cout << "end a" << endl;
  // REP(i, a.size()){
  //   REP(j, W){
  //     cout << a[i][j] ;
  //   }
  //   cout << endl;
  // }
  // cout << "end a" << endl;

  vector<vector<char > > b;
  vector<char > tmp2(a.size(), ' ');
  REP(j, W){
    onlydot = true;
    REP(i, a.size()){
      tmp2[i] = a[i][j];
      if(a[i][j] != '.'){
	onlydot = false;
      }
    }
    if(!onlydot){
      b.push_back(tmp2);
    }
  }

  REP(i, a.size()){
    REP(j, b.size()){
      cout << b[j][i];
    }
    cout << endl;
  }
}


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

typedef long long ll;

int mod(int a, int m){
    return ((a%m +m)%m);
}

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

    int n; cin>>n;
    int A[n+1], memo[n+1];
    memset(memo, 0, sizeof(memo));
    for (int i=1;i<=n;++i) cin>>A[i];

    for (int i=n;i>=1;i--){
        int cnt = 0;
        for (int j=2;j<=n/i;++j){
            int m = i*j;
            if (memo[m] == 1) cnt++;
        }
        memo[i] = mod(A[i]-cnt, 2);
    }
    int cnt = 0;
    for (int i=1;i<=n;++i) if (memo[i]==1) cnt++;
    if (cnt>0) cout<<cnt<<endl;
    bool solution = false;
    for (int i=1;i<=n;++i) 
        if (memo[i]==1){
            solution = true;
            cout<<i<<" ";
        }
    
    if (!solution) cout<<"0";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int n;
    cin >> n;
    int A[n];
    rep(i, 0, n) cin >> A[i];

    int tmp = A[0];
    int rsl = 1;
    int flag = 0;

    rep(i, 1, n) {
        if(flag == 0) {
            if(A[i] > tmp) flag = 1;
            else if(A[i] < tmp) flag = 2;
            tmp = A[i];
        } else if(flag == 1) {
            if(A[i] >= tmp) tmp = A[i];
            else {
                tmp = A[i];
                rsl++;
                flag = 0;
            }
        } else if(flag == 2) {
            if(A[i] <= tmp) tmp = A[i];
            else {
                tmp = A[i];
                rsl++;
                flag = 0;
            }
        }
    }
    cout << rsl << endl;
}


Measured memory_bytes: 640
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let  n = get!(i32);

    let mut s = 0;

    for i in n.to_string().chars() {
        s += i.to_digit(10).unwrap();
    }


    println!("{}", if n%s as i32 == 0 {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> G;
vector<bool> visited;

bool allVisited() {
  for (const auto &_ : visited) if (!_) return false;
  return true;
}

int dfs(int v) {
  if (visited[v]) return 0;

  visited[v] = true;
  int cnt = 0;
  if (allVisited()) cnt = 1;
  else for (const int &to : G[v]) cnt += dfs(to);
  visited[v] = false;

  return cnt;
}

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

  G.resize(N);
  visited.resize(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    G[--a].push_back(--b);
    G[b].push_back(a);
  }

  cout << dfs(0) << endl;
}


Measured memory_bytes: 3536
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(a[K-1])


Measured memory_bytes: 2940
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	string s, t, u;
	char input[11];

	scanf("%s", input);
	s = input;
	scanf("%s", input);
	t = input;

	int a, b;

	scanf("%d %d", &a, &b);

	scanf("%s", input);
	u = input;

	if (s == u)
	{
		a--;
	}

	else
	{
		b--;
	}

	printf("%d %d\n", a, b);

	return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }
    
int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n;
    while (cin >> n) {
        typedef pair<string,int> PSI;
        map<PSI,int> A;
        FOR(i,1,n+1) {
            string s; int p; cin >> s >> p;
            A[PSI(s,-p)] = i;
        }
        FOR_ALL(a,A)
            cout << a->second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
open Batteries
let rec loop i k ans =
  if i > k then ans else
  if (String.length @@ string_of_int i) mod 2 = 1 then loop (i+1) k (ans+1) else loop (i+1) k ans

let _ = Printf.printf "%d\n" @@ loop 1 (read_int ()) 0

Measured memory_bytes: 2688
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		ArrayList<Integer> nList = new ArrayList<>();

		for (int index = 1; index <= n; index++) {
			int m = sc.nextInt();
			nList.add(m);
		}
		Collections.sort(nList);
		int x = nList.get(0);
		int y = nList.get(nList.size() - 1);
		int z = y - x;
		System.out.println(z);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define LD long double
#define LL long long int
#define ULL unsigned long long
#define vi vector<int>
#define mod 1000000007

int main(){
    
    int N;
    cin>>N;
    vector<int> H(N,0);
    vector<int> A(N,0);
    for(int i=0; i<N; i++)
    {
        cin>>H[i];
    }
    
    A[1] = abs(H[1]-H[0]);
    
    for(int i=2; i<N; i++)
    {
        A[i] = min( (A[i-1] + abs(H[i] - H[i-1])) , (A[i-2] + abs(H[i] - H[i-2] ) ) ) ; 
    }
    
    cout << A[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
     int A,B;
   cin >> A >> B;

   int sum=A+B;
   int diff= A-B;
   int pro = A*B;
   int max = sum;

   if (diff > max){
    max = diff;
   }
   if (pro > max){
    max = pro;
   }
   cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 400005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
const int kcz=INF;
int n;
int x[MAXN],y[MAXN];
int f[5005][5005];
int js[400005],inv[400005];
inline int power(int a,int p)
{
	int ret=1;
	while(p>0)
	{
		if(p&1)
		ret=ret*1ll*a%kcz;
		a=1ll*a*a%kcz;
		p>>=1;
	}
	return ret;
}
inline void init(int n)
{
	js[0]=inv[0]=1;
	for(int i=1;i<=n;i++)
	js[i]=js[i-1]*1ll*i%kcz;
	inv[n]=power(js[n],kcz-2);
	for(int i=n-1;i;i--)
	inv[i]=inv[i+1]*1ll*(i+1)%kcz;
}
inline int C(int n,int m)
{
	return js[n]*1ll*inv[m]%kcz*inv[n-m]%kcz;
}
int main()
{
	n=read();
	init(400000);
	for(int i=1;i<=n;i++)
	{
		x[i]=read()+2500,y[i]=read()+2500;
		f[5000-x[i]][5000-y[i]]++;
	}
	for(int i=1;i<=5000;i++)
	for(int j=1;j<=5000;j++)
	{
		f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%kcz;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=((ans+f[x[i]][y[i]])%kcz-C(2*x[i]+2*y[i]-10000,2*x[i]-5000))%kcz;
	}
	printf("%d\n",(ans*1ll*inv[2]%kcz+kcz)%kcz);
	return 0;
}

Measured memory_bytes: 103424
using System;
using System.IO;

namespace Atcoder {
    class agc005a {
        static void Main(){
            string s = Console.ReadLine();

            // int T = 0;
            int S = 0;
            int len = s.Length;
            for(int i = 0; i < s.Length; i++){
                if(s[i] == 'T'){
                    if(S > 0){
                        len -= 2;
                        S -= 1;
                    }
                }
                else{
                    S += 1;
                }
            }

            Console.WriteLine(len);
        }
    }
}


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

#define repu(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a)    for(int i=0;i<a;i++)

using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n)
        cin>>a[i];
    int cnt=0;
    rep(i,n)
    {
        repu(j,i+1,n-1)
        {
            repu(k,j+1,n-1)
            {
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i] && a[i]!=a[k] && a[j]!=a[k] && a[i]!=a[j])
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            if (a == 0 && b == 0) break;
            var ret = Gcd(a, b);
            Console.WriteLine("{0} {1}",ret[0],ret[1]);
        }
    }
    public static int[] Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        var count = 0;
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
            count++;
        }
        var ret = new int[2];
        ret[0] = a;  ret[1] = count;
        return ret;
    }
}


Measured memory_bytes: 9272
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int INF = 1 << 24;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int sx = sc.nextInt();
			int sy = sc.nextInt();
			int gx = sc.nextInt();
			int gy = sc.nextInt();
			Line2D route = new Line2D.Double(sx, sy, gx, gy);
			Point2D [][] rect = new Point2D[n][4];
			int [] hlist = new int[n];
			for(int i = 0; i < n; i++){
				int x1 = sc.nextInt();
				int y1 = sc.nextInt();
				int x2 = sc.nextInt();
				int y2 = sc.nextInt();
				hlist[i] = sc.nextInt();
				rect[i][0] = new Point2D.Double(x1, y1);
				rect[i][1] = new Point2D.Double(x2, y1);
				rect[i][2] = new Point2D.Double(x2, y2);
				rect[i][3] = new Point2D.Double(x1, y2);
			}
			
			double ans = INF;
			for(int i = 0; i < n; i++){
				
				boolean isIntersect = false;
				for(int j = 0; j < 4; j++){
					Line2D nowline = new Line2D.Double(rect[i][j], rect[i][(j + 1) % 4]);
					if(route.intersectsLine(nowline)){
						isIntersect = true;
						break;
					}
				}
				if(isIntersect || isN(route, rect[i])){
					ans = 0.0;
					break;
				}
				
				double mindis = INF;
				
				for(int j = 0; j < 4; j++){
					Line2D nowline = new Line2D.Double(rect[i][j], rect[i][(j + 1) % 4]);
					double nowdis = distanceSS(route, nowline);
					mindis = Math.min(mindis, nowdis);
				}
				if(hlist[i] >= mindis){
					ans = Math.min(ans, mindis);
				}
				else{
					double r = (double)(hlist[i] * hlist[i] + mindis * mindis) / (2 * hlist[i]);
					ans = Math.min(ans, r);
				}
			}
			System.out.println(ans);
		}
		
	}
	private boolean isN(Line2D route, Point2D[] rect) {
		if(rect[0].getX() <= route.getX1() && rect[0].getY() <= route.getY1() &&
				rect[2].getX() >= route.getX1() && rect[2].getY() >= route.getY1()){
			return true;
		}
		return false;
	}
	private double distanceSS(Line2D l, Line2D m){
		double ans = 0.0;
		if(! l.intersectsLine(m)){
			double res1 = l.ptSegDist(m.getP1());
			double res2 = l.ptSegDist(m.getP2());
			double res3 = m.ptSegDist(l.getP1());
			double res4 = m.ptSegDist(l.getP2());
			ans = Math.min(Math.min(res1, res2), Math.min(res3, res4));
		}
		return ans;
	}
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 45672
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX 200000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)

int main(){
    int a;
    cin>>a;
    rept(i,1,10){
        if(a%i==0&&a/i<10){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
a, b, c = map(int, raw_input().split())

if a % 2 != 0 and b % 2 != 0 and c % 2 != 0:
	if a >= b and a >= c:
		print b * c
	elif b >= c and b >= a:
		print a * c
	elif c >= a and c >= b:
		print a * b
else:
	print 0

Measured memory_bytes: 2568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   long long L,R;
   cin >> L >> R;
   if(R-L+1>=673){
      cout << 0 << endl;
   }
   else{
      long long ans = LLONG_MAX/2;
      for(long long i=L; i<= R; i++){
         for(long long j = i+1; j <= R; j++){
            ans = min(ans, (i*j)%2019);
         }
      }
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 3e3 + 123;
const ll mod = 1e9 + 7;

int n;
string s;
ll dp[N][N];

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

	dp[1][1] = 1;
	for(int i = 2;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(s[i - 2] == '<'){
				dp[i][j] = dp[i - 1][j - 1];
			}
			else{
				dp[i][j] = (dp[i - 1][i - 1] - dp[i - 1][j - 1] + mod) % mod;
			}
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
			//cout << dp[i][j] << " " << i << " " << j << "\n";
		}
	}

	cout << dp[n][n];
	return 0;
}


Measured memory_bytes: 73984
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string s;

int main(){
    cin>>s;

    if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3])){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015
 
int main()
{

ll a,b,c,d,k=0;
cin>>a>>b>>c>>d;
while(1)
{
	//cout<<a<<c<<endl;
	c-=b;
	if(c<=0)
	{
		break;
	}
	a-=d;
	if(a<=0)
	{
		k=1;break;
	}
	
}
if(k==0)cout<<"Yes\n";
else cout<<"No\n";

}

Measured memory_bytes: 3588
#include<stdio.h>

int main(){

	int i, j, n, m, a[100][100], b[100], c[100] = {0};

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

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

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

	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			c[i] += a[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}

	return 0;
}

Measured memory_bytes: 636
def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True


def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73936
#include<stdio.h>
int main(){
    int N,M;
    scanf("%d %d",& N,&M);
    if(1<=N && N<=100){
        if(0<=M && M<=N){

        if(M==N){
            printf("Yes");
        }
        else{
            printf("No");
        }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 1000050
#define F first
#define S second
#define M 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
ll f[maxn],n,fc[maxn],fi[maxn],ans,s;
ll dp[105][105];

ll pow_(ll x,ll y){ll rt=1; while (y){if (y&1) rt=rt*x%M; x=x*x%M; y/=2;} return rt;}

ll c(ll x,ll y){if (x<y) return 0; else return fc[x]*fi[y]%M*fi[x-y]%M;}

int main()
{
    cin >> n;
    fc[0]=fc[1]=1; for (int i=2;i<=n;i++) fc[i]=fc[i-1]*i%M;
    fi[0]=fi[1]=1; for (int i=2;i<=n;i++) fi[i]=pow_(fc[i],M-2);
    ans=(n-1)*fc[n-1]%M;
    n--;
    for (int i=n/2+1;i<n;i++)
    {
        (s+=c(i-1,n-i)*fc[i]%M*fc[n-i]%M)%=M;
        //cout << i << ' ' << s << endl;
    }
    ans=(ans-s+M)%M;
    cout << ans << endl;
}


Measured memory_bytes: 16512
#include <stdio.h>
int main()
{
 int n,x;
 int s = 0,ans = 1;
 scanf("%d%d",&n,&x);
 int a[n];
 for(int i = 0;i < n;i++)
  scanf("%d",&a[i]);
 for(int i = 0;i < n;i++)
 {
  s += a[i];
  if(s <= x)
   ans++;
 }
 printf("%d\n",ans);
}

Measured memory_bytes: 128