akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);
#define tl cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"
#define Func {ans += solve(i); ++i;}


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

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
    x*=f;
    return x;
}


int main(){
#ifdef LOCAL_DEFINE
    f_in
#else
    _
#endif
    int n = nxt();
    cout << n / 3 << '\n';
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import fractions


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

    x.append(X)
    x.sort()

    sabun = []
    for i in range(len(x) - 1):
        sabun.append(x[i + 1] - x[i])

    ans = sabun[0]
    for i in range(1, len(sabun)):
        ans = fractions.gcd(ans, sabun[i])

    print(ans)


    
    


if __name__ == '__main__':
    main()



Measured memory_bytes: 16276
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    vector<pair<double, double>> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
    }

    double ans = 0;
    for(LL i = 0; i < n; ++i){
        for(LL j = i+1; j < n; ++j){
            double dx = a[i].first - a[j].first;
            double dy = a[i].second - a[j].second;
            double dist = sqrt(dx*dx + dy*dy);
            ans += dist;
        }
    }
    ans /= n*0.5;

    cout << setprecision(16) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static ArrayDeque<Point> que;
	public static int[][] ll;
	public static char[][] s;
	public static int h;
	public static int w;
	public static int[] xadd = {-1, 1, 0, 0}; 
	public static int[] yadd = {0, 0, -1, 1}; 
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		h = parseInt(sc.next());
		w = parseInt(sc.next());
		s = new char[h][];
		for(i=0;i<h;i++) {
			s[i] = sc.next().toCharArray();
		}
		sc.close();
		int mx=0;
		for (int hs = 0; hs < h; hs++) {
			for (int ws = 0; ws < w; ws++) {
				if(s[hs][ws]=='#') continue;
				for (int he = 0; he < h; he++) {
					for (int we = 0; we < w; we++) {
						if(s[he][we]=='#') continue;
						if(hs==he&&ws==we) continue;
						que = new ArrayDeque<>();
						ll = new int[h][w];
						for (i = 0; i < h; i++) {
							Arrays.fill(ll[i], 401);
						}
						ll[hs][ws] = 0;
						que.add(new Point(hs, ws));
//						out.printf("%d,%d -> %d,%d%n", hs, ws,he, we);
						while (que.size() > 0) {
							Point p = que.removeFirst();
							if(p.h == he && p.w == we) break;
							for (i=0; i<4; i++) {
								int ww = p.w+xadd[i];
								int hh = p.h+yadd[i];
								if(ww<0||ww>=w) continue;
								if(hh<0||hh>=h) continue;
								if (s[hh][ww] == '.'&&ll[hh][ww]==401) {
									que.addLast(new Point(hh, ww));
									ll[hh][ww] = ll[p.h][p.w] + 1;
//									out.printf("%d,%d%n",p.h,p.w);
//									out.println(Arrays.deepToString(ll));
								}
							}
						}
						int l = ll[he][we];
						if(mx<l) mx=l;
//						out.println(Arrays.deepToString(ll));
//						out.printf("%d%n", l);
						que = null;
						ll = null;
					}
				}
			}
		}
		out.println(mx);
	}
}
class Point {
	int h;
	int w;
	Point(int h, int w) {
		this.h = h;
		this.w = w;
	}
	
}


Measured memory_bytes: 227340
N, K = map(int, input().split(' '))
h = [int(input()) for i in range(N)]
sorted_h = sorted(h)
ans = float('inf')
for i in range(N-K+1):
    temp = sorted_h[i+K-1]-sorted_h[i]
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 8256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 2e6 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int C[3005][3005];
int dp[3005][3005];
int a, b, c, d;

int qp(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1)
            ans = x * ans % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

void solve() {
    rep(i, 0, 3000)C[i][0] = 1;
    rep(i, 1, 3000)rep(j, 1, i)C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for (int i = a; i <= c; ++i) {
        for (int j = b; j <= d; ++j) {
            if (a == i && b == j)
                continue;
            dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (j - 1) * (i - 1)) % mod;
        }
    }
    cout << (dp[c][d] % mod + mod) % mod << endl;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

int w,h;
string s[100];

void solve(int i,int j,char c){

  if(i < 0 || j < 0 || i == w || j == h) return;
  if(s[j][i] == 'W' || s[j][i] == 'B') return;
  if(c == 'W' && s[j][i] == '*') return;
  if(c == 'B' && s[j][i] == '#') return;
  if(s[j][i] == '@') return;

  if(s[j][i] == '.' && c == 'W') s[j][i] = '*';
  if(s[j][i] == '.' && c == 'B') s[j][i] = '#';

  if(s[j][i] == '*' && c == 'B') s[j][i] = '@';
  if(s[j][i] == '#' && c == 'W') s[j][i] = '@';

  solve(i+1,j,c);
  solve(i,j+1,c);
  solve(i-1,j,c);
  solve(i,j-1,c);

}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<h;i++) cin >> s[i];

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	if(s[j][i] == 'W' || s[j][i] == 'B'){
	  solve(i+1,j,s[j][i]);
	  solve(i,j+1,s[j][i]);
	  solve(i-1,j,s[j][i]);
	  solve(i,j-1,s[j][i]);
	}
      }
    }

    int answ = 0,ansb = 0;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	if(s[j][i] == '*') answ++;
	if(s[j][i] == '#') ansb++;
      }
    }

    cout << ansb << " " << answ << endl;

  }
}

Measured memory_bytes: 1272
// simple bfs / shortest path calc
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=2e5+10;
bool vis[55][55];
int dist[55][55],h,w;
string grid[55];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
bool val(int i,int j)
{
    return (i>=1&&i<=h&&j>=1&&j<=w);
}
int main ()
{
    cin >> h >> w;
    for(int i=0;i<h;i++){
        string S;cin >> S;
        S = "#" + S;
        grid[i+1]=S;
    }
    queue< pair<int,int> > Q;
    Q.push({1,1});
    memset(dist,31,sizeof dist);
    dist[1][1]=0;
    while(!Q.empty()){
        auto x = Q.front();
        int i = x.first;
        int j = x.second;
        Q.pop();
        if(vis[x.first][x.second])continue;
        vis[x.first][x.second]=1;
        for(int k=0;k<4;k++){
            int xx = dx[k]+i;
            int yy = dy[k]+j;
            if(val(xx,yy)&&grid[xx][yy]=='.'){
                dist[xx][yy]=min(dist[xx][yy],1+dist[i][j]);
                Q.push({xx,yy});
            }
        }
    }
    int b=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
         b+=(grid[i][j]=='#');
    }/*
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
        cout<<dist[i][j]<<" ";
        cout<<endl;
    }*/
    if(vis[h][w])
    cout<<h*w-(dist[h][w]+b+1)<<endl;
    else cout<<-1<<endl;
    return 0;
}
/*
*/





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 35600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repr(i, n) for(int i = int(n) - 1; i >= 0; i--)

lint mod = 1000000;

vector<vector<int>> combination;
vector<vector<int>> child;
vector<int> subtree_size;

lint dfs(int now){
    lint ans = 1;
    int size_sum = 0;
    for(int i: child[now]){
        ans = (ans * dfs(i)) % mod;
        ans = (ans * combination[size_sum + subtree_size[i]][subtree_size[i]]) % mod;
        size_sum += subtree_size[i];
    }
    subtree_size[now] = size_sum + 1;
    return ans;
}

int main(){
    combination.resize(1010);
    combination[0].resize(1);
    combination[0][0] = 1;
    for(int i = 1; i < 1010; i++){
        combination[i].resize(i + 1, 0);
        for(int j = 0; j <= i; j++){
            combination[i][j] += (j > 0 ? combination[i - 1][j - 1] : 0);
            combination[i][j] += (j < i ? combination[i - 1][j] : 0);
            combination[i][j] %= mod;
        }
    }
    
    int N;
    cin >> N;
    int a[N - 1], b[N - 1];
    vector<vector<int>> won_game(N);
    vector<int> lost_game(N, -1);
    rep(i, N - 1){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        won_game[a[i]].push_back(i);
        lost_game[b[i]] = i;
    }
    child.resize(N);
    rep(i, N - 1){
        child[lost_game[a[i]] + 1].push_back(i + 1);
    }
    subtree_size.resize(N);
    
    /*rep(i, N){
        for(int j: child[i]){
            cout << j << " ";
        }
        cout << endl;
    }*/
    
    /*rep(i, N){
        rep(j, i + 1){
            cout << combination[i][j] << " ";
        }
        cout << endl;
    }*/
    
    cout << dfs(0) << endl;
}





Measured memory_bytes: 5176
#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<<30;
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 main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<n;i++) a[i]=n-i;
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			vi b;
			x--;
			for(int i=0;i<y;i++) b.push_back(a[x+i]);
			for(int i=0;i<x;i++) b.push_back(a[i]);
			for(int i=x+y;i<n;i++) b.push_back(a[i]);
			a=b;
		}
		cout<<a[0]<<endl;
	}
}


Measured memory_bytes: 3164
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// mod
int mod = 2019;

struct mint {
    unsigned x;

    mint() : x(0) {}

    mint(signed sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    mint(signed long long sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    int get() const { return (int) x; }

    mint& operator+=(mint that) {
        if ((x += that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(mint that) {
        if ((x += mod - that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(mint that) {
        x = (unsigned long long) x * that.x % mod;
        return *this;
    }

    mint& operator/=(mint that) { return *this *= that.inverse(); }

    mint operator+(mint that) const { return mint(*this) += that; }

    mint operator-(mint that) const { return mint(*this) -= that; }

    mint operator*(mint that) const { return mint(*this) *= that; }

    mint operator/(mint that) const { return mint(*this) /= that; }

    mint inverse() const {
        long long a = x, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        return mint(u);
    }

    bool operator==(mint that) const { return x == that.x; }

    bool operator!=(mint that) const { return x != that.x; }

    mint operator-() const {
        mint t;
        t.x = x == 0 ? 0 : mod - x;
        return t;
    }
};

class DMultipleOf2019 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;

        mint c = 1;
        map<int, int> cnt;
        mint cur = 0;
        int res = 0;
        cnt[0] = 1;
        REP(i, s.size()) {
            int n = s[i] - '0';
            cur = cur * 10 + n;
            mint key = cur / c;
            res += cnt[key.get()];
            c *= 10;
            cnt[key.get()]++;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DMultipleOf2019 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3776
#include<stdio.h>

int calc_first_arg(int number_1, int number_2){
    while (number_2 < 10){
        int multiple = number_1 * number_2;
        printf("%dx%d=%d\n", number_1, number_2, multiple);
        number_2 = number_2 + 1;
    }
}

int main(){

    int a = 1;
    int b = 1;

    while (a < 10){
        calc_first_arg(a, b);
        a = a + 1;
    }

    return 0;
}

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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t , ans = 0;
void slove()
{
	int n;cin >> n;
	vector<int> f(n + 1);
	for(int i = 1;i <= n;i ++)
		cin >> f[i];
	vector<bool> vis(n + 1 , 0);
	vis[1] = 1;bool flag = false;
	int s = 1;
	while(f[s] != 2)
	{
		//printf("%d %d\n",s , f[s]);
		if(vis[f[s]])
		{
			flag = 1;
			break;
		}
		s = f[s];vis[s] = 1;ans++;
	}
	cout << (flag ? -1 : ans + 1) << endl;
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 3736
import collections
N = int(input())
A = [int(i) for i in input().split()]
Dict = dict(collections.Counter(A))
Cnt = []
for key in Dict.keys():
    cnt = Dict[key]
    Cnt.append([key,cnt])
Cnt.sort()
dp = [0 for i in range(len(Cnt)+1)]
Cnt.append([float('inf'),0])
if len(Cnt)<3:
    print(Cnt[0][1])
    exit()
else:
    if Cnt[1][0]-1==Cnt[0][0]:
        dp[0] = Cnt[0][1]+Cnt[1][1]
for i in range(1,len(Cnt)-1):
    if Cnt[i][0]==Cnt[i-1][0]+1:
        dp[i] += Cnt[i-1][1]
    if Cnt[i+1][0]-1==Cnt[i][0]:
        dp[i]+=Cnt[i+1][1]
    dp[i] += Cnt[i][1]
print(max(dp))


Measured memory_bytes: 17372
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())
for i in range(H):
    for j in range(W):
        safe = False
        s = S[i][j]
        if s == '#':
            if i != 0 and S[i-1][j] == '#': safe = True
            if j != 0 and S[i][j-1] == '#': safe = True
            if j != W-1 and S[i][j+1] == '#': safe = True
            if i != H-1 and S[i+1][j] == '#': safe = True
            if not safe:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 9144
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	slice := strings.Split(s, "")
	for i, str := range slice {

		if i%2 == 0 {
			if !(str == "R" || str == "U" || str == "D") {
				fmt.Println("No")
				return
			}
		} else {
			if !(str == "L" || str == "U" || str == "D") {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
mod = 998244353


N, S, *A = map(int, open(0).read().split())

dp = [0] * (S + 1)
ans = 0
for i, a in enumerate(A, 1):
    if a <= S:
        T = dp[:]
        for j in range(a, S + 1):
            dp[j] += T[j - a]
        dp[a] += i

    ans += dp[-1]
    ans %= mod

print(ans)

Measured memory_bytes: 3788
def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# いずれか2つの数字のGCDが1 必ずTrue
# いずれか2つの数字のGCDが2 かつ Ai - K % 2 == 0 のものが存在する場合 True
# いずれか2つのGCDが計算できれば、答えが導けるが、いずれか2つの組み合わせはA * (A-1) // 2通りあるから間に合わない
# 累積GCDで1になる → どうにかこうにか1にできる
# 累積GCDで2になる → どの組み合わせをとっても2にしかならない


def main():
    ma = max(A)
    if ma < K:
        return False
    if K in A:
        return True
    g = A[0]
    for a in A:
        g = gcd(g, a)
    for a in A:
        if (a-K) % g == 0:
            return True
    return False


if main():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 62576
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn match_impl(i: usize, j: usize, m: usize, im: &Vec<Vec<char>>, temp: &Vec<Vec<char>>) -> bool {
    for k1 in 0..m {
        for k2 in 0..m {
            if im[i+k1][j+k2] != temp[k1][k2] {
                return false;
            }
        }
    }
    true
}

fn solve(n: usize, m: usize, im: Vec<Vec<char>>, temp: Vec<Vec<char>>) -> &'static str {
    let diff = n - m;
    for i in 0..diff + 1 {
        for j in 0..diff + 1 {
            if match_impl(i, j, m, &im, &temp) {
                return "Yes";
            }
        }
    }
    "No"
}



fn main() {
    input!{
        n: usize,
        m: usize,
        im: [chars; n],
        temp: [chars; m],
    }
    println!("{}", solve(n, m, im, temp));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main()
{
    int N;
    cin >> N;
    int d[N];
    REP(i,0,N){
        cin >> d[i];
    }
    sort(d, d + N);

        cout << d[N / 2 ] - d[N / 2-1] << endl;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()
#define N 100001
int *par;
int *rrank;

int root(int x){
  if(par[x]==x)return x;
  else return par[x]=root(par[x]);
}

void init(int n){
  for(int i=0; i <= n; i++){
    par[i]=i;
    rrank[i]=0;
  }
}
bool same(int x,int y){
  return root(x)==root(y);
}

void link(int x,int y){
  int xx,yy;
  xx=root(x);
  yy=root(y);
  if(xx==yy)return;

  if(rrank[xx]<rrank[yy]) par[xx]=yy;
  else if(rrank[xx]>rrank[yy]){
    par[yy]=xx;
  }else{
    par[yy]=xx;
    rrank[xx]++;
  }
  return;
}

int main(){ 
  int n,m,a,b,cnt=0;
  cin>>n>>m;
  int ans=n-1;
  par=new int[n+1];
  rrank=new int[n+1];

  init(n);

  for (int i = 0; i < m; i++){
    cin >> a>>b;
    if(!same(a,b)){
      link(a,b);
    }
  }
  for (int i = 1; i <= n; i++)
  {
    if(i==par[i])cnt++;
  }
  
  cout << cnt-1 <<endl;
  return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;
ll dp[101][100001];

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> wn(n), vn(n);
    REP(i, n) cin >> wn[i] >> vn[i];
    for(int i=0; i<n; i++) {
        // i番目にwまで詰められるとした最大の価値
        for(int j=1; j<=w; j++) {
            if (j >= wn[i]) {
                // 詰める
                dp[i+1][j] = max(dp[i][j-wn[i]] + vn[i], dp[i][j]);
            } else {
                // 詰めない
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    /*REP(i, n+1) {
        REP(j, w+1) {
            printf("%4lld ", dp[i][j]);
        }
        printf("\n");
    }*/
    ll res = dp[n][w];
    cout << res << endl;
    return 0;
}


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

int main()
{
    double n;
    cin >> n;
    double count = 0;
    for(int i=1;i<=n;i++){
        if(i%2 == 1) count++;
    }
    cout << count/n << endl;
}

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

struct BinaryIndexedTree {
  BinaryIndexedTree(int h, int w) : h(h), w(w), v(h + 1, vector<int>(w + 1, 0)) {}
  BinaryIndexedTree(int n) : h(n), w(n), v(n + 1, vector<int>(n + 1, 0)) {}

  int h, w;
  vector<vector<int>> v;

  long long sum(int y, int x) {
    long long ret = 0;
    for (int i = y; i; i -= i & -i) {
      for (int j = x; j; j -= j & -j) {
        ret += v[i][j];
      }
    }

    return ret;
  }

  long long sum(int y1, int x1, int y2, int x2) {
    return sum(y1, x1) - sum(y1, x2) - sum(y2, x1) + sum(y2, x2);
  }

  void add(int y, int x) {
    for (int i = y; i <= h; i += i & -i) {
      for (int j = x; j <= w; j += j & -j) {
        v[i][j]++;
      }
    }
  }
};

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

  vector<long long> x, y, a, b;
  map<long long, int> X, Y;
  for (int i = 0; i < n; ++i) {
    int s, t;
    cin >> s >> t;
    x.push_back(s);
    y.push_back(t);
  }

  a = x;
  b = y;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < n; ++i) {
    X[a[i]] = i + 1;
    Y[b[i]] = i + 1;
  }

  BinaryIndexedTree bit(n);
  for (int i = 0; i < n; ++i) {
    bit.add(Y[y[i]], X[x[i]]);
  }

  long long ans = 5001001001001001001;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        for (int l = k + 1; l < n; ++l) {
          if (bit.sum(Y[b[l]], X[a[j]], Y[b[k]] - 1, X[a[i]] - 1) >= K) {
            ans = min(ans, (b[l] - b[k]) * (a[j] - a[i]));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}
const int N = 1e5 + 15;
vector<int>tree[N];
int sub[N] , d , parent[N] , n;
void dfs(int x , int level = 0){
    if(x == n) d = level-1;
    sub[x] = 1;
    for(int u : tree[x]){
        if(parent[x] == u) continue;
        parent[u] = x;
        dfs(u,level+1);
        sub[x] += sub[u];
    }
}

int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);
    FastIO;

    while(cin>>n){
        for(int i=1; i<=n; i++)tree[i].clear();
        for(int i=1; i<n; i++){
            int a,b;
            cin>>a>>b;
            tree[a].pb(b);
            tree[b].pb(a);
        }
        parent[1] = 1;
        dfs(1,0);
        d /= 2;
        int now = n;
        while(d){
            now = parent[now];
            d--;
        }
        if(sub[now]>=(n-sub[now])) cout<<"Snuke\n";
        else cout<<"Fennec\n";
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 12800
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [H,W] = nextIntArray()
    let s = []
    while(hasNext()){
        s.push(next().split(""))
    }
    let dir = [[1,0],[-1,0],[0,1],[0,-1]]
    for(let i = 0; i<H; i++){
        for(let j = 0; j<W; j++){
            if(s[i][j] == "#"){
                let res = false
                for(let el of dir){
                    let x = i+el[0]
                    let y = j+el[1]
                    if(x < 0 || x>=H || y<0|| y>=W) continue
                    if(s[x][y] == "#" || s[x][y] == "X"){
                        res = true
                        s[i][j] = "X"
                    } 
                }
                if(res == false){
                    console.log("No")
                    return
                }
            }
        }
    }
    console.log("Yes")
}
Main()


Measured memory_bytes: 30440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int n,a[100005];
vector<int>hoge[35];
bool need[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		for(int j=0;j<=30;j++){
			if(a[i] <= (1<<j)){
				if(a[i] != (1<<j)) need[i] = 1; 
				a[i] = j; //cout<<j<<endl;
				break;
			}
		}
	}
	int pre = 0; ll ans = 0;
	for(int i=1;i<=n;i++){
		if(pre < a[i]){
			ans+=a[i]-pre; pre = a[i];
		}
		else if(pre > a[i]){
			pre = a[i]; if(need[i]) pre--;
		}
		else if(need[i]){
			pre--;
		}
	}
	cout<<ans<<endl;
}
	

Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,m,ans=1;
	cin>>n>>m;
	if(m%n==0){cout<<m/n;return 0;}
	for(int i=2;i<=m/n;i++){
		if(m%i==0&&ans<i) ans=i;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  int64_t result = 0;
  if (abs(X) / D >= K) {
    result = abs(X) - K * D;
  }
  else {
    int64_t newK = abs(X) / D;
    result = abs(X) - newK * D;
    newK = K - newK;
    newK %= 2;
    if(newK == 1) {
      result -= D;
    }  
  }
  cout << abs(result) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
  float x,y;
  int a,b,c,d,e,f;

  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF)
    {
      x = (float)(c*e-b*f)/(a*e-b*d);
      y = (float)(d*c-a*f)/(b*d-a*e);
      if(x<=0&&-0.0005<x)
	x=0;
      if(y<=0&&-0.0005<y)
	y=0;
      printf("%.3f %.3f\n",x,y);
    }
  return 0;
}

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

int main() {
  int N, A,kekka;
  cin >> N;

  // ここにプログラムを追記
  for(int i = 0;i<N;i++){
  	string S;
    cin >>S;
    if(S =="Y"){
    	cout<<"Four"<<endl;
      break;
    }
    else if (i == N-1){
    	cout<<"Three"<<endl;
    }
  }
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
a = input_a

sum = 0
mod = 10 ** 9 + 7
(a.length).times do |i|
  sum = (sum + a[i]) % mod
end
minus = 0
anser = 0
(a.length - 1).times do |i|
  minus = (minus + a[i]) % mod
  anser += (a[i] * (sum - minus)) % mod
end
puts anser % mod


Measured memory_bytes: 27924
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
        if(A<=8 && B<=8) System.out.print("Yay!");
	else System.out.print(":(");
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b;
  c = 1;
  d = 0;
  while (b > c) {
    c--;
    c += a;
    d++;
  }
  cout << d;
  return 0;
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iomanip>
#include <iostream>
#include <cmath>
int main() {
    int A,B,H,M;
    std::cin >> A >> B >> H >> M;
    double dist;
    double th_H=0;
    double th_M=0;
    th_H = (double)((60*H+M))/720 * 2*M_PI;
    th_M = (double)M/60 * 2*M_PI;
    dist = sqrt(pow(A,2) + pow(B,2) -2*A*B*std::cos(th_H - th_M));
    std::cout << std::fixed << std::setprecision(15) <<dist;
}

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1000400
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll>nwala,swala;
void pre(){
	ll val=6;
	while(val<maxp){
		swala.pb(val);
		val*=6;
	}
	val=9;
	while(val<maxp){
		nwala.pb(val);
		val*=9;
	}
}
ll get(ll n,ll base){
	ll lp;
	if(base==9){
		lp=*(lower_bound(nwala.begin(), nwala.end(),n));
	}else{
		lp=*(lower_bound(swala.begin(), swala.end(),n));
	}
	if(lp!=n){
		lp/=base;
	}
	return lp;
}
void solve(){
	ll i,n;
	cin>>n;
	ll ans=n;
	sfl(i,0,n+1){
		ll lf=i;
		ll rf=n-i;
		ll temp=0;
		while(lf>=6){
			temp++;
			lf-=get(lf,6);
		}
		temp+=lf;
		while(rf>=9){
			temp++;
			rf-=get(rf,9);
		}
		temp+=rf;
		ans=min(ans,temp);
	}
	cout<<ans<<endl;

}	
int main(){
	gear_change;
	pre();
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 256
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

inputList=[]
for i in range(a):
    inputNum = input().split()
    inputList.append(inputNum)



cnt = 0
for i in range(a):
    for j in range(i+1, a):
        dstnc = 0
        for k in range(b):
            tmpi = inputList[i][k]
            tmpj = inputList[j][k]

            dstnc += math.pow(int(tmpi) - int(tmpj), 2)

        if math.sqrt(dstnc) % 1.0 == 0 :
            cnt += 1

print(cnt)


Measured memory_bytes: 38384
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class UnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)
		self.size = [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 union(self, x, y):
		x = self.find(x); y = self.find(y)
		if x == y:
			return

		if self.rank[x] < self.rank[y]:
			self.size[y] += self.size[x]
			self.size[x] = 0
			self.par[x] = y
		else:
			self.size[x] += self.size[y]
			self.size[y] = 0
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

	def getsize(self, x):
		x = self.find(x)
		return self.size[x]

def main():
	N, Q = getlist()
	UF = UnionFind(N)
	for i in range(Q):
		q, u, v = getlist()
		if q == 0:
			UF.union(u, v)
		else:
			if UF.same_check(u, v):
				print(1)
			else:
				print(0)

if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1000005
#define MAXC 205
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;
int K;
ll V[MAXN];

ll f(ll x)
{
	for(int i=0; i<K; i++) x = x - (x%V[i]);
	return x;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> K;
	vector <int> vi;
	for(int i=0; i<K; i++) {
		int x; cin >> x;
		if(vi.size()) if(vi[vi.size()-1] == x) continue;
		V[vi.size()] = x;
		vi.PB(x);
	}
	K = vi.size();
	if(vi[vi.size()-1] != 2) {
		cout << -1 << endl;
		return 0;
	}

	ll l=0;
	ll r=2e16;
	ll ans = -1;
	while(l <= r) {
		ll md = (l+r)/2LL;
		ll cnt = f(md);
		if(cnt == 2) ans = md;
		if(cnt >= 2) {
			r=md-1;
		}
		else { l=md+1; }
	}	
	if(ans == -1) {
		cout << -1 << endl;
		return 0;
	}
	l = ans;
	r = 2e16;
	ll ans2 = 0;
	while(l <= r) {
		ll md = (l+r)/2LL;
		ll cnt = f(md);
		if(cnt == 2) ans2 = md;
		if(cnt > 2) {
			r=md-1;
		}
		else { l=md+1; }
	}	
	cout << ans << ' ' << ans2 << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"
ll Ceil(ll val,ll div){	return (1 + (val - 1) / div);}

void Main()
{
	ll N=3;
	ll result=0;
	VI A(N);
	REP(i, N) cin >> A[i];
	SORTR(A);
	ll left=A[0]*2-(A[1]+A[2]);

	if(left%2==1) result+=2;
	result+=left/2;
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int IINF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 1, 1, 0, 0, -1, -1, -1}, dy[] = {1, 0, -1, 1, -1, 1, 0, -1};

struct S {
	char fld[5][5];
	int x, y, cnt;
};

bool can_Move(int y, int x, int n, char fld[5][5]) {
	if(x < 0 || y < 0 || n <= x || n <= y)
		return false;
	if(fld[y][x] == '.')
		return true;
	return false;
}

bool check(int y, int x, int n, char fld[5][5]) {
	if(x < 0 || y < 0 || n <= x || n <= y)
		return false;
	if(fld[y][x] == '#' || fld[y][x] == '@')
		return true;
	return false;
}

void infection(S &s, int n) {
	char fld[5][5];
	REP(i, n) REP(j, n) {
		int cnt = 0;
		REP(k, 8)
			cnt += check(i+dy[k], j+dx[k], n, s.fld);
		if(s.fld[i][j] == '#' && (cnt == 2 || cnt == 3))
			fld[i][j] = '#';
		else if(s.fld[i][j] == '.' && cnt == 3)
			fld[i][j] = '#';
		else if(s.fld[i][j] == '@')
			fld[i][j] = '@';
		else
			fld[i][j] = '.';
	}
	memcpy(s.fld, fld, sizeof(fld));
	return;
}

bool done(S &s, int n) {
	REP(i, n) REP(j, n)
		if(s.fld[i][j] == '#')
			return false;
	return true;
}

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

	int n;
	while(cin >> n, n) {
		S s;
		REP(i, n) REP(j, n) {
			cin >> s.fld[i][j];
			if(s.fld[i][j] == '@') {
				s.x = j; s.y = i;
			}
		}
		s.cnt = 0;
		queue<S> q; q.push(s);
		set<string> ss;

		bool flg = false;
		while(!q.empty()) {
			s = q.front(); q.pop();
			if(done(s, n)) {
				flg = true;
				break;
			}
			REP(i, 8) {
				int y = s.y + dy[i];
				int x = s.x + dx[i];
				if(!can_Move(y, x, n, s.fld)) continue;
				S s2(s);
				swap(s2.fld[y][x], s2.fld[s2.y][s2.x]);
				s2.y = y; s2.x = x;

				infection(s2, n);
				s2.cnt++;

				string str;
				REP(j, n) REP(k, n)
					str += s2.fld[j][k];
				if(!ss.count(str)) {
					q.push(s2);
					ss.insert(str);
				}
			}
		}
		cout << (flg? s.cnt : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if((100*r+10*g+b) % 4 == 0){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		System.out.println(d + " " + r + " " + String.format("%.10f",f));
	}
}
		


Measured memory_bytes: 26476
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
box = []
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a==b and b==c:
                box.append(gcd(a,b,c))
            elif a!=b and b!=c and c!=a:
                box.append(gcd(a,b,c)*6)
            else:
                box.append(gcd(a,b,c)*3)
print(sum(box))

Measured memory_bytes: 19860
// https://atcoder.jp/contests/abc154/tasks/abc154_c
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        n: usize,
        mut a: [i64; n]
    };
    a.sort();
    let mut ok = true;
    for i in 0..n-1 {
        ok &= a[i] != a[i+1];
    }
    println!("{}", ifv!(ok, "YES", "NO"));
}


Measured memory_bytes: 8444