akhauriyash/Code-Regression huggingface dataset:
N = int(input())
L = list(map(int, input().split()))

L = list(reversed(sorted(L)))
cnt = 0
for i1, l1 in enumerate(L):
    for i2, l2 in enumerate(L[i1+1:]):
        for i3, l3 in enumerate(L[(i1 + i2 + 1):]):
            if len(set([l1, l2, l3])) != 3:
                continue
            if l1 >= (l2 + l3):
                break
            cnt += 1
print(cnt)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    string s,ans="";cin>>s;
    int len=s.size();
    for(int i=0;i<len;i+=2){
        ans+=s[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int T[205];
int A[205], B[205], C[205];

//! dp[i日目に][服kを選んだ時の]=最大値
int dp[205][205];

int main()
{
	int D, N;
	cin >> D >> N;
	REP(i, D)
	{
		cin >> T[i];
	}
	REP(i, N)
	{
		cin >> A[i] >> B[i] >> C[i];
	}
	memset(dp, 0, sizeof(dp));

	FOR(i, D, 1)
	{
		REP(j, N)
		{
			//! i日目に選ぶ服
			if (T[i] < A[j] || B[j] < T[i])
			{
				dp[i][j] = 0;
				continue;
			}
			int m = 0;
			REP(k, N)
			{
				//! i-1に選ぶ服
				if (T[i - 1] < A[k] || B[k] < T[i - 1])
				{
					continue;
				}
				m = std::max(m, abs(C[k] - C[j]) + dp[i - 1][k]);
			}
			dp[i][j] = m;
		}
	}

	int max = 0;
	REP(i, N)
	{
		max = std::max(max, dp[D - 1][i]);
	}
	cout << max << endl;
	return 0;
}


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

int n, m, h[100005];
vector<pair<int, int> > adj[100005];

int main() {
	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		cin >> h[i];
	}
	int a, b;
	for (int i=0; i<m; i++) {
		cin >> a >> b;
		adj[a].push_back(make_pair(b, h[b]));
		adj[b].push_back(make_pair(a, h[a]));
	}
	int good = 0;
	for (int i=1; i<=n; i++) {
		if (adj[i].size() == 0) {
			good++;
			continue;
		}
		bool flag = true;
		for (auto x : adj[i]) {
			if (x.second >= h[i]) {
				flag = false;
				break;
			}
		}
		if (flag) good++;
	}
	cout << good << "\n";
}

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

const int N = 2005;

int n, a[N], E[N][N], e[N][N], ind[N], vis[N], inq[N];

void link(int x, int y) { ++ind[y], e[x][y] = 1; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> a[i];
	std::sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (std::__gcd(a[i], a[j]) > 1) E[i][j] = E[j][i] = 1;
	std::function<void(int)> dfs = [&] (int x) {
		vis[x] = 1;
		for (int i = 1; i <= n; ++i) if (E[x][i] && !vis[i])
			e[x][i] = 1, ++ind[i], dfs(i);
	};
	for (int i = 1; i <= n; ++i) if (!vis[i]) dfs(i);
	for (int i = 1; i <= n; ++i) if (!ind[i]) inq[i] = 1;
	for (int i = 1; i <= n; ++i) {
		int t;
		for (t = n; t; --t) if (inq[t]) break;
		inq[t] = 0, std::cout << a[t] << ' ';
		for (int j = 1; j <= n; ++j)
			if (e[t][j] && !--ind[j]) inq[j] = 1;
	}
	std::cout << '\n';
	return 0;
}

Measured memory_bytes: 30848
#include <iostream>
#include <string>
const double INF = 9999999999999999;
using namespace std;

const string kaikyu[] = {"light fly", "fly", "bantam", "feather", "light",
                         "light welter", "welter", "light middle", "middle",
                         "light heavy", "heavy" };
const double hikaku[] = {48, 51, 54, 57, 60, 64, 69, 75, 81, 91, INF};

int main(void) {
  double weight;
  while (cin >> weight) {
    int i = 0;
    while (hikaku[i] < weight) {
      i++;
    }
    cout << kaikyu[i] << endl;
  }

  return 0;
}

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

int main()
{
    int K, X;
    cin >> K >> X;
    int left = max(-1000000, X - (K - 1) - 1);
    int right = min(1000000, X + (K - 1) - 1);
    for (int i = left + 1; i <= right + 1; i++)
    {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */




import java.util.* ;

/**
 *
 * @author nai
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int man, gosen, sen;
        boolean isAns = false;
        
        LOOP1 : for(int mi = 0 ; mi <= N ; mi++){
            for(int gi = 0 ; gi <= N - mi ; gi++){
                int si =   ( Y - mi * 10000 - gi * 5000 ) / 1000; 
                if(si == N - mi - gi){
                    isAns =true;
                    System.out.print(mi+" "+gi+" "+si);
                    break LOOP1;
                }
            }
        }
        if(!isAns){
            System.out.println("-1 -1 -1");
        }
    }
}
  
    



Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <utility>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = LLONG_MAX;
const ll MAX_V = ll(1e5) + 5;

ll V, Q, k, dmin[MAX_V];

struct edge {
    ll from, to, cost;
};
vector<edge> G[MAX_V];

void dijkstra(int s) {
    fill(dmin, dmin + V, INF);
    dmin[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push({0, s});

    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (dmin[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (dmin[e.to] > dmin[v] + e.cost) {
                dmin[e.to] = dmin[v] + e.cost;
                q.push({dmin[e.to], e.to});
            }
        }
    }
}

int main() {
    cin >> V;
    for (int i = 0; i < V - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back({a, b, c});
        G[b].push_back({b, a, c});
    }
    cin >> Q >> k;
    k--;
    dijkstra(k);
    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dmin[x] + dmin[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 12464
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,tot,f[1010][5010],a[1010],mn[1010],g[5010],e[100010],nt[100010],hd[100010];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void dfs(int x,int fa){
	int i,j;
	for(i=1;i<=a[x];i++)f[x][i]=1e9;
	f[x][0]=0;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
		for(j=0;j<=a[x];j++)g[j]=1e9;
		for(j=a[x]-a[e[i]];j>=0;j--)if(f[x][j]<1e9)g[j+a[e[i]]]=min(g[j+a[e[i]]],f[x][j]+mn[e[i]]);
		//for(j=0;j<=a[x];j++)f[x][j]=min(f[x][j],g[j]);
		//for(j=0;j<=a[x];j++)g[j]=1e9;
		for(j=a[x]-mn[e[i]];j>=0;j--)if(f[x][j]<1e9)g[j+mn[e[i]]]=min(g[j+mn[e[i]]],f[x][j]+a[e[i]]);
		for(j=0;j<=a[x];j++)f[x][j]=g[j];
	}
	mn[x]=1e9;
	for(j=0;j<=a[x];j++)mn[x]=min(mn[x],f[x][j]);
	//printf("%d %d\n",x,mn[x]);
}
int main(){
	int i,x;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		scanf("%d",&x);
		build(x,i);
	}
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	dfs(1,0);
	if(mn[1]>50000000)puts("IMPOSSIBLE");
	 else puts("POSSIBLE");
}

Measured memory_bytes: 19456
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p,a,b) for(ll p=a ; p<b ; p++)
#define rap(p,a,b) for(ll p=a ; p<=b ; p++)
#define per(p,a,b) for(ll p=a ; p>=b ; p--)
#define F first
#define S second
using namespace std;

typedef vector <ll> vll;
typedef vector <ld> vld;
typedef pair< ll ,ll > pll;


int main()
{
    ll t,i,j,k,ans,n;

    //cin>>t;
    t=1;
    while(t--)
    {
        ll h,sum=0;
        cin>>n>>k;
        vll v(n);
        rep(p,0,n)cin>>v[p];
        sort(all(v));

        rep(p,0,n-k)sum += v[p];
        cout<<sum;
    }
    
    return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if((B - A) * (C- A) > 0 && (A - B) * (C - B) > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	private int count = 0;
	private void Judge(int p, int q, int r, int A, int B, int C){
		if (p <= A && q <= B && r <= C)
			count++;
	}
	public static void Main(){
		int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		int C = int.Parse(Console.ReadLine());
		int X = int.Parse(Console.ReadLine());
		Program prog = new Program();
		int p, q, r;
		for (p = 0 ;p <= X / 500 ;p++ ){
			for (q = 0 ;q <= (X - 500 * p) / 100 ;q++ ){
				r = (X - 500 * p - 100 * q) / 50;
				prog.Judge(p, q, r, A, B, C);
			}
		}
		Console.WriteLine(prog.count);
	}
}

Measured memory_bytes: 13140
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int BLOCK = (1<<11);
vector< vii > vec(123456);
int v[312345],w[312345];
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int i,j;
    f(i,1,n+1){
    	cin>>v[i]>>w[i];
    }
    vec[1].pb(mp(0,0));
    vec[1].pb(mp(w[1],v[1]));
    vii vec1;
    f(i,2,min(n+1,BLOCK)){
    	//cout<<i<<endl;
    	int ver=i/2;
    	//vec1.pb(mp(w[i],v[i]));
    	vec1.clear();
    
		rep(j,vec[ver].size()){
			vec1.pb(vec[ver][j]);
			vec1.pb(mp(vec[ver][j].ff+w[i],vec[ver][j].ss+v[i]));
		}

    	sort(all(vec1));
    	int last=-1;
    	rep(j,vec1.size()-1){
    		if(vec1[j].ff==vec1[j+1].ff)
    			continue;
    		if(vec1[j].ss>last){
    			last=vec1[j].ss;
    			vec[i].pb(vec1[j]);
    		}
    	}
    	if(vec1[j].ss>last){
    		vec[i].pb(vec1[j]);
    	}
    }
    // /return 0;
    int ver,lol,gg;
    int q;
    cin>>q;
    rep(i,q){
    	cin>>ver>>lol;
    	vec1.clear();
    	vec1.pb(mp(0,0));
    	//return 0;
    	//cout<<ver<<" "<<lol<<endl;
    	while(ver>=BLOCK){
    		int hh=vec1.size();
    		rep(j,hh){
    			vec1.pb(mp(vec1[j].ff+w[ver],vec1[j].ss+v[ver]));
    		}
    		ver/=2;
    	}

    	int ans=0;
    	vector<pii>::iterator it;
    	rep(j,vec1.size()){
    		int gg = vec1[j].ff;
    		if(gg>lol)
    			continue;
    		it=upper_bound(all(vec[ver]),mp(lol-gg,inf)); 

    		if(it!=vec[ver].begin()){
    			//cout<<vec[ver][1].ff<<"DS"<<endl;
    			it--;
    			ans=max(vec1[j].ss+it->ss,ans);
    		}
    		else{
    			ans=max(ans,gg);
    		}
    	}
    	cout<<ans<<endl;

    }
    return 0;   
}


Measured memory_bytes: 30156
#ALDS1_1-B Greatest Common Divisor
def gcd(x,y):
    if x%y == 0:
        print(y)
    else:
        gcd(y,x%y)

x,y = [int(x) for x in input().split()]
if x>y:
    gcd(x,y)
else:
    gcd(y,x)

Measured memory_bytes: 7620
# -*- coding: utf-8 -*-
# C -

'''
7
14 14 2 13 56 2 37
'''

import sys

# 再起回数上限変更
sys.setrecursionlimit(1000000)

N = int(input())
x = list(map(int, input().split()))

P = sum(x) / N
P = int(P)

res1 = sum([(x[i] - P)**2 for i in range(N)])
if P + 1 <= 100:
    res2 = sum([(x[i] - (P+1))**2 for i in range(N)])
else:
    res2 = float('inf')

print(min(res1, res2))


Measured memory_bytes: 38384
f = []
input = int(input())
for i in range(input + 1):
    if i % 3 == 0 and i % 5 == 0:
        c = 'FizzBuzz'
    elif i % 5 == 0:
        c = 'Buzz'
    elif i % 3 == 0:
        c = 'Fizz'
    else:
        c = i
    f.append(c)
c1 = [num for num in f if isinstance(num, (int, float))]
print(sum(c1))

Measured memory_bytes: 37840
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

# 繰り返し二乗法
def pow_r_mod(x:int, n:int, mod=10**9+7)->int:
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
# 逆元
for i in range(2, N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

mcb = mca

for i in range(a+1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r_mod(2, m)-1-mca-mcb) % P)
#print((mod_pow(2, m, P)-1-mca-mcb) % P)


Measured memory_bytes: 52976
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//static const ll MOD = 1e+9 + 7;
//static const int MAX = 10001;

int main() {

    int N; cin >> N;
    vector<int> A(N);
    int sum = 0, sum_even = 0;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i % 2 == 1) {
            sum_even += A[i];
        }
        sum += A[i];
    }

    vector<int> X(N);

    X[0] = sum - 2 * sum_even;
    for (int i = 0; i < N-1; i++) {
        X[i+1] = 2 * A[i] - X[i];
    }

    for (int i = 0; i < N; i++) {
        cout << X[i] << ' ';
    }
    cout << '\n';

}



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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 100010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
const int MOD = 1000000007;

int n,m;
int ways[1010][1010];
char grid[1010][1010];

bool valid(int x,int y) {
    return (x<=n and y<=m) and (grid[x][y]=='.');
}

int call(int x,int y) {
    if(x==n and y==m) return 1;
    if(ways[x][y]!=-1) return ways[x][y];
    int ret = 0;
    if(valid(x+1,y)) ret += call(x+1,y), ret %= MOD;
    if(valid(x,y+1)) ret += call(x,y+1), ret %= MOD;
    return ways[x][y] = ret;
}


int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    sii(n,m);
    for(int i=1;i<=n;i++) {
        scanf("%s",grid[i]+1);
//        puts(grid[i]+1);
    }

    SET(ways);
    printf("%d\n",call(1,1));

//    for(int i=1;i<=n;i++) {
//        for(int j=1;j<=m;j++) {
//            cout << ways[i][j] << " ";
//        }
//        puts("");
//    }

    return 0;
}



Measured memory_bytes: 5248
n = int(input())
A = list(map(int, input().split()))
b = A[0]
att = ''
cnt = 1
for a in A:
    # print(a,b,att)
    if a != b:
        if att == '':
            if a > b:
                att = '+'
            elif a < b:
                att = '-'
        elif att == '+':
            if a < b:
                cnt += 1
                att = ''
        elif att == '-':
            if a > b:
                cnt += 1
                att = ''
    b = a
print(cnt)


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

using i8  = int8_t;using i16 = int16_t;using i32 = int32_t;using i64 = int64_t;using u8  = uint8_t;using u16 = uint16_t;using u32 = uint32_t;using u64 = uint64_t;using f32 = float;using f64 = double;
using vi32 = vector<i32>;using vi64 = vector<i64>;using vvi32 = vector<vi32>;using vvi64 = vector<vi64>;using pi32 = pair<i32,i32>;using pi64 = pair<i64,i64>;

#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,x) for(i64 i=1;i<=(i64)(x);i++)
#define RREPS(i,x) for(i64 i=((i64)(x));i>0;i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define SZ(x) ((i64)(x).size())
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define cauto const auto&
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

i32 dx[4]={1,0,-1,0};
i32 dy[4]={0,1,0,-1};
const i32 INF32 = 0x3F3F3F3F;
const i64 INF64 = 0x3F3F3F3F3F3F3F3F;
/* template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } */
/* template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } */


void Main();
i32 main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    //-------------------------------------------------------------------------
    i64 n; cin >> n;
    i64 maxv = -INF64;
    i64 minv = INF64;
    for (i64 i = 0; i < n; i++) {
        i64 a; cin >> a;
        maxv = max(maxv, a - minv);
        minv = min(minv, a);
    }
    cout << maxv << endl;
    //-------------------------------------------------------------------------
}


Measured memory_bytes: 3172
#include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int cnt[10]={0};
        int age;
        while(n--){
            cin>>age;
            age/=10;
            if(age>=6)age=6;
            cnt[age]++;
        }
        for(int i=0;i<7;i++){
            cout<<cnt[i]<<endl;
        }
    }
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1) # 木の高さ
        self.n = [1] * (n+1)    # グループメンバー数
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def find_n(self, x):
        return self.n[self.find(x)]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.n[y] = self.n[x] + self.n[y]
        else:
            self.par[y] = x
            self.n[x] = self.n[x] + self.n[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y) 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            #p -= uf.find_n(px) * uf.find_n(py)
            p -= uf.n[px] * uf.n[py]
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    vector<int> cnt(30, 0);
    for (int i = 0; i < s.length(); ++i)
        cnt[s[i] - 'A']++;
        
    int res = 0;
    for (int i = 0; i < 30; ++i)
    {
        if (cnt[i] == 0)
            continue;
        if (cnt[i] == 2)
            ++res;
    }
    
    if (res == 2)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll M, D;
  cin >> M >> D;
  ll count = 0;
  for (ll m = 1; m <= M; m++) {
    for (ll d = 1; d <= D; d++) {
      auto d1 = d % 10;
      auto d10 = d / 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
        count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    st S;
    cin >> S;
    sort(S.begin(), S.end());
    cout << (S.at(0) == S.at(1) && S.at(2) != S.at(1) && S.at(2) == S.at(3) ? "Yes" : "No") << endl;
}

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

int main() {
  
  int N, l, r;
  int S = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    S += r - l + 1;
  }
  cout << S << endl;
}


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

int main() {
    int A, B, X;
    scanf("%d%d%d", &A, &B, &X);
    bool isOk = X >= A && X <= A + B;
    if (isOk) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    ll a,b, N, K, ans;
    cin >> N >> K;
    a = N % K;
    b = -(a-K);
    ans = min(a,b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
string s;
int tong[3],mmax,mmin;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++)tong[s[i]-'a']++;
	mmax=max(tong[0],max(tong[1],tong[2]));
	mmin=min(tong[0],min(tong[1],tong[2]));
	if(mmax-mmin>1){
		puts("NO");
	}else puts("YES");
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int prior = Integer.parseInt(sc.next());
		int post  = Integer.parseInt(sc.next());
		String notation = "";
		
		notation = prior > post ? ">" : prior == post ? "==" : "<";
		
		System.out.println("a " + notation + " b");
		
		sc.close();
		
	}

}



Measured memory_bytes: 26048
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  scanln(N);

  if (N%2 == 1) {
    0.writeln;
  } else {
    long ans = 0;
    long x = 5;
    foreach(i; 1..long.max) {
      ans += N.floor(2).floor(x);
      x*=5;
      if (x > 1000000000000000000L) {
        break;
      }
    }
    ans.writeln;
  }
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 12:02:56 2020

@author: shinba
"""
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())

ans = 1

for i in range(n):
    x = int(input())
    ans = lcm(x,ans)

print(ans)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int n,m; cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v; cin >> u >> v; u--; v--;
        g[u].push_back(v);
    }
    int s,t; cin >> s >> t; s--; t--;

    vector<vector<ll>> dist(n, vector<ll>(3, -1));

    queue<pii> que;
    dist[s][0] = 0;
    que.push({s, 0});
    while(!que.empty()){
        int v = que.front().first;
        int r = que.front().second;
        que.pop();
        for(auto nv : g[v]){
            int nr = (r+1) % 3;
            if(dist[nv][nr] == -1){
                dist[nv][nr] = dist[v][r] + 1;
                que.push({nv, nr});
            }
        }
    }
    
    if(dist[t][0] == -1) cout << "-1" << endl;
    else cout << dist[t][0] / 3 << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >>n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n)rep(j, n-1){
        cin >> a[i][j];
        a[i][j]--;
    }

    vector<int> idx(n, 0);
    queue<int> que;
    int ans = 0, rem = n*(n-1)/2;
    rep(i, n) que.push(i);
    while(!que.empty()){
        queue<int> que2;
        vector<int> used(n, 0);
        while(!que.empty()){
            int i = que.front(); que.pop();
            if(used[i] || idx[i] >= n-1) continue;
            int j = a[i][idx[i]];
            if(used[j] || idx[j] >= n-1) continue;
            if(a[j][idx[j]] == i){
                // cout << i << " " << j << endl;
                que2.push(i);
                que2.push(j);
                idx[i]++;
                idx[j]++;
                used[i] = 1;
                used[j] = 1;
                rem--;
            }
        }
        swap(que, que2);
        ans++;
        if(rem == 0) break;
    }
    cout << (rem ? -1 : ans) << endl;
}

Measured memory_bytes: 4224
import sys
N = int(input())
a = list()
for i in range(N):
  a.append(int(input()))
i = 0
ans = 1
for _ in range(N):
  next_a = a[i]
  if(next_a == 2):
    print(ans)
    sys.exit()
  else:
    i = next_a-1
    ans += 1
print(-1)

Measured memory_bytes: 12996
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int w;

int f(int h,int x){
	h--;
	bool B=((h+x)%2==1?1:0);
	int t=0;
	while(t<h){
		if(x==0&&B){
			int d=2*(w-1)+2;
			t+=(h-t)/d*d;
		}
		if(B){
			int d=w-x-1;
			x+=min(h-t,d);
			t+=d+1;
		}
		else{
			int d=x;
			x-=min(h-t,d);
			t+=d+1;
		}
		B^=1;
	}
	return x;
}

int h,n;

int main(){
	cin>>h>>w>>n;
	vi a(w);
	vp b(n);
	for(int i=0;i<w;i++){
		bool B=(i%2==0?1:0);
		int t=0,x=i;
		while(t<h){
			if(B){
				int d=w-x-1;
				x+=min(h-t,d);
				t+=d+1;
			}
			else{
				int d=x;
				x-=min(h-t,d);
				t+=d+1;
			}
			B^=1;
		}
		a[i]=x;
	}
	for(int i=0;i<n;i++) cin>>b[i].first>>b[i].second;
	sort(b.rbegin(),b.rend());
	for(int i=0;i<n;i++){
		int x=f(b[i].first,b[i].second-1),y=f(b[i].first,b[i].second);
		swap(a[x],a[y]);
	}
	for(auto i:a) cout<<i+1<<endl;
}


Measured memory_bytes: 5172
#include<stdio.h>

int a[100];

int main(void){
  int i,j,n;
  int time,tmp;

  while(scanf("%d",&n)!=EOF){
    time = 0;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }

    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(a[i]>a[j]){
	  tmp = a[i];
	  a[i] = a[j];
	  a[j] = tmp;
	}
      }
    }

    for(i=0;i<n;i++){
    time += (n-i)*a[i];
    }

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

Measured memory_bytes: 0
n = input()
key = ["3", "5", "7"]
cnt = 0
for k in range(3, len(n)+1):
    for i in range(3**k):
        t = []
        s = ""
        m = i
        for j in range(k):
            s += key[m%3]
            m = m//3
        if int(s) <= int(n) and len(set(list(s))) == 3:
            cnt += 1
print(cnt)
        

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

int main() {
    int a, b;

    cin >> a >> b;

    if (a <= b) {
        for (int i = 0; i < b; i++) cout << a;
    }
    else {
        for (int i = 0; i < a; i++) cout << b;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String[] str = {sc.next(), sc.next()};
			String max = str[0].length() > str[1].length() ? str[0] : str[1];
			String min = str[0].length() > str[1].length() ? str[1] : str[0];
			
			short[][] dp = new short[max.length()+1][min.length()+1];
			int count = 0;
			
			for(int i = 0; i < max.length(); i++){
				for(int j = 0; j < min.length(); j++){
					if(max.charAt(i) == min.charAt(j)){
						dp[i+1][j+1] = (short) (dp[i][j] + 1);
						count = Math.max(count, dp[i+1][j+1]);
					}
				}
			}
			
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 58000
/*
AizuOnline A1084
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n,k,c[100];
int max_teacher,max_student,max_product;
//
void get_max_product()
{
  int i,j,p,m_p;

  //for(i=0;i<n;i++)
  //  printf("%d:",c[i]);

  m_p=0;
  for(i=0;i<=n-k;i++)
    {
      p = 1;
      for(j=0;j<k;j++)
	p *= c[i+j];
      if(p>m_p)
	m_p=p;
    }
  //printf("%d\n",m_p);

  if(m_p > max_product)
    max_product=m_p;
}

main()
{
  int i,j,wk;

  while(EOF != scanf("%d %d",&n,&k) && (n || k))
    {
      for(i=0;i<n;i++)
	scanf("%d",&(c[i]));

      max_product=0;
      
      get_max_product();

      max_teacher=max_product;

      max_product=0;

      for(i=0;i<n-1;i++)
	for(j=i+1;j<n;j++)
	  {
	    //printf("%d %d:",i,j);
	    wk   = c[i];
	    c[i] = c[j];
	    c[j] = wk;
	    get_max_product();
	    wk   = c[i]; // restore
	    c[i] = c[j];
	    c[j] = wk;
	   
	  }
      max_student=max_product;
      //printf("%d %d\n",max_student , max_teacher);
      //if(max_student > max_teacher)
	printf("%d\n",max_student - max_teacher);
	//else
	//printf("NO GAME\n");
    }
return(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n, m; // 行きたいのは島n-1
    std::cin >> n >> m;
    std::vector<std::vector<int>> ship(n);
    for(int i = 0; i < m; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        ship[a].push_back(b);
        ship[b].push_back(a);
    }

    int now = 0;
    for(int i = 0; i < ship[now].size(); i++){
        int next = ship[now][i];
        for(int j = 0; j < ship[next].size(); j++){
            int target = ship[next][j];
            if(target == n - 1){
                std::cout << "POSSIBLE" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	
	int n, d;
	cin >> n >> d;

	int ans = (n % (2*d + 1) == 0) ? n / (2*d + 1) : n / (2*d + 1) + 1;

	cout << ans; 
    
    return 0;   
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for(int i=0;i<n;++i)
#define for1(n) for(int i=1;i<=n;i+=3)
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
const int mod = 1000000007LL;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif
}
ll arr[100009],dp[100009], n;

int main()
{
	GOAT();
	cin >> n;
	for (int i = 1; i <= n;i++)
		cin >> arr[i];
	arr[0] = arr[1];
	for (int i = 1; i <= n; i++)
	{
		if (i < 2)dp[i] = abs(arr[i]- arr[i - 1]);
		else {
			ll ch1 = dp[i - 1] + abs(arr[i] - arr[i - 1]);
			ll ch2 = dp[i - 2] + abs(arr[i] - arr[i - 2]);
			dp[i] = min(ch1, ch2);
		}

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


Measured memory_bytes: 1792
package main

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

func main() {
	n := getInt()
	as := getIntSlice(n)

	first := 0
	second := 0
	for _, a := range as {
		if a >= first {
			second = first
			first = a
		} else if a > second {
			second = a
		}
	}

	for _, a := range as {
		if a == first {
			fmt.Println(second)
		} else {
			fmt.Println(first)
		}
	}
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
long long a,b;
long long gcd(long long x,long long y)
{
    return x?gcd(y%x,x):y;
}
int main()
{
    scanf("%lld%lld",&a,&b);
    printf("%lld",a*b/gcd(a,b));
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N;
	cin >> N;
	vector<P> a(N);
	rep(i, N) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(begin(a), end(a));
	int ans = 0;
	rep(i, N) {
		if (i % 2 != a[i].second % 2) {
			ans++;
		}
	}
	cout << ans / 2 << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void func(char a[801][801])
{
  int s = 75, t = 25;
  int dx = 1, dy = 1, c = 0;

  while(0 <= s+dx && s+dx <= 800 && 0 <= t+dy && t+dy <= 800){
    s += dx;
    t += dy;
    if(a[t][s] == 'z'){
      dx = -dx;
      dy = -dy;
    } else if(a[t][s] == 'y'){
      dx = -dx;
    } else if(a[t][s] == 'x'){
      dy = -dy;
    }
    if(s == 75 && t == 25){
      break;
    }
    c++;
  }
  cout << s << " " << t << endl;

  return ;
}

int main()
{
  int n, s, t, u, v;
  char d, a[801][801];
  string str;

  while(cin>>n && n != -1){
    fill(&a[0][0], &a[800][800], '.');

    for(int j =0; j < n; j++){
      cin >> str >> s >> t;
      s *= 100;
      t *= 100;

      if(str == "y"){
	for(int i = 0; i <= 100; i++){
	  if(a[t+i][s] == 'x' || a[t+i][s] == 'z'){
	    a[t+i][s] = 'z';
	  } else {
	    a[t+i][s] = 'y';
	  }
	}
      } else {
	for(int i = 0; i <= 100; i++){
	  if(a[t][s+i] == 'y' || a[t][s+i] == 'z'){
	    a[t][s+i] = 'z';
	  } else {
	    a[t][s+i] = 'x';
	  }
	}
      }
    }

    func(a);
  }

  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    cout<<ceil(n/2.0);

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n, k;
	cin >> n;
  int a [100000];
  rep(i, n) {
    cin >> k;
    a[k-1] = i;
  }
  string s;
  rep(i,n) {
    s += to_string(a[i]+1);
    if(i != n-1) s += " ";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1920
program exp
implicit none
integer i,j,base,index
integer in,temp
read *, in ! 1<=in<=1000
base = 1
index =1
do i=1,int(sqrt(real(in)))  ! Base of exponential
  do j=1, 9 ! Index of exponential, 2^10>1000 therefore j<=9
    if(i**j<=in) then
      if(i**j>base**index) then
        base=i
        index = j
      end if
    end if
  end do
end do
print *, base**index
end program exp

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a[3],max=0,i,ans=0;

	for (i=0;i<3;i++) {
		cin >> a[i];
		if (max<a[i]) max = a[i];
		ans += a[i];
	}
	cout << ans - max << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int in_N;
    int in_i;

    int ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_N         = Integer.parseInt(in_str_split[0]);
      in_i         = Integer.parseInt(in_str_split[1]);

      /*----------------
       * 計算
       *----------------*/
      ans = in_N - in_i + 1;

      System.out.println(String.valueOf(ans));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


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

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) {
    if (n < m) {
      return 0;
    }
    return f[n] * mod::Inv(f[m] * f[n - m]);
  }
};

int main(int argc, const char *argv[]) {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  int h2 = h - a - 1;
  int w2 = w - b - 1;
  BinCoef bc(h + w);
  MInt ans(0);
  for (int i = b; i < w; ++i) {
    ans += bc.NCM(h2 + i, h2) * bc.NCM((a - 1) + (w - i - 1), a - 1);
  }

  cout << ans.Get() << '\n';

  return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int a,b,c;

int main(){
	cin >> a >> b;
	
	for(int i = 1; i <= 3; i++){
		if(a != i && b != i) cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long N;
  cin >> N;
  if(N % 2 == 1) cout << 0 << endl;
  else{
    long long temp = N / 2;
    long long t = 5;
    long long ans = 0;
    while(temp / t / 5 > 0){
      ans += temp / t;
      t *= 5;
    }
    ans += temp / t;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3604
import scala.io.Source.stdin

object Main extends App {
  for(d<-stdin.getLines.map(_.toInt)) {
    var (j,s) = (0,0)
    while(j*d < 600) {
      s += j*j
      j += 1
    }
    println(s*d*d*d)
  }
}

Measured memory_bytes: 43824