akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static int[] x,y;
    static int n;
    static double ans=0;
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        x = new int[n];
        y=new int[n];

        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
        }
        int[] town = new int[n];
        for(int i=0;i<n;i++)town[i]=-1;

        perm(town);
        System.out.println(ans/fact(n));




    }

    private static double fact(double n){
        if(n==0)return 1;
        return n*fact(n-1);
    }
    private static void perm(int[] town){
        boolean flag = true;
        for(int i=0;i<n;i++)if(town[i]==-1)flag=false;

        if(flag){
            double sum=0;
            for(int i=0;i<n-1;i++){
                sum += sqD(town[i],town[i+1]);
            }
            ans += sum;
        }

        HashSet<Integer> h = new HashSet<>();
        for(int i=0;i<n;i++)h.add(town[i]);
        for(int i=0;i<n;i++){
            if(!h.contains(i)){
                //System.out.println(i);
                int[] temp = town.clone();
                for(int j=0;;j++){
                    if(temp[j]==-1){
                        temp[j]=i;
                        perm(temp);
                        break;
                    }
                }
            }

        }
    }

    private static double sqD(int n1,int n2){
        int dx = x[n1]-x[n2];
        int dy = y[n1]-y[n2];
        return Math.sqrt(dx*dx+dy*dy);
    }

}


Measured memory_bytes: 47524
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int x, a;
	cin >> x >> a;

	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,p;
    for(int i=0;i<5;i++)
    {

        cin >> x;
        if(x==0)
        {

            p=i+1;
        }


    }
cout<<p;
    return 0;
}


Measured memory_bytes: 3592
def ship?(w, k, p)
  current_track = 0
  current_capacity = p
  w.each do |weight|
    while current_capacity < weight && current_track < k
      current_track += 1
      current_capacity = p
    end

    return false if current_track == k

    current_capacity -= weight
  end

  true
end

n, k = gets.split.map(&:to_i)
w = n.times.map{ gets.to_i }

p_min = w.max
p_max = w.inject(:+)
puts (p_min..p_max).bsearch{ |p| ship?(w, k, p) }

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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpii vector<pair<int,int> >
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mci map<char,int>  
#define pii pair<int,int>
#define pdd pair<double,double>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18
#define sp(x,y) fixed<<setprecision(y)<<x

void get_it_done(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
int gcd(int a, int b){ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void swap(int &a,int &b){
	a^=b;b^=a;a^=b;
}
const int N = 1e5+5;
int dp[N];
int n,k;
int height[N];

int solve(int i){
    if(i>=n){
        return inf;
    }
    if(i==(n-1)){
        return 0;
    }
    if(dp[i]!=-1) return dp[i];
    int ans = inf;
    // cout<<i<<endl;
    loop(j,i+1,i+k+1){
        if(j<n)
            ans = min(ans,abs(height[i]-height[j])+solve(j));    
    }

    return dp[i] = ans;
}

int32_t main(){
	get_it_done();
    int t=1;
    // cin >> t;
    while (t--){
        cin>>n>>k;
        loop(i,0,n) cin>>height[i];
        memset(dp,-1,sizeof(dp));
        cout<<solve(0)<<endl;

    }
}


Measured memory_bytes: 6528
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    val (d,x) = readLine()!!.split(" ").map(String::toInt)
    val b = (0 until n).map { (d - 1) / readLine()!!.toInt() + 1}
    println(b.sum() + x)
}

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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
int A, B;

int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#else
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif
    cin >> A >> B;
    cout << A * B;
    return 0;
}


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

vector<int> color;

void dfs(int v, int dis, vector<vector<pair<int, int>>> &G){
  if(dis % 2 == 0) color.at(v) = 0;
  else color.at(v) = 1;
  
  for(auto k: G.at(v)){
    int nv = k.first;
    int tmp = k.second;
    if(color.at(nv) != -1) continue;
    dfs(nv, dis + tmp, G);
  }
}

int main(){
  int n; cin >> n;
  vector<vector<pair<int, int>>> G(n);
  for(int i = 0; i < n-1; i++){
    int u, v, w; cin >> u >> v >> w;
    u--; v--;
    G.at(u).push_back({v, w});
    G.at(v).push_back({u, w});
  }
  color.resize(n, -1);
  color.at(0) = 0;
  dfs(0, 0, G);
  for(int a: color) cout << a << endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
	map<ll, ll> m;
	vector<ll> nums;
    int n; cin >> n;
    for(int i = 0; i < n; ++i){
    	ll x;
    	cin >> x;
    	nums.pb(x);
    	if(m.find(x) != m.end()) m[x]++;
    	else m.insert(make_pair(x, 1));
    }
    map<ll, ll> :: iterator it;
    ll sum = 0;
    for(it = m.begin(); it != m.end(); ++it){
    	ll x = it->se;
    	sum = sum + (x * (x - 1)) / 2;
    }
    for(int k = 1; k <= n; ++k){
    	ll ans = 0;
    	ll x = 0;
    	map<ll, ll> :: iterator ite;
    	ite = m.find(nums[k - 1]);
    	if(ite != m.end()){
    		x = ite->second;
    		ll y = (x * (x - 1)) / 2;
    		x = x - 1;
    		ll z = (x * (x - 1)) / 2;
    		ans = sum - y + z;
    	}
    	else ans = sum;
    	cout << ans << endl;
    }
    
	return 0;
} 

Measured memory_bytes: 11376
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();
        int sum = 0;
        for (int ct = a; ct <= b; ct++) {
            if (((ct + "").charAt(0)) == ((ct + "").charAt(4))) {
                if (((ct + "").charAt(1)) == ((ct + "").charAt(3))) {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 37588
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
import string

def main():
    s = input().rstrip()
    t = input().rstrip()
    t = t[0:-1]
    if s == t:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()


Measured memory_bytes: 71720
#include <bits/stdc++.h>
#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++)
using namespace std;

signed main(){
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if (u == s) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  OUT(s.substr(0,4) + " " + s.substr(4,8));
}

Measured memory_bytes: 256
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
  s=input()
  if s=="AC":
    a+=1
  elif s=="WA":
    b+=1
  elif s=="TLE":
    c+=1
  elif s=="RE":
    d+=1

print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9232
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//ios_base& scientific (ios_base& str);
	ll t, n, m;
	cin >> t;
	cin >> n >> m;
	ll ok = t * (n / t);
	if (ok >= n)
	{
		if (ok <= m or ok + t <= m)
			cout << "OK\n";
		else
			cout << "NG\n";
	}
	else
	{
		ok += t;
		if (ok <= m)
			cout << "OK\n";
		else
			cout << "NG\n";
	}


	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;
const int MOD=1e9+7;

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int get(int x1, int y1, int x2, int y2)
{
	int xdiff=x2-x1;
	int ydiff=y2-y1;
	return nCr(xdiff+ydiff, xdiff);
}

int32_t main()
{
	IOS;
	precompute();
	int n, m, p, q;
	cin>>n>>m>>p>>q;
	int ans=nCr(n-1+m-1, n-1);
	int curx=n-p+1, cury=q;
	while(curx<=n && cury>=1)
	{
		ans-=(get(1, 1, curx, cury) * get(curx, cury, n, m))%MOD;
		curx++;
		cury--;
		ans+=MOD;
		ans%=MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N, M;
    cin >> N >> M;
    VL a(N);
    ll sum=0;
    rep(i,0,N){cin>>a[i];sum+=a[i];}
    sort(ALL(a));

    ll ans=(M-sum)/a[0] + N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a,b;
int main() {
    n=gi(),a=gi(),b=gi();
    if((b-a)&1) puts("Borys");
    else puts("Alice");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>
using namespace std;

double dist(pair<double, double> a, pair<double, double> b) {
    double dx = a.first - b.first;
    double dy = a.second - b.second;
    return sqrt(dx * dx + dy * dy);
}

struct UnionFind {
    vector<int> parent; // 先祖. 親ではない
    UnionFind(int size) : parent(size, -1) {}
    int root(int x) {
        if (parent[x] < 0) return x;
        return parent[x] = root(parent[x]); 
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        parent[x] = y;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

struct Edge {
    int from, to;
    double cost;
    Edge(int from, int to, double cost) : from(from), to(to), cost(cost) {}
    bool operator<(const Edge &o) const {
        return (cost < o.cost);
    }
    bool operator>(const Edge &o) const {
        return (cost > o.cost);
    }
};

typedef vector<Edge> Vertex;

struct Graph {
    vector<Vertex> g;
    Graph(int vertex_count=0) : g(vertex_count) {}
    Graph(vector<Vertex> g) : g(g) {}

    inline Vertex& operator[](int index) {
        return g[index];
    }

    inline void push_back(Vertex v) {
        g.push_back(v);
    }

    inline void add_edge(int from, int to, double cost) {
        g[from].push_back(Edge(from, to, cost));
    }

    double whole_cost() {
        double ret = 0;
        for (int i = 0; i < g.size(); i++) 
            for (int j = 0; j < g[i].size(); j++) 
                ret += g[i][j].cost;
        return ret;
    }

    double kruskal() {
        vector<Edge> edges;
        for (int i = 0; i < g.size(); i++) 
            for (int j = 0; j < g[i].size(); j++) 
                edges.push_back(g[i][j]);
        sort(edges.begin(), edges.end(), greater<Edge>());

        UnionFind uf(g.size());

        double ret = 0;
        for (int i = 0; i < edges.size(); i++) {
            Edge e = edges[i];
            if (!uf.same(e.from, e.to)) {
                uf.unite(e.from, e.to);
                ret += e.cost;
            }
        }
        return whole_cost() - ret;
    }
};

int main() {
    int N, M; cin >> N >> M;
    Graph g(N);
    vector< pair<double, double> > pile;
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        pile.push_back(make_pair(x, y));
    }
    for (int i = 0; i < M; i++) {
        int from, to;
        cin >> from >> to; 
        from--, to--;
        g.add_edge(from, to, dist(pile[from], pile[to]));
    }
    printf("%6f\n", g.kruskal());
    return 0;
}

Measured memory_bytes: 2880
a,b,m = map(int,input().split())
f = list(map(int,input().split()))
r = list(map(int,input().split()))
mn = min(f) + min(r)

for i in range(m):
    x,y,c = map(int,input().split())
    if f[x-1] + r[y-1] - c < mn:
        mn = f[x-1] + r[y-1] - c 
print(mn)

Measured memory_bytes: 18740
import sys
input = sys.stdin.readline

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

C = p[:X] + q[:Y] + r
C.sort(reverse=True)

print(sum(C[:X+Y]))

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

void display(list<int> & lst){
    if (!lst.empty()){
        cout << lst.front();
        lst.pop_front();
    }
    for (auto element : lst){
        cout << ' ' << element;
    }
    cout << endl;    
}

int main()
{
    ios::sync_with_stdio(false);
    list<int> lst;
    int n = 0;
    cin >> n;
    for (int i = 0; i != n; ++i){
        string command;
        cin >> command;
        if (command == "insert"){
            int x = 0;
            cin >> x;
            lst.push_front(x);
        }else if (command == "delete"){
            int x = 0;
            cin >> x;
            for (auto it = lst.begin(); it != lst.end(); ++it){
                if (*it == x){
                    lst.erase(it);
                    break;
                }
            }
        }else if (command == "deleteFirst"){
            lst.pop_front();
        }else if (command == "deleteLast"){
            lst.pop_back();
        }
    }
    display(lst);
    return 0;
}

Measured memory_bytes: 34348
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

// Segment Tree
// updateは0-indexed !!!
// 根 = 1
// iの親 = i>>1
// iの子供 = {i<<1, (i<<1)|1}
// iの兄弟 = i^1
// i番目の要素に相当するセグメント : dat[n+i]
typedef int data_t;
const data_t inf = ((1LL<<31)-1);
struct SegTree {
    vector<data_t> dat; int n;
    SegTree(int n_){
        int k = 1;
        while(k < n_) k<<=1;
        this->n = k;
        dat.assign(k*2, inf);
    }
    // 0-indexed !!!
    // ボトムアップ
    void update(int k, int x){
        int i = n + k; // leaf
        dat[i] = x;
        while(i != 1){ // 1 is root
            dat[i>>1] = min(dat[i], dat[i^1]);
            i>>=1;
        }
    }
    // 区間[a,b)の最小値を求める
    // kはセグメントの番号でl,rはそれが覆う開区間の両端
    // トップダウン
    data_t query(int a, int b, int k=1, int l=0, int r=-1){
        if(r == -1) r = n;
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return dat[k];
        int v1 = query(a, b, k<<1,   l,       (l+r)/2 );
        int v2 = query(a, b, k<<1|1, (l+r)/2, r       );
        return min(v1, v2);
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    SegTree t(n);
    for(int i=0;i<q;i++){
        int c,x,y;
        cin>>c>>x>>y;
        if(c==0){ // update
            t.update(x, y);
        } else { // query
            cout << t.query(x, y+1) << endl;
        }
    }

    // for(int i=0;i<4;i++){
    //     for(int j=i+1;j<4;j++){
    //         printf("[%d %d) -> %d\n", i,j,t.query(i,j));
    //     }
    // }
    // for(int i=0;i<8;i++){
    //     printf("%d ", t.dat[i]);
    // }
    // puts("");
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
string s="abcdefghijklmnopqrstuvwxyz";
#define ll long long int
int main()
{
    ll n;cin>>n;
    vector <ll> N(n);
    ll sum=0ll;
    for(ll &x : N) cin>>x,sum=sum^x;
    for(ll x : N)
    {
        ll id=sum^x;
        cout<<id<<" ";
    }
    return 0;

}
/*




*/


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


struct Info {
  int x = 0; 
  bool y = false;
};

signed main(){
  int N; cin >> N;
  vector<vector<Info> > v(0);
  REP(x, N) {
    int A; cin >> A;
    vector<Info> inpV(A);
    REP(y, A) {
      cin >> inpV.at(y).x >> inpV.at(y).y;
    }
    v.push_back(inpV);
  }

  vector<bool> flags(N+1);
  int maxSum = 0;

  REP(bit, (1<<N)) {
    REP(x, N) {
      if(bit & (1<<x)){
        flags.at(x+1) = true;
      } else {
        flags.at(x+1) = false;
      }
    }

    bool isValid = true;
    // dv("bit", bit);
    FOR1(flagX, N) {
      if(flags.at(flagX)) {
        REP(y, (ll)v.at(flagX-1).size()) {
          if(v.at(flagX-1).at(y).y != flags.at((v.at(flagX-1).at(y).x))) {
            isValid = false;
          }
        }
      }
    }
    if (isValid) {
      // da(flags);
      int sum = 0;
      FOR1(x, N) {
        sum += flags.at(x) ? 1 : 0;
      }
      maxSum = max(maxSum, sum);
    }
  }

  cout << maxSum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int digit(int i)
{
    int ans = 0;
    while(i > 0){
        ans += i % 10;
        i = i / 10;
    }
    return ans;
}

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int ans = INF;
    for(int i = 1; i < n; i++){
        ans = min(ans, digit(i) + digit(n - i));
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if(x+r > W || x-r < 0 || y+r > H || y-r < 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3084
#include<stdio.h>
int main(void)
{
  int k;
  scanf("%d",&k);
  int even=0,odd=0;
  for(int i=1;i<=k;i++){
    if(i%2==0){
      even++;
    }else{
      odd++;
    }
  }

  printf("%d\n",even*odd);
  return 0;
}


Measured memory_bytes: 1736
import bisect

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

L.sort()

ans = 0
for i in range(N-2):
  for j in range(i + 1, N-1):
    idx = bisect.bisect_left(L, L[i] + L[j]) - 1
    ans += idx - j

print(ans)


Measured memory_bytes: 42972
N,M = map(int, input().split())

ansA = 0

if N < 2 and M < 2:
    ansA = 0
if N >=2:
    ansA += ((N * (N-1)) / 2)
if M >= 2:
    ansA += ((M * (M-1)) / 2)

print(int(ansA))

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  int times, diff, init, iteration_init;
  scanf("%d %d %d", &times, &diff, &init);

  iteration_init = init;
  for (short i = 0; i < 10; i += 1) {
    iteration_init = (iteration_init * times) - diff;
    printf("%d\n", iteration_init);
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long a = s.nextLong(), b = s.nextLong(), c = s.nextLong(), k = s.nextLong();
		long ans = 0;
		if(k > 0) {
			long temp = Math.min(k, a);
			k -= temp;
			ans += temp;
		} 
		if(k > 0) {
			long temp = Math.min(k, b);
			k -= temp;
			ans += temp * 0;
		}
		if(k > 0) {
			long temp = Math.min(k, c);
			k -= temp;
			ans += temp * -1;
		}
		System.out.println(ans);
	}

}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s, t;
    cin >> s >> t;
    if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		//code starts now
		boolean possible=true;
      	for(int i=0; i<s.length(); i++){
   			if(i%2==0){
   			    if(s.charAt(i)!='R' && s.charAt(i)!='U' && s.charAt(i)!='D'){
   			    possible=false;
                 break;
                }
   			}else{
   			    if(s.charAt(i)!='L' && s.charAt(i)!='U' && s.charAt(i)!='D'){
   			    possible=false;
                 break;
                }
   			}
        }
        if(possible)
            System.out.println("Yes");
        else
            System.out.println("No");
	}
}

Measured memory_bytes: 23380
#include <stdio.h>

#define CARD_MAX (36)

typedef struct _card {
	char suit;
	int number;
} CARD;

void CheckStable(CARD org[], CARD srt[], int len);
void Swap(CARD c[], int a, int b);
void BubbleSort(CARD c[], int len);
void SelectionSort(CARD c[], int len);
void PrintCards(CARD c[], int len);

int main(void) {
	int N, i;
	CARD input[CARD_MAX + 1];
	CARD bub[CARD_MAX + 1];
	CARD sel[CARD_MAX + 1];
	
	scanf("%d\n", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%c%d ", &input[i].suit, &input[i].number);
		bub[i] = sel[i] = input[i];
	}
	
	BubbleSort(bub, N);
	PrintCards(bub, N);
	CheckStable(input, bub, N);
	
	SelectionSort(sel, N);
	PrintCards(sel, N);
	CheckStable(input, sel, N);
	
	return 0;
}

void CheckStable(CARD org[], CARD srt[], int len) {
	int chk[CARD_MAX + 1] = {0};
	int i, j, t;
	for (i = 1; i <= len; ++i) {
		t = ++chk[srt[i].number];
		for (j = 1; j <= len; ++j) {
			if (org[j].number == srt[i].number) {
				if (--t == 0) {
					if (org[j].suit != srt[i].suit) {
						printf("Not stable\n");
						return;
					}
				}
			}
		}
	}
	printf("Stable\n");
}

void PrintCards(CARD c[], int len) {
	int i;
	for (i = 1; i <= len; ++i) {
		if (i > 1) {
			putchar(' ');
		}
		printf("%c%d", c[i].suit, c[i].number);
	}
	putchar('\n');
}

void Swap(CARD c[], int a, int b) {
	CARD t = c[a];
	c[a] = c[b];
	c[b] = t;
}

void BubbleSort(CARD c[], int len) {
	int i, j;
	for (i = 1; i <= len; ++i) {
		for (j = len; j >= i + 1; --j) {
			if (c[j].number < c[j - 1].number) {
				Swap(c, j, j - 1);
			}
		}
	}
}

void SelectionSort(CARD c[], int len) {
	int i, j, mini;
	for (i = 1; i <= len; ++i) {
		mini = i;
		for (j = i; j <= len; ++j) {
			if (c[j].number < c[mini].number) {
				mini = j;
			}
		}
		Swap(c, i, mini);
	}
}

Measured memory_bytes: 616
mod=998244353
n,m,k=map(int,input().split())
fac=[1]
for i in range(n):
	fac.append(fac[-1]*(i+1)%mod)
ans=0
for x in range(k+1):
	rev=pow(fac[x]*fac[n-1-x]%mod,mod-2,mod)
	r=fac[n-1]*rev%mod*m*pow(m-1,n-x-1,mod)%mod
	ans+=r
	ans%=mod
print(ans)



Measured memory_bytes: 16800
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if (s[0]=='7') {cout<<"Yes";return 0;}
    if (s[1]=='7') {cout<<"Yes";return 0;}
    if (s[2]=='7') {cout<<"Yes";return 0;}
    cout<<"No";
    return 0;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int MAXN = 1000001;
int32_t main(){
    SPEED;
    int n, l;
    cin >> n >> l;
    string s[n];
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }
    sort(s, s+ n);
    for(auto it: s){
        cout << it;
    }
}

Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            Console.WriteLine("A" +s[1][0] + "C");

        }
    }
}

Measured memory_bytes: 11092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}



Measured memory_bytes: 7072
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<bool> a(1000000000, false);
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    --ai;
    if (a.at(ai)) {
      puts("NO");
      return 0;
    }
    a.at(ai) = true;
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 122368
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
int kaijo(int n){
    int c=1;
    REP(i,n) c*= i+1;
    return c;
}
int main()
{
    int n;
    cin >> n;
    vector<int>P(n);
    vector<int>Q(n);
    vector<int>A(n+1,0);
    vector<int>B(n+1,0);
    A[0]=1;
    B[0]=1;
    
    int t=0,s=0;

    REP(i,n){
        cin >> P[i];

    } 
    REP(i,n){
        cin >> Q[i];
    } 
    REP(i,n){
        A[P[i]]= 1;
        int cc=0;
        FOR(j,1,P[i]){
            if(A[j]==0) cc++;
        }
        t+= cc*kaijo(n-(i+1));
    }
    REP(i,n){
        B[Q[i]]= 1;
        int cc=0;
        FOR(j,1,Q[i]){
            if(B[j]==0) cc++;
        }
        s+= cc*kaijo(n-(i+1));
    }
    cout << abs(s-t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		if(n ==0 )cout<<"1\n";
		else cout<<"0\n";
 	}
 	return 0;
}


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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rep2(i,a,b,c) for(i=a;i<=b;i+=c)

int a,b,c,sa,sb,sc;

int main(){
	cin>>a>>b>>c;
	int sa=0,sb=0,sc=0;
	int has=0;
	while(!(a&1) && !(b&1) && !(c&1)){
		sa=(b+c)>>1;
		sb=(a+c)>>1;
		sc=(a+b)>>1;
		a=sa;
		b=sb;
		c=sc;
		has++;
		if(has > 1000000){
			break;
		}
	}
	if(has > 1000000){
		has=-1;
	}
	cout<<has<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N[4];
	rep(i, 0, 4) {
		int a; cin >> a;
		N[i] = a;
	}
	int num[] = { 1,9,7,4 };
	int cnt = 0;
	rep(i, 0, 4) {
		bool ok = false;
		rep(j, 0, 4) {
			if (num[i] == N[j])ok = true;
		}
		if (ok)++cnt;
	}
	if (cnt == 4)cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}


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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] prime = new bool[100010];
            for (int i = 2; i < 100010; i++)
            {
                prime[i] = true;
            }
            for (long i = 0; i <= Math.Sqrt(100010); i++)
            {
                if (prime[i])
                {
                    for (long j = i * i; j < 100010; j += i)
                    {
                        prime[j] = false;
                    }
                }
            }
            int[] like2017 = new int[100010];
            for (int i = 1; i < 100010; i++)
            {
                like2017[i] = like2017[i - 1];
                if (i % 2 == 1 && prime[i] && prime[(i + 1) / 2]) like2017[i]++;
            }
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Console.WriteLine(like2017[x[1]] - like2017[x[0] - 1]);
            }
        }
    }
}

Measured memory_bytes: 17988
#include <bits/stdc++.h>
using namespace std;
int main() {
  char A;
  cin >> A;
  if(A == 'A') {
    cout << "T" << endl;
  }
  if(A == 'T') {
    cout << "A" << endl;
  }
  if(A == 'G') {
    cout << "C" << endl;
  }
  if(A == 'C') {
    cout << "G" << endl;
  }
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return -int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]

#sp.sort(reverse=True, key = lambda x: x[1])
#sp.sort(key = lambda x: x[0])

sp.sort()

for i in range(N):
    print(sp[i][2])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  int len;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(string S_,ull B_=1000000007LL):
    S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};
//END CUT HERE

signed main(){
  int n,m;
  cin>>n>>m;
  string t,p;
  cin>>t;
  RollingHash R(t);
  int l=0,r=1;
  set<unsigned long long>s;
  while(m--){
    cin>>p;
    if(p[0]=='R'){
      if(p[1]=='-')r--;
      else r++;
    }
    else{
      if(p[1]=='-')l--;
      else l++;
    }
    s.insert(R.find(l,r));
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 22232
def solve():
  ans = 0
  N, K = map(int, input().split())
  V = list(map(int, input().split()))
  A = V[:]*2
  for k in range(K,-1,-1): #kは操作回数
    if k>=N:
      suteru = k-N
      a = V[:]
      a.sort()
      ans = max(ans,sum(a[suteru:]))
    else:
      for i in range(k//2+1,k+1): #iは取る回数
        suteru = k-i
        for j in range(i+1):
          a = A[N-j:N+i-j]
          a.sort()
          ans = max(ans,sum(a[suteru:]))
  return ans
print(solve())

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

int main() {
 
  ll n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
  }
  
  vector<int> c(n);
  int x = 1;
  int count = 0;
  int l = 0;
  c[0] = 1;
  
  REP(i,k) {
    x = a[x-1];
    c[x-1]++;
    if (c[x-1] == 2) count++;
    if (c[x-1] == 3) {
      l = (k - i - 1) % count;
      break;
    }
  }
  
  REP(i,l) {
    x = a[x-1];
  }
  
  cout << x << endl;
}


Measured memory_bytes: 4836
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const ll INF = 1e10;
int main(){
    int n, m;
    cin >> n;
    VEC(ll, d, n);
    cin >> m;
    VEC(ll, t, m);
    sort(ALL(d));
    sort(ALL(t));

    if(n < m){
        cout << "NO" << endl;
        return 0;
    }

    int now = 0;
    vector<bool> seen(m, false);
    rep(i, m){
        if(t[i] == d[now]){
            now++;
            seen[i] = true;
        }

        else {
            while(now < n){
                now++;
                if(t[i] == d[now]){
                    now++;
                    break;
                }
            }
            if(now >= n)break;
            seen[i] = true;
        }
        if(now >= n)break;
    }
    bool all_seen = true;
    rep(i, m)if(!seen[i])all_seen = false;

    cout << (all_seen ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    fastio;
    long long n,i,j,k,sum=0;
    static long long ara[103];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ara[i];
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            if(ara[i]==ara[j])
                continue;
            else
            {
                for(k=j+1;k<n;k++)
                {
                    if(ara[j]==ara[k] || ara[i]==ara[k])
                        continue;
                    else
                    {
                        if(ara[i]+ara[j]>ara[k] && ara[i]+ara[k]>ara[j] && ara[j]+ara[k]>ara[i])
                            sum++;
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int n;
	cin>>n;
	vector<LL> a(n);
	int i;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	if (n==1){
		cout<<a[0]<<endl;
		return 0;
	}
	for (i=n-1;i>=0;i-=2){
		cout<<a[i]<<" ";
	}
	if (n%2==0){
		i=0;
	}else{
		i=1;
	}
	for (;i<n;i+=2){
		cout<<a[i];
		if (i<n-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]
cd = [list(map(int,input().split())) for i in range(M)]
ans = [0]*N
for i in range(N):
    dist = 4*(10**8)
    for j in range(M):
        if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])<dist:
            dist = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            ans[i] = j+1
for i in range(N):
    print(ans[i])

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>

using namespace std;

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

struct Rect
{
    int h, w;

    int d() const {
        return h*h + w*w;
    }

    bool operator< (const Rect& r) const {
        return d() < r.d() || (d() == r.d() && h < r.h);
    }
};


int main()
{
    Rect s;

    while(cin >> s.h >> s.w, s.h && s.w){
        Rect ans{1000, 1000};

        reps(i, 1, 151){
            reps(j, i+1, 151){
                Rect tmp{i, j};
                if(s < tmp){
                    ans = min(tmp, ans);
                }
            }
        }

        cout << ans.h <<' ' << ans.w << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
typedef long long int ll;


int main(void){
	int N;
	ll res = 0;
	std::cin >> N;
	std::vector<ll> cnt(N, 0);
	for(int i = 1; i <= N; i++){
		for(int j = 1; i*j <= N; j++)
			cnt[i*j]++;
	}
	for(int i = 1; i <= N; i++)
		res += cnt[i] * i;
	std::cout << res << std::endl;
	return 0;
}


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

int main(void){
	int n,i;
	long int *a,max,min,sum;
	
	scanf("%d",&n);
	a = (long int*)malloc(sizeof(long int)*n);
	for(i=0; i<n; i++)
		scanf("%ld",&a[i]);
	max = min = sum = a[0];
	for(i=1; i<n; i++){
		if(max < a[i])max = a[i];
		else if(min > a[i])min = a[i];
		sum += a[i];
	}
	printf("%ld %ld %ld\n", min, max, sum);
	
	free(a);
	
	return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int r,g,b;
	cin>>r>>g>>b;
	int a =100*r+10*g+b;
	if(a%4==0){
		cout<<"YES"<<endl;
	  }
	  else{
		  cout<<"NO"<<endl;
		}
  }


Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();

    if a+c == 2*b {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n;cin>>n;
    int arr[n];
    map<int,ll> mp;
    int temp;
    fr(i,0,n-1){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    ll res=0;
    for(auto x:mp){
        res+=(((x.second)*(x.second-1))/2);
    }
    fr(i,0,n-1){
        cout<<res-((mp[arr[i]])*(mp[arr[i]]-1))/2+((mp[arr[i]]-1)*(mp[arr[i]]-2))/2<<endl;
    }
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 10368
import java.io.*;

/**
 * Created by Ayushi on 01/09/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        long[] a = new long[n];
        temp = r.readLine().split(" ");
        long c, m;
        c = m = 1;
        a[0] = Long.parseLong(temp[0]);
        for (int i = 1; i < n; i++) {
            a[i] = Long.parseLong(temp[i]);

            if (a[i] > a[i-1]) {
                m = Math.max(m, c);
                c = 1;
                //i++;
            }
            else {
                c++;
            }

            /*System.out.println("a[i] = " + a[i]);
            System.out.println("c = " + c);
            System.out.println("m = " + m);*/
        }
        r.close();

        System.out.println(Math.max(m, c)-1);
    }
}


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

const int Maxn = 100005;

int n, k, q;
int my[Maxn];

int main()
{
    scanf("%d %d %d", &n, &k, &q);
    for (int i = 0; i < q; i++) {
        int a; scanf("%d", &a);
        my[a]++;
    }
    for (int i = 1; i <= n; i++)
        if (k - q + my[i] <= 0) printf("No\n");
        else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1024