akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Player
{
    static void Main(string[] args)
    {
        int Yen = int.Parse(Console.ReadLine());
        string Ans = "No";
        if(Yen < 4)
        {
            Console.WriteLine(Ans);
            return;
        }

        if (Yen % 4 == 0 || Yen % 7 == 0)
        {
            Console.WriteLine("Yes");
            return;
        }

        while (Yen > 0)
        {
            if(Yen % 7 == 0)
            {
                Ans = "Yes";
                break;
            }
            Yen -= 4;
        }
        Console.WriteLine(Ans);

    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll x;
    cin>>x;
    ll n=0,i=0;
    for(i=1;i<x;i++){
        n+=i;
        if(x<=n)break;
    }
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        int[] n = new int[] {p+q, q+r, r+p};
        int min = p+q;
        for (int i : n) {
            if (min >= i) {
                min = i;
            }
        }
        System.out.println(min);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  cout << (k == 1 ? 0 : n - k) << endl;


  
  return 0;
}

Measured memory_bytes: 256
// ~/BAU/ACM-ICPC/Teams/Rampage/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 300001;
const ll MOD = 1e9 + 7;

int n, e[N+1];
char s[N];

int main() {
	scanf("%d%s", &n, s);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'E') e[i]++;
		e[i] += e[i + 1];
	}

	int ans = 2e9, w = 0;
	for (int i = 0; i < n; i++) {
		ans = min(ans, w + e[i + 1]);
		if (s[i] == 'W') w++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>

#define ran 333

int n;
int a[ran];
int f[ran*ran], g[ran*ran];

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 998244353;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
};
modular_arithmetic ma;

int main() {
	scanf("%d", &n);
	
	int s = 0;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		s += a[i];
	}
	
	memset(f, 0, sizeof f);
	f[0] = 1;
	int lim = 0;
	for(int i=1;i<=n;i++) {
		for(int j=lim;j>=0;j--) {
			if (f[j]>0) f[j+a[i]] = ma.add(f[j+a[i]], f[j]);
			f[j] = ma.mul(f[j], 2);
		}
		lim += a[i];
	}
	
	g[0] = 1;
	lim = 0;
	for(int i=1;i<=n;i++) {
		for(int j=lim;j>=0;j--)
			g[j+a[i]] = ma.add(g[j+a[i]], g[j]);
		lim += a[i];
	}
	
	int v = 0;
	for(int i=(s+1)/2;i<=s;i++) {
		v = ma.add(v, f[i]);
	}
	v = ma.mul(v, 3);
	if(s%2==0) v = ma.sub(v, ma.mul(g[s/2], 3));
	
	int ans = ma.pw(3, n);
	printf("%d\n", ma.sub(ans, v));
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main() {
  double a, b, x; cin >> a >> b >> x;
  cout << setprecision(16);
  if(x <= a * a * b / 2) {
    double ttheta = (a * b * b / (2 * x));
    cout << atan(ttheta) * 360 / (2 * 3.14159265358979) << endl;
    return 0;
  }
  double ttheta = 2 * (a * a * b - x) / (a * a * a);
  cout << atan(ttheta) * 360 / (2 * 3.14159265358979) << endl;
}

Measured memory_bytes: 384
/**
*    created: 25.07.2020 07:17:50
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int h, w; cin >> h >> w;
    int n; cin >> n;
    vector<int> con;
    rep(i,n) {
        int a; cin >> a;
        rep(j,a) con.push_back(i+1);
    }
    vector<vector<int>> v(h,vector<int>(w));
    rep(i,h) rep(j,w) v[i][j] = con[w*i+j];
    rep(i,h) if (i % 2 == 1) reverse(all(v[i]));
    rep(i,h) {
        rep(j,w) {
            if (j == 0) cout << v[i][j];
            else cout << " " << v[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
a = list(input())
b = "BDEFGHIJKLMNOPQRSTUVWXYZ"
c = list(b)

if a.count("A") != 1 or a.count("C")!= 1:
  print("WA")
elif a.index("A") == 0 and a.index("C") >= 2 and a.index("C") <= (len(a)-2):
  for i in range(len(a)):
    if a[i] in c:
      print("WA")
      break
  else:
    print("AC")
else:
  print("WA")

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

int main()
{
	int N;
	cin >> N;
	if (N == 1) {
		puts("Hello World");
		return 0;
	}
	int A, B;
	cin >> A >> B;
	cout << A + B << endl;
	return 0;
}


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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " <<  x << " " << y;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int b;
    vector<int> a(200005,0);
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> b;
        a[b]++;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    vector<int> c;
    for(int i=0;i<N;i++){
        if(a[i]>0){
            c.push_back(a[i]);
        }else{
            break;
        }
    }
    sort(c.begin(),c.end());
    int size = c.size();
    int res = 0;
    if(size<=K){
        cout << 0 << endl;
    }else{
        for(int i=0;i<N;i++){
            res = res + c[i];
            size--;
            if(size<=K){
                cout << res << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define Pii pair<int,int>
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std; 

#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}    


void solve(){
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if((x/d)<=k){
        int ans1=(x%d);
        int lau=k-(x/d);
        int ans2=abs(ans1-d);
        if(lau&1){
            cout<<ans2;
        }else{
            cout<<ans1;
        }
    }else{
        cout<<(x-(k*d));
    }

}

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
    
}

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

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false);     
    long long int X, K, D; std::cin >> X >> K >> D;
    if(X < 0) X = -X;
    const long long int t = X / D;
    if(K <= t){
        const long long int d = X - K * D;
        std::cout << d << '\n';
        return 0;
    }
    K -= t; const long long int d = X % D;
    if(K % 2 == 0) std::cout << d << '\n';
    else std::cout << D - d << '\n'; 
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
const int INF = 1e9;

void solve(){

}

int main(){
	load;
	int x,y;
	cin>>x>>y;
	if (y>4*x || 2*x > y || y%2!=0) cout << "No";
	else cout << "Yes";
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int x, n; std::cin >> x >> n;
    if(n){
        std::vector<int> p;
        for(int i=0; i<n; i++){
            int b; std::cin >> b; p.push_back(b);
        }

        std::sort(p.begin(), p.end());
        int ans, cnt=1145141919;
        for(int i=0,j=0; i<=101; i++){
            if(i==p[j]){
                j++;
            }else if(abs(x-i)<cnt){
                ans = i;
                cnt = abs(x-i);
            }
        }
        std::cout << ans;
    }else{
        std::cout << x;
    }
    return 0;
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

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

int main(){
  double R; cin >> R;
  cout << setprecision(16) << 2 * R * PI << endl;

  return 0;
}


Measured memory_bytes: 3784
use std::io;

fn read_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    s
}

fn solve(s: String) {
    let r:i32 = s.trim().parse().unwrap();
    let ans = match r {
        0...1199 => "ABC",
        1200...2799 => "ARC",
        _ => "AGC"
    };
    println!("{}", ans);
}

fn main() {
    let s = read_input();
    solve(s);
}

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

using namespace std;

int mincost(int heights[], int n, int k)
{
    int dp[n + 1];
    int minm;
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(heights[1] - heights[0]);
    for (int i = 3; i <= n; i++)
    {
        minm = INT_MAX;
        for (int j = 1; j <= k; j++)
        {
            if (i - j > 0)
            {
                minm = min(minm, dp[i - j] + abs(heights[i - 1] - heights[i - j - 1]));
                dp[i] = minm;
            }
        }
    }
    return dp[n];
}

int main()
{
    int n, k;
    cin >> n >> k;
    int heights[n];
    for (int i = 0; i < n; i++)
    {
        cin >> heights[i];
    }
    int p = mincost(heights, n, k);
    cout << p;
    return 0;
}

Measured memory_bytes: 4368
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	map<int, int> mp;
	rep(i, n)
	{
		int d; cin >> d;
		++mp[d];
	}
	int m; cin >> m;
	while (m--)
	{
		int t; cin >> t;
		if (!mp[t])
		{
			cout << "NO" << endl;
			return 0;
		}
		--mp[t];
	}
	cout << "YES" << endl;
}

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

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

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



int main() {
    std::string c;
    cin >> c ;
    std::string alp = "abcdefghijklmnopqrstuvwxyz";
    char ans = alp[alp.find(c)+1];
    cout << ans << endl;
}



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

using namespace std;

const int MAX = 1e9;

template<typename T>
struct BinaryIndexedTree{
private:
  int n;
  T *data;

public:
  BinaryIndexedTree(int n = 0) : n(n){
    data = new T[n + 1];
    for(int i = 0; i <= n; i++) data[i] = 0;
  }

  bool add(int index, T x = 1){
    if(index < 0 || n <= index) return false;
    for(index++; index <= n; index += index & -index){
      data[index] += x;
    }
    return true;
  }

  T sum(int index){
    if(index < 0) index = 0;
    else if(index >= n) index = n - 1;

    T x = 0;
    for(index++; index; index -= index & -index){
      x += data[index];
    }
    return x;
  }

  ~BinaryIndexedTree(){
    delete [] data;
  }
};

int median_of_medians(vector<int>& a){
  int n = a.size();
  
  int ok = MAX, ng = 0;
  while(ok - ng > 1){
    int mid = (ok + ng) >> 1;
    
    vector<int> o(n);
    for(int i = 0; i < n; i++){
      o[i] = a[i] <= mid ? 1 : -1;
      if(i) o[i] += o[i - 1];
    }
    
    long long num = 0;
    BinaryIndexedTree<int> bit(2 * n + 1);
    bit.add(n);
    for(int i = 0; i < n; i++){
      num += bit.sum(o[i] + n - 1);
      bit.add(o[i] + n);
    }
    
    (num > (((long long)n * (n + 1) >> 1) >> 1) ? ok : ng) = mid;
  }
  
  return ok;
}

int main(){
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  cout << median_of_medians(a) << endl;
  
  return 0;
}

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

const int MOD = 1000000007;

ll Pow2[200001];

ll gcd(ll a, ll b){
    if(a<b)
        swap(a,b);
    while(a%b!=0LL){
        a %= b;
        swap(a,b);
    }
    return b;
}

void initPow2(int n){
    ll rtn = 1LL;
    Pow2[0] = rtn;
    for(int i=1; i<=n; i++){
        rtn *= 2LL;
        rtn %= MOD;
        Pow2[i]=rtn;
    }
}

int main(){
    
    initPow2(200000);
    
    int n;cin>>n;
    
    map<pair<ll,ll>, P> yuri;
    
    ll a,b;
    ll xy0 = 0LL;
    
    rep(i,n){
        cin >> a >> b;
        if(a==0 && b==0){
            xy0++;
        }else if(b==0){
            yuri[{1,0}].first++;
        }else if(a==0){
            yuri[{1,0}].second++;
        }else if(a/abs(a)==b/abs(b)){//傾き正
            ll g = gcd(abs(a), abs(b));
            ll na = abs(a)/g;
            ll nb = abs(b)/g;
            yuri[{na,nb}].first++;
        }else{
            ll g = gcd(abs(a), abs(b));
            ll na = abs(a)/g;
            ll nb = abs(b)/g;
            yuri[{nb,na}].second++;
        }
    }
    
    ll ans = 1LL;
    
    for(auto y : yuri){
        ll now = Pow2[y.second.first]-1LL;
        now %= MOD;
        now += Pow2[y.second.second];
        now %= MOD;
        ans *= now;
        ans %= MOD;
    }
    
    ans += xy0 + MOD - 1LL;
    ans %= MOD;
    
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    long int n;
    cin>>n;
    long int a[n];
    unordered_map<long int,long int> mp;
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    //    mp[a[i]]++;
    }
    for(long int i=0;i<n;i++)
    {
        for(long int j=31;j>=0;j--)
        {
            long int temp=a[i]>>j;
            if(temp&1)
            {
                mp[j]++;
            }
        }
    }
    for(long int j=31;j>=0;j--)
    {
        if(mp[j]==0)
        {
            continue;
        }
        if(mp[j]%2!=0)
        {
            
            cout<<"No";
            exit(0);
        }
    }
    
    cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define MAX 1000005
int F[MAX]={1,1},i,j,p=0,N,M,C[1005][1005],pos[MAX][2],dp[MAX],t,nc;
typedef struct D{int c,np,now;}D;

void set(int n,int y,int x){C[y][x]=n;pos[n][0]=y;pos[n][1]=x;}

void vortex()
{
	int i,j,pre,nx,ny,mv[5]={-1,0,1,0,-1};
	memset(C,0x7f,sizeof(C));
	nx=1005/2;ny=1005/2;
	set(1,ny,nx++);
	set(2,ny,nx);
	for(i=3,pre=i-1;i<MAX;pre=i++)
	{
		for(j=0;j<4;j++)
		{
			if(C[ny+mv[j]][nx+mv[j+1]]==pre-1)
				break;
		}
		for(;C[ny+mv[j]][nx+mv[j+1]]<MAX;)
			j=(j+1)%4;
		ny+=mv[j];
		nx+=mv[j+1];
		set(i,ny,nx);
	}
}

int main()
{
	for(i=2;i<MAX;i++)
		if(!F[i])
		{
			for(j=i*2;j<MAX;j+=i)
				F[j]=1;
		}
	vortex();
	for(;scanf("%d%d",&M,&N),N+M;)
	{
		memset(dp,-1,sizeof(dp));
		queue<D>Q;
		D tmp={!F[N],(!F[N])?N:0,N},r=tmp;
		Q.push(tmp); 
		while(!Q.empty())
		{
			tmp=Q.front();Q.pop();
			if(r.c<tmp.c||(tmp.c==r.c&&tmp.np>r.np))
				r=tmp;
			if(tmp.c<dp[tmp.now])continue;
			dp[tmp.now]=tmp.c;
			for(i=-1;i<2;i++)
			{
				t=C[pos[tmp.now][0]+1][pos[tmp.now][1]+i];
				if(t>M)continue;
				nc=tmp.c+(!F[t]);
				if(dp[t]<nc)
				{
					D ins={nc,(!F[t])?t:tmp.np,t};
					dp[t]=ins.c;
					Q.push(ins);
				}
			}
		}
		printf("%d %d\n",r.c,r.np);
	}
	return 0;
}

Measured memory_bytes: 20648
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


#include <set>
void solve() {
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.rbegin(), A.rend());
  cout << A[0] * 10 + A[1] + A[2] << endl;
}


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

int main()
{
  list<int> ltiNumber;
  list<int>::iterator itlti;
  list<int>::iterator itltEND = ltiNumber.end();
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      ltiNumber.push_front(iNumber);
    }
    else if (acCommand[6] == 'F')
      ltiNumber.pop_front();
    else if (acCommand[6] == 'L')
      ltiNumber.pop_back();
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti)
      {
        if (*itlti == iNumber)
        {
          ltiNumber.erase(itlti);
          break;
        }
      }
    }
  }

  int i = 0;
  for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti)
  {
    if (i++) cout << " ";
    cout << *itlti;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 32444
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static Node[] nodes;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int V = sc.nextInt();
		nodes = new Node[V];

		int node_id,tmp_num,tmp;

		//エッジ情報取得
		for(int loop = 0; loop < V; loop++){

			node_id = sc.nextInt();
			node_id--;

			nodes[node_id] = new Node();

			tmp_num = sc.nextInt();
			nodes[node_id].num_edge = tmp_num;

			for(int a = 0; a < tmp_num; a++){
				tmp = sc.nextInt();
				tmp--;
				nodes[node_id].list.add(tmp);
			}
		}

		int[] min_dist = new int[V];

		for(int i = 1; i < V; i++){
			min_dist[i] = BIG_NUM;
		}
		min_dist[0] = 0;

		Queue<Info> Q = new ArrayDeque<Info>();
		Q.add(new Info(0,0));

		int next_node,next_cost;

		while(!Q.isEmpty()){

			for(int i = 0; i < nodes[Q.peek().node_id].num_edge; i++){

				next_node = nodes[Q.peek().node_id].list.get(i);
				next_cost = Q.peek().sum_cost+1;

				if(min_dist[next_node] > next_cost){
					min_dist[next_node] = next_cost;
					Q.add(new Info(next_node,next_cost));
				}
			}
			Q.poll();
		}

		for(int i = 0; i < V; i++){
			if(min_dist[i] == BIG_NUM){
				min_dist[i] = -1;
			}
		}

		for(int i = 0; i < V; i++){
			System.out.println(Integer.toString(i+1)+" "+Integer.toString(min_dist[i]));
		}
	}
}


class Node{

	public int num_edge;
	public ArrayList<Integer> list;

	Node(){
		list = new ArrayList<Integer>();
	}
}


class Info{

	public int node_id;
	public int sum_cost;

	Info(int arg_node_id,int arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
#define currPoint(P, i) P[i]
#define nextPoint(P, i) P[(i+1)%P.size()]

const int MAX_N = 1000;
int n;
Point dp[MAX_N+1];

int main()
{
  dp[1] = Point(1.0, 0.0);
  erep(i, 2, MAX_N) dp[i] = dp[i-1] + polar(1.0, (arg(dp[i-1]) * 180 / M_PI + 90) * M_PI / 180.0);

  while((cin >> n) && n > 0)  printf("%.15f\n%.15f\n", dp[n].real(), dp[n].imag());

  return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long b[n + 1];
  b[0] = 0;
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  sort(b, b + n + 1);
  long long res = 0;
  int i = 0;
  while (i <= n) {
    long long cnt = upper_bound(b, b + n + 1, b[i]) - lower_bound(b, b + n + 1, b[i]);
    res += cnt * (cnt - 1) / 2;
    i += cnt;
  }
  cout << res << "\n";
  return 0;
}

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

void buildMaxHeap(int *);
void MaxHeapify(int *,int);
void swap(int*,int,int);

int size;

int main(void){
	int *A;
	int i;
	scanf("%d",&size);

	A=(int*)malloc(sizeof(int)*(size+1));

	for(i=1;i<=size;i++) scanf("%d",&A[i]);

	buildMaxHeap(A);

	for(i=1;i<=size;i++) printf(" %d",A[i]);
	printf("\n");

	free(A);

	return 0;
}

void buildMaxHeap(int *A){
	int i,j;

	for(i=size/2;i>0;i--){
		MaxHeapify(A,i);
	}
}

void MaxHeapify(int *A,int num){
	int large;

	if(2*num <= size && A[num] < A[2*num]) large=2*num;
	else large=num;
	if(2*num+1 <= size && A[large] < A[2*num+1]) large=2*num+1;

	if(large!=num){
		swap(A,num,large);
		MaxHeapify(A,large);
	}

}

void swap(int *A,int a,int b){
	int work;

	work=A[a];
	A[a]=A[b];
	A[b]=work;
}

Measured memory_bytes: 2472
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string.h>

using namespace std;

int main(){
    string s;
    while(getline(cin,s)){
        if(s=="END OF INPUT")break;
        int c=0;
        bool f=false;
        for(int i=0;i<s.length();i++){
            if(s[i]==' '){
                cout<<c;
                c=0;
            }else {
                f=false;
                c++;
            }
        }
        if(c)cout<<c<<endl;
        else cout<<endl;
    }
}

Measured memory_bytes: 1184
def ascend(anc, union, dist, rec):
	count = 0
	while anc != union[anc]:
		rec[count] = anc
		anc = union[anc]
		count += 1
	rec[count] = anc
	for i in range(count - 1, -1, -1):
		dist[rec[i]] += dist[rec[i + 1]]
		union[rec[i]] = anc
	return anc

def connect(l, r, d, union, dist, rec):
	l_anc = ascend(l, union, dist, rec)
	r_anc = ascend(r, union, dist, rec)
	if l_anc != r_anc:
		union[l_anc] = r_anc
		dist[l_anc] = dist[r] + d - dist[l]

def is_union(l, r, union, dist, rec):
	return ascend(l, union, dist, rec) == ascend(r, union, dist, rec)

def main():
	N, M = map(int, input().split())
	union = list(range(N + 1))
	dist = [0] * (N + 1)
	rec = [0] * (N + 1)
	for i in range(M):
		l, r, d = map(int, input().split())
		if is_union(l, r, union, dist, rec):
			if dist[r] + d != dist[l]:
				print("No")
				break
		else:
			connect(l, r, d, union, dist, rec)
	else:
		print("Yes")

if __name__ == "__main__":
	main()


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int count =0;
    for (int i=0; i<N; i++) {
        string s1, s2, s3, s; 
        s1= S[i];
        s2 = S[i+1];
        s3 = S[i+2];
        s = s1 + s2 + s3;
        if (s == "ABC") {
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;

ll n,m;


struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


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

    UnionFind tree(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }

    set<int> s;
    rep(i,n){
        s.insert(tree.find(i));
    }
    cout << s.size()-1 << endl;
}

Measured memory_bytes: 7504
def main():
    N = int(input())
    A = list(map(int, input().split()))
    app = True
    for a in A:
        if a%2==0:
            if not (a%3==0 or a%5==0):
                app = False
                break
    if app:
        print("APPROVED")
    else:
        print("DENIED")

main()


Measured memory_bytes: 2940
/*input
0100100
1111111

11010
10001

1
0

1010
1100

11110111111111101110101111111101111111111111010111000000000000000010111101110111010000000000000000
11110111111111101110101111111101111111111111010111000000000000000000000100000000000000000000000000


*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 2005
#define bit(x,y) ((x>>y)&1LL)
#define na(x) (#x) << ":" << x
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

struct data {
	int fi, dl, dr;
	data(int _fi, int _dl, int _dr): fi(_fi), dl(_dl), dr(_dr) {};
};

string S, T;
deque<data> a;
deque<int> b;
int n;
const int INF = 1e9;
int ans;

void prep() {
	for (int i = 0; i < n; i++) {
		int dis = 0; bool ok = false;
		for (int j = i; j >= 0; j--) {
			if (b[j] == 1) {
				ok = true; break;
			}
			dis++;
		}
		if (ok) {
			a[i].dl = dis;
			continue;
		}
		for (int j = n - 1; j > i; j--) {
			if (b[j] == 1) {
				ok = true; break;
			}
			dis++;
		}
		if (ok)
			a[i].dl = dis;
	}
	for (int i = 0; i < n; i++) {
		int dis = 0; bool ok = false;
		for (int j = i; j < n; j++) {
			if (b[j] == 1) {
				ok = true; break;
			}
			dis++;
		}
		if (ok) {
			a[i].dr = dis;
			continue;
		}
		for (int j = 0; j < i; j++) {
			if (b[j] == 1) {
				ok = true; break;
			}
			dis++;
		}
		if (ok)
			a[i].dr = dis;
	}
}

void solve() {
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < n; i++) if (b[i] == 1) a[i].dl = 0, a[i].dr = 0;
		priority_queue<pair<int, int> > pq;
		for (int i = 0; i < n; i++) {
			if (a[i].fi != b[i]) {
				pq.push(mp(a[i].dl, a[i].dr));
			}
		}
		int mndis = 1e9; int rmx = 0;
		while (!pq.empty()) {
			int x = pq.top().fi; int y = pq.top().se;
			pq.pop();
			mndis = min(mndis, x * 2 + max(0LL, (rmx - j)) * 2);
			rmx = max(rmx, y);
		}
		mndis = min(mndis, max(0LL, (rmx - j)) * 2);
		for (int i = 0; i < n; i++) {
			if (a[i].fi != b[i])
				mndis++;
		}
		ans = min(ans, mndis + j);
		a.push_front(a.back()); a.pop_back();
	}
}

void mainSolve() {
	a.clear(); b.clear();
	for (int i = 1; i <= n; i++)
		a.push_back(data(S[i - 1] - '0', INF, INF));
	for (int i = 1; i <= n; i++)
		b.push_back(T[i - 1] - '0');
	prep();
	solve();

}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef UncleGrandpa
	freopen("1test.inp", "r", stdin);
#endif
	cin >> S >> T; n = S.size(); ans = INF;
	mainSolve();
	reverse(S.begin(), S.end()); reverse(T.begin(), T.end());
	mainSolve();
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll divide(ll x, ll y) {
    return multiply(x, modpower(y, mod - 2));
}

ll frac[1000000];
ll invfrac[1000000];

void fracinvfrac(ll n) {
    frac[0] = 1;
    for (int i = 1; i <= n; i++) {
        frac[i] = multiply(frac[i - 1], i);
    }
    invfrac[n] = divide(1, frac[n]);
    for (int i = n - 1; i >= 0; i--) {
        invfrac[i] = multiply(invfrac[i + 1], i + 1);
    }
}

int main() {
    ll n;
    cin >> n;
    pii ab[2 * n];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ab[i] = pii(a, 1);
    }
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        ab[i + n] = pii(b, -1);
    }
    sort(ab, ab + 2 * n);
    ll ans = 1;
    ll tmp = 0;
    for (int i = 0; i < 2 * n; i++) {
        if (ab[i].second == 1) {
            if (tmp < 0) {
                ans = multiply(ans, abs(tmp));
            }
            tmp++;
        } else {
            if (tmp > 0) {
                ans = multiply(ans, tmp);
            }
            tmp--;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int n;
	ll m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<ll> f(1 << n);
	for (int i = 1; i < (1 << n); i++) {
		ll lcm = 1;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				ll tmp = a[j] / __gcd(lcm, a[j]);
				if (tmp > (m + lcm - 1) / lcm) {
					lcm = m + 1;
				}
				else {
					lcm *= tmp;
				}
			}
		}
		f[i] = (__builtin_popcount(i) & 1 ? 1 : -1) * m / lcm;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if ((j & (1 << i))) {
				f[j] += f[j ^ (1 << i)];
			}
		}
	}
	ld res = 0;
	for (int i = 0; i < (1 << n); i++) {
		ld x = 1;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				x *= (ld)p[j] / 100;
			}
			else {
				x *= (ld)(100 - p[j]) / 100;
			}
		}
		res += f[i] * x;
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}



Measured memory_bytes: 11016
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind_hv{
  vector<int> d, weight;
  UnionFind_hv(int n) : d(n, -1), weight(n, 0){}
  int find(int x){
    if(d.at(x) < 0) return x;
    int ret = find(d.at(x));
    weight.at(x) += weight.at(d.at(x));
    return d.at(x) = ret;
  }
  int get_weight(int x){
    find(x);
    return weight.at(x);
  }
  int diff(int x, int y){
    return weight.at(y) - weight.at(x);
  }
  bool unite(int x, int y, int w){
    w += weight.at(x); w -= weight.at(y);
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y), w = -w;
    d.at(x) += d.at(y);
    d.at(y)= x;
    weight.at(y) = w;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind_hv uf(n);
  rep(i, m){
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if(uf.same(l, r) == false){
      uf.unite(l, r, d);
    }else{
      if(uf.diff(l, r) != d){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 4056
#include <iostream>
int main()
{
  int a, b, c, store;
  std::cin >> a >> b >> c;
  if(a > b){
    store = a;
    a = b;
    b = store;
  }
  if(b > c){
    store = b;
    b = c;
    c = store;
  }
  if(a > b){
    store = a;
    a = b;
    b = store;
  }
  std::cout << a << " " << b << " " << c << '\n';
  return (0);
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
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;}
#define debug(v) {cout<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

typedef long long int64;


int main() {
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace c
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var inp = Array.ConvertAll (Console.ReadLine ().Split(), int.Parse);
			var list = new List<int[]> ();
			for(int i = 0; i < inp[0];i++)list.Add(Array.ConvertAll(Console.ReadLine().Split(),int.Parse));
			int ans = 0;
			for(int i = 0; i < inp[0]; i++)
			{
				for(int j = i+1; j < inp[0];j++)
				{
					double x = 0;
					for(int k = 0; k < inp[1]; k++)
					{
						x += Math.Pow (list [i] [k] - list [j] [k],2.0);
					}
					x = Math.Sqrt(x);
					if(x==Math.Ceiling(x))ans++;
				}
			}
			Console.WriteLine (ans);
		}
	}
}

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

using namespace std;

int
main(void){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	double cmp = -1;
	int ans1 = 0, ans2 = 0;
	for(int i = 0; i <= f; i += a){
		for(int j = 0; i + j <= f; j += b){
			if(i + j == 0) continue;
			int w = i + j;
			int maxs = (w * e)/100;
			for(int k = 0; k <= maxs; k += c){
				for(int l = 0; k + l <= maxs; l += d){
					int s = k + l;
					if(s + w > f) continue;
					double cur = (1000000 * s)/(s + w);
					if(cur > cmp){
						ans1 = s + w;
						ans2 = s;
						cmp = cur;
					}	
				}
			}
		}
	}
	cout << ans1 << " " << ans2;
}

Measured memory_bytes: 256
#include <stdio.h>
    int main(void){
    	int n, max, min;	
        scanf("%d", &n);
        int a[n];
        for(int i = 0;i < n;i++){
            scanf("%d", &a[i]);
        }
        max = a[0];
        min = a[0];
        for(int i= 0;i < n; i++){
            if(a[i] > max) max = a[i];
            if(a[i] < min) min = a[i];
        }
        printf("%d", max - min);
    	return 0;
    }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "delete" :
            list.delete( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public StringBuilder getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf;
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    current = nil.next;

    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 190744
n = gets.to_i
a = gets.split.map(&:to_i)
hash = Hash.new(0)
a.each do |x|
  hash[x] += 1
end

ans = 0
hash.each do |k, v|
  if k > v
    ans += v
  else
    ans += v - k
  end
end
puts ans

Measured memory_bytes: 14468
my @A;
my $N = <STDIN>;
foreach my $i (0..$N-1) {
        $A[$i] = <STDIN>;
}
if ($A[0] > 0) {
        print -1;
        exit 0;
}
foreach my $i (0..$N-2) {
        if ($A[$i+1] > $A[$i]){
                if ($A[$i+1] - $A[$i] != 1){
                        print -1;
                        exit 0;
                }
        }
}
my $t = 0;
foreach my $i (0..$N-2) {
        if($A[$i+1] - $A[$i] != 1){
                $t += $A[$i];
        }
}
$t += $A[$N-1];
print $t;

Measured memory_bytes: 33536
#include<iostream>

using namespace std;

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


if(X<=599){cout << "8" << endl;
}else if(X<=799&&X>=600){cout << "7" <<endl;
}else if(X<=999&&X>=800){cout << "6" <<endl;
}else if(X<=1199&&X>=1000){cout << "5" <<endl;
}else if(X<=1399&&X>=1200){cout << "4" <<endl;
}else if(X<=1599&&X>=1400){cout << "3" <<endl;
}else if(X<=1799&&X>=1600){cout << "2" <<endl;
}else if(X<=1999&&X>=1800){cout << "1" <<endl;
}




return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <math.h>
#include <string>
#include <ios>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

#define LL long long
using namespace std;
int main() {
	LL N;
	LL res = 0;
	cin >> N;

	vector<string> s(N);
	map<string, int> s_map;

	for (int i = 0; i < N; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());

		s_map[s[i]] += 1;
	}

	for (const auto x: s_map) {
		for (int i = 0; i < x.second; i++) {
			res += i;
		}
	}

	cout << res;
	return 0;
}

Measured memory_bytes: 18176
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = input[0];
            var m = input[1];

            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var gcd = GCD(n, m);
            var ss = n / gcd;
            var tt = m / gcd;
            for (int i = 0; i < gcd; i++)
            {
                if(s[ss * i] != t[tt * i])
                {
                    Console.WriteLine("-1");
                    return;
                }
            }
            Console.WriteLine((long)ss * tt * gcd);
    }


        static int GCD(int x, int y)
        {
            if (x < y) return GCD(y, x);
            var r = x % y;
            if (r == 0) return y;
            return GCD(y, r);
        }

}


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

int main() {
	int a,b;
	cin>>a>> b;
	if(a==b){cout<<"Draw"<<endl;return 0;}
	
	if(a==1 || (a>b && b!=1)){cout<<"Alice"<<endl;}
	else{
		cout<<"Bob"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)
 
inline ll score( const vector<ll>& s, ll a, ll b, ll n )
{
	ll cur = 0;
	ll ret = 0;
	while( cur < n )
	{
		cur += a;
		ret += s[cur];
		if( cur == n - 1 ) break;
		cur -= b;
		ret += s[cur];
	}
	return ret;
}
 
template <typename T>
inline vector<T> divisor( T n )
{
	vector<T> res;
	for( T i = 1; i * i <= n; ++i )
	{
		if( n % i == 0 )
		{
			res.push_back( i );
			if( i != n / i ) res.push_back( n / i );
		}
	}
	sort( ALL( res ) );
	return res;
}
 
template <typename T>
inline T gcd(T a, T b)
{
	if (a < b)
		swap(a, b);
	return b ? gcd(b, a % b) : a;
}
 
int main()
{
	ll n; cin >> n;
	vector<ll> s( n, 0 );
	REP(i,n) cin>>s[i];

	vector<vector<ll>> sum( 300, vector<ll>( n, 0 ) );
	REP(i,300) if( i != 0 ) REP(j,n)
	{
		if( j < i ) sum[i][j] = s[j];
		else sum[i][j] = s[j] + sum[i][j-i];
	}
	auto getSum = [sum]( ll start, ll end, ll step ) -> ll
	{
		if( start - step < 0 ) return sum[step][end];
		return sum[step][end] - sum[step][start - step];
	};
 
	ll ans = 0;
	REP( a, n )
	{
		if( a <= 2 || a == n - 1 ) continue;
		auto div = divisor<ll>( n - 1 - a );
		for( auto m : div )
		{
			ll b = a - ( n - 1 - a ) / m;
			//cout << a << " " << b << " " << m << " " << endl;
			if( a <= b || b <= 0 ) continue;
 
			// どぼん
			ll g = gcd<ll>( a, b );
			ll a_ = a / g;
			ll b_ = b / g;
			if( a_ == b_ + 1 && b_ < m ) continue;
 
			ll sc;
			if( a-b < 300 ) sc = getSum( a, n-1, a-b ) + getSum( a-b, n-1-a, a-b );
			else sc = score( s, a, b, n );
			//cout << a << " " << b << " " << sc << endl;
			ans = max( ans, sc );
		}
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 472688