akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> s(n);
	rep(i,n)cin >> s[i];
	sort(s.begin(),s.end());
	int ret =0 ;
	for(int i = 0;i < n;i++)for(int j = i+1;j < n ;j++)for(int k = j+1;k < n ;k++){
		ret += (s[i]+s[j] > s[k] && s[i]!= s[j] && s[j] != s[k] && s[k] != s[i]);

	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3628
from itertools import groupby
stdin = [input().split() for _ in range(2)]

def div2(x):
    b = bin(int(x))
    n = len(b)
    for i in range(n):
        if not b[n - 1 - i] == "0":
            break
    return i

res = map(div2, stdin[1])
print(min(res))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int M = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int ans = 0;
		
		for(int i = 1; i <= M; i++) {
			for(int y = 22; y <= D; y++) {
				int d1 = y / 10;
				int d10 = y % 10;
				if(i == d1 * d10 && d1 >= 2 && d10 >= 2) {
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n,a[200004],b[200004];
int main(){
	cin>>n;
	a[100000]++;
	b[100000]++;
	while (n--){
		int l,r;
		cin>>l>>r;
		a[l+100000]++;
		b[r+100000]++;
	}
	for (int i=200000;i>=0;i--)
		a[i]+=a[i+1];
	for (int i=1;i<=200000;i++)
		b[i]+=b[i-1];
	long long ans=0;
	for (int i=0;i<=200000;i++) ans+=min(b[i],a[i+1]);
	cout<<ans*2;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int count=0;
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]) count++;
  }
  cout << n-(count+1)/2*2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

long long n,m;
char s1[100010],s2[100010];

long long gcd(long long x,long long y){
	if(y==0) return x;
	return gcd(y,x%y);
}

int main(){
	scanf("%lld %lld",&n,&m);
	scanf("%s %s",s1+1,s2+1);
	long long lcm=n/gcd(n,m)*m;
	long long a=lcm/n,b=lcm/m;
	long long g=a/gcd(a,b)*b;
	int x=0,y=0;
	while(x+1<=n && y+1<=m){
		if(s1[x+1]!=s2[y+1]){
			printf("-1\n");
			return 0;
		}
		x+=g/a;y+=g/b;
	}
	printf("%lld\n",lcm);
}

Measured memory_bytes: 384
import static java.lang.Math.*;

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			double a, b , C;
			a = scan.nextDouble();
			b = scan.nextDouble();
			C = scan.nextDouble();
			double S = a * b * sin(toRadians(C)) / 2;
			System.out.println(S);
			double c = sqrt(pow(a , 2) + pow(b , 2) - 2 * a * b * cos(toRadians(C))) ;
			System.out.println(a + b + c);
			double h = 2 * S / a ;
			System.out.println (h);
		}finally{
			if(scan!=null)scan.close();
		}
	}
}

Measured memory_bytes: 18192
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(n)]

ab = sorted(ab, key=lambda x:(x[1], x[0]), reverse=True)
cd = sorted(cd, key=lambda x:(x[0], x[1]))

cnt = 0
i = j = 0
free_ab = [True] * n
while j < n:
    a, b = ab[i][0], ab[i][1]
    c, d = cd[j][0], cd[j][1]
    if a < c and b < d and free_ab[i]:
        cnt += 1
        free_ab[i] = False
        i = 0 
        j += 1
        continue
    elif j <= n-1 and i < n-1:
        i += 1
    elif j < n-1 and i == n-1:
        i = 0
        j += 1
    else:
        break
print(cnt)

Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

template <typename T = int>
struct Range {
    struct RangeIterator {
        T i, step;

        RangeIterator(T i, T step): i{i}, step{step} {}

        T& operator*() { return i; }
        RangeIterator& operator++() {
            i += step;
            return *this;
        }
        bool operator!=(const RangeIterator& rhs) const {
            return (step > 0 && i < rhs.i) || (step < 0 && i > rhs.i);
        }
    };

    T start, stop, step;

    Range(T start, T stop, T step): start{start}, stop{stop}, step{step} {}
    Range(T start, T stop): Range(start, stop, 1) {}
    Range(T stop): Range(0, stop, 1) {}
    
    RangeIterator begin() const { return RangeIterator(start, step); }
    RangeIterator end() const { return RangeIterator(stop, step); }
};

bool graph[100][100];

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

    int N;
    std::cin >> N;

    for (const int i : Range<>(N)) {
        for (const int j : Range<>(N)) {
            graph[i][j] = (i != j);
        }
    }

    if (N % 2 == 0) {
        for (const int i : Range<>(N)) {
            graph[i][N - 1 - i] = false;
        }
    } else {
        for (const int i : Range<>(N - 1)) {
            graph[i][N - i - 2] = false;
        }
    }

    std::vector<std::pair<int, int>> edges;
    for (const int i : Range<>(N)) {
        for (const int j : Range<>(i + 1, N)) {
            if (graph[i][j]) edges.emplace_back(i + 1, j + 1);
        }
    }

    std::cout << edges.size() << std::endl;
    for (const auto& e : edges) {
        std::cout << e.first << " " << e.second << std::endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second

ll n, k, ans, f[2005], m = 1e9+7;

ll fac(int x) {
	if (x == 0 or x == 1) return 1;
	if (f[x] != -1) return f[x];
	return f[x] = (ll) (x * fac(x-1)) % m;
}

ll qexp(ll a, ll b) {
    a %= m;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= m;
        }
        base *= base;
        base %= m;
        b >>= 1;
    }
    return res % m;
}

inline ll divide(ll a, ll b) {
	return ((a%m) * qexp(b, m-2)) % m;
}

ll choose(ll n, ll k) {
	if (n < k) return 0;
	return divide(fac(n), (fac(k) * fac(n-k))%m);
}

int main() {
	memset(f, -1, sizeof f);
	cin >> n >> k;
	FOR(i, 1, k) {
		cout << (choose(k-1, i-1) * choose(n-k+1, i))%m << "\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
#define longlong ll
int main()
{
   long long a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<=b&&c<=d)
    {
        cout<<max(a*d,max(b*d,max(a*c,b*c)));
    }
    return 0;
}


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

int main(){
	
	int n, k, ans = 0;
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		
		if (a >= k){
			ans++;
		}
	
	}
	
	cout << ans;
	
	
}


Measured memory_bytes: 256
nums = gets.split("").map(&:to_i)
paths = [[nums[0], nums[0]]]
1.upto(3) do |i|
  tmp = paths.flat_map do |v1, v2|
    [
      [v1 + nums[i], "#{v2}+#{nums[i]}"],
      [v1 - nums[i], "#{v2}-#{nums[i]}"],
    ]
  end
  paths = tmp
end

result = paths.find { |v1, _| v1 == 7  }
puts "#{result[1]}=7"

Measured memory_bytes: 1788
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

double pi = 3.14159265358979323846264338327;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    ll n, m;
    cin>>n>>m;
    ll si, sj;
    cin>>si>>sj;
    --si, --sj;
    ll ei, ej;
    cin>>ei>>ej;
    --ei, --ej;
    vector<vector<ll> > v(n, vector<ll>(m));
    for(ll i=0; i<n; i++){
        for(ll j=0; j<m; j++){
            char c;
            cin>>c;
            if(c=='#'){
                v[i][j]=0;
            }
            else{
                v[i][j]=1;
            }
        }
    }
    if(v[si][sj]==0){
        cout<<-1<<endl;
        return 0;
    }
    deque<pair<ll, ll> > pq;
    pq.push_back({si, sj});
    vector<vector<ll> > dis(n, vector<ll>(m, INT_MAX));
    dis[si][sj]=0;
    vector<ll> dx({1, 0, -1, 0});
    vector<ll> dy({0, 1, 0, -1});
    while(!pq.empty()){
        auto p = pq.front();
        pq.pop_front();
        for(ll k=0; k<4; k++){
            ll newX = p.first+dx[k];
            ll newY = p.second+dy[k];
            if(newX<0 || newY<0 || newX>=n || newY>=m) continue;
            if(v[newX][newY]==0) continue;
            if(dis[newX][newY]>dis[p.first][p.second]+0){
                dis[newX][newY]=dis[p.first][p.second];
                pq.push_front({newX, newY});
            }
        }
        for(ll i=p.first-2; i<=p.first+2; i++){
            for(ll j=p.second-2; j<=p.second+2; j++){
                ll newX = i;
                ll newY = j;
                if(newX<0 || newY<0 || newX>=n || newY>=m) continue;
                if(v[newX][newY]==0) continue;
                if(dis[newX][newY]>dis[p.first][p.second]+1){
                    dis[newX][newY]=dis[p.first][p.second]+1;
                    pq.push_back({newX, newY});
                }
            }
        }
    }
    cout<<(dis[ei][ej]!=INT_MAX?dis[ei][ej]:-1)<<endl;
    return 0;
}



Measured memory_bytes: 19400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int n, m; 
int main()
{
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<int>> dist(N + 1, vector<int>(N + 1, INF));
  int a, b, c;
  vector<pair<pair<int, int>, int>> edges;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    dist[a][b] = dist[b][a] = c;
    edges.push_back(make_pair(make_pair(a, b), c));
  }
  for (int i = 0; i <= N; ++i) { dist[i][i] = 0; }
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = M;
  for (int i = 0; i < M; ++i) {
    bool need = false;
    int a = edges[i].first.first, b = edges[i].first.second, c = edges[i].second;
    for (int j = 1; j <= N; ++j) {
      if (dist[j][b] == dist[j][a] + c) {
        need = true;
        break;
      }
    }
    if (need) { --ans; }
  }
  printf("%d\n", ans);
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

vector<i64> G[100'000];

int main() {
    i64 N, s, t; cin >> N >> s >> t;
    s--, t--;
    if (s == t) {
        cout << 1 << endl;
        return 0;
    }
    REP(i, N - 1) {
        i64 a, b; cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    auto calc = [&](i64 s) {
        vector<i64> d(N, -1);
        d[s] = 0;
        queue<i64> que;
        que.push(s);
        while (!que.empty()) {
            i64 u = que.front(); que.pop();

            for (i64 v : G[u]) {
                if (d[v] == -1) {
                    d[v] = d[u] + 1;
                    que.push(v);
                }
            }
        }
        return d;
    };

    vector<i64> ds = calc(s);
    vector<i64> dt = calc(t);

    i64 maxd = 0;
    REP(i, N) {
        if (ds[i] < dt[i]) chmax(maxd, dt[i]);
    }

    cout << (maxd - 1) << endl;

    return 0;
}

Measured memory_bytes: 8064
N,M,C = map(int,input().split())
b = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    tmpsum=C
    for j in range(M):
        tmpsum += l[i][j]*b[j]
    if(tmpsum > 0):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
N = int(input())
black1 = ["AGC", "GAC", "ACG"]
black2 = ["AAGC", "ACGC", "AGGC", "ATGC",
        "AGAC", "AGCC", "AGGC", "AGTC"]
memo = [{} for _ in range(N+1)]

def func(cur, S):
    if S[-3:] in black1:
        return 0
    if S[-4:] in black2:
        return 0
    if S[-3:] in memo[cur]:
        return memo[cur][S[-3:]]
    else:
        if cur==N:
            return 1
        ret = 0
        for s in "ACGT":
            ret = ret + func(cur+1, S+s)
        memo[cur][S[-3:]] = ret
        return ret


print(func(0, "____")%(10**9+7))

Measured memory_bytes: 46300
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1<<30;
const double eps = 1e-13;

char d[2009][2009];
int rs[2009][2009];
int rsv[2009][2009];
int rsh[2009][2009];

int main(){
	DRIII(n,m,q);
	REP(i,n)RS(d[i]);
	REP(i,n){
		REP(j,m){
			rs[i+1][j+1]=rs[i][j+1]+rs[i+1][j]-rs[i][j]+(d[i][j]=='1');
			if(i+1<n)rsv[i+1][j+1]=rsv[i][j+1]+rsv[i+1][j]-rsv[i][j]+(d[i][j]=='1'&&d[i+1][j]=='1');
			if(j+1<m)rsh[i+1][j+1]=rsh[i][j+1]+rsh[i+1][j]-rsh[i][j]+(d[i][j]=='1'&&d[i][j+1]=='1');
		}
	}
	REP(i,q){
		DRII(x1,y1);DRII(x2,y2);
		int ans=rs[x2][y2]-rs[x1-1][y2]-rs[x2][y1-1]+rs[x1-1][y1-1];
		//printf("%d",ans);
		ans-=rsv[x2-1][y2]-rsv[x1-1][y2]-rsv[x2-1][y1-1]+rsv[x1-1][y1-1];
		ans-=rsh[x2][y2-1]-rsh[x1-1][y2-1]-rsh[x2][y1-1]+rsh[x1-1][y1-1];
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 52992
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;

int n;
string s[10010];
int a[10010];
signed main(){
  int ans=0;
  int A=0,B=0;
  bool flag=false;
  cin>>n;
  rep(i,n){
    cin>>s[i];
    a[i]=s[i].length();
    rep(j,a[i]-1){
      if(s[i][j]=='A' && s[i][j+1]=='B')ans++;
    }
    if(s[i][0]=='B')B++;
    if(s[i][a[i]-1]=='A')A++;
    if((s[i][0]=='B')^(s[i][a[i]-1]=='A')==1)flag=true;
  }
  ans+=min(A,B);
  if(!flag && A+B>0)ans--;
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vint a(N);
  map<int, int> mp;
  int mx = 0;
  rep(i, N) {
    cin >> a[i];
    mp[a[i]]++;
    chmax(mx, a[i]);
  }
  auto solve = [&]() {
    for(int i = mx; i > mx/2; i--) {
      if(mp[i] < 2) return false;
      mp[i] -= 2;
    }
    if(mx%2 == 0) {
      if(mp[mx/2] < 1) return false;
      mp[mx/2]--;
    }
    for(int i = 1; i < N; i++) {
      if(i < mx/2+1+mx%2 && mp[i] > 0) return false;
    }
    return true;
  };
  cout << (solve() ? "Possible" : "Impossible") << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
n = int(input())
for i in range(n):
    q = input().split()
    if q[0] == "print":
        print(s[int(q[1]) : int(q[2]) + 1 ])
    elif q[0] == "reverse":
        sa = s[int(q[1]):int(q[2]) + 1]
        sa = sa[::-1]
        s = s[:int(q[1])] + sa + s[int(q[2]) + 1:]
    else:
        s = s[:int(q[1])] + q[3] + s[int(q[2]) + 1:]


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
int main() {
	int D;
	cin>>D;
	if(D<1200){
		cout<<"ABC"<<endl;
	}
	else if(D>=2800){
		cout<<"AGC"<<endl;
	}
	else{
		cout<<"ARC"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*

fun <T> permutationList(sortedList: Array<T>): List<List<T>> {
    val permutations = mutableListOf<List<T>>()
    val queue = ArrayDeque<List<T>>().apply { addLast(listOf()) }
    while (queue.isNotEmpty()) {
        queue.removeLast().let { p ->
            if (p.size == sortedList.size) {
                permutations.add(p)
            } else {
                sortedList.filterNot { p.contains(it) }
                    .forEach { queue.addLast(p + it) }
            }
        }
    }

    return permutations
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    val per = permutationList((1..n).toList().toTypedArray())
    Math.abs(per.indexOf(p) - per.indexOf(q)).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

int main(){
  int K,S; cin >> K >> S;
  int count=0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      if(S-x-y>=0&&S-x-y<=K){
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define H 500000

int n;
int A[H+1];

void maxHeapify(int);
void buildMaxHeap();

int main(){
  int i;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
    
    for(i=1;i<=n;i++){
    if(i == n){
      printf(" %d\n",A[i]);
    }
    else printf(" %d",A[i]);
    }

  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,hozon;
  l = left(i);
  r = right(i);

  if(l <= n && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r <= n && A[r]>A[largest]){
    largest = r;
  }
  if (largest != i){
    hozon = A[i];
    A[i] = A[largest];
    A[largest] = hozon;
    maxHeapify(largest);
  }
  
}

void buildMaxHeap(){
  int i;
  for(i = n/2;i >= 1;i--){
    maxHeapify(i);
  }
}
  
  



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

N, M, Q = map(int, input().split())
abcd = [[int(i) for i in input().split()] for _ in range(Q)]

ret = -float('inf')
def dfs(A, cur, depth) :
  if depth == N :
    s = 0
    for a, b, c, d in abcd :
      a, b = a - 1, b - 1
      if A[b] - A[a] == c :
        s += d
    global ret
    ret = max(ret, s)
    return 
      
  for nex in range(cur, M + 1) :
    dfs(A + [nex], nex, depth + 1)
    
dfs([], 1, 0)

print(ret)

Measured memory_bytes: 71048
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;
typedef unsigned int UINT;
typedef int INT;

bool isKaibun(string S)
{
	int N = S.length();
	bool kaibun = true;

	for (int i = 0; i < N / 2; ++i) {
		if (S[i] != S[N - 1 - i]) { kaibun = false; }
	}

	return kaibun;
}

int main()
{
	string S;
	cin >> S;
	int N = S.length();

	bool item1 = isKaibun(S);

	string S_sub = S.substr(0, (N - 1) / 2);
	bool item2 = isKaibun(S_sub);

	string S_sub2 = S.substr((N + 3) / 2 - 1);
	bool item3 = isKaibun(S_sub2);

	if (item1 && item2 && item3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  
  int count = 0;
  for (int i = 0; i < 3; i ++)
    if (s.at(i) == t.at(i)) count ++;
  
  cout << count << endl;
  
  return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

template <typename Container>
void UNIQUE(Container &&c)
{
    c.erase(std::unique(c.begin(), c.end()), c.end());
}

void Main()
{
    int n = in();
    vll a = in(n);
    rep(i, n) a[i] -= i + 1;

    sort(ALL(a));
    int b = a[n / 2];
    ll ans = 0;
    rep(i, n)
    {
        ans += abs(a[i] - b);
    }
    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
nums = map(int, raw_input().split())
WH = [nums[0], nums[1]]
xy = [nums[2], nums[3]]
r  = nums[4]

up    = xy[1] + r
low   = xy[1] - r
right = xy[0] + r
left  = xy[0] - r

if up > WH[1] or low < 0 or right > WH[0] or left < 0:
    print "No"
else:
    print "Yes"

Measured memory_bytes: 6456
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n,k,a;
    cin >> n >> k;
    
    for(int i=0;i<31;i++){
        if(n<pow(k,i)){
            a = i;
            break;
        }
    }
   cout << a << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split(" ");
		if(Integer.parseInt(str[2]) >= Integer.parseInt(str[0]) && Integer.parseInt(str[2]) <= Integer.parseInt(str[1])){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    ll a = abs(n % k);
    OP(min(a, abs(a - k)));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[3240000];
Int revfact[3240000];
Int rev[3240000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 3240000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}

Int res;
Int n, m;
int main(){
    init();
    cin >> n >> m;
    res = nCk(3*m + n - 1, n - 1);
    res -= n * nCk(m - 1 + n - 1, n - 1) % MOD;
    for(int i = m+1;i <= n && i <= 3 * m;i++){
        if((3 * m - i) % 2)continue;
        int rest = (3 * m - i) / 2;
        res -= nCk(n, i) * nCk(rest + n - 1, n - 1) % MOD;
        res %= MOD;
    }
    if(res < 0)res += MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 76160
#include<cstdio>
#include<algorithm>
using namespace std;
int n, A, B, C, D;
int DP[1010][1010], Mod = 1000000007, F[1010], invF[1010];
long long po[1010];
int Pow(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1)r = 1ll * r*a%Mod;
		a = 1ll * a*a%Mod; b >>= 1;
	}
	return r;
}
int main() {
	int i, j;
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	DP[A - 1][0] = 1;
	F[0] = 1;
	invF[0] = 1;
	for (i = 1; i <= n; i++) {
		F[i] = 1ll * F[i - 1] * i%Mod;
		invF[i] = Pow(F[i], Mod - 2);
	}
	for (i = A; i <= B; i++) {
		long long inv = Pow(F[i], Mod - 2);
		po[0] = 1;
		for (j = 1; j <= n; j++)po[j] = po[j - 1] * inv%Mod;
		for (j = 0; j <= n; j++) {
			DP[i][j] = (DP[i][j] + DP[i - 1][j]) % Mod;
			int M = min(D, (n - j) / i);
			for (int k = C; k <= M; k++) {
				DP[i][j + k * i] = (DP[i][j + k * i] + DP[i - 1][j] * po[k]%Mod*invF[k]) % Mod;
			}
		}
	}
	printf("%lld\n", 1ll * DP[B][n] * F[n] % Mod);
}

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

int main()
{
    string s; cin>>s;
    array<int, 2019> cnt={};
    for(int i=1; i<2019; ++i) cnt[i]=-1;

    int64_t res=0;
    int t=0, p=1;
    reverse(begin(s), end(s));
    for(auto& c: s) {
        t=(p*(c-'0')+t)%2019;
        cnt[t]++;
        res+=cnt[t];
        p=p*10%2019;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 3728
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int tmp=1;
		if(n==tmp) {
			System.out.println("1");
		}else {
			while(tmp<=n) {
				tmp*=2;
			}
			System.out.println(tmp/2);
		}
	}
}

Measured memory_bytes: 35840
"""
edge is an integer from 1 to N
it's a complete graph
"""

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())

sz=2
while sz*(sz-1)<n*2:
    sz+=1

if sz*(sz-1)==n*2:
    # complete graph
    out=[[] for _ in range(sz)]
    num=1
    for i in range(sz):
        for j in range(i):
            out[i].append(num)
            out[j].append(num)
            num+=1
    print("Yes")
    print(len(out))
    for p in out:
        print("%d %s"%(len(p)," ".join(map(str,p))))
else:
    print("No")

Measured memory_bytes: 8944
n,m,k = map(int,input().split())
mod = 998244353
ans = 0

def comb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


for i in range(k+1):
    a = pow(m-1, n-i-1, mod)
    b = comb(n-1,i,mod)
    ans += (a*b)%mod
ans *= m
print(ans%mod)

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

namespace program {
  class Program {
    static void Main()
    {
      var n = Input.ScanInt();
      Out(n*n*n);
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int x;
  cin>>x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll i,x,j,y,z,k,n;
string s,t,p="";
cin>>n>>s>>t;
rep(i,0,n,1){
	p+=s[i];
	p+=t[i];
}
ce(p)
}


Measured memory_bytes: 256
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

fn main() {
    let n = readln();
    let mut txys = vec![(0, 0, 0); n];
    for i in 0..n {
        let txy: Vec<i64> = reads();

        txys[i] = (txy[0], txy[1], txy[2]);
    }

    let mut res = true;
    let mut t = 0;
    let mut x = 0;
    let mut y = 0;

    for (nt, nx, ny) in txys {
        let dt = nt - t;
        let val = (nx - x).abs() + (ny - y).abs();

        if !(dt == val || (dt > val && (dt - val) % 2 == 0)) {
            res = false;
            break;
        }

        t = nt;
        x = nx;
        y = ny;
    }

    println!("{}",
    if res {
        "Yes"
    }
    else {
        "No"
    })
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint p(n);
    rep(i, n) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    rep(i, n) {
        if (i == n - 1) {
            ans += p[i] / 2;
            continue;
        }
        else {
            ans += p[i];
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int d[n];
  rep(i, 0, n) cin >> d[i];
  int rsl = 0;
  rep(i, 0, n) rep(j, i + 1, n) {
      rsl += d[i] * d[j];
  }
  cout << rsl << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

double eps = 1e-9;

bool dis(vector<int> v1, vector<int> v2){
	int n = v1.size();
	double ans = 0;
	for(int i=0; i<n; ++i)
		ans += pow(v1[i]-v2[i], 2);
	ans = sqrt(ans);
	return (fabs(ll(ans)-ans)<eps);
}
int main(){
	ios::sync_with_stdio(0);
	int n, d;
	cin >> n >> d;
	vector<vector<int>> vs(n, vector<int>(d));
	for(auto &v:vs)
		for(auto &x:v) cin >> x;
	int ans = 0;
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j)
			if(dis(vs[i], vs[j])) ++ans;
		
	cout << ans << endl;
}



Measured memory_bytes: 384
s = input()
k = int(input())

if len(set(s)) == 1:
    print(len(s) * k // 2)
else:
    l = []
    tmp = s[0]
    tmp_c = 1
    for i in range(1,len(s)):
        if s[i] == tmp:
            tmp_c += 1
        else:
            l.append(tmp_c)
            tmp_c = 1
            tmp = s[i]
    l.append(tmp_c)
    ans = sum([k*(x//2) for x in l])
    if s[0] == s[-1]:
        a = 1
        tmp = s[0]
        for i in range(1,len(s)):
            if s[i] == tmp:
                a += 1
            else:
                break
        b = 1
        tmp = s[-1]
        for i in s[-2::-1]:
            if i == tmp:
                b += 1
            else:
                break
        ans -= (a//2 + b//2 - (a+b)//2) * (k-1)
    print(ans)

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string original_S = S;
    reverse(S.begin(), S.end());

    string s, t;
    s = S.substr(0, (N-1)/2); t = S.substr((N-1)/2 + 1);
    string original_s = s, original_t = t;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());

    bool ok = false;
    if (original_S == S && original_s == s && original_t == t) {
        ok = true;
    }
    
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

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

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

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

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

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

using namespace std;

typedef pair<int,int> P;

int main(){
	int n ; cin>>n;
	if(0==n%2){
		cout << n << endl;
	  }
	  else{
		  cout << 2 * n <<endl;
		}
	  }



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n[10000],q[500];
  int s,t,i,j,count=0;

  scanf("%d",&s);
  for(i=0;i<s;i++) scanf("%d",&n[i]);
  scanf("%d",&t);
  for(i=0;i<t;i++) scanf("%d",&q[i]);

  for(i=0;i<t;i++){
    for(j=0;j<s;j++){
      if(q[i]==n[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  string a = "0131212112121";
  if(a[x] == a[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
namespace 私が灰コーダーです{
    class Inonoa{
        static void Main(){
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);
            string[] sa = Console.ReadLine().Split();
            int[] a = new int[n];
            for(int i=0;i<n;i++){
                a[i] = int.Parse(sa[i]);
            }
            Array.Sort(a);
            int[][] bc = new int[m][];
            for(int i=0;i<m;i++){
                string[] b_c = Console.ReadLine().Split();
                bc[i] = new int[]{int.Parse(b_c[0]),int.Parse(b_c[1])};
            }
            Array.Sort(bc,Compare);
            bool owari = false;
            int k = 0;
            for(int i=bc.Length-1;i>-1;i--){
                for(int j=0;j<bc[i][0];j++){
                    if(k>a.Length-1){
                        owari = true;
                        break;
                    }
                    if(a[k]>bc[i][1]){
                        owari = true;
                        break;
                    }
                    a[k] = bc[i][1];
                    k ++;
                }
                if(owari){break;}
            }
            long ans = 0;
            for(int i=0;i<a.Length;i++){
                ans += a[i];
            }
            Console.WriteLine(ans);
        }

        static int Compare(int[] a, int[] b){
            if(a[1]>b[1]){
                return 1;
            }
            if(a[1]<b[1]){
                return -1;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 30408
n,t = gets.split(" ").map(&:to_i)
tt = gets.split(" ").map(&:to_i)
count=0
for i in 1..n-1 do
	if tt[i]-tt[i-1]>=t then
		count+=t
	else
		count+=tt[i]-tt[i-1]
    end
end
puts count+t

Measured memory_bytes: 15876