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

const int MAX = 1e6;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	while (cin >> N, N) {
		vector<int> hp(N);
		for (int i = 0; i < N; i++) {
			cin >> hp[i];
		}
		sort(hp.begin(), hp.end());
		int M;
		cin >> M;
		vector<ll> dp_s(MAX + 1, 1e17);
		vector<ll> dp_a(MAX + 1, 1e17);
		dp_s[0] = dp_a[0] = 0;
		for (int i = 0; i < M; i++) {
			string sp, ta;
			int mp, dm;
			cin >> sp >> mp >> ta >> dm;
			if (ta == "Single") {
				for (int i = 0; i <= MAX; i++) {
					int t = min(MAX, i + dm);
					dp_s[t] = min(dp_s[t], dp_s[i] + mp);
				}
				for (int i = MAX - 1; i >= 0; i--) {
					dp_s[i] = min(dp_s[i + 1], dp_s[i]);
				}
			}
			else {
				for (int i = 0; i <= MAX; i++) {
					int t = min(MAX, i + dm);
					dp_a[t] = min(dp_a[t], dp_a[i] + mp);
				}
				for (int i = MAX - 1; i >= 0; i--) {
					dp_a[i] = min(dp_a[i + 1], dp_a[i]);
				}
			}
		}
		ll res = LLONG_MAX;
		for (int i = 0; i <= MAX; i++) {
			ll val = dp_a[i];
			for (int j = 0; j < N; j++) {
				val += dp_s[max(0, hp[j] - i)];
			}
			res = min(res, val);
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 18560
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int r = 0;
  sort(l, l+n);
  for(int i = 0; i < n;) {
    int j = i+1;
    while(j < n && l[i] == l[j]) {
      j++;
    }
    r += j-i-1;
    i = j;
  }
  printf("%d\n", n-2*((r+1)/2));
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int cnt = 0;
		for(int i = 0; i < n; i++){
			int h = sc.nextInt();
			if(h >= max){
				cnt++;
				max = h;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21716
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,T = LMIIS()
    AB = []
    for i in range(N):
        AB.append(LMIIS())
    
    AB.sort()
    dp = [-1] * (T+3000)
    dp[0] = 0
    for a,b in AB:
        tmpdp = dp[:]
        for j in range(T):
            if dp[j] != -1:
                tmpdp[j+a] = max(dp[j+a],dp[j]+b)
        dp = tmpdp
    print(max(dp))






if __name__ == '__main__':
    main()

Measured memory_bytes: 71032
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

const int MAXN = 2002;
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;

template<typename T> inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}

template<typename T> inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}

template <typename T> inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

int n, T;
int c[MAXN], t[MAXN];

signed main() {
	read(n), read(T);
	int ans = INF;
	for(int i = 1; i <= n; i++) {
		read(c[i]), read(t[i]);
		if(t[i] <= T) CheckMin(ans, c[i]);
	}
	if(ans != INF) printf("%d\n", ans);
	else puts("TLE");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int P[100000];
int inv[100000];
int main(){
  int KL2GvlyY, Q5VJL1cS, i, k, lef1, lef2, rig1, rig2;
  long long res=0;
  multiset<int> s;
  multiset<int>::iterator it1, it2;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(P[Lj4PdHRW]);P[Lj4PdHRW] += (-1);
    }
  }
  for(i=0;i<(N);i++){
    inv[P[i]] = i;
  }
  for(KL2GvlyY=0;KL2GvlyY<(2);KL2GvlyY++){
    s.insert(-1);
  }
  for(Q5VJL1cS=0;Q5VJL1cS<(2);Q5VJL1cS++){
    s.insert(N);
  }
  for(k=N-1;k>=0;k--){
    i = inv[k];
    it1 = it2 = s.insert(i);
    lef1 = *(--it1);
    lef2 = *(--it1);
    rig1 = *(++it2);
    rig2 = *(++it2);
    res += (long long) (k+1) * (lef1-lef2) * (rig1 - i);
    res += (long long) (k+1) * (rig2-rig1) * (i - lef1);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, P[1d5];
// 
// int inv[1d5];
// {
//   int i, k;
//   int lef1, lef2, rig1, rig2;
//   multiset<int> s;
//   multiset<int>::iterator it1, it2;
//   ll res = 0;
//   
//   rd(N,(P--)(N));
//   rep(i,N) inv[P[i]] = i;
// 
//   rep(2) s.insert(-1);
//   rep(2) s.insert(N);
// 
//   for(k=N-1;k>=0;k--){
//     i = inv[k];
//     it1 = it2 = s.insert(i);
//     lef1 = *(--it1);
//     lef2 = *(--it1);
//     rig1 = *(++it2);
//     rig2 = *(++it2);
// 
//     res += (ll) (k+1) * (lef1-lef2) * (rig1 - i);
//     res += (ll) (k+1) * (rig2-rig1) * (i - lef1);
//   }
// 
//   wt(res);
// }


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

#define MOD 1000000007

typedef long long ll;

void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
ll modInverse(ll a) { return modPow(a, MOD-2); }
ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

int main() {

	#ifdef tajir
		freopen("input.txt","r",stdin);
	#else
		//online submission
	#endif
	
	int n,k;

	cin >> n >> k;

	vector < int > dp(k+1,0);

	dp[0] = 1;

	for(int child = 0; child < n; ++child)  {
		int up_to;
		cin >> up_to;

		vector < int > dp2(k+1,0);

		for(int used = k; used >= 0; --used) {
			int L = used + 1 , R = used + min(up_to , k - used);
			if(L > R)	continue; 
			dp2[L] = modAdd(dp2[L] , dp[used]);
			if(R+1 <= k)
				dp2[R+1] = modSub(dp2[R+1] , dp[used]);
		}

		for(int i = 0; i <= k; ++i) {
			dp2[i] = modAdd(dp2[i] , dp2[i-1]);

			dp[i] = modAdd(dp[i] , dp2[i]);
		}
	}

	cout << dp[k] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct{
  int k;
  int v[100];
}G;

void dfs(int);
void visit(int);

int time;
int d[MAX],f[MAX],color[MAX];
G Adj[101];

int main(){
  int i,j,k,n,u;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&Adj[u].k);
    for(j=0;j<Adj[u].k;j++) scanf("%d",&Adj[u].v[j]);
  }  
  
  dfs(n);

  for(i=1;i<=n;i++) printf("%d %d %d\n",i,d[i],f[i]);
  
  return 0;
}

void dfs(int u){
  int i;

  for(i=1;i<=u;i++) color[i]=WHITE;

  time=0;

  for(i=1;i<=u;i++){
    if(color[i]==WHITE) visit(i);
  }
}

void visit(int u){
  int a,i;
  
  color[u]=GRAY;
  d[u]=++time;

  for(i=0;i<Adj[u].k;i++){
    a=Adj[u].v[i];
    if(color[a]==WHITE) visit(a);
  }

  color[u]=BLACK;
  f[u]=++time;
}



Measured memory_bytes: 2112
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   
   int l,r,d;
   cin >> l >> r >> d;
   int c = 0;
   for(int i = l ; i<=r ; i++){
    if(i%d==0){
      c++;
    }
   }
   cout << c;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;

const int N = 1000 + 10;

int a[N*2], b[N*2];
ll c[N*2];
int main(void)
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    ll dist[N];
    bool negative[N];
    memset(dist, 0x3f, sizeof dist);
    memset(negative, 0, sizeof negative);
    dist[1] = 0;

    for (int loop = 0; loop < n - 1; ++ loop)
    {
        for (int i = 1; i <= m; ++i)
        {
            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    ll ans = dist[n];
    for (int loop = 0; loop < n ; ++ loop)
    {
        for (int i = 1; i <= m; ++i)
        {

            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
                negative[b[i]] = true;
            }

            if (negative[a[i]] == true)
            {
                negative[b[i]] = true;
            }
        }
    }
    if (negative[n])
        cout << "inf" << endl;
    else
        cout << -ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	reader *bufio.Scanner
}

func (s *Scanner) Next() string {
	s.reader.Scan()
	return s.reader.Text()
}

func (s *Scanner) NextInt() int {
	s.reader.Scan()
	val, err := strconv.Atoi(s.reader.Text())
	if err != nil {
		panic(err)
	}
	return val
}

var sc *Scanner

func init() {
	sc = &Scanner{bufio.NewScanner(os.Stdin)}
	sc.reader.Split(bufio.ScanWords)
}

func main() {
	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()

	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1092
n = int(input())
a = [(int(i), 0) for i in input().split()]
b = [(int(i), 1) for i in input().split()]
c = [(int(i), 2) for i in input().split()]

d = {}
for i, j in sorted(a + b + c):
    if i in d:
        d[i].append(j)
    else:
        d[i] = [j]


x = 0
y = 0
z = 0

for i in sorted(list(d)):
    xx = x
    yy = y

    for j in d[i]:
        if j == 0:
            x = x + 1
        elif j == 1:
            y += xx
        else:
            z += yy

print(z)


Measured memory_bytes: 126516
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

line x1 y1 x2 y2 x y = (y2 - y1) * x - (x2 - x1) * y - x1 * y2 + x2 * y1

convex [xa,ya,xb,yb,xc,yc,xd,yd] = l1 xb yb * l1 xd yd < 0 && l2 xa ya * l2 xc yc < 0
  where
    l1 = line xa ya xc yc
    l2 = line xb yb xd yd

main = do
    ls <- map (map read . wordsBy (==',')) . lines <$> getContents :: IO [[Double]]
    forM_ ls $ \line -> do
    putStrLn $ cond "YES" "NO" $ convex line
        

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> alis(n+1), blis(m+1);
    REP(i, 0, n){
        cin >> alis[i+1];
    }
    REP(i, 0, m){
        cin >> blis[i+1];
    }
    REP(i, 0, n){
        alis[i+1] = alis[i+1] + alis[i];
    }
    REP(i, 0, m){
        blis[i+1] = blis[i+1] + blis[i];
    }
    ll ans = 0;
    REP(i, 0, n+1){
        ll c = k - alis[i];
        if(c < 0){
            break;
        }
        auto It = upper_bound(ALL(blis), c);
        ll mid  = i + ((It - blis.begin()) - 1);
        ans = max(mid, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6424
#include <algorithm> //STLÍ¨ÓÃËã·¨
#include <cmath> //¶¨ÒåÊýÑ§º¯Êý
#include <cstdio> //¶¨ÒåÊäÈë/Êä³öº¯Êý
#include <iostream> //Êý¾ÝÁ÷ÊäÈë/Êä³ö
#include <cstring> //×Ö·û´®´¦Àí
#include <string> //×Ö·û´®Àà
#include <ctime> //¶¨Òå¹ØÓÚÊ±¼äµÄº¯Êý
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLÎ»¼¯ÈÝÆ÷
#include <cstype> //×Ö·û´¦Àí
#include <cerrno> //¶¨Òå´íÎóÂë
#include <complex> //¸´ÊýÀà
#include <clocale> //¶¨Òå±¾µØ»¯º¯Êý
#include <cstdlib> //¶¨ÒåÔÓÏîº¯Êý¼°ÄÚ´æ·ÖÅäº¯Êý
#include <deque> //STLË«¶Ë¶ÓÁÐÈÝÆ÷
#include <exception> //Òì³£´¦ÀíÀà
#include <fstream> //ÎÄ¼þÊäÈë/Êä³ö
#include <functional> //STL¶¨ÒåÔËËãº¯Êý(´úÌæÔËËã·û)
#include <limits> //¶¨Òå¸÷ÖÖÊý¾ÝÀàÐÍ×îÖµ³£Á¿
#include <list> //STLÏßÐÔÁÐ±íÈÝÆ÷
#include <map> //STLÓ³ÉäÈÝÆ÷
#include <iomanip> //²ÎÊý»¯ÊäÈë/Êä³ö
#include <ios> //»ù±¾ÊäÈë/Êä³öÖ§³Ö
#include <iosfwd> //ÊäÈë/Êä³öÏµÍ³Ê¹ÓÃµÄÇ°ÖÃÉùÃ÷
#include <istream> //»ù±¾ÊäÈëÁ÷
#include <ostream> //»ù±¾Êä³öÁ÷
#include <queue> //STL¶ÓÁÐÈÝÆ÷
#include <set> //STL¼¯ºÏÈÝÆ÷
#include <sstream> //»ùÓÚ×Ö·û´®µÄÁ÷
#include <stack> //STL¶ÑÕ»ÈÝÆ÷
#include <stdexcept> //±ê×¼Òì³£Àà
#include <streambuf> //µ×²ãÊäÈë/Êä³öÖ§³Ö
#include <utility> //STLÍ¨ÓÃÄ£°åÀà
#include <vector> //STL¶¯Ì¬Êý×éÈÝÆ÷
#include <cwchar.h>//¿í×Ö·û´¦Àí¼°ÊäÈë/Êä³ö
#include <cwctype.h> //¿í×Ö·û·ÖÀà*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

const int N=1010;
int cnt=0;
int a[N],s[N],d[N],f[N];

void add(int x,int y,int z){a[++cnt]=x;s[cnt]=y;d[cnt]=z;}

int main()
{
	int L,n;
	read(L);
	n=20;
	for (int i=n-1;i>=2;i--) add(i,i+1,1<<n-i-1),add(i,i+1,0);
	int top=0,sum=0;
	while (L>=262144) add(1,2,sum),sum+=262144,L-=262144;
	while (L) f[++top]=L%2,L/=2;
	for (int i=top;i>=1;i--)
	{
		if (!f[i]) continue;
		add(1,n-i+1,sum);
		sum+=1<<i-1;
	}
	printf("%d %d\n",n,cnt);
	for (int i=1;i<=cnt;i++) printf("%d %d %d\n",a[i],s[i],d[i]);
	return 0;
}








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

int main()
{
    int N;
    cin >> N;
    set<string> ans;
    rep(i,N){
      string S;
      cin >> S;
      ans.insert(S);
    }
    cout << ans.size() << endl;
    return 0;
}

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

int main()
{
	char p,q;
	int a,b,c;
	int x=0,y=0;
	while(cin >> a >> p >> b >> q >> c)
	{
		if(a*a+b*b==c*c)	x++;
		if(a==b)			y++;
	}
	cout << x << endl << y << endl;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        long X = cin.nextlong;
        long Y = cin.nextlong;

        if (X % Y == 0)
        { 
            WriteLine(-1);
        }
        else
        {
            var d = gcd(X, Y);
            var l = X * Y / d;
            WriteLine(l + X);
        }
    }

    long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int mn = inf;
	
	sort(a, a + 3);
	do {
		mn = min(mn, abs(a[2] - a[1]) + abs(a[1] - a[0]));
	}	while (next_permutation(a, a + 3));

	cout << mn;
	end_routine;
}


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

void fnTrace(vector<int> &argviSort, int argiSize)
{
  for (int i = 0; i < argiSize; i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
}

void insertionSort(vector<int> &argviSort, int argiSize)
{
  for (int i = 1; i < argiSize; i++)
  {
    int iTarget = argviSort[i];
    int j = i - 1;
    while (iTarget < argviSort[j] &&
           j       >= 0            )
    {
      argviSort[j + 1] = argviSort[j];
      j--;
    }
    argviSort[j + 1] = iTarget;
    fnTrace(argviSort, argiSize);
  }
}

int main()
{
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  viSort.resize( iMaxSize );
  for (int i = 0; i < iMaxSize; i++) cin >> viSort[i];

  fnTrace(viSort, iMaxSize);
  insertionSort(viSort, iMaxSize);

  return 0;
}

Measured memory_bytes: 1200
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
flg=False

def check(i, j):
    cnt=0
    for k in range(M):
        for l in range(M):
            if A[i+k][j+l] == B[k][l]:
                cnt += 1
    if cnt==M**2:
        return True
    
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            flg = check(i, j)
            if flg:
                break
    if flg:
        break
            
ans='Yes' if flg else 'No'
print(ans)

Measured memory_bytes: 3064
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

bool f(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    string s;
    cin >> s;
    int n = sz(s);
    string r = s.substr(0, (n-1)/2);
    string t = s.substr((n+3)/2-1, n-(n+3)/2+1);
    if (f(r) && f(t) && f(s))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}



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

int n,l;
int ice[100002],memo[100002];

int drop(int i){
	if(~memo[i])return memo[i];
	int res=0;
	if(ice[i+1]>ice[i])res=max(res,drop(i+1));
	if(ice[i-1]>ice[i])res=max(res,drop(i-1));
	return memo[i]=res+(l-ice[i]);
}

int main(void){
	int ans=0;
	scanf("%d%d",&n,&l);
	memset(ice,0,sizeof(ice));
	memset(memo,-1,sizeof(memo));
	for(int i=1;i<=n;i++){
		scanf("%d",&ice[i]);
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,drop(i));
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n;
	cin >> n;
	map<int,int> m;
	int a[100005] = {};
	rep(i,0,n){
        int b;
        cin >> a[i] >>b;
        m[a[i]] = b;
	}
	sort(a,a+n);

    P(a[n-1] -a[0]+1 + a[0]-1 + m[a[n-1]]);

	return  0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] dist = new int[h * w][h * w];
		int road = 1000;
		int inf = 5000;
		String[] s = new String[h];
		for(int i = 0; i < h; i++) {
			s[i] = sc.next();
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				for(int k = 0; k < h; k++) {
					for(int l = 0; l < w; l++) {
						if(s[i].charAt(j) == '.' && s[k].charAt(l) == '.') {
							if(i == k && j == l) {
								dist[i * w + j][k * w + l] = 0;
								dist[k * w + l][i * w + j] = 0;
							} else {
								dist[i * w + j][k * w + l] = road;
								dist[k * w + l][i * w + j] = road;
							}
						} else {
							dist[i * w + j][k * w + l] = inf;
							dist[k * w + l][i * w + j] = inf;
						}
					}
				}
			}
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(i != 0 && s[i - 1].charAt(j) == '.' && s[i].charAt(j) == '.') {
					dist[i * w + j][(i - 1) * w + j] = 1;
					dist[(i - 1) * w + j][i * w + j] = 1;
				}
				if(i != h - 1 && s[i + 1].charAt(j) == '.' && s[i].charAt(j) == '.') {
					dist[i * w + j][(i + 1) * w + j] = 1;
					dist[(i + 1) * w + j][i * w + j] = 1;
				}
				if(j != 0 && s[i].charAt(j - 1) == '.' && s[i].charAt(j) == '.') {
					dist[i * w + j][i * w + j - 1] = 1;
					dist[i * w + j - 1][i * w + j] = 1;
				}
				if(j != w - 1 && s[i].charAt(j + 1) == '.' && s[i].charAt(j) == '.') {
					dist[i * w + j][i * w + j + 1] = 1;
					dist[i * w + j + 1][i * w + j] = 1;
				}
			}
		}
		for(int k = 0; k < h * w; k++) {
			for(int i = 0; i < h * w; i++) {
				for(int j = 0; j < h * w; j++) {
					if(dist[i][k] + dist[k][j] < dist[i][j] && dist[i][j] != inf) {
						dist[i][j] = dist[i][k] + dist[k][j];
					}
				}
			}
		}

		int ans = 0;
		for(int i = 0; i < h * w; i++) {
			for(int j = 0; j < h * w; j++) {
				if(dist[i][j] != inf)
					ans = Math.max(ans, dist[i][j]);
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 33772
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin >> n >> k;
  k--;
  string s;
  cin >>s;
  s[k]+=32;
  cout<<s<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

void dfs(vvll &g, vll &ns, vll &vis, ll i, ll x) {
	vis[i] = 1;
	ns[i] += x;
	for (int j = 0; j < g[i].size(); j++) {
		if (vis[g[i][j]] == 0)
			dfs(g, ns, vis, g[i][j], ns[i]);
	}
}

int main()
{
	ll n, q, i, a, b, p, x;
	scanf("%lld %lld", &n , &q);
	vvll gr(n + 1);
	vll ns(n + 1), vis(n + 1);
	for (i = 0; i < n - 1; i++) {
		scanf("%lld %lld", &a, &b);
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	for (i = 0; i < q; i++) {
		scanf("%lld %lld", &p, &x);
		ns[p] += x; 
	}
	dfs(gr, ns, vis, 1, 0);
	for (i = 1; i <= n; i++)
		printf("%lld ", ns[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 28928
def main():
    cost = []
    for _ in range(5):
        cost.append(int(input()))

    cost.sort(key=lambda v: (v - 1) % 10)

    t = 0
    for c in cost[1:]:
        t += c
        if t % 10 != 0:
            t = (t // 10 + 1) * 10
    t += cost[0]
    print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
{AT2523}
var
n:int64;
i:longint;
s:string;
begin
read(n);
for i:=trunc(sqrt(n)) downto 1 do
 if n mod i=0 then
 begin
 str(n div i,s);
 writeln(length(s));
 halt;
 end;
end.

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{

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

    string s , t;
    cin >> s >> t;
    vi freq(400);
    for(char c : s)freq[c]++;
    for(char c : t){
        if(freq[c] == 0){
            cout << -1 << endl;
            return 0;
        }
    }

    for(char &c : s)c -= 'a';
    for(char &c : t)c -= 'a';


    vector<vi> dp(SZ(s) + 1 , vi(26));

    loop(i,26)dp.back()[i] = SZ(dp);

    rloop(i,SZ(dp)-2){
        loop(j,26)dp[i][j] = dp[i+1][j];
        dp[i][s[i]] = i;
    }

    int cnt = 0 , lst = 0;
    loop(i,SZ(t)){
        if(dp[lst][t[i]] == SZ(dp)){
            lst = 0;
            i--;
            cnt++;
            continue;
        }

        lst = dp[lst][t[i]] + 1;
    }

    cout << 1LL * cnt * SZ(s) + lst << endl;


    return 0;
}


Measured memory_bytes: 13776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,a[114514];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans=0,x;
	bool f=1;
	for(int i=0;i<n;i++){
		if(i==n-1)ans++;
		else{
			if(f){
				if(a[i]==a[i+1])x=0;
				else{
					f=0;
					if(a[i]<a[i+1])x=1;
					if(a[i]>a[i+1])x=2;
				}
			}else{
				if(x==1){
					if(a[i]>a[i+1]){
						f=1;
						ans++;
					}
				}else{
					if(a[i]<a[i+1]){
						f=1;
						ans++;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
//abc133_d.cpp
//Sun Jul  7 20:47:41 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	ll ans[n];
	fill(ans,ans+n,0);

	ll temp = 0;
	for (int i=1;i<n-1;i=i+2){
		temp += a[i];
	}

	ans[0] = total-2*temp;

	for (int i=1;i<n;i++){
		ans[i] = a[i-1]*2-ans[i-1];
	}
	for (int i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	printf("\n");
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9;
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for(int i = 1; i <= n; ++i){
    if(i%3 != 0 && i%5 != 0)sum+=i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <list>

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e19;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<double> A(N);
    double ttl = 1;
    double up = 1;
    REP(i, N){
        cin >> A[i];
        ttl *= A[i];
        up *= A[i];
    }
    double lwr = 0;

    REP(i, N){
        lwr += ttl/(double)A[i];
    }
//    cout << ttl << "," << up << ","<< lwr << endl;
    printf("%lf\n", up/lwr);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    // a+b = l*K, b = l*K - a
    // b+c = m*K, l*K + n*K - 2*a = m*K
    // c+a = n*K, c = n*K - a
    //
    // (l+n-m)*K = 2*a
    // x*K = 2*a
    // y*K = 2*b
    // z*K = 2*c
    
    int sum1 = 0;
    int sum2 = 0;
    for (int a = 1; a <= N; a++) {
      if (a%K == 0) {
        sum1++;
      }
      if (K%2 == 0 && a%K == K/2) {
        sum2++;
      }
    }
    
    System.out.println((long)sum1*sum1*sum1 + (long)sum2*sum2*sum2);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int N; cin >> N;
    vec s(N);
    vec COPY(N);
    int sum = 0;
    REP(i,N){
        cin>>s[i];
        COPY[i] = s[i];
        sum += s[i];
    }
    Sort(COPY);
    int L= COPY[N/2-1];
    int M = COPY[N/2];
    REP(i,N){
        if(s[i]<=L) Out(M);
        else Out(L);
    }
}
  


Measured memory_bytes: 5376
package main

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

func main() {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanLines)

	if ok := stdin.Scan(); !ok {
		print("Error to scan.")
	}

	if err := stdin.Err(); err != nil {
		print("Error to scan.")
	}

	age, err := strconv.Atoi(stdin.Text())
	if err != nil {
		print("Error to parse.")
	}

	switch age {
	case 3, 5, 7:
		fmt.Println("YES")
	default:
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int cmpx=c-a,cmpy=d-b;
    cout << c-cmpy << " " << d+cmpx << " " << (c-cmpy)-cmpx << " " << (d+cmpx)-cmpy << endl;



    return 0;
}

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

map<pair<int, int>, int> mp;
int h, w, n;
int cnt[10];

int main(){
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        for(int X = x - 2; X <= x; X++){
            for(int Y = y - 2; Y <= y; Y++){
                if(1 <= X && 1 <= Y && X <= h - 2 && Y <= w - 2) mp[make_pair(X, Y)]++;
            }
        }
    }
    for(map<pair<int, int>, int>::iterator it = mp.begin(); it != mp.end(); it++) cnt[it->second]++;
    long long ans = (long long)(h - 2) * (long long)(w - 2);
    for(int i = 1; i <= 9; i++) ans -= (long long)cnt[i];
    printf("%lld\n", ans);
    for(int i = 1; i <= 9; i++) printf("%d\n", cnt[i]);
}


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

ll knapsack(vector <ll> weight, vector <ll> value, ll w, ll n)
{
    ll knapsackDP[n+1][w+1];

    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                knapsackDP[i][j] = 0;
            else if(weight[i-1] <= j)
                knapsackDP[i][j] = max(knapsackDP[i-1][j], knapsackDP[i-1][j-weight[i-1]]+value[i-1]);
            else
                knapsackDP[i][j] = knapsackDP[i-1][j];
        }
    }

    return knapsackDP[n][w];
}

int main()
{
    ll n,w,solution;
    cin>>n>>w;
    
    vector <ll> weight(n);
    vector <ll> value(n);

    for(int i=0;i<n;i++)
    {
        cin>>weight.at(i);
        cin>>value.at(i);
    }

    solution = knapsack(weight, value, w, n);

    cout<<solution<<"\n";

    return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int n,d;
int X[20][20];

int calc(int i, int j){
    int sum = 0;
    rep(v, d){
        sum += (X[i][v] - X[j][v]) * (X[i][v] - X[j][v]);
    }
    return sum;
}

int main(){
    cin >> n >> d;
    rep(i,n){
        rep(j,d){
            cin >> X[i][j];
        }
    }
    int ans = 0;
    rep(i,n){
        for(int j=i+1; j<n; j++){
            
            int temp = calc(i,j);
            for(int k=1; k<=temp; k++){
                if(k*k == temp){
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <cassert>

using namespace std;

int change( int *data, int floor )
{
	switch( data[floor] ){
		case 0:
			return floor;
			break;
		case 1:
			while( data[floor] == 1 ) floor++;
			floor--;
			return floor;
			break;
		case 2:
			while( data[floor] == 2 ) floor--;
			return floor;
			break;
	}

	assert(0);
	return -1;
}

int solve( int data1[], int data2[], int n, int s )
{
	int dist[2000];
	int pred[2000];

	int start1 = change( data1, 0 );
	int start2 = change( data2, 0 );
	set<int> history;

	for( int i = 0;i < 2000;i++ ) pred[i] = -1;
	for( int i = 0;i < 2000;i++ ) dist[i] = 999999;

	dist[start1 << 1] = 0;
	dist[( start2 << 1 ) + 1] = 0;
	queue<int> q;

	q.push( ( start1 << 1 ) );
	q.push( ( start2 << 1 ) + 1 );
	while( !q.empty() ){
		int u = q.front();
		int hoge = u;
		int *data = ( u & 1 ) ? data1 : data2;
		int building = !( u & 1 );
		u = ( u >> 1 );

		if( u == n - 1 ) return dist[hoge];

		for( int i = 0;i < 3;i++ ){
			if( i + u >= n ) break;
			int v = change( data, u + i );
			v = ( v << 1 ) + building;
			if( history.count( v ) ) continue;
			if( dist[v] == 999999 ) dist[v] = dist[hoge] + 1;
			pred[v] = hoge;
			q.push( v );
			history.insert( v );
		}

		q.pop();
	}
	return -1;
}



int main(void)
{
	int n;
	int data1[101];
	int data2[101];

	while( cin >> n && n != 0 ){
		for( int i = 0;i < 101;i++ ) data1[i] = data2[i] = 0;

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

		int answer = solve( data1, data2, n, 0 );
		if( answer == -1 ) cout << "NA" << endl;
		else cout << answer << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto ab = readln.split.to!(int[]);
    int s, i = 1;
    while (i <= ab[1] - ab[0]) {
        s += i;
        ++i;
    }
    writeln(s - ab[1]);
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	final static PrintStream so = System.out;
	final static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		int k = sc.nextInt();
		int[] b = new int[k];
		for (int i = 0; i < k; i++) {
			b[i] = sc.nextInt();
		}
		
		for (int i = n; ; i++) {
			if (!containtsDigit(i, b)) {
				so.println(i);
				return;
			}
		}
	}
	
	static boolean containtsDigit(final int in, final int[] digits) {
		int i = in;
		while (i > 0) {
			int digit = i % 10;
			for (int d: digits)
				if (digit == d)
					return true;
			i = i / 10;
		}
		return false;
	}
}


Measured memory_bytes: 21972
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑


int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) { cout << 0 << endl; }
	else { cout << 10 << endl; }
}

Measured memory_bytes: 256
import math
A, B, H, M = [int(_) for _ in input().split()]

radA = math.radians(H * 360 / 12 + M * 360 / 12 / 60)
radB = math.radians(M * 360 / 60)

xa = A * math.sin(radA)
ya = A * math.cos(radA)

xb = B * math.sin(radB)
yb = B * math.cos(radB)

print(math.sqrt((xa - xb) ** 2 + (ya - yb) ** 2))


Measured memory_bytes: 9500
#include<stdio.h>
int main()
{
	long long n,a[100],x[100][21]={0},i,j;
	scanf("%lld",&n);
	for(i=0;i<n;++i)scanf("%lld",&a[i]);
	x[0][a[0]]=1;
	for(i=1;i<n-1;++i)
	{
		for(j=0;j<21;++j)if(x[i-1][j])
		{
			if(j-a[i]>=0) x[i][j-a[i]]+=x[i-1][j];
			if(j+a[i]<=20)x[i][j+a[i]]+=x[i-1][j];
		}
	}
	printf("%lld\n",x[n-2][a[n-1]]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	cin >> n;
	int b[n + 1] = {0};
	int i;
	for (i = 1; i < n; i++)
	{
		cin >> k;
		b[k]++;
	}

	for (i = 1; i < n + 1; i++)
	{
		cout << b[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 4412