akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = (int) 1e5;
int a[N], n, l;

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> l;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i + 1 < n; ++i) if (a[i] + a[i + 1] >= l) {
        cout << "Possible\n";
        for (int j = 1; j < i + 1; ++j) cout << j << '\n';
        for (int j = n - 1; j > i + 1; --j) cout << j << '\n';
        cout << i + 1 << '\n';
        return 0;
    }
    cout << "Impossible\n";
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vi p(n);

	rep(i, n) cin >> p[i];

	int cnt = 0;

	for (int i = 1; i < n; i++)
	{
		if (i + 1 >= n) break;

		if (p[i - 1] < p[i] && p[i] < p[i + 1]) cnt++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1]) cnt++;
	}

	ANS(cnt);
}

Measured memory_bytes: 256
#include <iostream>                                                
#include <vector>                                                  
#include <array>                                                   
#include <set>                                                     
#include <cmath>                                                   
#include <string>                                                  
#include <queue>                                                   
#include <list>                                                    
#include <stack>                                                   
#include <unordered_map>                                           
#include <algorithm>                                               
#include <numeric>                                                 
#include <functional>                                              
#include <iomanip> // std::std::setprecision(X)                    
#include <limits>  //std::numeric_limits<int>::max(), min()        
                                                                   
typedef long long ll;                                              
                                                                   
int main (void) {                                                  
  int N; std::cin >> N;                                            
  if ( N == 1 ) std::cout << "Hello World" << std::endl;           
  else {                                                           
    int A, B; std::cin >> A >> B;                                  
    std::cout << A+B << std::endl;                                 
  }                                                                
                                                                   
  return 0;                                                        
}                                                                  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define prin(ans) cout << ans << endl
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 105
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

ll N, M;
Map mp;
ll fact[100101];
ll rfact[100101];


ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

void pdiv(ll n) {
    ll cpy_n=n;
    for(ll i=2; i<=n; i++) {
        while(cpy_n%i==0) {
            mp[i]++;
            cpy_n/=i;
        }
        
        if(cpy_n==1) break;
    }
}


int main(void) {
    cin >> N >> M;
    pdiv(M);
    ll ans=1;
    ll i;
    
    fact[0]=rfact[0]=1;
    for(i=1; i<=100100; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ans*=fact[N+it->second-1]*rfact[N-1]%MOD*rfact[it->second]%MOD;
        ans%=MOD;
    }
    
    prin(ans);
}

Measured memory_bytes: 1792
from sys import stdin
A, B, C = [int(_) for _ in stdin.readline().rstrip().split()]
K = int(stdin.readline().rstrip())
for i in range(K):
    if not B > A:
        B *= 2
    elif not C > B:
        C *= 2
if A < B < C:
    print("Yes")
else:
    print("No")

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

int main() {
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a+3);
  int ans = 0;
  rep(i, 2) ans += abs(a[i+1] - a[i]);
  cout << ans << endl;
  return 0;
}

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

typedef pair<int, int> P;
int n, m, s, t;
vector<P> graph[100001];

vector<long long> dijkstra(int start, vector<int> costs) {
  priority_queue<P, vector<P>, greater<P> > que;
  vector<long long> d(n);
  for (int i=0; i<n; i++) d[i] = 1e14;

  d[start] = 0;
  que.push(P(0, start));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i=0; i<graph[v].size(); i++) {
      auto e = graph[v][i];
      if (d[e.first] > d[v] + costs[e.second]) {
        d[e.first] = d[v] + costs[e.second];
        que.push(P(d[e.first], e.first));
      }
    }
  }
  return d;
}
int main() {

  cin>>n>>m>>s>>t;
  --s;
  --t;
  vector<int> a(m), b(m);
  for (int i=0; i<m; i++) {
    int ui, vi;
    cin>>ui>>vi>>a[i]>>b[i];
    --ui;
    --vi;
    graph[ui].push_back(P(vi, i));
    graph[vi].push_back(P(ui, i));
  }
  vector<long long> d_yen = dijkstra(s, a);
  vector<long long> d_snk = dijkstra(t, b);

  vector<long long> ans;
  long long init = 1e15;
  ans.push_back(1e15 - d_yen[n-1] - d_snk[n-1]);
  for (int i=1; i<n; i++) {
    long long tmp = 1e15 - d_yen[n-i-1] - d_snk[n-i-1];
    ans.push_back(max(tmp, ans[i-1]));
  }
  reverse(ans.begin(), ans.end());
  for (auto a: ans) {
    cout<<a<<endl;
  }
}

Measured memory_bytes: 11436
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long h,a,p,i,n;
cin>>h>>n;
long long arr[n];
long long s=0;
for(i=0;i<n;i++)
{
	cin>>arr[i];
	s+=arr[i];
}
if(s>=h)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415926535

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    set<int> s;
    rep(i, n) {
        cin >> v[i];
        s.insert(v[i]);
    }
    if (v.size() == s.size())
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;

    }
    
    
}

Measured memory_bytes: 10368
N = int(input())

tmp_x = 0
tmp_y = 0
tmp_t = 0

for i in range(N):
  t, x, y = map(int, input().split())
  T = t - tmp_t
  d = (x - tmp_x) + (y - tmp_y)
  
  if T < d:
    print('No')
    break
  elif T % 2 == 0 and d % 2 == 1:
    print('No')
    break
  elif T % 2 == 1 and d % 2 == 0:
    print('No')
    break
    
else:
  print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
map<int,int>mp;
int n,ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		if(((it->first)-(it->second))<0)
		{
			ans+=(it->second)-(it->first);
		}
		else if(((it->first)-(it->second))>0)
		{
			ans+=it->second;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif

#define mod 1000000007
typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    
    
    if(sqrtl(c) - sqrtl(a) - sqrtl(b) > -0.0001 && (c-a-b)*(c-a-b) - 4*a*b > 0) Yes;
    else No;
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n,m,sum=0,k;
  float q;
  cin>>n>>m;
  int a[n][m];
 long int c=0;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      cin>>a[i][j];
  }
  for(int i=0;i<n-1;i++)
  {
    for(int k=1;k<n-i;k++)
    {sum=0;
    	for(int j=0;j<m;j++)
    	{
    		
      sum=sum+((a[i][j]-a[i+k][j])*(a[i][j]-a[i+k][j]));
    }
     q=sqrt(sum);
    
    if (floor(q)==ceil(q))
        c++;
    }
        
        }
        cout<<c;
        return 0;
        }

Measured memory_bytes: 256
N = [int(i) for i in input().split()][0]
W = [int(i) for i in input().split()]

out = max(W)
for i in range(N):
  s1 = 0
  s2 = 0
  for tmp in W[:i]:
    s1 = s1+tmp
  for tmp in W[i:]:
    s2 = s2 + tmp
  sa = abs(s2 - s1)
  if sa<out:
    out = sa
    
print(out)

Measured memory_bytes: 3064
using System;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static void Main()
    {
    lb:
        long hp = long.Parse(ReadLine());
        long count = 1;
        long result = 0;
        while (0 < hp)
        {
            result += count;
            hp /= 2;
            count *= 2;
        }
        WriteLine(result);
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int c, b, e;
    cin >> c >> b >> e;
    if (c == 0) {
      int ans = 1000000001;
      for (int j = b; j < e; j++) {
        ans = min(ans, v.at(j));
      }
      cout << ans << endl;
    }
    if (c == 1) {
      int ans = -1000000001;
      for (int j = b; j < e; j++) {
        ans = max(ans, v.at(j));
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

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

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  vector<pair<int,int>> resu;
  for(int i=0;i<55;i++){
    int n;cin>>n;
    if(n==0) break;
    vector<int> l;
    map<int,int> m;
    for(int j=0;j<n;j++){
      int p,a,b,all;
      cin>>p>>a>>b;
      all=a+b;
      l.pb(all);
      m[all]=p;
    }
    sort(all(l),greater<int>());
    pair<int,int> g;
    int num=l[0];
    g.first=m[num];
    g.second=num;
    resu.pb(g);
  }
  for(int i=0;i<resu.size();i++){
    cout<<resu[i].first<<" "<<resu[i].second<<endl;
  }
}


Measured memory_bytes: 3440
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

typedef long long int LLI;
int main(void) {
	int n;
	scanf("%d", &n);
	int max = -1000000, min = 1000000, an;
	LLI sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &an);
		if (an > max) {
			max = an;
		}
		if (min > an) {
			min = an;
		}
		sum += an;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli n, k;
    cin >> n >> k;
    lli a[100005];
    rep(i, n) cin >> a[i];
    lli g = a[0];
    rep(i, n) g = __gcd(a[i], g);
    lli h = *max_element(a, a + n);
    if (h < k) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if (g == 1) {
        if (h >= k) {
            cout << "POSSIBLE" << endl;
        } else {
            cout << "IMPOSSIBLE" << endl;
        }
    } else {
        if (k % g == 0) {
            cout << "POSSIBLE" << endl;
        } else {

            cout << "IMPOSSIBLE" << endl;
        }
    }
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	priority_queue<ll> q;
	
	ll N, M;
	
	cin >> N >> M;
	
	rep(i, N){
		ll x;
		cin >> x;
		q.push(x);
	}
	
	while(M > 0){
		ll x = q.top();
		q.pop();
		x /= 2;
		q.push(x);
		M--;
	}
	
	ll ans = 0;
	
	while(!q.empty()){
		ans += q.top();
		q.pop();
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1400
H, W, K = map(int, input().split())
C = [ input() for i in range(H)]
ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for m in range(H):
            for n in range(W):
                if ((i >> m) & 1): 
                    continue
                if ((j >> n) & 1): 
                    continue
                if C[m][n] == '#':
                    cnt += 1
        if cnt == K: 
            ans += 1
        
print(ans)


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		// solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;
	String[] pass;

	public void init() {
		N = 0;
		cnt = 0;
		pass = new String[2];
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 2;
	}

	public void readBody(String str) {
		pass[cnt] = str;
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
		for (int i = 0; i < pass[0].length(); i++) {
			System.out.print(pass[0].charAt(i));
			if (i < pass[1].length())
				System.out.print(pass[1].charAt(i));
		}
		System.out.println();
	}
}


Measured memory_bytes: 23252
import java.util.*;
//安定したソート
public class  Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        String a[] = new String[N];
        String b[] = new String[N]; 
        for(int i = 0; i < N; i++){
            a[i] = sc.next();
            b[i] = a[i];
        }
        BubbleSort(a);
        System.out.println("Stable");
        SelectionSort(b);
        System.out.println(Stable(a, b)? "Stable": "Not stable");
    }
    

    static void BubbleSort(String[] a){
        for (int i = 0; i <  a.length- 1; i++) {
            // 繰り返し最後から比べる
            for (int j = a.length - 1; j > i; j--) {
                if (a[j-1].charAt(1) > a[j].charAt(1)) {     
                    String tmp = a[j - 1];
                    a[j - 1] = a[j];
                    a[j] = tmp;
                }
            }
        }
        System.out.println(Arrays.toString(a) .replaceAll("[\\[\\],]", ""));
        // replaceAll() 、「文字列を正規表現で置換」対象の文字列.replaceAll("[正規表現]", "置換する文字列")
        // \ 　→　\\\  ,　*  →  \\*　, {} →  \\{\\} , [], → \\[\\],
    }
    


    static void SelectionSort(String[] b){
        for (int i = 0; i <  b.length - 1; i++) {
            int mini = i; 
            //最小値探す
            for (int j = i + 1; j < b.length; j++) {
                if (b[mini].charAt(1) > b[j].charAt(1)) {     
                    //miniに最小値の場所入れて置く
                   mini = j;
                }
            }    
            //最小値の場所が入れ替わっているとき
            if(mini != i){
                String e = b[mini];
                b[mini] = b[i];
                b[i] = e;
            }
        }
    System.out.println(Arrays.toString(b) .replaceAll("[\\[\\],]", ""));
    // replaceAll() 、「文字列を正規表現で置換」対象の文字列.replaceAll("[正規表現]", "置換する文字列")
    // \ 　→　\\\  ,　*  →  \\*　, {} →  \\{\\} , [], → \\[\\],
    }

    static boolean Stable(String[] a, String[] b){
        for(int i = 0; i < a.length; i++){
            if(!a[i].equals(b[i]))return false;
        }
        return true;
    }
    
}




Measured memory_bytes: 26404
#include<stdio.h>
#include<limits.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define TRUE 1
#define FALSE 0
/*void DFSVisit(int);
  void DFS(void);*/
void BFS(int);
int deQueue(void);
void enQueue(int);
int isEmpty(void);
int G[MAX][MAX];
int D[MAX];
int F[MAX];
int color[MAX];
int Q[MAX];
int n;
int time;
int head = 0, tail = 0;
main(){
  int i, j, m, k, value, start = 1;
  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){

      G[i][j] = 0;

    }
  }

  for(i = 1; i <= n; i++){

    scanf("%d %d", &k, &m);

    for(j = 1; j <= m; j++){

      scanf("%d",&value);

      G[i][value] = 1;
    }
  }
 
  BFS(start);

  for(i = 1; i <= n; i++)
    {
      if(D[i]==INT_MAX)D[i] = -1;
      printf("%d %d\n", i, D[i]);
    }

 return 0;

}




/*void DFS(void){
  int u;

  for( u = 1; u <= n; u++ ){

    color[u] = WHITE;

  }

  time = 0;

 for( u = 1; u <= n; u++ ){
   if( color[u] == WHITE )
     DFSVisit(u);

  }

}

void DFSVisit(int u){
  int v;

  color[u] = GRAY;

  time++;
 
  D[u] = time;

  for(v = 1; v <= n ; v++){

    if(G[u][v] == 1 && color[v] == WHITE)
      DFSVisit(v);
  }
  color[u] = BLACK;

  F[u] = ++time;
  }*/

void BFS(int start){
  int u, v;

  for(u = 2; u <= n; u++ ){

    color[u] =  WHITE;

    D[u] = INT_MAX;

  }

  color[start] = GRAY;

  D[start] = 0;

  enQueue(start);
  while(isEmpty() != FALSE){

    u = deQueue();

    for( v = 1; v <= n; v++ ){
      if(color[v] == WHITE && G[u][v] == 1){

	color[v] = GRAY;

	D[v] = D[u] + 1;

	enQueue(v);
      }
    }
  }
}

void enQueue(int x){

  Q[tail] = x;

    if(tail == 100)tail = 0;
    
    else tail ++; 

}

int deQueue(){

  int x;

  x = Q[head];

  if(head == 100)head = 0;

  else head++;

  return x;
}


int isEmpty(){
  if(tail == head)return FALSE;

  else return TRUE;
}

Measured memory_bytes: 1064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	int ans = 0;
	string S1, S2;
	cin >> S1;
	cin >> S2;
	rep(i, 3) {
		if (S1[i] == S2[i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void){
  int n, max=0, max_i=0, sum=0, sum2;
  scanf("%d", &n);
  int l[n];
  for(int i=0; i<n;i++){
    scanf("%d", &l[i]);
    if(l[i]>max){
      max = l[i];
      max_i = i;
    }
    sum+=l[i];
  }
  
  sum2 = sum - l[max_i];
  
  if(max<sum2){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;

int main() {
	cin >> N;
	bool f = false;
	rep(i, N) {
		int x;
		cin >> x;
		if (x & 1) f ^= 1;
	}
	puts(!f ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 500005
#define lson (now<<1)
#define rson ((now<<1)|1)
typedef long long ll;
using namespace std;
int n,m,k;
ll a[maxn],b[maxn];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),a[i]+=a[i-1];
	for(int i=1;i<=m;i++)
		scanf("%lld",&b[i]),b[i]+=b[i-1];
	int nr=n,ans=0;
	for(int i=1;i<=m;i++)
	{
		while(a[nr]+b[i]>1ll*k && nr>0)
			nr--;
		if(a[nr]+b[i]<=1ll*k)
			ans=max(ans,nr+i);
	}
	
	nr=m;
	for(int i=1;i<=n;i++)
	{
		while(b[nr]+a[i]>1ll*k && nr>0)
			nr--;
		if(b[nr]+a[i]<=1ll*k)
			ans=max(ans,nr+i);
	}
	printf("%d\n",ans);
	
}

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


void solve(std::string S){
  long long N = S.size();
  for(long long i = 0; i < N; i++){
    cout << "x";
  }
  cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


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

#define MOD  1000000007

int main() {
    int N, M; cin >> N >> M;
    if (abs(N - M) >= 2) {
        cout << 0 << endl;
    } else {
        long long n = 1, m = 1;
        rep(i, 1, N + 1) {
            n *= i;
            n %= MOD;
        }
        rep(i, 1, M + 1) {
            m *= i;
            m %= MOD;
        }
        if (N == M) {
            cout << (2 * n * m) % MOD << endl;
        } else {
            cout << (n * m) % MOD << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int numCount;
		List<Integer> lists = new ArrayList<Integer>();

		boolean okFlg = false;

		numCount = scan.nextInt();

		for (int i = 0; i < numCount; i++) {
			lists.add(scan.nextInt());
		}

		Optional<Integer> item = lists.stream().filter(num -> num % 2 == 0)
				.filter(num -> num % 3 != 0 && num % 5 != 0)
				.findFirst();

		if (item.isPresent()) {
			System.out.println("DENIED");
		} else {
			System.out.println("APPROVED");
		}

		// APPROVED を、しないならば DENIED を出力
	}

}

Measured memory_bytes: 28496
n = int(input())
dp = [[0] * 3 for i in range(n + 1)]
a, b, c = [], [], []
for i in range(n):
    a_, b_, c_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
    c.append(c_)
for i in range(1, n + 1):
    dp[i][0] = max(dp[i - 1][1] + a[i - 1], dp[i - 1][2] + a[i - 1])
    dp[i][1] = max(dp[i - 1][0] + b[i - 1], dp[i - 1][2] + b[i - 1])
    dp[i][2] = max(dp[i - 1][0] + c[i - 1], dp[i - 1][1] + c[i - 1])
print(max(dp[n][0], dp[n][1], dp[n][2]))

Measured memory_bytes: 40616
#include<cstdio>
using namespace std;

void b_sort(int *a,int N);

int main(){
	int a[100];
	int N;
	scanf("%d",&N);
	for(int i = 0; i < N;i++){
		scanf("%d",&a[i]);
	}
	
	b_sort(a,N);	
}

void b_sort(int *a,int N){
	int j = N-1;
	int t;
	int count = 0;
	
	while(1){
		for(int i = 0;i < j;i++){
			if(a[i]  > a[i+1]){
				t = a[i];
				a[i] = a[i+1];
				a[i+1] = t;
				count++;
			}
		}
		if(j != 0) j--;
		if(j == 0) {
			break;
		}
	}
	for(int i = 0;i < N;i++){
		printf("%d",a[i]);
		if(i != N-1){
			 printf(" ");
			}else{
				printf("\n");
			}
	}
	printf("%d\n",count);
}
	

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

int calc(){
	
	return 0;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a * b < c)cout << a*b << endl;
	else cout << c << endl;
	
	return 0;
}

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

int main() {
  string n;
  char c;
  cin >> n;
  int count=0;
  string ans="No";
  c=n[0];
  for (int i=1;i<4;i++) {
    if (c == n[i]){
      count++;
      if (count==2) {
        ans="Yes";
      }
    } else {
      count = 0;
      c=n[i];
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    int n;
    cin>>n;
    int p[n];
    rep(i,n) cin>>p[i];
    int count=1;
    int MIN=p[0];
    for(int i=1;i<n;i++){
        bool flag=true;
        if(MIN>p[i]) {
            count++;
            MIN=p[i];
            //cout<<i+1<<endl;
        }
    }
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

//ABC
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (b == "+") {
		ll num1 = stoi(a);
		ll num2 = stoi(c);
		cout << num1 + num2 << endl;
	}
	else {
		ll num1 = stoi(a);
		ll num2 = stoi(c);
		cout << num1 - num2 << endl;
	}
	/*int n, m, time = 0, a, b;
	cin >> n;
	vector<int>t(n);
	for (int i = 0;i < n;i++) {
		cin >> t[i];
		time += t[i];
	}
	cin >> m;
	vector<int>ans(m);
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		ans[i] = time - t[a - 1] + b;
	}
	for (int i = 0;i < m;i++)cout << ans[i] << endl;*/
	/*ll n, sum1 = 0, sum2 = 0;
	cin >> n;
	vector<int>a(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i];
		sum2 += a[i];
	}
	ll ans = 10000000000;
	for (ll i = 0;i < n-1;i++) {
		sum1 += a[i];
		sum2 -= a[i];
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;*/
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <tuple>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    tuple<int, int, int> data[M];
    // (Y_i, P_i, i)の配列

    for (int i = 0; i < M; ++i) {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    // tupleをソートするときは第一要素がkeyとなる
    sort(data, data + M);

    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0);
    // 各県について、今属している市の数

    pair<int, int> id[M];
    // 各市の(属する県、県の中で誕生した順番)

    for (int i = 0; i < M; ++i) {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i) {
        // setwで文字数、setfillで埋める文字を指定
        // iomanipをincludeする必要があるので注意
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3840
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print("No")
elif S[0] == S[1] and S[2] == S[3]:
  print("Yes")
elif S[0] == S[2] and S[1] == S[3]:
  print("Yes")
elif S[0] == S[3] and S[1] == S[2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 61936
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int draw = 0;
    rep(i,h){
        rep(j,w){
            if(j<a)cout << draw;
            else cout << int(draw^1);
        }
        cout << endl;
        if(b!=0 && i+1==b)draw^=1;
    }
    return 0;
}

Measured memory_bytes: 1280
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2/16/2019, 8:51:35 PM
# Powered by Visual Studio Code
#

a, b = gets.chomp.split(" ").map{|i| i.to_i}
if b % a == 0
  puts a + b
else
  puts b - a
end

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
  return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '{';
  for (auto it = c.begin(); it != c.end();)
    o << *it << (++it != c.end() ? ", " : "}");
  return o;
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}


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

    vi h(n);
    F0R(i, n) cin >> h[i];

    vector<ll> dp(n + 1, 1e18);
    dp[0] = 0;
    F0R(i, n - 1) {
        ckmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        ckmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n - 1] << endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
const int N = 4001;
const int M = 1001;

int dp[5][N];

int main(void){
    rep(i, 5) fill(dp[i], dp[i] + N, 0);
    dp[0][0] = 1;

    COUNT(i, 4) rep(j, N) if(dp[i - 1][j]) rep(k, M) dp[i][j + k] += dp[i - 1][j];

    for(int n; cin >> n; cout << dp[4][n] << endl);

    return 0;
}

Measured memory_bytes: 1240
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

tiji = abs(W-V)
kyori = abs(A-B)

migiiku = False
tukamae = False
if B>A:
    migiiku=True

if W>=V and A!=B:
    print('NO')
elif T*tiji < kyori:
    print('NO')
else:
    for i in range(1,T+1):
        if migiiku:
            A +=V
            B +=W
        else:
            A -= V
            B -= W
        
        if A==B:
            tukamae = True
            break
    
    if tukamae:
        print('YES')
    else:
        print('YES')

Measured memory_bytes: 63116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=ll(1e9+7);

int n,m;
int a[maxn];
string s;

int main()
{
	IOS;
   cin>>n;
   int x,y;
   cin>>x>>y;
   if(abs(x-y)%2)
      cout<<"Borys\n";
   else
      cout<<"Alice\n";

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = Hash.new(0)
p = 34
n.times do |i|
    b[a[i]] += 1
end
c = b.keys.sort.reverse
ans = 0
c.each do |i|
    while i*2 < 1 << p
        p -= 1
    end
    if b[i] > 0
        if i*2 == (1 << p)
            ans += b[i]/2
        else
            m = (b[i] < b[(1 << p)-i] ? b[i] : b[(1 << p)-i])
            ans += m
            b[(1 << p)-i] -= m
        end
    end
end
p ans

Measured memory_bytes: 46572
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

res = 0
for j in B:
    i = bisect.bisect_left(A, j)
    k = bisect.bisect_right(C, j)
    k = len(C) - k
    res += i * k

print(res)


Measured memory_bytes: 105572
#include <stdio.h>
#include <algorithm>

using namespace std;

const long long mod= 998244353 ;

struct point{
    int x,y;
}p[200001];
int n;int y_list[200001];
bool cmp(point a,point b){return a.x<b.x;}
int fin(int tmp){
    int ll=1,rr=n;
    while (ll<=rr){
        int mid=(ll+rr)/2;
        if (y_list[mid]==tmp) return mid;
        if (y_list[mid]>tmp) rr=mid-1;
        else ll=mid+1;
    }
}
int pre1[200001],las1[200001],pre2[200001],las2[200001];
int num[800020];

int build(int i,int l,int r){
    if (l==r){
        num[i]=0;return 0;
    }
    build(i*2,l,(l+r)/2);build(i*2+1,(l+r)/2+1,r);
    num[i]=0;
}
int query(int i,int l,int r,int ql,int qr){
    if (l>=ql && r<=qr){
        return num[i];
    }
    if (qr<=(l+r)/2)
        return query(i*2,l,(l+r)/2,ql,qr);
    if (ql>(l+r)/2)
        return query(i*2+1,(l+r)/2+1,r,ql,qr);
    return query(i*2,l,(l+r)/2,ql,(l+r)/2)+query(i*2+1,(l+r)/2+1,r,(l+r)/2+1,qr);
}
int addt(int i,int l,int r,int tmp){
    if (l==r) {
        num[i]++;return 0;
    }
    if (tmp>(l+r)/2) addt(i*2+1,(l+r)/2+1,r,tmp);
    else addt(i*2,l,(l+r)/2,tmp);
    num[i]=num[i*2]+num[i*2+1];
}

long long pow(long long base,long long tmp){
    long long t_ans=1;
    while (tmp){
        if (tmp%2) t_ans*=base;
        t_ans%=mod;
        base*=base;base%=mod;
        tmp/=2;
    }
    t_ans-=1;
    return t_ans;
}
long long check(long long ans){
    while (ans<0) ans+=mod;
    ans%=mod;return ans;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%d%d",&p[i].x,&p[i].y);
    sort(p+1,p+n+1,cmp);


    for (int i=1;i<=n;++i) y_list[i]=p[i].y;
    sort(y_list+1,y_list+n+1);

    //for (int i=1;i<=n;++i) printf("%d ",y_list[i]);

    build(1,1,n);
    for (int i=1;i<=n;++i)
    {
        int tmp=fin(p[i].y);
        pre1[i]= query(1,1,n,1,tmp);
        pre2[i]= query(1,1,n,tmp,n);
        addt(1,1,n,tmp);
        //printf("%d %d\n",tmp,pre[i]);
    }
    build(1,1,n);
    for (int i=n;i>0;--i)
    {
        int tmp=fin(p[i].y);
        las1[i]=query(1,1,n,tmp,n);
        las2[i]=query(1,1,n,1,tmp);
        addt(1,1,n,tmp);
    }
    long long ans=1;
    for (int i=0;i<n;++i) ans= ans*2 % mod;
    ans-=1;ans*=n;ans%=mod;
    for (int i=1;i<=n;++i){
            //printf("%d %d %d %d\n",pre1[i],las1[i],pre2[i],las2[i]);
        ans+=pow(2,pre1[i]);ans=check(ans);ans+=pow(2,pre2[i]);ans=check(ans);
        ans+=pow(2,las1[i]);ans=check(ans);ans+=pow(2,las2[i]);ans=check(ans);
        ans-=pow(2,pre1[i]+pre2[i]);ans=check(ans);ans-=pow(2,las1[i]+las2[i]);ans=check(ans);
        ans-=pow(2,pre2[i]+las1[i]);ans=check(ans);ans-=pow(2,pre1[i]+las2[i]);ans=check(ans);
    }
    printf("%lld\n",ans);



}


Measured memory_bytes: 8704
import itertools

N = int(input())
XY = []

zerotoN = ""
for i in range(0,N):
    zerotoN += str(i)
keiro_list = list(itertools.permutations(zerotoN))

for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x,y))

all_sum = 0

for keiro in keiro_list:
    for i in range(N-1):
        x1 = XY[int(keiro[i])][0]
        y1 = XY[int(keiro[i])][1]
        x2 = XY[int(keiro[i+1])][0]
        y2 = XY[int(keiro[i+1])][1]
        all_sum += ((x1-x2)**2 + (y1-y2)**2)**0.5

keiro_num = len(keiro_list)
print(all_sum/keiro_num)


Measured memory_bytes: 8052
# 重複順列　19C10
from itertools import combinations_with_replacement as cw

n,m,q = map(int, input().split())
a_candidates = cw([i+1 for i in range(m)],n)
fs = [list(map(int, input().split())) for i in range(q)]

def calc(fs,As):
    cnt = 0
    for a,b,c,d in fs:
        a -= 1
        b -= 1
        if As[b]-As[a] == c: cnt += d
    return cnt

ans = 0
for As in list(a_candidates):
    ans = max(ans, calc(fs,As))

print(ans)

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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
    }
    let s = n.clone().to_string().chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>();
    if (n as i32) % (s as i32) == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

ll bit(ll N){
  ll count=0;
  while(N>0){
    count+=N%2;
    N=(N-(N%2))/2;
  }
  return count;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<vector<ll>> X(N,vector<ll>(0));
  vector<vector<ll>> Y(N,vector<ll>(0));
  for(ll i=0;i<N;i++){
    cin >> A[i];
    for(ll j=0;j<A[i];j++){
      ll x,y;
      cin >> x >> y;
      X[i].push_back(x);
      Y[i].push_back(y);
    }
  }
  ll ans=0;
  for(ll i=0;i<(1<<N);i++){
    bool TF=true;
    for(ll j=0;j<N;j++){
      if(i & (1<<j)){
        for(ll k=0;k<A[j];k++){
          if((i / (1<<(X[j][k]-1)))%2 != Y[j][k]){
            TF=false;
            break;
          }
        }
      }
    }
    if(TF){
      ans=max(bit(i),ans);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3640
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn get_divisors(x: usize) -> Vec<usize> {
    let mut ret = Vec::new();
    let mut i = 1;
    while i * i < x {
        if x % i != 0 {
            i += 1;
            continue;
        }
        ret.push(i);
        ret.push(x / i);
        i += 1;
    }
    if i * i == x {
        ret.push(i);
    }
    ret
}

fn g(a: isize, b: isize) -> isize {
    a * a * a * a * a - b * b * b * b * b
}

fn f(a: isize, x: usize, X: usize) -> bool {
    let x = x as isize;
    let X = X as isize;
    let b = a - x;
    g(a, b) >= X
}

#[allow(non_snake_case)]
fn main() {
    input! {X:usize}
    let d = get_divisors(X);
    for x in d {
        for A in (-1e3 as isize)..(1e3 as isize) {
            let B = A - x as isize;
            if g(A, B) == X as isize {
                println!("{} {}", A, B);
                return;
            }
        }
    }
}


Measured memory_bytes: 2116