akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mk(arr,n,type)  type *arr=new type[n];
 
clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
int main(){
	 ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << endl;
	
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

// X = b_k * (2p + 1)
// p = (X - b_k) / 2b_k

/*!* [intutil] *!*/
/*+* 整数演算いろいろ *+*/
i64 divceil(i64 a, i64 b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
i64 logceil(i64 a, i64 b) {
    for(i64 i = 0, x = 1; a >= 2; x *= a, i++) if(x <= b) return i; return 0;
}
i64 gcd(i64 a, i64 b) {
    for (i64 c; a;) c = a, a = b % a, b = c; return b;
}
i64 lcm(i64 a, i64 b) {
    return (a / gcd(a, b) * b);
}


int main() {
    i64 N, M;
    cin >> N >> M;
    vector<i64> A(N);
    i64 l = 1;
    for(i64 &a : A) {
        cin >> a;
        a /= 2;
        l = lcm(l, a);
        if(l > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    for(i64 a : A) {
        if((l / a) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    i64 ans = (M + l) / (2 * l);
    cout << ans << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	int a[4];
	for(int i = 0; i < 4; i++) {
		a[i] = n % 10;
		n /= 10;
	}
	reverse(a, a + 4);
	for(int i = 0; i < (1 << 3); i++) {
		int sum = a[0];
		string ans;
		ans += a[0] + '0';
		for(int j = 0; j < 3; j++) {
			if(1 & (i >> j)) {
				sum -= a[j + 1];
				ans += '-';
				ans += a[j + 1] + '0';
			}
			else {
				sum += a[j + 1];
				ans += '+';
				ans += a[j + 1] + '0';
			}
		}
		if(sum == 7) {
			cout << ans << "=7" << endl;
			return 0;
		}
	}
	
		
	return 0;	
}


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

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

Measured memory_bytes: 256
H, W = gets.split(" ").map(&:to_i)
k, m, r = Array.new(W, 0), Array.new(W, 0), 0

H.times do
    l = 0
    s = gets.chomp
    (0...W).each do |j| 
        if s[j] == "."
            if l == 0
                t = j + 1
                while (t < W) && (s[t] == ".") do
                    t += 1
                end
                l = t - j
            end
            k[j] += 1
            m[j] = l if m[j] < l #横方向に何マス照らすかを記憶
        else
            x = k[j] + m[j] #　今いるマスの横に照らすマスの個数　＋　今いるマスより上に位置する照らすマスの個数
            r = x if r < x 
            l = 0 #ｌをリセットして横方向のカウントを再開できるようにする
            k[j] = 0
            m[j] = 0
        end
    end
end

(0...W).each do |j|
    x = k[j] + m[j] 
    if x > r
        r = x
    end
end

puts r - 1

Measured memory_bytes: 3068
from collections import deque
n,m = map(int,input().split())
edge = [[] for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
visited = [float('inf') for i in range(n)]
visited[0] = 0
ans = [float('inf') for i in range(n)]
que = deque()
que.append(0)
while que:
    t = que.popleft()
    for j in edge[t]:
        if visited[j] == float('inf'):
            visited[j] = t+1
            que.append(j)
if float('inf') in visited:
    print("No")
    exit()
print("Yes")
for i in range(1,n):
    print(visited[i])

Measured memory_bytes: 97512
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static long mod = 1000000007;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		char mozi[][] = new char[h][w];

		for(int i = 0;i < h;i++){
			mozi[i] = sc.next().toCharArray();

		}

		for(int i = 0;i < h+2;i++){
			for(int j = 0;j < w+2;j++){
				if(i == 0 || i == h+1 || j == 0 | j == w+1){
					System.out.print("#");
				}else{
					System.out.print(mozi[i-1][j-1]);
				}

			}
			System.out.println();
		}



	}


}




Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
 
    
    int t1;
  	t1=1;

    while(t1--){
    	string s,t;
    	cin>>s>>t;

    	int sLen = s.length();
    	int tLen = t.length();

    	int ans=1001;
    	for(int i=0;i<=(sLen-tLen);i++){
    		int temp=0;
    		for(int k=i;k<(i+tLen);k++){
    			if(s[k]!=t[k-i])
    				temp++;

    		}
    		ans=min(ans,temp);
    	}

    	cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		int ma = -1, mi = inf;
		bool a = true, b = true;
		for(int i=0; i < n; i++){
			cin >> v[i];
			if(ma < v[i]) ma = v[i];
			if(v[i] < mi) mi = v[i];
		}
		int sum = 0;
		rep(i, v.size()){
			if(ma == v[i] && a){a = false; continue;}
			if(mi == v[i] && b){b = false; continue;}

			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
const int inf=1e5+9;
long long  dp[inf],a[inf];

int main(){

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=1e9+9;
        for(int j=max(i-k,1);j<i;j++)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));

    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;

template<typename T> class SegmentTree{
  private:
    typedef function<T(T,T)> F;
    int n;
    T d0;
    vector<T> vertex;
    F f;
    F g;
  public:
    SegmentTree(int _n,F f,F g,int d):d0(d),f(f),g(g){
        init(_n);
    }
    void init(int _n){
        n=1;
        while(n<_n) n*=2;
        vertex.resize(2*n-1,d0);
    }
    void update(int i,T x){
        int k=i+n-1;
        vertex[k]=g(vertex[k],x);
        while(k>0){
            k=(k-1)/2;
            vertex[k]=f(vertex[2*k+1],vertex[2*k+2]);
        }
        return;
    }
    inline T query(int l,int r){
        l+=n-1;r+=n-1;
        T vl=vertex[l],vr=vertex[r];
        for(;l<r;l>>=1,r>>=1){
            vl=f(vl,vertex[l]);
            vr=f(vr,vertex[--r]);
        }
        return f(vl,vr);
    }
};
int gcd(int x,int y){return y?gcd(y,x%y):x;};
int main(){
    int n;cin>>n;
    
    SegmentTree<int> seg(n,[](int x,int y){return gcd(x,y);},[](int x,int y){return y;},0);
    REP(i,n){
        int a;cin>>a;
        seg.update(i,a);
    }
    int ans=seg.query(1,n-1);
    REP(i,n-2) ans=max(ans,gcd(seg.query(0,i),seg.query(i+2,n-1)));
    ans=max(ans,seg.query(0,n-2));
    cout<<ans<<endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
 int n,s=0;cin>>n;
  for(int  i =1;i<=n;i++)
    for(int  j =1;j<=n;j++)
      for(int  k =1;k<=n;k++)
          s+=gcd(i,gcd(j,k));
 cout<<s;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1000000000000000000;
int main()
{
	ll n;
	cin >> n;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	sort(arr,arr+n);
	ll ans = 1;
	if(arr[0] == 0)
		ans = 0;
	else
	{
		for(ll i=0;i<n;i++)
		{
			ll temp = N/ans;
			if(temp >= arr[i])
				ans = ans * arr[i];
			else
			{
				ans = -1;
				break;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
Graph G;
//始点sからS回以内の移動でたどりつける町を探索
void bfs(vec &dist, ll s)
{
    queue<ll> que;
    dist[s] = 0;
    que.push(s);
    while (!que.empty())
    {
        ll v = que.front();
        que.pop();
        for (auto next_v : G[v])
        {
            if (dist[next_v] != -1)
                continue;
            dist[next_v] = dist[v] + 1;
            que.push(next_v);
        }
    }
}
int main()
{
    cout << fixed << setprecision(30);
    ll N;
    ll x, y;
    cin >> N >> x >> y;
    x--;
    y--;
    G.resize(N);
    loop(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (G[x].size() == 1 && G[x][0] == y)
    {
        putout(0);
        return 0;
    }
    vector<ll> distT(N, -1), distA(N, -1);
    bfs(distT, x);
    bfs(distA, y);
    ll ans = 0;
    loop(i, N)
    {
        if (distT[i] < distA[i])
            ans = max(ans, distA[i] - 1);
    }
    putout(ans);
    return 0;
}


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

typedef long long int ll;
typedef pair<ll,ll> pll;

ll ar[1<<17+5];
vector<pll >vec;

bool cmp(pll a, pll b)
{
    if(a.first==b.first)return a.second>b.second;
    return a.first>b.first;
}
int main() {
    ll n, h;
    cin>>n>>h;
    ll a,b,sum=0;
    while(n--){
        cin>>a>>b;
        vec.push_back({a,1});
        vec.push_back({b,0});

    }
    sort(vec.begin(),vec.end(),cmp);
    for(pll x:vec)
    {
        if(h<=0)
            break;
        if(x.second==1)
        {
            sum+=h/x.first+(h%x.first!=0);
            h=0;
        }else
        {
            h-=x.first;sum++;
        }
    }
    cout<<sum<<endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  int a = 0;
  REP(i,N) {
    if(A[i] % 2 == 1) ++a;
  }
  cout << (a % 2 == 0 ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long LL;
const LL P = 1e9+7;
const int N = 6e5+5;
 
int fac[N], ifac[N];
int n, m, L, R;

int pw(LL x,int n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%P)if(n&1)res=res*x%P;
	return res;
}
int C(int x,int y){
	if(y<0 || y>x) return 0;
	return 1ll * fac[x] * ifac[y] % P * ifac[x-y] % P;
}
int calc(int n,int sumL,int sumR){
	return (C(sumR+n,n) - C(sumL-1+n,n) + P) % P;
}
 
int main(){
	fac[0] = 1;
	rep(i,1,N-1) fac[i] = 1ll * fac[i-1] * i % P;
	ifac[N-1] = pw(fac[N-1], P-2);
	rrep(i,N-2,0) ifac[i] = 1ll * ifac[i+1] * (i+1) % P;
	
	cin>>n>>m>>L>>R;
	int sall = calc(n,L,R), s1 = 0;
	
	rep(i,1,R){
		int sL = L - m * i, sR = R - m * i, r = i - 1, res = 0;
		if(sR<0) break;
		
		rep(j,0,n-m){
			int sl = sL - j * (r+1), sr = sR - j * (r+1);
			if(sr<0) break;
			res = (res + (j%2==0 ? 1ll : -1ll) * calc(n,sl,sr) * C(n-m, j) % P + P) % P;
		}
		
		sL = L - m * (i+1), sR = R - m * (i+1);
		rep(j,0,n-m){
			int sl = sL - j * (r+1), sr = sR - j * (r+1);
			if(sr<0) break;
			res = (res - (j%2==0 ? 1ll : -1ll) * calc(n,sl,sr) * C(n-m, j) % P + P) % P;
		}
		s1 = (s1 + 1ll * res * C(n, m) % P) % P;
	}
	cout<<(sall - s1 + P) % P <<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

char t[N];
string s;
int act, i, le[N], pr[N], n;
LL res;

int main() {
scanf("%s", t);
s = t;
n = s.size();
le[0] = 0;
act = 0;
for (i=1;i<=n;i++) {
	if (s[i - 1] == '<') act++; else act = 0;
	le[i] = act;
}
pr[n] = 0;
act = 0;
for (i=n-1;i>=0;i--) {
	if (s[i] == '>') act++; else act = 0;
	pr[i] = act;
}
res = 0;
for (i=0;i<=n;i++) res += max(le[i], pr[i]);
printf("%lld\n", res);
}





Measured memory_bytes: 5120
#include<iostream>
#include<iomanip>

double Cut(double figure,int keta)
{
	for(int i=0; i<keta+1; ++i)
	{
		figure *= 10.0;
	}

	int figureI = figure;

	figureI = figureI-figureI%10+(figureI%10>=5 ? 10 : 0);//四捨五入　一回1の桁を0として、1の位が5以上なら〜と場合分け

	figure = figureI;

	for(int i=0; i<keta+1; ++i)
	{
		figure /= 10.0;
	}

	return figure;
}

int main()
{
	std::cout << std::setprecision(3);//小数点以下の”表示”桁数
	
	std::cout << std::setiosflags(std::ios::fixed);
	
	double a,b,c,d,e,f;

	while(std::cin >> a >> b >> c >> d >> e >> f)
	{
		double x = (c*e-b*f)/(a*e-b*d);

		double y = (c*d-a*f)/(b*d-a*e);

		std::cout << Cut(x,3) << ' ' << Cut(y,3) << '\n';
	}
	
}

Measured memory_bytes: 1280
#include <stdio.h>

int a[222222];

int main(void)
{
	int n, i, all;

	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);

		if (i == 1)
			all = a[1];
		else
			all = all ^ a[i];
	}

	for (i = 1; i <= n; i++)
		printf("%d ", all ^ a[i]);
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	uint32_t a, b, c, d;
	cin >> a >> b >> c >> d;

	printf("%d\n", (min(a, b) + min(c, d)));
	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
a = readints()
# print(a)
c = Counter(a)  # リストの各要素の出現回数をカウント
# print(c)
cnt = 0
# print(c.values())
for i in c.values():
    # 各要素の値に対してforループ処理
    cnt += i*(i-1)//2
for aa in a:
    x = c[aa]
    # print(x)
    ans = (cnt-x*(x-1)//2+(x-1)*(x-2)//2)
    print(ans)


Measured memory_bytes: 27164
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    ArrayList<Integer> d = new ArrayList();
    int ans = 0;
    int val = 0;
    for(int i=0; i<N; i++) {
      val = scan.nextInt();
      for(int j=0; j<d.size(); j++) {
        ans += val*d.get(j);
      }
      d.add(val);
    }
    System.out.println(ans);
  }
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;

  while (k) {
    k--;
    if (a >= b) {
      b *= 2;
    } else if (b >= c) {
      c *= 2;
    } else {
      break;
    }
  }
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		long p = 1;
		for (int i = 1; i <= n; i++) {
			p = (long) ((long) (p % (Math.pow(10, 9) + 7) * (i % (Math.pow(10, 9) + 7))) % (Math.pow(10, 9) + 7));
		}
		System.out.println(p);

	}
}

Measured memory_bytes: 21844
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");

		//コード
		//    	Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String ans = "";
		for(int i=0;i<S.length();i++) {
			ans += "x";
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>mp;
    int n,m;
    mp.clear();
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        for(int i=0;i<k;i++)
        {
            int num;
            cin>>num;
            mp[num]++;
        }
    }
    int ans=0;
    for(int i=0;i<=m;i++)
    {
        if(mp[i]==n)
            ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

ll Pow(ll n,ll r){
	ll dim=1;
	for(ll i=0;i<r;i++)dim*=n;
	return dim;
}

int main(){
	ll n,nmax=1,ans=1;
	cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=2;i<=n;i++){
		for(int j=2;;j++){
			ll dim=Pow(i,j);
			if(dim>n)break;
			ans=std::max(ans,dim);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

class Vtx {
public:
	int id;
	int dist = -1;
	vector<int> vtxs;
};

void dfs(int n, Vtx vtxs[]){
	queue<pair<int,int> > q;
	q.push(make_pair(vtxs[0].id, 0));
	while(!q.empty()){
		pair<int,int> p=q.front();
		q.pop();
		int id=p.first-1;
		int d=p.second;
		Vtx v = vtxs[id];
		if(v.dist==-1){
			vtxs[id].dist=d;
		}
		for(int i=0;i<v.vtxs.size();i++){
			int nId=v.vtxs[i];
			if(vtxs[nId-1].dist==-1){
				q.push(make_pair(nId,d+1));
			}
		}
	}
}

int main(){
	int n;
	cin >> n;
	Vtx vtxs[n];
	for(int i=0;i<n;i++){
		int id, k;
		cin >> id >> k;
		vtxs[i].id = id;
		for(int j=0;j<k;j++){
			int v;
			cin >> v;
			vtxs[i].vtxs.push_back(v);
		}
	}
	
	dfs(n, vtxs);
	
	for(int i=0;i<n;i++){
		Vtx v = vtxs[i];
		cout << v.id << " ";
		cout << v.dist << endl;
	}
	return 0;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    
    vector<vector<int>> X(N), Y(N);

    rep(i, N) {
        int A;
        cin >> A;
        rep(j, A) {
            int x, y;
            cin >> x >> y;
            X[i].push_back(x);
            Y[i].push_back(y);
        }
    }

    int ans = 0;
    rep(bit, 1 << N) {
        int cnt = 0;
        vector<bool> liar(N, false);
        rep(i, N) {
            if ((bit >> i) & 1) {
                cnt++;
                liar[i] = true;
            }
        }

        bool flag = true;
        rep(i, N) {
            if (!liar[i]) continue;
            rep(j, X[i].size()) {
                if (liar[X[i][j] - 1] != Y[i][j]) flag = false;
            }
        }

        if (flag) chmax(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    string cubes;
    cin >> cubes;

    sll zeros = 0;
    sll ones = 0;
    for (size_t i = 0; i < cubes.length(); i++) {
        if (cubes[i] == '0')
            zeros++;
        else
            ones++;
    }

    cout << 2*min(zeros, ones) << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

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

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

int main(void){
  ll N; cin >> N;
  vector<ll> T(N);
  for(auto& _T: T) cin >> _T;

  ll ans = 1;
  for(ll i = 0; i < N; i++){
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, w, a, b, ans = 0;
  scanf("%lld%lld", &n, &w);
  ll dp[w + 1];
  for(i = 0; i <= w; ++i) dp[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a, &b);
    for(j = w; j >= 0; --j) if(j + a <= w && dp[j] + b > dp[j + a]) dp[j + a] = dp[j] + b;
  }
  for(i = 0; i <= w; ++i) if(ans < dp[i]) ans = dp[i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 896
#D

X=int(input())
flag=True

#B=0
for a in range(1,100):
    if a**5==X:
        flag=False
        print(a,0)
        break

#A>0>B
if flag:
    br=False
    for a in range(1,101):
        for b in range(1,101):
            if a**5+b**5==X:
                flag=False
                br=True
                print(a,-b)
                break
        if br:
            break
        
#A>B>0
if flag:
    br=False
    for b in range(1,201):
        for a in range(b+1,201):
            if X%(a-b)==0:
                if a**5-b**5==X:
                    print(a,b)
                    br=True
                    break
        if br:
            break

Measured memory_bytes: 65108
#include <iostream>
using namespace std;
typedef long long ll;

const ll mod  = 1e9 + 7;
ll modpow(ll a, ll n) {
    ll r = 1;
    while(n > 0) {
        r = r * ( (n%2) ? a : 1) % mod;
        a = a * a % mod;
        n /= 2;
    }
    return r;
}

ll modcomb(int n, int k) {
    if ( n < 0 || k < 0 || k > n) return 0;
    k = min(k, n - k); //nCk = nC(n-k)
    ll p = 1, q = 1;
    while ( k > 0 ) {
        p = p * n-- % mod; // p = n*(n-1)*(n-2)...(n-k+1)
        q = q * k-- % mod; // q = k*(k-1)*(k-2)...1
    }
    // 1/q = q^(p-2) (mod p)
    return p * modpow(q, mod - 2) % mod;
}


int main() {
	int N;
    ll res = 0;
    cin >> N;

    res = (res + modpow(10, N)) % mod;
    res = (res - modpow(9, N)) % mod;
    res = (res - modpow(9, N)) % mod;
    res = (res + modpow(8, N)) % mod;
    res = (res + mod) % mod;

    cout << res << endl;
	return 0;
}

Measured memory_bytes: 3628
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
d = LI()
ans = 0
l = list(itertools.combinations(d,2))
for i, j in l:
    ans += i*j
print(ans)

Measured memory_bytes: 74576
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;string S;cin>>N>>S;
  int ans=0,x=0;
  REP(i,0,N){
    if((int)S.at(i)=='I'){
      x++;
    }
    else{
      x--;
    }
    ans=max(ans,x);
  }
  print(ans);

}


Measured memory_bytes: 256
MOD=10**9+7
n,m=map(int,input().split())
x=sorted(map(int,input().split()))
y=sorted(map(int,input().split()))
X,Y=0,0
for i in range(n):
    X=X+x[i]*(i+1)%MOD
    X=(X-x[i]*(n-i)+MOD)%MOD
for k in range(m):
    Y=Y+y[k]*(k+1)%MOD
    Y=(Y-y[k]*(m-k)%MOD+MOD)%MOD
print(X*Y%MOD)

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MOD = 1000*1000*1000+7;
int n;
int dp[(1<<21)];
bool com[21][21];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0; i<n;i++) {
        for(int j=0; j<n;j++) {
            cin>>com[i][j];
        }
    }
    dp[0]=1;
    for(int mask=1; mask<(1<<n);mask++) {
        int men = __builtin_popcount(mask);
        for(int i=0; i<n;i++) {
            if((mask&(1<<i))&&com[men-1][i]) {
                dp[mask]=(dp[mask]+dp[mask^(1<<i)])%MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1];
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)


const int inf=2e9+5;

int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    int ans=inf;
    rep(i,n){
        int kari=0;
        while(p[i]%2==0){
            kari++;
            p[i]/=2;
        }
        ans=min(ans, kari);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String lastWeekContest = scan.next();

		if (lastWeekContest.equals("ABC")) {
			System.out.print("ARC");
		} else {
			System.out.print("ABC");
		}

	}

}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  rep(i,n) {
    if (i%2 == 0 && s[i] == 'L') ok = false;
    if (i%2 == 1 && s[i] == 'R') ok = false;
  }
  if (ok) puts("Yes"); else puts("No");
  return 0;
}

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

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

using namespace std;

int main(){
  ll x,y;cin>>x>>y;

  if(x==y){
    cout<<0;
    return 0;
  }

  if(-1*x==y){
    cout<<1;
    return 0;
  }

  ll result=1<<30;
  ll result1 = max<ll>(0, y-x);
  if(result1!=0)result=min<ll>(result, result1);

  ll result2 = max<ll>(0, -y-x+1);
  if(result2!=0)result=min<ll>(result, result2);

  ll result3 = max<ll>(0, x-y+2);
  if(result3!=0)result=min<ll>(result, result3);

  ll result4 = max<ll>(0, y+x+1);
  if(result4!=0)result=min<ll>(result, result4);

  cout<<result;

  return 0;
}

Measured memory_bytes: 256
k = int(input())
a,b = map(int,input().split())
if a == b and a%k == 0:
    print("OK")
elif b-a >= k:
    print("OK")
else:
    if a%k == 0 or b%k == 0:
        print("OK")
    elif a//k != b//k:
        print("OK")
    else:
        print("NG")


Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXL = 5010;
int dp[MAXL][MAXL];

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

  rep(i, n) rep(j, n) {
    int ni = i + 1;
    int nj = j + 1;
    chmax(dp[ni][nj], dp[i][j]);
    if(s[i] == s[j]) chmax(dp[ni][nj], dp[i][j] + 1);
    else dp[ni][nj] = 0;
    
  }

  int ans = 0;
  rep(i, n)rep(j, n) {
    // cout <<dp[n][i + 1] << endl;
    if (i >= j) continue;
    int now = min(dp[i + 1][j + 1], j - i);
    ans = max(ans, now);
  }
  cout << ans << endl;
  
}


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

int main() {
    string s;
    cin >> s;

    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
  int l[11];
  int a[11];
  int v1,v2;
  int suml;
  double h;
  int i,j;
  double p;
  l[0]=0;
 while((scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&l[10],&v1,&v2))!=EOF){
    suml=0;
    for(i=0;i<11;i++){
      a[i]=0;
    }
    for(i=1;i<11;i++){
      suml+=l[i];
    }
    for(i=1;i<11;i++){
      for(j=1;j<=i;j++){
	a[i]+=l[j];
      }
      //printf("a[%d]:%d\n",i,a[i]);
    }
    p=(double)v1/(v1+v2);
    h=suml*p;
    //printf("l:%d h:%f\n",suml,h);
    
    for(i=0;i<10;i++){
      if(a[i]<h&&a[i+1]>=h){
	printf("%d\n",i+1);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;

long long int c(long long int n){
  long long int re=1;
  for(long long int i=n; i>n-2; i--){
      re*=i;
  }
  if(n<=0){
    re=0;
  }
  re/=2;
  return re;
}

int main(void){
  long long int n;
  cin>>n;
  vector<long long int> hoge(n);
  for (long long int i = 0; i < n; i++)
  {
    cin>>hoge.at(i);
  }
  vector<long long int> normal(n+1, 0);
  vector<long long int> nothing(n+1, 0);
  vector<long long int> sor=hoge;
  sort(sor.begin(), sor.end());
  long long int streak=1;
  long long int all=0;
  for(long long int i=0; i<n; i++){
    if(i<n-1){
      if(sor.at(i)==sor.at(i+1)){
      streak++;
    }else{
      normal.at(sor.at(i))=c(streak);
      nothing.at(sor.at(i))=c(streak-1);
      streak=1;
      all+=normal.at(sor.at(i));
    }
    }else if(i==n-1){
      if (streak==1)
      {
        normal.at(sor.at(i))=0;
        nothing.at(sor.at(i))=0;
      }else{
        normal.at(sor.at(i))=c(streak);
        nothing.at(sor.at(i))=c(streak-1);
        all+=normal.at(sor.at(i));
      }
  }
  }

  for(long long int i=0; i<n; i++){
    long long int ans=all - normal.at(hoge.at(i)) + nothing.at(hoge.at(i));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 9344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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



int n;
bool j = false;

int main() {

	cin >> n;

	while (n) {
		if (n % 10 == 7)j = true;
		n /= 10;
	}

	if (j)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, K;
   cin >> N >> K;
   vector<ll> V(N);
   for (int i = 0; i < N; i++) cin >> V[i];

   ll ans = 0;
   
   for (int l = 0; l <= K; l++) {
      vector<ll> vl(l);
      copy(V.begin(), V.begin() + l, vl.begin());
      /*
      cout << "vl" << endl;
      for (int i = 0; i < vl.size(); i++) {
         cout << vl[i] << " ";
      }
      cout << endl;
      */
      for (int r = 0; r <= K - l; r++) {
         if (l + r > N) continue;
         vector<ll> vr(l + r);
         copy(V.rbegin(), V.rbegin() + r, vr.begin());
         /*
         cout << "vr" << endl;
         for (int i = 0; i < r; i++) {
            cout << vr[i] << " ";
         }
         cout << endl;
         */
         copy(vl.begin(), vl.end(), vr.begin() + r);
         for (int m = 0; m <= K - l - r; m++) {
            sort(vr.rbegin(), vr.rend());
            if (l + r < m) continue;
            // cout << l << " " << r << " " << m << endl;
            ll tmp = 0;
            for (int i = 0; i < l + r - m; i++) {
               tmp += vr[i];
            }
            ans = llmax(ans, tmp);
         }
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
import std.math;

void main()
{
    string[] input = split(readln());
    int x = to!int(input[0]);
    int a = to!int(input[1]);
    int b = to!int(input[2]);
    if(abs(x - a) < abs(x - b)){
        writeln("A");
    } else {
        writeln("B");
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [0] * N
for i in range(N):
    a[i] = list(input())

del_N = []
del_M = []

for i in range(N):
    if a[i].count('.') == M :
        del_N.append(i)

for i in range(M):
    tmp = []
    for j in range(N):
        tmp.append(a[j][i])
    if tmp.count('.') == N:
        del_M.append(i)



ans1 = []
for i in range(N):
    if i not in del_N:
        ans1.append(a[i])



ans2 = [[] for _ in range(len(ans1))]
for i in range(len(ans1)):
    for j in range(M):
        if j not in del_M:
            ans2[i].append(str(ans1[i][j]))



for i in range(len(ans2)):
    ans2[i] = ''.join(ans2[i])
    print(ans2[i])

Measured memory_bytes: 3188
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String point = sc.nextLine();
		
		String[] points = point.split(" ");
		int intN = Integer.parseInt(points[0]);
		int intD = Integer.parseInt(points[1]);
		
		double d2 = intD * 2.0 + 1;
		double observer = Math.ceil(intN / d2);

		System.out.println((int)observer);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,x;
    cin>>k>>x;
    if(k*500>=x){
        cout<<"Yes\n";
    }else{
    cout<<"No\n";
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a;
	set<int>s;
	set<int>::iterator ite;
	for(int i=1;i<=n;i++){
		cin>>a;
		ite=s.find(a);
		if(ite==s.end()) s.insert(a);
		else s.erase(ite);
	}
	int ans=0;
	for(ite=s.begin();ite!=s.end();ite++){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int A, B, C;
	int flag;

	flag = 0;
	scanf("%d %d %d", &A, &B, &C);

	if (A == 5) {
		if (B == 5) {
			if (C == 7) {
				flag = 1;
			}
		} else if (B == 7) {
			if (C == 5) {
				flag = 1;
			}
		}
	} else if (A == 7) {
		if (B == 5) {
			if (C == 5) {
				flag = 1;
			}
		}
	}

	if(flag==1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  cin >> S;

  ;
}
int ans;
void solve() {
  rep(i, 0, N - 1) {
    if (S.substr(i, 3) == "ABC") {
      ans++;
    }
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int in = 1000000001;
    long long int ax = 0;
    long long int now;
    for (int i = 0; i < n; i++){
        cin >> now;
        in = min(in, now);
        ax = max(ax, now);
    }
    cout << ax - in << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(N); inl(T);
  vl t(N); in(t);
  t.pb(infLL);
  ll ans = 0;
  rep(i , N){
    ans += min(T , t[i+1] - t[i]);
  }
  out(ans);


}

Measured memory_bytes: 4736
//
// Created by yoshihito.hotta on 2018/06/10.
//
#include <iostream>
using namespace std;

int main() {
    int n;
    int *a;
    cin >> n;
    a = new int [n];

    for (int i = 0; i < n ; i++) cin >> a[i];

    int sw = 0;
    for (int i = 0; i < n; i++) {
        int jmin = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[jmin]) jmin = j;
        }
        swap(a[jmin], a[i]) ;
        if(jmin != i) sw ++ ;
    }
    for (int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl << sw << endl;

    return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <stack>

using namespace std;

int main(void){
	int n;
	stack<int> st;

	while(cin >> n){
		if(n != 0){
			st.push(n);
		}else{
			cout << st.top() << endl;
			st.pop();
		}
		//if(st.empty() == true) break;
	}
	return 0;
}

Measured memory_bytes: 0