akhauriyash/Code-Regression huggingface dataset:
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }
void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }

int main() {
	int A = in(); int B = in();
	print(A*B - (A + B - 1));

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    V = list(int(_) for _ in input().split())
    C = list(int(_) for _ in input().split())
    ans = 0
    for i in range(N):
        if(C[i] < V[i]):
            ans += V[i] - C[i]
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int po = 0;
	for(int i = 1; i < s.size(); ++i) po += (s[i] == s[0]);
	cout << ((s.size() - (po * 2 - (s[0] == s[s.size() - 1]))) % 2 ? "First\n" : "Second\n");
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            Console.WriteLine(n < 1200?"ABC":"ARC");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
K, N = map(int,input().split())
A = list(map(int,input().split()))

A_K = [A[x]-K for x in range(len(A))] 
newA = A_K + A

kyorist = [newA[x+len(A)-1] - newA[x] for x in range(len(A))]

print(min(kyorist))

Measured memory_bytes: 32356
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;



int main()
{
    godspeed
    //  ll  t,n,i,j;
    ll i,t,n,j,k,d,x,l;
    cin>>x>>k>>d;
    x=abs(x);
    ll mov=min(x/d,k);
    k-=mov;
    x-=mov*d;
    if(k%2)
        x=d-x;
        cout<<x<<endl;


    return 0;
}





Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 200000
  
int main(){
     int n,a[MAX],i;
     cin >> n;
     for(i=0;i<n;i++)cin >> a[i];
  
     int maxv,minv;
     maxv = -2000000000;
     minv = a[0];
     for(i=1;i<n;i++){
       maxv = max(maxv,a[i]-minv);
       minv = min(minv,a[i]);
     }
  
     cout << maxv << endl;
  
     return 0;
}

Measured memory_bytes: 1940
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int main() {
  ios_base::sync_with_stdio(0);
 ll int t, i, j, k, p, q, r, x, y, u, v, n, m;
    t=1;
    //cin>>t;
    while(t--){
    cin>>n;
    ll int a[n];
    fo(i,n)cin>>a[i];
    ll int mx=a[0],ans=0;
    fo(i,n){
        if(mx>a[i])
        ans+=mx-a[i];
        else
            mx=a[i];
    }
    cout<<ans;

    }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].pb(v - 1);
    g[v - 1].pb(u - 1);
  }
}

void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}





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

int main (){
	int K, X;
	scanf("%d",&K);
	scanf("%d", &X);
	for (int i=X-K+1; i<K+X-1; i++){
			printf("%d ", i);
	}
	printf("%d\n",K+X-1);
	return 0;
}

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

int d[300000];
int a[300000];

#ifndef MAX
#define MAX 1200000
#endif

//Range Update Query+Range Sum Query
template<class T>
class RUQ_RSQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO, DEFAULT;
	void init(int n_, T d = INT_MAX, T t = 0) {
		DEFAULT = d;
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = t; lazy[i] = DEFAULT;
		}
	}
	inline void push(int k, int s) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k] * s;
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k, r - l); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return ZERO;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		return lb + rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};

RUQ_RSQ<int> seg1,seg2;
int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d",&d[i]);
		a[i]=i*10;
	}
	seg1.init(n);seg1.update(0,1);
	seg2.init(n);seg2.update(n-1,1);
	rep(i,n){
		if(!seg1.query(i))continue;
		int k=upper_bound(a,a+n,a[i]+d[i])-a;
		seg1.update(i+1,k,1);
	}
	if(seg1.query(n-1)==0){
		puts("no");return 0;
	}
	for(int i=n-1;i>=0;i--){
		if(!seg2.query(i))continue;
		int k=lower_bound(a,a+n,a[i]-d[i])-a;
		seg2.update(k,i,1);	
	}
	if(seg2.query(0)==0){
		puts("no");
		return 0;
	}
	puts("yes");
}

Measured memory_bytes: 21864
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

typedef pair<int, int> P;

int N;
int A[100000];
map<int, bool> m;

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    m[A[i]] = (i % 2 == 1);
  }
  sort(A, A+N);
  int c = 0;
  for (int i=0; i<N; i++) {
    if (i % 2 == 1) {
      if (!m[A[i]]) c++;
    }
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 5376
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	int total = 0;
	if ((a + b) >= (2 * c))
	{
		total += (min(x, y) * 2 * c);
		if (x >= y)
		{
			if (a >= (2 * c))
			{
				total += (x - y) * 2 * c;
			}
			else
			{
				total += (x - y) * a;
			}
		}
		else
		{
			if (b >= (2 * c))
			{
				total += (y - x) * 2 * c;
			}
			else
			{
				total += (y -x) * b;
			}
		}
	}
	else
	{
		total += (a * x);
		total += (b * y);
	}
	
	cout << total << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1000002;
long long prime[MAXN],pricnt,ans,a,b,kc[MAXN],kccnt,gys[MAXN],gyscnt;
bool npri[MAXN];

inline void init()
{
    for (long long i = 2; i < 1000000ll; ++i)
    {
        if(!npri[i]) prime[++pricnt] = i;
        for (long long j = 1; j <= pricnt && i * prime[j] < 1000000ll; ++j)
        {
            npri[i * prime[j]] = true;
            if(i % prime[j] == 0) break;
        }
    }
}

int main()
{
    init();
    read(a);
    read(b);
    for (int i=1;i<=pricnt;++i)
    {
        if(a%prime[i]==0 && b%prime[i]==0) ++ans;
        while(a%prime[i]==0) a/=prime[i];
        while(b%prime[i]==0) b/=prime[i];
    }
    if(a!=1&&a==b) ans+=2;
    else ans+=1;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 5268
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define MOD (1000000007)

long long invmodp(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(void) {

    int N;
    cin >> N;
    long long X[N];
    long long fact = 1;
    rep(i, N) {
        cin >> X[i];
        fact = fact * max(1, i) % MOD;
    }

    long long ans = 0;
    long long inv = 0;
    rep(i, N-1) {
        long long diff = X[i+1] - X[i];
        inv = inv + invmodp(i+1, MOD) % MOD;
        long long add = diff * inv % MOD;
        ans = (ans + add) % MOD;
    }

    cout << (ans*fact)%MOD;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 n,W;
    cin >> n >> W;
    int dp[10100];
    vector<int>v(n),w(n);
    rep(i,n) cin >> v[i] >> w[i];
    rep(i,10100) dp[i] = 0;
    for(int i = 0;i<n;i++) {
        for(int j = w[i];j<=W;j++) {
            dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
    
}


Measured memory_bytes: 3152
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Measured memory_bytes: 14020
#include <stdio.h>

int main(){
  int a,b,k;
  scanf("%d %d %d",&a,&b,&k);
  int d;
  if(a > b){
    d = a - b;
  }else if (a < b){
    d = b - a;
  }else{
    d = a;
  }
  int count = 0;
  for(int i=d;d>0;d--){
    if (a%d==0 && b%d==0){
      count += 1;
      if (count == k){
        printf("%d\n",d);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
from fractions import gcd

mod = 10 ** 9 + 7
n, m, t = map(int, input().split())
a = gcd(n, t)
b = gcd(m, t)
n //= a
m //= b
ret = pow(2, n, mod) + pow(2, m, mod) + pow(2, gcd(n, m), mod) - 3
print(pow(ret, a * b, mod))


Measured memory_bytes: 5344
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
const int MOD =  1e9 + 7;
int mul(int a, int b){
	return (long long) a * b  % MOD;
}

int my_pow(int a, int b){
	int r = 1;
	while(b){
		if(b % 2){
			r = mul(r, a);
		}
		a = mul(a, a);
		b /= 2;
	}
	return r;
}

int my_inv(int a){
	return my_pow(a, MOD - 2);
}

void sub_self(int& a ,int b){
	a -= b;
	if(a < 0){
		a += MOD;
	}
}

int main(){
	int n, k; cin>>n>>k;
	vector<int> fac(2 * n + 1);
	fac[0] = 1;
	for(int i = 1; i <= 2 * n; i++){
		fac[i] = mul(fac[i - 1], i);
	}
	
	auto binomial = [&](int a, int b){
		if(a < b) return 0;
		return mul(fac[a], my_inv(mul(fac[b], fac[a - b])));
	};
	
	vector<int> a(n);
	for(int i = 0; i<n; ++i){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i = 0; i < n - 1; i++){
		int diff = (a[i + 1] - a[i]) % MOD;
		int ways = binomial(n, k);
		sub_self(ways, binomial(i + 1, k));
		sub_self(ways, binomial(n - i - 1,k));
		ans = (ans + mul(diff, ways)) % MOD;
	}
	cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
 
using namespace std;
 
const int N = 2e5 + 10;
int pre[N];
 
int find(int a)
{
	if(a != pre[a]) pre[a] = find(pre[a]);
	return pre[a];
}
 
int cnt[N];
 
int main()
{
	int n;
	int m;
	cin>>n>>m;
	for(int i=1; i<=n; i++) pre[i] = i,cnt[i] = 1;
	for(int i=1; i<=m; i++)
	{
		int a,b;
		cin>>a>>b;
		int pa = find(a);
		int pb = find(b);
		if(pa != pb)
		{
			pre[pa] = pb;
			cnt[pb]+=cnt[pa];
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++) ans = max(cnt[i], ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4720
import java.io.*;
  
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line;
        LOOP: while ((line = input.readLine()) != null) {
            int line_len = line.length();
            if (line_len == 1 && line.charAt(0) == '0')
                break LOOP;
            long total = 0;
            for (int i = 0; i < line_len; i++) {
                total += line.charAt(i) - '0';
            }
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 24212
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, dat[200009], a;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        cin >> a;
        dat[a]++;
    }
    for (int i = 0; i < n; i++) {
        cout << dat[i + 1] << E;
    }
    //system("pause");
    return 0;
}

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

        int n = console.nextInt();
        int m = console.nextInt();
        int c = console.nextInt();
        console.nextLine();

        int listB[];
        listB = new int[m];
        for(int i = 0; i < m; i++){
            listB[i] = console.nextInt();
        }
        console.nextLine();

        int listA[][];
        listA = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                listA[i][j] = console.nextInt();
            }
            console.nextLine();
        }

        int answer = 0;
        for(int i = 0; i < n; i++){
            int num = c;
            for(int j = 0; j < m; j++){
                num += (listA[i][j] * listB[j]);
            }
            if(num > 0){
                answer++;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 36268
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int K = cin.nextInt();
        int ans = 1;
 
        for(int i = 0; i < N; i++){
            int ans_1 = ans * 2;
            int ans_2 = ans + K;
            if(ans_1 >= ans_2)
                ans = ans_2;
            else if(ans_2 >= ans_1)
                ans = ans_1;
        }
 
        System.out.println(ans);
 
        cin.close();
    }
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	string S[2];
	cin >> S[0];
	cin >> S[1];
	int i = 0;
	vector<int> vec;
	while (i < N) {
		if (S[0][i] == S[1][i]) {
			vec.push_back(0);
			i++;
		}
		else {
			vec.push_back(1);
			i += 2;
		}
	}
	ll ans;
	if (vec[0]) ans = 6;
	else ans = 3;
	for (int i = 1; i < vec.size(); i++) {
		if (vec[i - 1]) {
			if (vec[i]) (ans *= 3) %= MOD;
		}
		else {
			(ans *= 2) %= MOD;
		}
	}
	cout << ans << endl;
 }

Measured memory_bytes: 256
def yymm(x):
    a = x[2]+x[3]
    return a in ['01','02','03','04','05','06','07','08','09','10','11','12']

def mmyy(x):
    a = x[0]+x[1]
    return a in ['01','02','03','04','05','06','07','08','09','10','11','12']

S = input()
if yymm(S) and mmyy(S):
    print("AMBIGUOUS")
elif not(yymm(S)) and mmyy(S):
    print("MMYY")
elif yymm(S) and not(mmyy(S)):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000000)
H, W = map(int, input().split())
S = [input() for _ in range(H)]
seen = [[0]*W for _ in range(H)]


def rec(h,w,seen):
	if S[h][w] == '.':
		res = [1, 0]
	else:
		res = [0, 1]
	dh = [-1, 1, 0, 0]
	dw = [0, 0, -1, 1] 
	seen[h][w] = 1
	for i in range(4):
		nh = h+dh[i]
		nw = w+dw[i]
		if 0 <= nh <= H-1 and 0 <= nw <= W-1:
			if seen[nh][nw] == 0 and S[nh][nw] != S[h][w]:
				r0, r1 = rec(nh, nw, seen)
				res[0] += r0
				res[1] += r1
					
	return res

ans = 0
for h in range(H):
	for w in range(W):
		if seen[h][w] != 1:
			t0, t1 = rec(h, w, seen)
			ans += t0 * t1
print(ans)


Measured memory_bytes: 210900
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define endl '\n'
ll dp[3005][3005];
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	string s,t;
	getline(cin,s);
	getline(cin,t);
	for(ll i=1;i<=s.length();i++)
	{
		for(ll j=1;j<=t.length();j++)
		{
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans="";
	ll i=s.length(),j=t.length();
	while(i>0 && j>0)
	{
		if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==t[j-1])
		{
			ans=s[i-1]+ans;
			i--;
			j--;
		}
		else if(dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready, resolve
    string S;
    int s,t;
    cin >> S;

    for (int i=0; i<S.size(); i++) cout << "x";
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repe(i,x) for (edge *i=fst[x]; i; i=i->nxt)
using namespace std;

int n,l[100100],r[100100],root;
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void dfs1(int x,int fa)
{
    repe(i,x)
        if (i->v!=fa)
            dfs1(i->v,x),l[x]=max(l[x],l[i->v]-1),r[x]=min(r[x],r[i->v]+1);
    if (l[x]>r[x])
    {
        puts("No");
        exit(0);
    }
}

void dfs2(int x,int fa)
{
    repe(i,x)
        if (i->v!=fa)
            if (l[x]-1>=l[i->v] && l[x]-1<=r[i->v])
                l[i->v]=r[i->v]=l[x]-1,dfs2(i->v,x);
            else
                if (l[x]+1>=l[i->v] && l[x]+1<=r[i->v])
                    l[i->v]=r[i->v]=l[x]+1,dfs2(i->v,x);
                else
                {
                    puts("No");
                    exit(0);
                }
}

int main()
{
    n=getint();
    repu(i,1,n-1)
    {
        int u=getint(),v=getint();
        *tp=(edge){u,fst[v]},fst[v]=tp++;
        *tp=(edge){v,fst[u]},fst[u]=tp++;
    }
    repu(i,1,n)
        l[i]=-1<<30,r[i]=1<<30;
    for (int k=getint(); k--;)
        root=getint(),l[root]=r[root]=getint();
    dfs1(root,0),dfs2(root,0);
    puts("Yes");
    repu(i,1,n)
        printf("%d\n",l[i]);
    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int k;
  cin >> k;
  ll now = 7;
  int ans = 1;
  map<int, bool> mp;
  while (now % k != 0) {
    if (now > k) {
      while (now > k) now -= k;
    }
    now %= k;
    if (mp[now]) {
      cout << -1 << endl;
      return;
    }
    mp[now] = true;
    //cout << now << endl;
    if (now == 0) break;
    now *= 10;
    now += 7;
    ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 50424
import sys

s = input()
t = input()
a = len(s)
b = len(t)
c = sys.maxsize
for i in range(a - b + 1):
    d = 0
    for k in range(b):
        if t[k] != s[i+k]:
            d += 1
    c = min(d, c)
print(c)


Measured memory_bytes: 9052
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  set_bool_name("Alice", "Borys");
  int n, a, b;
  cin >> n >> a >> b;
  cout << (a % 2 == b % 2) << endl;
}



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

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

const double PI=acos(-1.0);

int N,M; vpii P;
void input()
{
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b; cin>>a>>b; 
        P.emplace_back(make_pair(a,b));
    }
    return;
}

void solve()
{
    sort(P.begin(),P.end());
    vi tmp(N,-1);
    for(int i=0;i<M;++i){
        if(tmp[P[i].first-1]==-1) tmp[P[i].first-1]=P[i].second;
        else{
            if(tmp[P[i].first-1]!=P[i].second){
                cout<<"-1"<<endl;
                return;
            }
        }
    }
    int ans=0;
    if(N>1) {
        if(tmp[0]==0){
            cout<<"-1"<<endl; return;
        }
        else if(tmp[0]==-1) tmp[0]=1;
    }
    for(int i=0;i<N;++i){
        if(tmp[i]==-1) tmp[i]=0;
    }
    for(int i=0;i<N;++i) ans=ans*10+tmp[i];
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <set>
using namespace std;

int main() {
  int qq;
  scanf("%d", &qq);
  qq--;
  int tf, xf, sampahf;
  scanf("%d %d %d", &tf, &xf, &sampahf);
  multiset<int> left, right;
  long long val = 0, left_sum = xf, right_sum = 0, b = sampahf;
  left.insert(xf);
  while (qq--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x, sampah;
      scanf("%d %d", &x, &sampah);
      b += sampah;
      if (x <= *left.rbegin()) {
        left.insert(x);
        left_sum += x;
        if (left.size() == right.size() + 2) {
          int era = *left.rbegin();
          left.erase(left.find(era));
          right.insert(era);
          left_sum -= era;
          right_sum += era;
        }
      } else {
        right.insert(x);
        right_sum += x;
        if (right.size() > left.size()) {
          int era = *right.begin();
          right.erase(right.find(era));
          left.insert(era);
          right_sum -= era;
          left_sum += era;
        }
      }
      long long med = *left.rbegin();
      val = (med * left.size() - left_sum) + (right_sum - med * right.size());
    }
    if (t == 2) {
      printf("%d %lld\n", *left.rbegin(), val + b);
    }
  }
  return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int w,a,b;
  cin>>w>>a>>b;
  int ans;
  if(b + w < a) {
    ans = a - (b + w);
  } else if(a + w < b) {
    ans = b - (a + w);
  } else {
    ans = 0;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int N,M,Q;
  int list[502][502] = {0};
  int ruiseki[502][502] = {0};

  cin >>N>>M>>Q;

  for(int i = 0;i < M;i++){
    int x,y;
    cin >>x>>y;
    list[x][y]++;
  }


  for(int i = 0;i<=N;i++){
    for(int j = 1;j <= N;j++){
      ruiseki[i][j] = list[i][j]+ruiseki[i][j-1];
    }
  }

  for(int i= 0;i<Q;i++){
    int L,R,sum = 0;cin >>L>>R;
    for(int j = L;j<=R;j++){
      sum += ruiseki[j][R]-ruiseki[j][L-1];
    }
    cout <<sum<<endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include <iostream>

using namespace std;
 
int main() {
    while(true) {
    	int h, w;
    	cin >> h >> w;
    	if(h==0 && w==0) {
    		break;
    	}
    	for(int i=0; i<h; i++) {
    		for(int j=0; j<w; j++) {
    			cout << "#";
    		}
    		cout << endl;
    	}
    	cout << endl;
    }
}


Measured memory_bytes: 3100
#AtCoder Beginner Contest 132 A問題
S=input()
A=[S[0]]
for i in range(4):
    if S[0]!=S[i]:
        A+=S[i]
A=list(set(A))

if len(A)==2:
    cou=S.count(S[0])
    if cou==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    cin >> n;
    vector<LL> a_sum(n);
    LL a;
    LL kiyu=0;
    LL sum_m=0;
    LL sum_p=0;
    LL ans_m=0;
    LL ans_p=0;
    for(LL i=0; i<n; i++){
        cin >> a;
        kiyu+=a;
        a_sum[i]=kiyu;
    }

    for(LL i=0; i<n; i++){
        if(i%2==0){
            if(a_sum[i]+sum_m>=0){
                ans_m=ans_m+(a_sum[i]+sum_m+1);
                sum_m=sum_m-(a_sum[i]+sum_m+1);
            }
        }else{
            if(a_sum[i]+sum_m<=0){
                ans_m=ans_m-(a_sum[i]+sum_m-1);
                sum_m=sum_m-(a_sum[i]+sum_m-1);
            }
        }
        //cout << ans_m << " " << sum_m << endl;
    }

    for(LL i=0; i<n; i++){
        if(i%2==0){
            if(a_sum[i]+sum_p<=0){
                ans_p=ans_p-(a_sum[i]+sum_p-1);
                sum_p=sum_p-(a_sum[i]+sum_p-1);
            }
        }else{
            if(a_sum[i]+sum_p>=0){
                ans_p=ans_p+(a_sum[i]+sum_p+1);
                sum_p=sum_p-(a_sum[i]+sum_p+1);
            }
        }
        //cout << ans_p << " " << sum_p << endl;
    }

    cout << min(ans_p, ans_m) << endl;

    return 0;
}


Measured memory_bytes: 4024
package main

import (
        "fmt"
)

func solution(s, t string) string {
        if s == t[:len(t)-1] {
                return "Yes"
        }
        return "No"
}

func main() {
        var s, t string
        fmt.Scan(&s, &t)
        fmt.Println(solution(s, t))
}


Measured memory_bytes: 1752
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 15:49:43 2020

@author: naoki
"""

X,N = map(int,input().split()) # input X and N 
p = list(map(int,input().split())) # input the row of integer 
p.sort() # sorting the row "p"
p1 = [ i for i in range(-101,102)] # making the other row of integer -100<= i <= 100 
gap = 201
row = []
for i in range(N):
    p1.remove(p[i]) # removing the number which is same to p[i]

for i in p1:
    if gap >= abs(X-i):
        gap = abs(X-i)
 
num1 = X-gap
num2 = X+gap

if num1 in p1:
    print(num1)
elif num2 in p1:
    print(num2)
    


        




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

int main() {
	int K;
	string S;
	cin >> K >> S;

	if(S.size() <= K){
		cout << S << endl;
	}else{
		string ans;
		for(int i=0;i<K;i++){
			ans.push_back(S.at(i));
		}
		ans.push_back('.');
		ans.push_back('.');
		ans.push_back('.');
		cout << ans << endl;
	}
}


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

int main(void)
{
    int i;
    int n;
    long long sum;
    long long temp;
    long long ans;
    long long kotae;
    cin >> n;
    long long a[n];
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    sum = 0;

    for(i = 0; i < n; i++){
        sum = sum +a[i];
    }

    kotae = 2*a[0] - sum;
    if(kotae < 0){
        kotae = kotae * -1;
    }

    temp = a[0];
    for(i = 1; i < n-1; i++){
        ans = 0;
        temp = temp + a[i];
        ans = 2*temp - sum;
        //絶対値処理
        if(ans < 0){
            ans = ans * -1;
        }
        if(ans < kotae){
            kotae = ans;
        }
        if(kotae == 0){
            break;
        }
        
    }

    cout << kotae << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
class MainClass {
  public static void Main (string[] args) {
    string input = Console.ReadLine();
    long[] arr = input.Select(x => long.Parse(x.ToString())).ToArray();

    Console.WriteLine(arr.Sum() % 9 == 0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 26124
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    s = input()
    if s == "RRR":
        print(3)
    elif "RR" in s:
        print(2)
    elif "R" in s:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
def kk(n,m):
    if n<m:
        n,m=m,n
    while  n%m!=0:
        n=n%m
        n,m=m,n
    return m


k= int(input())
count=0
for p in range(1,k+1):
    for q in range(p,k+1):
        pq=  kk(p,q)
        for r in range(q,k+1):
            pqr= kk(pq,r)
            if p==r:
                 pqr=pqr
            elif p==q or q==r:
                pqr=pqr*3
            else:
                pqr=pqr*6
            count= count+ pqr
print(count)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T> vector<T> divisor(T N) {
    vector<T> ret;
    if (N == 1) {
        ret.emplace_back(1);
        return ret;
    }
    if (N <= 0) {
        return ret;
    }
    for (unsigned long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.emplace_back(i);
            if (i != 1 && i * i != N) {
                ret.emplace_back(N / i);
            }
        }
    }
    ret.emplace_back(N);
    return ret;
}

int main() {
    ll N;
    cin >> N;

    auto divs = divisor(N);
    ll ans    = (1LL << 60);
    for (auto &&i : divs) {
        ll cnt = (i - 1) + (N / i - 1);
        chmin(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
if __name__ == "__main__":
	N = int(input())
	a = list(map(int, input().split()))
	ans = 0
	num = 1
	flag = False
	for i in range(N):
		if num == a[i]:
			num += 1
			flag = True
		else:
			ans += 1
	if flag:
		print(ans)
	else:
		print("-1")

Measured memory_bytes: 24744
#include <iostream>

using namespace std;

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

	int x1 = n / 10;
	int x2 = n % 10;

	bool ok = (x1 % 111 == 0) || (x2 % 111 == 0);
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  

mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;
const int N = 5e5 + 123;

int n, m, k;
int a[N] , b[N];
int pra[N] , prb[N];
string s;

main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m;
  	
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	for(int j = 1; j <= m; j++)
		cin >> b[j];

	for(int i = 1; i <= n; i++){
		if(a[i] < 0)
			a[i] += mod;

		a[i]%=mod;
		pra[i] = pra[i - 1]%mod + a[i];
		pra[i] %= mod;
	}
	int tot = 0;
	for(int i = 1; i <= m; i++){
		if(b[i] < 0)b[i] += mod;
		b[i] %= mod;
		tot += (b[i] * (i - 1) % mod - prb[i - 1] + mod) % mod;
		tot %= mod;
        prb[i] = prb[i - 1]%mod + b[i]%mod;
        prb[i] %= mod;
	}
	int tot2 = 0;
	for(int i = 1; i <= n; i++){
		tot2 += (a[i] * (i - 1) % mod - pra[i - 1] + mod) % mod;
		tot2 %= mod;
	}
	cout << tot2 * tot % mod;

}
 


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

int main(){

    int N,M;
    cin >> N >>M;

    vector<int> v(N);
    for(auto& temp:v){
        cin >> temp;
    }

    int sum;
    sum = accumulate(v.begin(),v.end(),0);
    
    int pn=0;

    double s = sum/(4.0*M);

    for(int i = 0;i<N;i++){
        if(v[i]>=s){
            pn++;
        }
    }

    if(pn >= M)cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    println!("{}", if a <= c && c <= b { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, cnt[4] = {0,0,0,0};
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AC") cnt[0]++;
    else if (s == "WA") cnt[1]++;
    else if (s == "TLE") cnt[2]++;
    else cnt[3]++;
  }
  cout << "AC" << " x " << cnt[0] << '\n' << "WA" << " x " << cnt[1] << '\n' << "TLE" << " x " << cnt[2] << '\n' << "RE" << " x " << cnt[3] << '\n';
  return 0;
}

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

int main()
{
    int n, a;
    cin >> n >> a;
    n %= 500;
    if(a >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{

  int n;
  cin>>n;
  int a[n];
  fr(i,n)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  fr(i,n)
  {
      frf(j,i+1,n-1)
      {
          if(a[i]==a[j])continue;
          frf(k,j+1,n-1)
          {
              if(a[j]==a[k] || a[i]==a[k])continue;
              if(a[i]+a[j]>a[k] && a[i]>a[k]-a[j])
              ans++;
          }
      }
  }
  cout<<ans;
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3652
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  map<ll,ll> mp;
  for(ll i=2;i*i<=n;i++){
    ll cnt = 0;
    while(n%i==0){
      n /= i;
      cnt++;
    }
    if(cnt!=0){
      mp[i] = cnt;
    }
  }
  if(n!=1){
    mp[n] = 1;
  }
  for(auto m: mp){
    ll l=1,r=m.second;
    while(r-l>1){
      ll h = (r+l)/2;
      ll v = m.second - ((h+1)*h)/2;
      if(v>=0){
        l = h;
      }else{
        r = h;
      }
    }
    ans += l;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-6;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll mul(ll a,ll b){ll ans=0;a%=mod,b%=mod;while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }return ans;}
ll powmod(ll a,ll b){ ll ans = 1, pow = a; while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; } return ans;}
//(b/a)%p=b*a^(p-2)%p
//int pr(ll num){//判素
//     if(num == 1) return 0;
//     if(num ==2|| num==3 ) return 1 ;
//     if(num %6!= 1&&num %6!= 5) return 0 ;
//     int tmp =sqrt( num);
//     for(int i= 5;i <=tmp; i+=6 )
//          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
//     return 1 ;
//}
int Day(int y,int m, int d){if(m==1||m==2) { m+=12; y--; }int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;return w+1;}
//int pri[10000005];
//void getpri(){
//    memset(pri,true,sizeof(pri));
//    pri[0]=pri[1]=0;
//    for(int i=2;i<=10000000;i++){
//        if(pri[i]){
//            for(int j=2*i;j<=10000000;j+=i) pri[j]=0;
//        }
//    }
//}
//struct ac{
//    int x,y;
//    int fa;
//} pre[10000005];
//void init(){
//    for(int i=1; i<=10000005;++i) pre[i].fa=i;
//}
//int getf(int x){
//    if(pre[x].fa == x) return x;
//    else return pre[x].fa = getf(pre[x].fa);
//}
//void join(int x,int y){
//    int a = getf(x);
//    int b = getf(y);
//    if(a!=b) pre[b].fa=a;
//}
//大小写转换
//String s;
//Form(s.begin(),s.end(),s.begin(),::toupper);
//Form(s.begin(),s.end(),s.begin(),::tolower);
//(char)toupper('a')
//(char)tolower('B')
//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec
//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址
const int maxn=2e5+5;
double a[3005];
double dp[3005][3005]={0};
int main(){
    int n;
    cin>>n;
    dp[0][0]=1.00;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    for(int i=0;i<=n;++i){
        for(int j=0;j<=i;++j){
            int x=j,y=i-j;
            if(x) dp[x][y]+=dp[x-1][y]*a[i];
            if(y) dp[x][y]+=dp[x][y-1]*(1-a[i]);
        }
    }
    double ans=0;
    for(int i=0;i<=n;++i){
        if(2*i>n) ans+=dp[i][n-i];
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 49824
#!/usr/bin/env python3
import sys
import heapq


def solve(N: int, v: "List[int]"):
    heapq.heapify(v)
    while v:
        mix = (heapq.heappop(v) + heapq.heappop(v)) / 2
        heapq.heappush(v, mix)

        if len(v) == 1:
            break
    print(*v)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064