akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
using namespace std;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int gcd_of_vector(int A[100000], int begin, int end){
  int result = A[begin];
  for(int i=begin;i<end;i++){
    result = gcd(A[i],result);
  }
  return result;
}

int gcd_of_vector_with_skip(int A[100000], int skip, int size){
  int result = A[0];
  if(skip==0)result=A[1];
  for(int i=1;i<size;i++){
    if(i==skip)continue;
    result = gcd(A[i],result);
  }
  return result;
}

int main() {
  int gcd1,gcd2,ans,N=getint();
  int A[100000];
  for(int i=0;i<N;i++)A[i]=getint();

  if(N>=100){
    ans=1000000010;
    gcd1 = gcd_of_vector(A,0,N/2);
    gcd2 = gcd_of_vector(A,N/2,N);
    ans = max(gcd1,gcd2);
  }else{
    ans=0;
    for(int i=0;i<N;i++){
      ans=max(ans,gcd_of_vector_with_skip(A,i,N));
    }
  }

  cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 768
#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 N; 
    cin >> N;
    int A[N]={0};
    for(int i=1; i<N; i++) cin >> A[i];
    
    int B[N]={0};
    rep(i, N) B[A[i]-1]++;

    rep(i, N) cout << B[i] << endl;
    return 0;
}

Measured memory_bytes: 5112
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  long long int X, K, D, ans = 0, maxi = 0, count, place = 0 ;
  cin >> X >> K >> D ;
  if(X < 0ll) X = -X ;
  if((X / D) >= K){
    ans = X - (K * D) ;
    cout << ans << endl ;
    return 0 ;
  }
  count = (X / D) ;
  place = (X % D) ;
  K = K - count ;
  if((K % 2) == 0){
    cout << place << endl ;
    return 0 ;
  }
  else{
    cout << (D - place) << endl ;
    return 0 ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int n, a, b, min = 100000000;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    a = n - i;
    b = i;
    long long int c = 0;
    while (a >= 10) {
      c += a % 10;
      a = a / 10;
    }
    c += a;
    while (b >= 10) {
      c += b % 10;
      b = b / 10;
    }
    c += b;
    if (min > c)
      min = c;
  }
  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL INT_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF INT_MAX
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> ii;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};
#define MAXN 200010
#define MAXL 20

int n;
vector<lli> vec;

lli pd[MAXN][2];

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

  cin >> n;
  for(int i=0;i<n;i++){
  	int a;
  	cin >> a;
  	vec.pb(a);
  }

  for(int i=0;i<=n;i++) for(int j=0;j<=2;j++) pd[i][j] = INT_MAX;

  pd[1][1] = abs(vec[1] - vec[0]);
	pd[2][2] = abs(vec[2] - vec[0]);

  for(int i=1;i<sz(vec);i++){

  	pd[i+1][1] = min(pd[i+1][1], pd[i][1] + abs(vec[i] - vec[i+1]));
  	pd[i+1][1] = min(pd[i+1][1], pd[i][2] + abs(vec[i] - vec[i+1]));
  	pd[i+2][2] = min(pd[i+2][2], pd[i][2] + abs(vec[i] - vec[i+2]));
  	pd[i+2][2] = min(pd[i+2][2], pd[i][1] + abs(vec[i] - vec[i+2]));

  }

 // for(int i=0;i<sz(vec);i++){
  //	for(int j=1;j<=2;j++) cout << pd[i][j] << " ";
  	//	cout << endl;
  //}

  cout << min(pd[n-1][1], pd[n-1][2]);

  return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=61;
char str[MAXN];
int ff[MAXN][MAXN],N,f[MAXN];
int main(){
    N=read();for(int i=0;i<26;i++) f[i]=51;
    for(int i=1;i<=N;i++){
        scanf("%s",str+1);int len=strlen(str+1);
        for(int j=1;j<=len;j++) ff[i][str[j]-'a']++;
        for(int j=0;j<26;j++) f[j]=min(f[j],ff[i][j]);
    }
    for(int i=0;i<26;i++) for(int j=1;j<=f[i];j++) printf("%c",i+'a');printf("\n");return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int X[114514];

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  rep(i, N) {
    cin >> X[i];
  }

  LL ans = 1;
  int k = 1;
  reps(i, 1, N) {
    ++k;
    MN(k, (X[i-1]+3)/2);
    MN(k, i+1);
    //cout << k << endl;;
    ans *= k;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
N = gets.to_i
a = gets.split.map(&:to_i)
m = Hash.new(0)
a.each do |i|
    m[i] += 1
end
ans = 0
m.each do |k, v|
    if v < k
        ans += v
    else
        ans += v - k
    end
end
puts ans

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  char c; cin>>c;
  char a=c+1;
  cout<<a<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
kx = [list(map(int,input().split())) for i in range(n)]
c1 = 0
c2 = 0

for i in range(1,len(kx[0])):
  for j in range(1,n):
    if kx[0][i] in kx[j][1:]:
      c1 += 1
  if c1 == n-1:
    c2 += 1
  c1 = 0

print(c2)

Measured memory_bytes: 3064
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
s=input()
l=[0]*1000
for _ in range(n):
    i=s[_]
    for j in range(1000):
        k=str(j).zfill(3)
        if k[0]==i and l[j]==2:
            l[j]=3
        if k[1]==i and l[j]==1:
            l[j]=2
        if k[2]==i and l[j]==0:
            l[j]=1
ans=0
for i in l:
    if i==3:
        ans+=1
print(ans)

Measured memory_bytes: 96200
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[0])
ans = 0
for a, b in AB:
    if b <= M:
       ans += a * b
       M -= b
    else:
        ans += a * M
        break
    if M == 0:
        break
print(ans)

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

using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  ll ans = 0;
  for (int l = 0; l < N; ++l) {
    int r = l + K - 1;
    if (r >= N) break;
    ll score = min(abs(x[l]) + abs(x[r] - x[l]), abs(x[r]) + abs(x[r] - x[l]));
    if (l == 0) {
      ans = score;
    } else {
      ans = min(ans, score);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <string>
#include <algorithm>
#include <limits.h>
#include <iostream>

using namespace std;

int main()
{
	long long i, j, k, ol;
	string O, E, ANS;

	cin >> O; cin >> E;
	ol = O.length();

	for (i = 0; i < ol; i++) {
		ANS += O[i];
		if (E[i] != NULL)
			ANS += E[i];
	}

	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    unordered_map<int, unordered_map<int, int>> um;
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        um[l][r] = d;
        um[r][l] = -d;
    }
    vector<int> v(n + 1, 0), dist(n + 1, 0);
    v[1] = 1;
    int index = 1;
    vector<int> nodes(1, 1);
    while (nodes.size() > 0) {
        int node = nodes.back();
        nodes.pop_back();
        for (auto p : um[node]) {
            int next = p.first;
            int d = p.second;
            if (v[next] == 0) {
                v[next] = 1;
                nodes.push_back(next);
                dist[next] = dist[node] + d;
            } else {
                if (dist[next] != dist[node] + d) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        if (nodes.size() == 0) {
            for (int i = index; i <= n; i++) {
                if (v[i] == 0) {
                    v[i] = 1;
                    index = i + 1;
                    nodes.push_back(i);
                    break;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 31328
import java.util.Scanner;

public class Main {
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i=0; i<n; i++) {
            v[i] = sc.nextInt();
        }

        int ans = solve(n, v);

        System.out.println(ans);
    }

    private static int solve(int n, int[] v) {
        int[] hist = new int[100_001];
        int count = 0;

        for (int i = 0; i < n; i += 2) {
            hist[v[i]]++;
        }
        int[][] ans1 = top(hist);

        hist = new int[100_001];
        for (int i = 1; i < n; i += 2) {
            hist[v[i]]++;
        }
        int[][] ans2 = top(hist);

//        System.err.println(ans1[0][0] + "," + ans1[0][1] + " / " + ans1[1][0] + "," + ans1[1][1]);
//        System.err.println(ans2[0][0] + "," + ans2[0][1] + " / " + ans2[1][0] + "," + ans2[1][1]);

        if (ans1[0][1] != ans2[0][1]) {
            count = n - ans1[0][0] - ans2[0][0];
        } else {
            count = Math.min(n - ans1[0][0] - ans2[1][0], n - ans1[1][0] - ans2[0][0]); 
        }

        return count;
    }

    private static int[][] top(int[] hist) {
        int[][] ans = new int[2][2];
        for (int i=0; i<hist.length; i++) {
            if (hist[i] > 0) {
              if (hist[i] >= ans[0][0]) {
                  ans[1][0] = ans[0][0];
                  ans[1][1] = ans[0][1];

                  ans[0][0] = hist[i];
                  ans[0][1] = i;
              } else if (hist[i] > ans[1][0]) {
                  ans[1][0] = hist[i];
                  ans[1][1] = i;
              }
            }
        }

        return ans;
    }
}


Measured memory_bytes: 50468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

//[mint]
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(100005);

mint f(ll x, ll y){
    if(x==0)return 0;
    mint res=comb(x,y);
    //res*=comb.fact[y];
    return res;
}

int main(void){
    int n,k;cin>>n>>k;
    vector<int> a(n),combmemo(n,0);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    
    combination c(n+5);
    
    mint ans=0;
    rep(ri,2){
        rep(i,n){
            mint now = c(i,k-1);
            if(ri==1)now*=(-1);
            ans+=(mint)a[i]*now;
        }
        reverse(a.begin(),a.end());
    }
    
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
void go(int sx, int sy, int tx, int ty) {
    for(int i = 0; i < abs(sx - tx); i++) {
        cout << (sx < tx ? 'R' : 'L');
    }
    for(int i = 0; i < abs(sy - ty); i++) {
        cout << (sy < ty ? 'U' : 'D');
    }
}
void go_outer(int sx, int sy, int tx, int ty) {
    if(sx < tx and sy < ty) {
        cout << 'D';
        go(sx, sy - 1, tx + 1, ty);
        cout << 'L';
    } else if(sx < tx and sy > ty) {
        cout << 'U';
        go(sx, sy + 1, tx + 1, ty);
        cout << 'L';
    } else if(sx > tx and sy < ty) {
        cout << 'D';
        go(sx, sy - 1, tx - 1, ty);
        cout << 'R';
    } else {
        cout << 'U';
        go(sx, sy + 1, tx - 1, ty);
        cout << 'R';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    go(sx, sy, tx, ty);
    go(tx, ty, sx, sy);
    go_outer(sx, sy, tx, ty);
    go_outer(tx, ty, sx, sy);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, k): (u32, u32) = parse_line().unwrap();
    let mut v: Vec<u32> = parse_line().unwrap();
    v.sort();
    let ans = &v[..k as usize].iter().sum::<u32>();
    println!("{}", ans);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
string s;
int main(void){
    int h,w;
    cin>>h>>w;
    string s[h+2];
    rep(i,1,h+1){
        cin>>s[i];
        s[i]="."+s[i]+".";
    }
    rep(i,0,w+2){
        s[0]+=".";
        s[h+1]+=".";
    }
    rep(i,1,h+1)rep(j,1,w+1){
        if(s[i][j]=='#'&&s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

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


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

vector<string> res;
int N;
void solve(int n, string s, char lim){
    if(n == 0)return;
    if(s.size() == N)res.push_back(s);
    for(char c = 'a'; c <= lim + 1; c++){

        if(c != lim + 1)solve(n - 1, s + c, lim);
        else solve(n - 1, s + c, (char)(lim + 1));
    }
}

int main(){
    cin >> N;
    solve(N, "a", 'a');
    sort(ALL(res));
    for(string s : res)cout << s << endl;
}



Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr Int MOD = 2019;
	string s;
	cin >> s;

	reverse(s.begin(), s.end());
	Int ans = 0;
	map<Int, Int> mp;
	mp[0] = 1;
	Int S = 0;
	Int d = 1;
	for (int i = 0; i < s.size(); ++i) {
		(S += (int)(s[i] - '0') * d % MOD) %= MOD;
		(d *= 10) %= MOD;
		ans += mp[S];
		mp[S] += 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const int mx = 2200;
ll n, z, w, a[mx], dp[mx][mx], bst[mx][mx];

int main()
{
    cin >> n >> z >> w;
    for (int i = 0; i < n; ++i) {
        cin >> a[i + 2];
    }
    a[0] = z;
    a[1] = w;
    n += 2;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dp[i][j] = -1;
            bst[i][j] = -1;
        }
    }
    for (int i = n - 1; i >= 0; --i) {
        for (int j = n - 1; j >= 0; --j) {
            if (i == n - 1 || j == n - 1) {
                if (i != j) {
                    dp[i][j] = abs(a[i] - a[j]);
                    bst[i][j] = dp[i][j];
                }
                continue;
            }
            if (i < j) {
                dp[i][j] = bst[j + 1][j];
                bst[i][j] = min(bst[i][j + 1], dp[i][j]);
            }
            if (j < i) {
                dp[i][j] = bst[i][i + 1];
                bst[i][j] = max(bst[i + 1][j], dp[i][j]);
            }
        }
    }
    cout << dp[0][1] << endl;
    return 0;
}


Measured memory_bytes: 71936
N, M = map(int, input().split())
l = []
for _ in range(M):
    a,b = list(map(int, input().split()))
    l.append([a-1,b-1])
visit = [0]*N
graph = [0]*N*N
g = []
def dfs(v):
  visit[v] = 1
  for v2 in range(N):
    if graph[v*N+v2] == 1 and visit[v2] == 0:
      g.append(v2)
    if v2 == N-1 and len(g) != 0:
      a = g[0]
      g.pop(0)
      return dfs(a)
ans = 0
for a,b in l:
  graph[a*N+b] = graph[b*N+a] = 1
for a,b, in l:
  graph[a*N+b] = graph[b*N+a] = 0
  visit = [0]*N
  dfs(0)
  if sum(visit) != N:
    ans += 1
  graph[a*N+b] = graph[b*N+a] = 1
print(ans)


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

int main(){
  string s;
  cin >> s;
  bool key = false;
  for (int i = 0; i < 3; i++){
    if (s[i] == s[i+1]){
      key = true;
    }
  }
  string ans = "Good";
  if (key){
    ans = "Bad";
  }
  cout << ans << endl;
}

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



int main(){
    string S;
    cin >> S;
    char first = S[0];
    if(S[1] == first){
        if(S[2] == S[3] && S[2] != first){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(S[2] == first){
        if(S[1]==S[3] && S[1] != first){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(S[3]==first){
        if(S[1]==S[2] && S[2] != first){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int exchange(string s){
  int res=0;
  res = (s[0]-48)*36000+(s[1]-48)*3600+(s[3]-48)*600+(s[4]-48)*60+
        (s[6]-48)*10+(s[7]-48);
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(cin >> n,n){
    int time[900000]={0};
    for(int i=0;i<n;i++){
      string s1,s2;cin >>s1>>s2;
      int start=exchange(s1),end=exchange(s2);
      time[start]++;time[end]--;
    }
    for(int i=1;i<900000;i++) time[i]+=time[i-1];
    int res=-1;
    for(int i=0;i<900000;i++) res=max(res,time[i]);
    cout << res << endl;
  }
}

Measured memory_bytes: 6692
/*
 * @author : ashish1610
 */
#include <bits/stdc++.h>
using namespace std;
#define ll	long long int
#define MOD	1000000007
int main() {
	ll n, k, x, y;
	cin >> n >> k >> x >> y;
	ll res = min(n, k) * x + max(n - k, 0LL) * y;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i >= n - m + 1 || j >= n - m + 1) continue;
      bool flag = true;
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(a[k + i][l + j] != b[k][l]) flag = false;
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n, a[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < (1 << n); i++)
		cin >> a[i];
}

int answer[MAXN];
int cnt[MAXN];
bool used[MAXN];
vector<int> li;

void add(int mask, int val)
{
	if(cnt[mask] == 2) 
		return;
	
	used[mask] = true;
	cnt[mask]++;
	answer[mask] += val;
	li.push_back(mask);

	for(int l = 0; l < n; l++)
		if(!((mask >> l) & 1))
			if(cnt[mask ^ (1 << l)] < 2 && !used[mask ^ (1 << l)])
				add(mask ^ (1 << l), val);
}

void solve()
{
	vector<pair<int, int> > li;
	for(int i = 0; i < (1 << n); i++)
		li.push_back({a[i], i});

	sort(li.begin(), li.end());
	for(int i = (1 << n) - 1; i >= 0; i--)
	{
		add(li[i].second, li[i].first);
		for(auto it: ::li) used[it] = false;
		::li.clear();
	}

	for(int i = 2; i < (1 << n); i++)
		chkmax(answer[i], answer[i - 1]);

	for(int i = 1; i < (1 << n); i++)
		cout << answer[i] << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 17648
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	// your code goes here
	int n,m,id,x;
	cin>>n;
	int t[n+2];
	i64 total = 0LL;
	for(int i=1;i<=n;i++) {
		cin>>t[i];
		total+=t[i];
	}
	cin>>m;
	while(m--){
		cin>>id>>x;
		printf("%lld\n", total-t[id]+x);
	}
	return 0;
}

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

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nab: Vec<usize> = util::gets();
    let mut vs: Vec<i64> = util::gets();

    let a = nab[1];
    let b = nab[2];

    vs.sort_by_key(|&x| -x);

    let len = vs.iter().take_while(|&&x| x == vs[0]).count();

    let ave = vs[0..a].iter().sum::<i64>() as f64 / a as f64;
    println!("{}", ave);

    if len <= a {
        let p = ncr(vs.iter().filter(|&&x| x == vs[a - 1]).count(),
                    vs[0..a].iter().filter(|&&x| x == vs[a - 1]).count());
        println!("{}", p);
    } else {
        let p = (a..min(len + 1, b + 1))
            .map(|r| ncr(len, r))
            .fold(0, |acc, p| acc + p);
        println!("{}", p);
    }
}

fn ncr(n: usize, r: usize) -> usize {
    if n - r < r {
        return ncr(n, n - r);
    }

    let mut ans = 1;

    for i in 1..r + 1 {
        ans *= n - r + i;
        ans /= i;
    }

    ans
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int f[110][11];
int p[110][12];
int b[10];
int main(){
	int n;
	int ans = -1000000007;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	for (int bit = 1; bit < (1 << 10); bit++) {
		for (int i = 0; i < 10; i++) {
			if (bit & (1 << i)) {
				b[i] = true;
			}
			else {
				b[i] = false;
			}
		}
		int sum = 0;
		for (int j = 0; j < n; j++) {
			int co = 0;
			for (int k = 0; k < 10; k++) {
				if (b[k] == true && f[j][k] == 1) {
					co++;
				}
			}
			sum += p[j][co];
		}
		if (sum > ans) {
			ans = sum;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: chars,
    }
    let n = s.len();
    const M: i64 = 2019;
    let mut dp = vec![0; n + 1];
    let mut hm = HashMap::new();
    let mut tot = 0;
    hm.insert(0, 1);
    let mut cur = 1;
    for i in (0..n).rev() {
        let c = (s[i] as u8 - b'0') as i64;
        dp[i] = (dp[i + 1] + c * cur) % M;
        let val = dp[i];
        *hm.entry(val).or_insert(0) += 1;
        tot += hm[&val] - 1;
        cur = cur * 10 % M;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

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

    map<string, int> m = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
    rep(i, 0, n) {
        string s;
        cin >> s;
        m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3628
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	n := nextInt()
	fmt.Println(n * (n - 1) / 2)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
  int i;
  
  cin>>s;
  
  for(i=0;i<3;i++){
    if(s[i]=='1')
      s[i]='9';
    else if(s[i]=='9')
      s[i]='1';
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
rgb = [0]*3
rgb[0],rgb[1],rgb[2],n = map(int,input().split())
rgb.sort()

ans=0
for i in range(n//rgb[2]+1):
    for j in range((n-i*rgb[2])//rgb[1]+1):
        d = n-i*rgb[2]-j*rgb[1]
        if d%rgb[0]==0 and d>=0:
            ans+=1

print(ans)

Measured memory_bytes: 3060
chomp($s = <>);

$ans1 = 0;
$ans2 = 0;

$len = length($s);

for($i = 0; $i < $len; $i++){
  $s1 = substr($s, $i, 1);
  # print"$s1\n";
  if($s1 eq "0" and $i % 2 == 0 or
     $s1 eq "1" and $i % 2 == 1){
    $ans1++;
  }else{
    $ans2++;
  }
}

# print "$ans1 $ans2\n";

$ans = min($ans1, $ans2);

print "$ans\n";

sub max(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $a;
  }else{
    $b;
  }
}

sub min(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $b;
  }else{
    $a;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long a,b,n,k; cin>>n>>k;
  if(k&1){ a=n/k; cout<<a*a*a<<endl;}
  else{ a=n/k; b=(n+k/2)/k; cout<<a*a*a+b*b*b<<endl;}
  return 0;
}


Measured memory_bytes: 3436
r,g,b,n = map(int,input().split())
count = 0
n1 = n
for i in range(n1//r +1):
  n = n1- r*i
  n2 = n
  for j in range(n2//g +1):
    n = n2 - g*j
    if n%b == 0:
      count += 1
    else:
      pass
print(count)

Measured memory_bytes: 3064
/**
	Language: C++
	Author  : ebby21
**/

#include <bits/stdc++.h>

using namespace std;

#define fastio() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define debug(v) cerr << '\n' << #v << " :\t" << v << '\n'
#define loop(i, L, U) for (ll i = (L); i <= (U); ++i)
#define rloop(i, U, L) for (ll i = (U); i >= (L); --i)
#define foreach(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

int main() {
	fastio();
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	loop(i, 0, h - 1) {
		cin >> s[i];
	}
	vector< vi > l(h, vi(w, 0));
	int ini = 0;
	loop(i, 0, h - 1) {
		loop(j, 0, w - 1) {
			if (s[i][j] == '#') continue;
			int k = j;
			while (++k < w && s[i][k] == '.');
			int score = k - j;
			while (j < k) {
				l[i][j] += score;
				++j;
			}
		}
	}
	loop(j, 0, w - 1) {
		loop(i, 0, h - 1) {
			if (s[i][j] == '#') continue;
			int k = i;
			while (++k < h && s[k][j] == '.');
			int score = k - i;
			while (i < k) {
				l[i][j] += score;
				++i;
			}
		}
	}
	int md = INT_MIN;
	loop(i, 0, h - 1) {
		loop(j, 0, w - 1) {
			md = max(md, l[i][j] - 1);
		}
	}
	cout << md <<'\n';
	return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 20005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int par[SIZE]; //親
int rnk[SIZE]; //木の深さ

//初期化(n要素0オリジン)
void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rnk[i] = 0;
  }
}

//xの根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

//x,yの属する集合を併合
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y)return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y])rnk[x]++;
  }
}

int n,q,a,x,y;

int main(){
  cin >> n >> q;
  init(n);
  rep(i,0,q){
    cin >> a >> x >> y;
    if(a==0) unite(x,y);
    else{
      if(find(x) == find(y)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3180
N = int(input())
H = list(map(int, input().split(" ")))
H.reverse()
possible = True
for i in range(1, N):
    if H[i] == H[i - 1] + 1:
        H[i] -= 1
    elif H[i] > H[i - 1]:
        possible &= False
print('Yes' if possible else 'No')

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
ll L;
ll x[MAXN], ps[MAXN];

bool read() {
    if (!(cin >> L >> n))
        return false;

    forn (i, n)
        cin >> x[i];

    return true;
}

void solve() {
    ll ans = max(x[n - 1], L - x[0]);
    sort(x, x + n);
    ps[0] = 0;

    forn (i, n)
        ps[i + 1] = ps[i] + x[i];

    for (int i = 1; i < n; ++i) {
        int k = min(i, n - i);
        ll cur = 2 * (ps[i] - ps[i - k] + k * L - (ps[i + k] - ps[i])) - min(x[i - 1], L - x[i]);
        ans = max(ans, cur);
    }

    for (int i = 2; i < n; ++i) {
        int k = min(i - 1, n - i);
        ll cur = 2 * (ps[i - 1] - ps[i - 1 - k] + k * L - (ps[i + k] - ps[i])) + max(x[i - 1], L - x[i - 1]);
        ans = max(ans, cur);
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <limits>
#include <type_traits>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;
int gcd(int a,int b) {
  if(a==0) return b;
  if(a>=b) return gcd(a%b, b);
  else return gcd(b%a, a);
}

int main() {
  int i,n,x;
  cin >> n >> x;
  vector<int> X;
  for(i=0;i<n;i++) {
    int tmp;
    cin >> tmp;
    X.push_back(tmp);
  }
  if(X.size()==1) {
    cout << abs(X[0]-x) << endl;
    return 0;
  }
  int xgcd=abs(X[0]-X[1]);
  //配列Xすべての最大公約数を求める
  for(i=0;i < X.size()-1;i++) {
    xgcd = gcd(xgcd, abs(X[i]-X[i+1]) );
  }
  //gcdが一番大きくなるxから最初に移るXの座標
  int max=1;
  for(i=0;i<n;i++) {
    int t = gcd(xgcd, abs(X[i]-x) );
    if(t>max) {
      max=t;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 892
import sys
import itertools
import numpy as np

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
perms = list(itertools.permutations(range(N)))
combs = list(itertools.combinations(range(N), 2))

arr_2d = np.zeros((N,2))
if N <= 2:
	arr_dist_memo = np.zeros((len(combs)+1,len(combs)+1))
else:
	arr_dist_memo = np.zeros((len(combs),len(combs)))

arr_dist_ave = np.zeros(len(perms))

for i, line in enumerate(lines[1:]):
    x, y = map(int,line.split(' '))
    arr_2d[i, 0] = x
    arr_2d[i, 1] = y

for i,j in combs:
    arr_dist_memo[i, j] = np.linalg.norm(arr_2d[i] - arr_2d[j])

for index, l in enumerate(perms):
    for i, j  in zip(range(N-1), range(1, N)):
        arr_dist_ave[index] += arr_dist_memo[l[i],l[j]]

print(np.mean(arr_dist_ave)*2)

Measured memory_bytes: 17268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll mod = 1000000007;//998244353;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll t1, t2; cin >> t1 >> t2;
    ll a1, a2; cin >> a1 >> a2;
    ll b1, b2; cin >> b1 >> b2;
    ll c1, c2; c1 = a1-b1; c2 = a2-b2;
    ll d1, d2; d1 = c1*t1; d2 = c2*t2;
    ll ans;
    if (d1>0){
        d1 *= -1;
        d2 *= -1;
    }
    if (d1+d2==0){
        cout << "infinity" << endl;
        return 0;
    }
    else if (d1+d2<0){
        cout << 0 << endl;
    }
    else {
        ll s = (-d1)/(d1+d2);
        ll t = (-d1)%(d1+d2);
        cout << s*2+(t!=0) << endl;;
    }
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$S = $key->A[0];
$len = strlen($S);
$ary = array();
for($i=0;$i<$len;$i++) {
  if (isset($ary[$S[$i]])) {
    printf("no\n");
    exit;
  }
  $ary[$S[$i]]=1;
}
printf("yes\n");


Measured memory_bytes: 3828
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int a, b, c;
    std::cin >> a >> b >> c;
    if (a > b) std::swap(a, b);
    std::cout << ((a <= c && c <= b) ? "Yes" : "No") << std::endl;
    return 0;
}


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

long long gozyo(long long a,long long b){
  if(a<b){
    long long temp=a;
    a=b;
    b=temp;
  }
  while(a%b!=0){
    long long  temp=a%b;
    a=b;
    b=temp;
  }
  return b;
}

main(){
  int n;
  long long d[11];
  long long v[11];
  long long a[11];
  long long g;
  long long k1,k2,k3;
  long long t1,t2,t3;
  while( (cin >> n),n ){
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      g= gozyo(d[i],v[i]);
      d[i]/=g;
      v[i]/=g;
    }



    k1=d[0];
    t1=d[0];
    for(int i=1;i<n;i++){
      k1 = gozyo(t1,d[i]);
      t1=t1*d[i]/k1;
    }

    for(int i=0;i<n;i++) a[i]=t1/d[i]*v[i];

    k2=a[0];
    for(int i=1;i<n;i++) k2 = gozyo(k2,a[i]);

    for(int i=0;i<n;i++){
      cout << a[i]/k2 << endl;
    }
    

  }
}

Measured memory_bytes: 1164
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    mi = 0
    le = len(a)
    cost = 0
    for i in range(le-1):
        if mi > a[i+1] or a[i] > a[i+1]:
            mi = max(a[i], mi)
            cost += mi - a[i+1]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 109520
#include <iostream>
//#include <array>
#include <vector>
#include <cstdlib>
#include <algorithm>

int main()
{
    std::vector<int> x;
    std::vector<int> y;
    std::vector<int> h;
    int n;
    int hp = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int xn, yn, hn;
        std::cin >> xn >> yn >> hn;
        x.push_back(xn);
        y.push_back(yn);
        h.push_back(hn);
        if (hn > hp) {
            hp = hn;
        }
    }
    while (true) {
        for (int xp = 0; xp <= 100; xp++) {
            for (int yp = 0; yp <= 100; yp++) {
                bool flag = 1;
                for (int i = 0; i < n; i++) {
                    if (std::max(hp - std::abs(x[i] - xp) - std::abs(y[i] - yp), 0) != h[i]) {
                        flag = 0;
                        break;
                    }
                }
                if (flag) {
                    std::cout << xp << " " << yp << " " << hp << std::endl;
                    return 0;
                    //        }else{
                    //              std::cout << "timeout :"<<<< xp << " " << yp << " " << hp << std::endl;
                }
            }
        }
        hp++;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    int l,r,d;
    cin >> l >> r >> d;
    int count = 0;

    for (int i = l; i <= r; i++) {
        if (i%d == 0) count++;
    }

    cout << count;

    return 0;
}



Measured memory_bytes: 3572
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer A = Integer.parseInt(scan.next());
        Integer B = Integer.parseInt(scan.next());
        Integer C = Integer.parseInt(scan.next());

        if(C<=(A-B)){
            System.out.println(0);
        }else{
            System.out.println(C-(A-B));
        }

    }
}


Measured memory_bytes: 21716
H,W=map(int,input().split())
anslist = [["#" for i in range(W+2)]for j in range(H+2)]
for i in range(H):
    a=input()
    for j in range(W):
        anslist[i+1][j+1]=a[j]
for i in range(H+2):
    for j in range(W+2):
        print(anslist[i][j],end="")
    print()

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

using namespace std;
typedef long long ll;
#define PI acos(-1.0)
#define eps 1e-12
const ll INF_LL = 9223372036854775807LL;
const ll N = 1e9 + 7;
bool flag ;

int main()
{
	//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
	//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a,b,c,x,y,ans,res;
	cin>>a>>b>>c>>x>>y;
	if(a+b>=c*2)
    {
        if(x>y)
            ans=y*c*2;
        else
            ans=x*c*2;
    }
    else{
        ans=min(x,y)*(a+b);
    }
    if(x>y)
    {
        if(c*2>a)
            res=a*(x-y);
        else
            res=(x-y)*2*c;
    }
    else
    {
        if(c*2>b)
            res=b*(y-x);
        else
            res=(y-x)*2*c;
    }
    cout<<res+ans;
    return 0;
}


Measured memory_bytes: 256