akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll N = 0;
vector<double> probs;

int main() {

    cin >> N;
    probs.resize(N);
    FOR(i, 0, N){
        cin >> probs[i];
    }
    vector<double> heads(N+1, 0);
    heads[0] = 1;
    ll heads_needed = N-N/2;
    double res = 0.;
    FOR(i, 0, N){
        vector<double> new_heads;
        new_heads.resize(N+1);
        new_heads[0] = (1-probs[i]) * heads[0];
        FOR(j, 1, N+1){
            new_heads[j] = probs[i]*heads[j-1]+(1-probs[i])*heads[j];
        }

        heads.swap(new_heads);
    }
    
    FOR(i, heads_needed, N+1){
        res += heads[i];
    }
    
    cout << setprecision(15) << res << endl;

    return 0;
}



Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = input.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++){
            if (i+1 == a[a[i]-1]){
                ans += 1;
            }
        }
        System.out.println(ans/2);
    }
}

Measured memory_bytes: 50660
package main

import "fmt"

func main() {
	var n, t, a, ans int
	fmt.Scan(&n, &t, &a)
	x := a - t
	diff := 1000000000

	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)

		if y := abs(x*500 + h*3); y < diff {
			diff = y
			ans = i
		}
	}

	fmt.Println(ans + 1)
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<bool> ans;
	for(int i=1;i<=n;++i){
		if(i*(i+1)/2>=n){
			ans.resize(i+1,true);
			ans[i*(i+1)/2-n]=false;
			break;
		}
	}
	for(int i=1;i<ans.size();++i){
		if(ans[i]) cout << i << endl;
	}
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n,x,t;
    cin >> n >> x >> t;
    int num=(n/x)*t;
    if(n%x>0){
        num+=t;
    }
    cout << num << endl;
}

Measured memory_bytes: 3588
#include<algorithm>
#include<functional>
#include<queue>
#include<vector>

using Vertex   = int;
using Flow     = int;
using Cost     = long double;

const Flow INF = 10000;

struct Edge {
  Vertex from, to;
  Flow capacity;
  Cost cost;
  int rev;
  Edge(Vertex from, Vertex to, Flow capacity = 0, Cost cost = 0, int rev = -1) : from(from), to(to), capacity(capacity), cost(cost), rev(rev) {}
};

class FlowNetwork {
public:
  FlowNetwork(int n);
  int size() const;
  void insert(const Edge&);
  Flow maximum_flow(Vertex source, Vertex sink) const;
  Flow minimum_cost_flow(Vertex source, Vertex sink, Flow f) const;
private:
  Vertex size_;
  std::vector<std::vector<Edge>> edge_;
};

// ????£?
FlowNetwork::FlowNetwork(int n) : size_(n), edge_(n) {}

int FlowNetwork::size() const {return size_;}

void FlowNetwork::insert(const Edge& e) {
  edge_.at(e.from).emplace_back(e.from, e.to, e.capacity, e.cost, edge_.at(e.to).size());
  edge_.at(e.to).emplace_back(e.to, e.from, 0, 0, edge_.at(e.from).size() - 1);
}

// ?????§??? O(|V|^2 * |E|)
Flow FlowNetwork::maximum_flow(Vertex source, Vertex sink) const {
  std::vector<int> level;   // ?????????????????????source??????????????¢
  std::vector<int> itr;     // ????????????????????????itr[v]????????\?????????????????£??????????§?
  auto edge = edge_;
  // source????????????????????§????????¢????¨??????????sink?????§????????¢?????????
  auto bfs = [&]() {
    level.assign(size(), -1);
    level.at(source) = 0;
    std::queue<int> q;
    q.push(source);
    while(!q.empty()) {
      auto v = q.front();
      q.pop();
      for(const auto& e: edge.at(v)) if(level.at(e.to) == -1) if(0 < e.capacity) {
        level.at(e.to) = level.at(e.from) + 1;
        q.push(e.to);
      }
    }
    return level.at(sink);
  };
  // ?????????????????????????????¨????????????????????????
  std::function<Flow(Vertex, Flow)> dfs = [&](Vertex v, Flow cur) {
    if(v == sink) return cur;
    for(auto& i = itr.at(v); i < edge.at(v).size(); ++i) {
      auto& e = edge.at(v).at(i);
      if(level.at(e.from) < level.at(e.to)) if(0 < e.capacity) {
        auto f = dfs(e.to, std::min(cur, e.capacity));
        if(f == 0) continue;
        e.capacity -= f;
        edge.at(e.to).at(e.rev).capacity += f;
        return f;
      }
    }
    return Flow(0);
  };
  // Dinic
  Flow result = 0;
  while(bfs() != -1) {
    itr.assign(size(), 0);
    while(auto f = dfs(source, INF)) result += f;
  }
  return result;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  int V, E;
  cin >> V >> E;
  FlowNetwork G(V);
  for(int i = 0; i < E; ++i) {
    Vertex u, v; Flow c;
    cin >> u >> v >> c;
    G.insert(Edge(u, v, c));
  }
  cout << G.maximum_flow(0, V - 1) << endl;
}

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

const int N = 100005;
const int M = 32;

#define int long long

int Pow[M] ,n , m , a[N] , b[N] , ans , valid[N]  , k , maxbit , Max , sum , vis[N] , dp[M] , can[M];

main(void) {
	memset(dp , -1 , sizeof(dp));
	scanf("%lld%lld",&n,&k);
	Pow[0] = 1;
	for(int i = 1;i <= 31;i ++) Pow[i] = Pow[i - 1] * 2;
	for(int i = 1;i <= 31;i ++) if(Pow[i] > k) {
		maxbit = i - 1; Max = Pow[i - 1];
		break;
	}
	for(int i = 1;i <= n;i ++) {
		scanf("%lld%lld",&a[i] , &b[i]);
		if(a[i] < Max) ans += b[i];
		valid[i] = 1; if(a[i] >= 2 * Max) valid[i] = 0;
	}
	
	for(int i = 1;i <= n;i ++) {
		int it = 1;
		for(int j = 0;j < 32;j ++) {
			if((!(k & (Pow[j])) && (a[i] & Pow[j]))) it = 0;
//			if(a[i] & Pow[j])
//			cerr<<(k & (Pow[j])) <<" "<<(a[i] & Pow[j])<<" "<<endl;
		}
//		cerr<<it<<endl;
		sum += it * b[i];
	}
	
	ans = max(ans ,sum);
	
	for(int i = maxbit - 1; i >= 0;i --) if(k & Pow[i + 1]) {
		int now = k | (Pow[i] * 2 - 1); now = now ^ Pow[i + 1];
		int that = 0;
		for(int j = 1;j <= n;j ++) {
			int it = 1;
			for(int p = 0;p < 32;p ++) if((!(now & Pow[p])) && (a[j] & Pow[p])) it = 0;
			that += b[j] * it;
		}
		ans = max(ans , that);
	}
	
	cout<<ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 10000000;

int main(){
    int n,T;
    cin >> n >> T;
    int cost[n],timee[n];
    for ( int i = 0;i < n;i++) cin >> cost[i] >> timee[i];

    int ans = INF;

     for ( int i = 0;i < n;i++) {
         if (timee[i] <= T) ans = min(ans,cost[i]);
     }
     if (ans == INF) cout << "TLE" << endl;
     else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

constexpr int X = 200, Y = X * 2 + 1;

int enc(int v, int t) {
    return v * Y + t;
}

constexpr int INF = 1 << 30;

void solve() {
    int n, m, x;
    std::cin >> n >> m >> x;

    std::vector<int> ts(n);
    for (auto& t : ts) std::cin >> t;

    int nn = n * Y;
    std::vector<std::vector<std::pair<int, int>>> graph(nn);
    while (m--) {
        int u, v, d;
        std::cin >> u >> v >> d;
        --u, --v;

        for (int i = 0; i < 2; ++i) {
            for (int t = 0; t < Y; ++t) {
                int nt = (t >= X ? std::max(X, t - d) : std::min(X, t + d));

                if (ts[v] == 1) {
                    graph[enc(u, t)].emplace_back(enc(v, nt), d);
                } else if (ts[v] == 0) {
                    if (nt > X) continue;
                    graph[enc(u, t)].emplace_back(enc(v, X - x), d);
                } else {
                    if (nt < X) continue;
                    graph[enc(u, t)].emplace_back(enc(v, X + x), d);
                }
            }

            std::swap(u, v);
        }
    }

    int r = enc(0, X - x);
    std::vector<int> dist(nn, INF);
    dist[r] = 0;

    MinHeap<std::pair<int, int>> que;
    que.emplace(0, r);

    while (!que.empty()) {
        int d, v;
        std::tie(d, v) = que.top();
        que.pop();
        if (dist[v] > d) continue;

        for (auto p : graph[v]) {
            int u, c;
            std::tie(u, c) = p;
            if (dist[u] <= dist[v] + c) continue;

            dist[u] = dist[v] + c;
            que.emplace(dist[u], u);
        }
    }

    int ans = INF;
    for (int t = 0; t < Y; ++t) {
        ans = std::min(ans, dist[enc(n - 1, t)]);
    }
    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



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

using namespace std;

const int Maxn = 5e3+7;

int n, k, maxl;
char minc = 'z';
string s, res;

inline void Ope(int p)
{
    int step = k, nowl = maxl;
    string S = s, U, T;
    if (step > 1 && p != n-1) {
        U = S;
        reverse(U.begin(), U.end());
        T = S+U;
        S = T.substr(n-p+nowl-1, n);
        --step;
    }
    for (int i = 1; i < step; ++i) {
        S = S.substr(nowl)+string(nowl, minc);
        nowl <<= 1;
        if (nowl >= n) {
            cout << string(n, minc) << endl;
            exit(0);
        }
    }
    // last step
    U = S;
    reverse(U.begin(), U.end());
    T = S+U;
    S = T.substr(n-nowl, n);
    res = min(res, S);
}

int main()
{
    cin >> n >> k >> s;
    res = s;
    for (char c : s) minc = min(minc, c);
    // special judge
    if (k >= 14) {
        cout << string(n, minc) << endl;
        return 0;
    }
    if (k == 1) {
        string S = s, U = s, T;
        reverse(U.begin(), U.end());
        T = S+U;
        for (int i = 1; i <= n; ++i) {
            if (T[i] == minc && T[i] != T[i-1]) {
                res = min(res, T.substr(i, n));
            }
        }
        cout << res << endl;
        return 0;
    }
    for (int i = 0, curl = 0; i < n; ++i) {
        if (s[i] == minc) {
            ++curl;
            maxl = max(maxl, curl);
        } else {
            curl = 0;
        }
    }
    for (int i = 0, curl = 0; i < n; ++i) {
        if (s[i] == minc) {
            if (++curl == maxl) {
                Ope(i);
            }
        } else {
            curl = 0;
        }
    }
    if (s[n-1] == minc) {
        int pp = n-1;
        maxl = 1;
        while (pp-1 >= 0 && s[pp-1] == minc) {
            ++maxl;
            --pp;
        }
        Ope(n-1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2
 
using namespace std;

int a[ 50 ];

int main() {
	int n, ans = 0;
	scanf( "%d", &n );
	for( int i = 0; i < n; ++i )
		scanf( "%d", &a[ i ] );
	for( int i = 0; i < n; ++i )
		for( int j = i + 1; j < n; ++j )
			ans += a[ i ] * a[ j ];
	printf( "%d", ans );
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _001_FindingMissingCards
{

    class Program
    {
        static void Main()
        {

            string givenWord = Console.ReadLine();
            int num = Convert.ToInt32(Console.ReadLine());
            

            for (int i = 0; i < num; i++)
            {
                string []inputWords = Console.ReadLine().Split(' ');
                string givenCommand = inputWords[0];


                if (givenCommand == "print")
                {
                    int a = Convert.ToInt32(inputWords[1]);
                    int b = Convert.ToInt32(inputWords[2]);

                    Console.WriteLine("{0}",
                        givenWord.Substring(a, b - a + 1));
                }
                else if (givenCommand == "reverse")
                {
                    int a = Convert.ToInt32(inputWords[1]);
                    int b = Convert.ToInt32(inputWords[2]);

                    char[] givenChars = givenWord.ToCharArray();
                    char[] answerChars  = new char[givenChars.Length];
                    for (int j = 0; j < givenChars.Length; j++)
                    {
                        answerChars[j] = givenChars[j];
                    }
                    for (int j = 0;
                        j < b - a + 1; j++)
                    {
                        answerChars[j + a] = givenChars[b - j];
                    }
                    givenWord = new string(answerChars);
                }
                else if (givenCommand == "replace")
                {
                    int a = Convert.ToInt32(inputWords[1]);
                    int b = Convert.ToInt32(inputWords[2]);

                    string answerWord = givenWord.Substring(0, a)
                        + Convert.ToString(inputWords[3])
                        + givenWord.Substring(b + 1);
                    givenWord = answerWord;
                }

                
            }
        }
    }
}

Measured memory_bytes: 9132
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
Node root;
Node t;
Node treeMinimum(Node x){
  while(x->l != NIL)
    x = x->l;
  return x;
}
 
Node treeMaximum(Node x){
  while(x->r != NIL)
    x = x->r;
  return x;
}
 
Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->r != NIL) return treeMinimum(x->r);
  y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    x = y->p;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y;
  Node x;
  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->l != NIL) x = y->l;
  else x = y->r;
  if(x != NIL) x->p = y->p;
  if(y->p == NIL) root = x;
  else if(y == y->p->l) y->p->l = x;
  else y->p->r = x;
  if(y != z) z->key = y->key;
  }
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else  x = x->r;   
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z; 
}
 
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}
void preorder(Node u){ 
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}
int main(){
  int n, i, x;
  char str[7];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", str);
    if ( str[0] == 'f' ){
      scanf("%d", &x);
      t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( str[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( str[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( str[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}
 

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
// #define PI 3.1415926535897932384626433832795
#define PI acos(-1.0)
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

// map<char, int> m;
// bool cmp(const pair< pair<int,int> , int>& a, const pair < pair<int,int> , int>& b) {
// 	return a.ff.ss < b.ff.ss;
// }
int mod=1e9+7;

int32_t main(void) {
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		a[i]--;
	}
	vi pos(n);
	for(int i = 0; i < n; i++)
		pos[a[i]]=i;
	int ans=0;
	// for(int i: pos) cout<<i<<" ";
	// cout<<endl;
	set<int> s; s.insert(pos[n-1]);
	for(int i = n-2; i >= 0; i--) {
		s.insert(pos[i]);
		auto it = s.find(pos[i]);
		auto it1 = it;
		int s1,s2,e1,e2;
		if(it==s.begin()) {
			s1=(*it)+1; s2=0;
		} else {
			it--;
			if(it==s.begin()) {
				s1=pos[i]-(*it);
				s2=(*it)+1;
			} else {
				s1=pos[i]-(*it);
				int ind = *it;
				it--;
				s2 = ind-(*it);
			}
		}
		auto last = s.end();
		last--;
		if(it1==last) {
			e1=n-(*it1); e2=0;
		} else {
			it1++;
			if(it1==last) {
				e1=(*it1)-pos[i];
				e2=n-(*it1);
			} else {
				e1=(*it1)-pos[i];
				int ind = *it1;
				it1++;
				e2 = (*it1)-ind;
			}
		}
		// cout<<s1<<" "<<s2<<" "<<e1<<" "<<e2<<endl;

		ans += (s1*e2+s2*e1)*(i+1);
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;cin>>n>>d;
    int ans=0;
    double x,y;
    double a;
    for(int i=0;i<n;++i){
        cin>>x>>y;
        x*=x;
        y*=y;
        a=x+y;
        a=sqrt(a);
        if(a<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3860
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))

int compare_long(const void *a, const void *b)
{
	long *A = (long *)a;
	long *B = (long *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


int compare_long_inv(const void *a, const void *b)
{
	long *A = (long *)a;
	long *B = (long *)b;
	if (*B < *A) return 1;
	if (*B > *A) return -1;
	return 0;
}

int main(void)
{
	//変数の宣言
	int n;
	static llong int a[200010];
	static llong int b[200010];
	static llong int amod[200010];
	static llong int bmod[200010];
	static llong int ruijou;
	int sec1,sec2,sec3;
	int xor[30];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	long long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	
	for(i=0;i<n;i++){
		scanf("%lld",&b[i]);
	}
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<=28;i++){//範囲あってる？？
		if(i==0){
			ruijou=1;
		}else{
			ruijou=ruijou*2;
		}
		for(j=0;j<n;j++){
			amod[j]=a[j]%(ruijou*2);
			bmod[j]=b[j]%(ruijou*2);
		}
		
//		printf("i=%d\n",i);
//		for(j=0;j<n;j++){
//			printf("amod[%d]=%d\n",j,amod[j]);
//			printf("bmod[%d]=%d\n",j,bmod[j]);
//		}
		
		qsort(amod, n, sizeof(llong), compare_long);
		qsort(bmod, n, sizeof(llong), compare_long_inv);
		
//		for(j=0;j<n;j++){
//			printf("amod[%d]=%d\n",j,amod[j]);
//			printf("bmod[%d]=%d\n",j,bmod[j]);
//		}
		
		sec1=0;
		sec2=0;
		sec3=0;
		temp=0;
		for(j=0;j<n;j++){
			while(amod[j]+bmod[sec1]<ruijou&&sec1<n){
				sec1++;
			}
			sec2=max(sec1,sec2);
//			printf("amod[%d]=%d,bmod[%d]=%d\n",j,amod[j],sec2,bmod[sec2]);
			while(amod[j]+bmod[sec2]<2*ruijou&&sec2<n){
//				printf("amod[%d]=%d,bmod[%d]=%d\n",j,amod[j],sec2,bmod[sec2]);
				sec2++;
			}
//			printf("amod[%d]=%d,bmod[%d]=%d\n",j,amod[j],sec2,bmod[sec2]);
			
			sec3=max(sec2,sec3);
			while(amod[j]+bmod[sec3]<3*ruijou&&sec3<n){
				sec3++;
			}
//			printf("i=%d,j=%d,sec1=%d,sec2=%d,sec3=%d\n",i,j,sec1,sec2,sec3);
			temp=temp+n-sec3+sec2-sec1;
		}
		
		xor[i]=temp%2;
	}
	
	ans=0;
	for(i=28;i>=0;i--){
//		printf("xor[%d]=%d\n",i,xor[i]);
		ans=ans*2;
		ans=ans+xor[i];
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%lld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 8036
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  ll n;
  cin>>n;
  v(ll) a(n),b(n),c(n);
  ll ans=0;
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(all(a)); sort(all(b)); sort(all(c));
  rep(i,n){
    ll s= lower_bound(all(a),b[i])-a.begin();
    ll g= c.end()-upper_bound(all(c),b[i]);
    ans+=s*g;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5608
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
    int a, b, c;
    int mod[100];
    scanf("%d%d%d", &a, &b, &c);
    int inita = a;
    memset(mod, 0, 100 * sizeof(int));
    int flag = 0;
    while (mod[a%b] == 0) {
        //printf("%d ", a%b);
        mod[a%b] = 1;
        if (a%b == c) {
            flag = 1;
            break;
        }
        a += inita;
    }
   
    if (flag)
        printf("YES");
    else
        printf("NO");
}


Measured memory_bytes: 128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    T=ST()
    if(T[:len(S)]==S):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 78016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) begin(v), end(v)
bool mas[444][444];

void color(int x, int y, int gx, int gy)
{
  for(int i = x; i < gx; i++) {
    for(int j = y; j < gy; j++) mas[i][j] = true;
  }  
}

int main(){
  int n;
  int t = 0;
  while(cin >> n, n) {
    t++;
    memset(mas, false, sizeof(mas));
    vector<double> xx, yy;
    vector<double> X, Y;
    rep(i, n) {
      double x, y, r;
      cin >> x >> y >> r;
      xx.push_back(x - r);
      xx.push_back(x + r);
      yy.push_back(y - r);
      yy.push_back(y + r);
      X.push_back(x - r);
      X.push_back(x + r);
      Y.push_back(y - r);
      Y.push_back(y + r);
    }
    sort(all(X)); 
    sort(all(Y));
    X.erase(unique(all(X)), X.end());
    Y.erase(unique(all(Y)), Y.end());
    for(int i = 0; i < (int)xx.size(); i+=2) {
      xx[i] = find(all(X), xx[i]) - begin(X);
      yy[i] = find(all(Y), yy[i]) - begin(Y);
      xx[i+1] = find(all(X), xx[i+1]) - begin(X);
      yy[i+1] = find(all(Y), yy[i+1]) - begin(Y);
      color(xx[i], yy[i], xx[i+1], yy[i+1]);
    }
    /*//
    rep(i, Y.size()) {
      rep(j, X.size()) cout << (int)mas[j][i];
      cout << endl;
    }
    //*/
    double ans = 0;
    rep(i, X.size()-1) rep(j, Y.size()-1) {
      if(!mas[i][j]) continue;
      ans += (X[i+1]-X[i]) * (Y[j+1]-Y[j]);
      //cout << X[i+1] << " " << X[i] <<  " " << Y[j+1] << " " << Y[j] << endl;
    }
    printf("%d %.2f\n", t, ans);
  }
  
  return 0;
}

Measured memory_bytes: 3324
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
int ara[50001];

int main()
{

    ios_base::sync_with_stdio(0);

    ll x,hp=0;
    cin>>x;
    while(1)
    {
        if(x>=500)
        {
            hp+=(x/500)*1000;
            x-=(x/500)*500;
        }
        if(x>=100&&x<500)
        {
            hp+=(x/100)*100;

            x-=(x/100)*100;
        }
        if(x>=50&&x<100)
        {
            hp+=(x/50)*50;
            x-=(x/50)*50;

        }
        if(x>=10&&x<50)
        {
            hp+=(x/10)*10;
            x-=(x/10)*10;
        }
        if(x>=5&&x<10)
        {
            hp+=(x/5)*5;
            x-=(x/5)*5;
        }
        if(x<5) break;
    }
    cout<<hp<<endl;
}






Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
       // int L = int.Parse(input[1]);
        string[] s = new string[N];
        for(int i = 0;i < N;i++){
            s[i] = Console.ReadLine();
        }
        Array.Sort(s);
        string ans = String.Join("",s);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13476
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

const long long MAXN = 300005;
long long N, n, a[MAXN], cnt[MAXN];
long long sum[MAXN];
long long ans[MAXN];
bool check(long long k, long long x) {
	long long pos = upper_bound(a + 1, a + n + 1, x) - a;
	return sum[pos - 1] + (n - pos + 1) * x >= k * x;
}

int main() {
	cin >> N;
	for(long long i = 1, x; i <= N; i++)
        cin >> x, cnt[x]++;
	for(long long i = 1; i <= N; i++)
        if(cnt[i])
            a[++n] = cnt[i];
	sort(a + 1, a + n + 1);
	for(long long i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + a[i];
	long long now = 0;
	for(long long k = n; k >= 1; k--) {
		while(now < N && check(k, now + 1))
            now++;
        ans[k] = now;
	}
	for(long long i = 1; i <= N; i++)
        cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 10112
let id x = x

let () =
  let n = Scanf.scanf "%d\n" id in
  let ar = Array.init n (fun _ -> Scanf.scanf "%d " id) in
  let sum = Array.fold_left ( + ) 0 ar in
  let m = Scanf.scanf "%d\n" id in
  let b = Buffer.create (2 * m) in
  for i = 0 to m - 1 do
    let ans = Scanf.scanf "%d %d\n" (fun p x -> sum - (ar.(p - 1) - x)) in
    string_of_int ans ^ "\n" |> Buffer.add_string b
  done ;
  print_string (Buffer.contents b)

Measured memory_bytes: 512
//use proconio::{input, fastout};
use proconio::input;
use std::collections::BTreeMap;

const M: u64 = 1_000_000_007;

//#[fastout]
fn main() {
    input! {
        n: usize,
        d: [(i64, i64); n],
    }

    let mut z = 0;
    let mut t = BTreeMap::new();
    for e in d {
        if e.0 == 0 && e.1 == 0 {
            z += 1;
        } else if e.0 == 0 {
            let e = t.entry((0, 1)).or_insert(0);
            *e += 1;
            if *e >= M {
                *e -= M;
            }
        } else if e.1 == 0 {
            let e = t.entry((1, 0)).or_insert(0);
            *e += 1;
            if *e >= M {
                *e -= M;
            }
        } else {
            let g = num::integer::gcd(e.0.abs(), e.1.abs());
            let e = if e.0 < 0 {
                (-e.0, -e.1)
            } else {
                e
            };
            let e = (e.0 / g, e.1 / g);
            let e = t.entry((e.0, e.1)).or_insert(0);
            *e += 1;
            if *e >= M {
                *e -= M;
            }
        }
    }
    z %= M;

    let mut ans = 1;
    while let Some((&k, &c)) = t.iter().next() {
        t.remove(&k);
        let p = if k.1 < 0 {
            (-k.1, k.0)
        } else {
            (k.1, -k.0)
        };

        let c2 = modpow(2, c);
        if let Some(invc) = t.remove(&p) {
            let i2 = modpow(2, invc);
            ans = ans * (c2 + i2 + M - 1) % M;
        } else {
            ans = ans * c2 % M;
        }
    }
    ans = (ans + z + M - 1) % M;
    println!("{}", ans);
}

fn modpow(x: u64, y: u64) -> u64 {
    let mut result = 1;
    let mut a = x;
    let mut b = y;
    while b > 0 {
        if b % 2 == 1 {
            result = result * a % M;
        }
        a = a * a % M;
        b /= 2;
    }
    result
}


Measured memory_bytes: 20576
#include <iostream>

using namespace std;

int main() {
	long a, b, c, d;
	cin >> a >> b >> c >> d;
	long one = a * c;
	long two = a * d;
	long three = b * c;
	long four = b * d;
	cout << max(max(max(one, two), three), four);
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
using namespace std;
 
bool isLYear(int y){
    if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)){
        return true;
    }
    return false;
}
 
int MaDays(int m, int y){
    if (m == 2){
        if (isLYear(y))
            return 29;
        else
            return 28;
    }
    else if (m == 4 || m == 6 || m == 9 || m == 11){
        return 30;
    }
    return 31;
}
 
unsigned long int getDay(int y, int m, int d){
    unsigned long int ans = 0;
    if (y == 2012 && m == 12){
        ans = d - 21;
    }
    else{
        ans = 10;
 
        for (int i = 2013; i<y; i++){
            if (isLYear(i)){
                ans += 366;
            }
            else{
                ans += 365;
            }
        }
 
        for (int i = 1; i<m; i++){
            ans += MaDays(i, y);
        }
 
        ans += d ;
    }
    return ans;
}
 
void ADtoM(int n[]){
    unsigned long int DA = getDay(n[0], n[1], n[2]);
 
    DA %= 1872000;
    int ki = DA % 20;
    DA /= 20;
    int w = DA % 18;
    DA /= 18;
    int t = DA % 20;
    DA /= 20;
    int ka = DA % 20;
    DA /= 20;
    int b = DA % 20;
    DA /= 20;
 
    cout << b << '.' << ka << '.' << t << '.' << w << '.' << ki << endl;
}
 
void MtoAD(int n[]){
    int DM = (n[0] * 144000) + (n[1] * 7200) + (n[2] * 360) + (n[3] * 20) + n[4];
    int y = 2012, m = 12, d = 21;
    if (DM <= 10){
        d += DM;
        DM = 0;
    }
    else{
        DM -= 11;
        y++;
        m = d = 1;
    }
    while ((isLYear(y)) ? DM >= 366 : DM >= 365){
        if (DM >= 366 && isLYear(y)){
            DM -= 366;
            y++;
        }
        else if (DM >= 365 && !isLYear(y)){
            DM -= 365;
            y++;
        }
    }
    while (DM >= MaDays(m, y) && m != 12){
        DM -= MaDays(m, y);
        m++;
    }
    cout << y << '.' << m << '.' << d + DM << endl;
}
 
int main(){
    char c[32];
    while (cin >> c){
        if (c[0] == '#'){
            break;
        }
        int i = 0, cnt = 0;
        while (c[i] != '\0')
        {
            if (c[i] == '.'){
                cnt++;
            }
            i++;
        }
        if (cnt == 2){
            int na[3];
            sscanf(c, "%lld.%lld.%lld", &na[0], &na[1], &na[2]);
            ADtoM(na);
        }
        else if (cnt == 4){
            int nm[5];
            sscanf(c, "%lld.%lld.%lld.%lld.%lld", &nm[0], &nm[1], &nm[2], &nm[3], &nm[4]);
            MtoAD(nm);
        }
    }
    return 0;
}


Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::vector<int > p(N);
  for (int i=0; i<N; i++){
    scanf("%d",&p[i]);
  }
  int min = N+5;
  int ans = 0;
  for (int i=0; i<N; i++){
    if (p[i]<min){
      ans++;
      min=p[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1024
N, A = map(int, input().split())
x = list(map(int, input().split()))

X = max(x)
if X < A:
    X = A

def check(j, k, s):
    if dp[j][k][s] != -1:
        return dp[j][k][s]
    if j == 0 and k == 0 and s == 0:
        dp[j][k][s] = 1
        return 1
    if j >= 1 and s < x[j-1]:
        a = check(j-1, k ,s)
        dp[j][k][s] = a
        return a
    if j >= 1 and k >= 1 and s >= x[j-1]:
        a = check(j-1, k, s) + check(j-1, k-1, s-x[j-1])
        dp[j][k][s] = a
        return a
    dp[j][k][s] = 0
    return 0
        
dp = [[[-1] * (N*X+1) for _ in range(N+1)] for _ in range(N + 1)]
# dp = np.array(dp)
# print (dp)
# for j in range(N+1):
#     for k in range(N+1):
#         for s in range(N*X + 1):
#             print (j, k, s)
#             dp[j][k][s] = check(j, k, s)

ans = 0
for k in range(1, N+1):
    ans += check(N, k, k * A)
    # ans += dp[N][k][k * A]

print (ans)

Measured memory_bytes: 103644
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 100005
#define M 4000005
#define mod 1000000007
int n, m, k, a[N], ans;
int main ()
{
    scanf("%d %d", &n, &k);
    fo (i, 1, n)
        scanf("%d", &a[i]);
    std::sort(a + 1, a + n + 1);
    ans = inf;
    fo (i, 1, n - k + 1)
        ans = std::min(ans, a[i + k - 1] - a[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	
	int a,b,i,j=0;
	
	scanf("%d %d",&a,&b);
	
	a = b - a;
	
	for(i=0;i<=a;i++)j=j+i;
	
	printf("%d\n",j-b);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[] a = sc.next().toCharArray();
      char[] b = sc.next().toCharArray();
      char[] c = sc.next().toCharArray();
      int cnt = 0;
      for(int i = 0;i < n;i++){
        if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])cnt+=2;
        else if(a[i]==b[i]&&b[i]==c[i]){}
        else cnt++;
      }
      System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cstdint>
#include <unordered_map>
#include <algorithm>

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
    constexpr u64& value() noexcept { return a; }
    constexpr const u64& value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint& operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint& operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint& operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint& operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using Mint = modint<(int)1e9 + 7>;
using i64 = std::int64_t;

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

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

    std::vector<int> a(n);
    for (auto&& e : a)
        std::cin >> e;

    std::unordered_map<int, int> ps;
    for (auto&& e : a) {
        bool isPrime = true;
int x=e;
        for (int  i = 2; i * i <= e; ++i) {
            int cnt = 0;

            while (x % i == 0) {
                isPrime = false;
                x /= i;
                ++cnt;
            }

            if (cnt != 0)
                ps[i] = std::max(cnt, ps[i]);
        }

        
            ps[x] = std::max(ps[x], 1);
    }

    Mint lcm = 1;
    for (auto&& p : ps)
        for (int i = 0; i < p.second; ++i)
            lcm *= p.first;

    Mint ans = 0;
    for (auto&& e : a)
        ans += lcm / e;

    std::cout << ans.a << std::endl;
}


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

using ll=long long;
int n;
vector<ll> ans;
 
int SIZE;
ll calc(ll x,ll y,ll z,ll k){
    ll res=0;
    auto sum=[&](ll a,ll b,ll l,ll r){
        l=max(l,0LL);
        r=min(r,x+1);
        if(a==1) l=max(l,-b);
        if(a==-1) r=min(r,b+1);
        if(l>=r) return 0LL;
        return (l*a+b+a*(r-1)+b)*(r-l)/2;
    };
    res+=sum(1,y+z+1-k,0,k-z);
    res+=sum(0,y+1,k-z,k-y);
    res+=sum(-1,k+1,k-y,x+1);
    return res;
}
void solve(int x,int y,int z,int buf){
    if(y>z) swap(y,z);
    for(int k=0;k<SIZE;k++){
        ans[(k+buf)%n]+=calc(x,y,z,k);
    }
}
int main(){
    int x,y,z,a,b,c;
    cin>>x>>y>>z>>a>>b>>c>>n;
    x--,y--,z--;
    SIZE=x+y+z+1;
    ans.resize(n);

    vector<int> xs={a,x-a-1};
    vector<int> ys={b,y-b-1};
    vector<int> zs={c,z-c-1};
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                if(xs[i]<0) continue;
                if(ys[j]<0) continue;
                if(zs[k]<0) continue;
                solve(xs[i],ys[j],zs[k],i+j+k);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<(i+1==n ? "\n" : " ");
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	int a[100005];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int counter[100005];
	for(int i=0;i<100005;i++){
		counter[i] = 0;
	}
	int b[100005];
	int c[100005];
	for(int i=0;i<n;i++){
		b[i] = a[i] + 1;
		c[i] = a[i] - 1;
		counter[a[i]]++;
		counter[b[i]]++;
		counter[c[i]]++;
	}
	int ans = 0;
	for(int i=0;i<100005;i++){
		if(ans<counter[i]){
			ans = counter[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut L = read![[i64]];
    L.sort();
    println!(
        "{}",
        if L[0..N - 1].iter().sum::<i64>() > L[N - 1] {
            "Yes"
        } else {
            "No"
        }
    )
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
if n % 2:exit(print("First"))
edges = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
def dfs(v, prev):
    res = sum(dfs(u, v) for u in edges[v] if u != prev)
    if res >= 2:exit(print("First"))
    return not res
print("First" if dfs(0, -float("inf")) else "Second")

Measured memory_bytes: 25868
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        if(h % 3 == 0 || w % 3 == 0){
            System.out.println(0);
            return;
        }
        long res = Math.min(h, w);
        if(w % 2 == 1){
            long diff = (3*w - 1) * (h/3 + 1) / 2 - h*(w-1)/2;
            res = Math.min(res, diff);
            diff = h*(w + 1) / 2 - (3*w + 1) * (h/ 3) / 2;
            res = Math.min(res, diff);
        }else{
            long diff = 3*w*(h / 3 + 1) / 2 - h*w/2;
            res = Math.min(res, diff);
            diff = w*h / 2 - 3*w*(h/3) / 2;
            res = Math.min(res, diff);
        }
        if(h % 2 == 1){
            long diff = (3*h - 1) * (w/3 + 1) / 2 - w*(h-1)/2;
            res = Math.min(res, diff);
            diff = w*(h+1) / 2 - (3*h + 1) * (w/3) / 2;
            res = Math.min(res, diff);
        }else{
            long diff = 3*h*(w/3 + 1) / 2 - w*h/2;
            res = Math.min(res, diff);
            diff = w*h / 2 - 3*h*(w/3) / 2;
            res = Math.min(res, diff);
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

string s[1024][3],ans[1024][3];
bool ck(string c1,string c2){
    bool flag=true;
    rep(i,8){
        if(c2[i]=='?') continue;
        if(c1[i]!=c2[i]){
            flag =false;break;
        } 
    }
    return flag;
}
int main(){
    int n,m; 
    while(cin>>n>>m,n||m){
        int cnt=0;
        rep(i,n) cin>>s[i][0]>>s[i][1]>>s[i][2];
        rep(i,m){
            string t1, t2,t3;
            cin>>t1>>t2>>t3;
            for(int j=n-1;j>=0;--j){
                if(ck(t1,s[j][1])&&ck(t2,s[j][2])){
                    if(s[j][0][0]=='p'){
                        ans[cnt][0]=t1,ans[cnt][1]=t2,ans[cnt][2]=t3;
                        ++cnt;
                    }
                    break;
                }
            }
        }
        cout<<cnt<<endl;
        rep(i,cnt) cout<<ans[i][0]<<' '<<ans[i][1]<<' '<<ans[i][2]<<endl;;
    }
    return 0;
}

Measured memory_bytes: 3360