akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
            readint(x); readint(n);
            set<int> p;
            forr(i,0,n) {
                readint(kk);
                p.insert(kk);
            }
            int ret = 1000;
            int min_dist = 1000;
            for(int poss = 300; poss > -300; poss--) {
                if (!set_map_includes(p, poss)) {
                  if (abs(poss-x)<=min_dist) {
                      min_dist = abs(poss-x);
                      ret = min(ret, poss);
                  }
                }
            }
            cout << ret << endl;

    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  int H,W,h,w,i=1,j;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    for(;i<=H;++i,puts("")) for(j=1;j<=W;++j)
      printf("%d ",(i%h||j%w)?1000:-1000*(h*w-1)-1);
  }else puts("No");
  return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 998244353;
int N, M, K;
ll Comb[200005], Zyo[200005]; // n-1Ck.

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

// a^{-1} mod を計算する
ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

void init(){
  Comb[0] = 1ll;
  rep(i, N) {
    Comb[i+1]=Comb[i]*(N-1-i)%MOD*modinv(i+1);
    Comb[i+1]%=MOD;
  }
  Zyo[0] = 1ll;
  rep(i, N) {
    if (i==0) continue;
    Zyo[i] = Zyo[i-1]*(M-1);
    Zyo[i]%=MOD;
  }
}

// 隣り合う組で同じ色で塗られているのをK色と固定
// 左端の色はM通り、それ以外は左と違う色がN-1-K, 同じがK個。それの並べ替え
// M*n-1Ck*(M-1)^(N-1-K)*1^K

int main() {
  INCANT;
  cin >> N >> M >> K;
  init();
  ll SUM=0;
  rep(i, K+1) {
    SUM += M*Comb[i]%MOD*Zyo[N-1-i];
    SUM%=MOD;
  }
  if (SUM<0) SUM+=MOD;

  cout << SUM << "\n";
  return 0;
}

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

typedef long long LL;
const int N = 2e5+7;

pair<int, int> pr[N];
LL x[N], h[N];
int rr[N];

LL add[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, d, a;
    cin>>n>>d>>a;

    for (int i=1; i<=n; i++) {
        cin>>pr[i].first>>pr[i].second;
    }

    sort(pr+1, pr+n+1);
    for (int i=1; i<=n; i++) {
        x[i] = pr[i].first;
        h[i] = pr[i].second;
    }

    int r = 0;
    for (int l=1; l<=n; l++) {
        while (r+1 <= n && x[r+1]-x[l] <= 2*d)   r++;
        rr[l] = r;
    }

    LL sub = 0, ans = 0;
    for (int i=1; i<=n; i++) {
        h[i] -= sub;
        if (h[i] > 0) {
            LL need = (h[i] + a-1)/a;
            ans += need;
            LL total = need * a;
            h[i] -= total;
            sub += total;
            add[rr[i]] += total;
        }

        assert(h[i] <= 0);
        sub -= add[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7296
program rain_flows_into_dams
  implicit none
  integer :: n, i
  integer(8) :: a(100000), x(100000), s, t
  a = 0_8
  x = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  s = sum(a(1:n))/2_8
  t = sum(a(1:n:2))
  x(1) = t-s
  do i = 2, n
    x(i) = a(i-1)-x(i-1)
  end do
  x(n) = a(n)-x(1)
  x(1:n) = 2_8*x(1:n)
  write(*,'(i0)',advance='no') x(1)
  do i = 2, n
    write(*,'(x,i0)',advance='no') x(i)
  end do
  write(*,*)
  stop
end program rain_flows_into_dams

Measured memory_bytes: 3456
require 'bigdecimal'

height = []
x = gets
until x.nil?
 y = x.to_f
 height << y
 x = gets
end

maxh = height.max
minh = height.min
maxs = maxh.to_s
mins = minh.to_s 
ansf = (BigDecimal(maxs) - BigDecimal(mins)).to_f
ans = ansf.floor(2)
puts ans


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

void work()
{
    int n, m, k;
    cin >>n >>m >>k;

    cout <<min((k + n - 1) / n, (k + m - 1) / m);
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int x,y;
  x = a*b;
  y = x%2;
  if (y <= 0) {
    cout << "Even" << endl;
  }
  else if (y > 0) {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    ll total = 0;
    rep(a, 1, k+1) {
        rep(b, a, k+1) {
            rep(c, b, k+1) {
//                cout << a << b << c << endl;
                if (a == b) {
                    if (b == c) {
                        total += a;
                    } else {
                        total += gcd(b, c) * 3;
                    }
                } else {
                    if (b == c) {
                        total += gcd(a, b) * 3;
                    } else {
                        total += gcd(gcd(a, b), c) * 6;
                    }
                }
            }
        }
    }

    cout << total << '\n';

    return 0;
}


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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);

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


int n;
ll x;

ll ans;

int main(void){
  scanf("%d %lld", &n, &x);
  for (int i = 0; i < n; ++i) {
    ll tmp;
    scanf("%lld", &tmp);
    ans = gcd(ans, abs(x - tmp));
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#define rep( i, a, n ) for( int i = a; i < n; i++ )
#define per( i, a, n ) for( int i = n - 1; i >= a; i-- )
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define INF 0x3f3f3f3f

using namespace std;
const int N = 1500;
const int M = 35;
const int MAX = 5;
const double g = 9.80;
const double PI = acos( -1.0 );
int m, n, pos, t;
ll k;
char s[N];

int main( ){
    while( scanf( "%s", s ) != EOF ){
        scanf( "%lld", &k );
        int len = strlen( s );
        pos = -1;
        rep( i, 0, len ){
            if( s[i] != '1' ){
                pos = i + 1;
                break;
            }
        }
        if( k < pos || pos == -1 )
            cout << "1" << '\n';
        else
            cout << s[pos-1] << '\n';
    }
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  vector<char> v;
  rep(i,s.size()){
    if(s[i]=='0'){
      v.push_back('0');
    }
    if(s[i]=='1'){
      v.push_back('1');
    }
    if(s[i]=='B'){
      if(v.size()>=1) v.pop_back();
    }
  }
  rep(i,v.size()){
    cout<<v[i];
  }
  cout<<endl;
  
}
///////////////////////////



Measured memory_bytes: 256
#include <stdio.h> 

int main(void){
    int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	
	if(0<=a,b,c<=10000){
	    if(a<b){
	    	if(a<=c){
	    		if(b<=c){
	    		printf("%d %d %d\n",a,b,c);
	    		}if(c<b){
	    		printf("%d %d %d\n",a,c,b);
	    		}
	    	}
	    	if(c<a){
    			printf("%d %d %d\n",c,a,b);
	    	}
	    }
    	if(b<a){
    		if(b<=c){
	    		if(c<a){
	    		printf("%d %d %d\n",b,c,a);
	    		}if(a<=c){
	    		printf("%d %d %d\n",b,a,c);
	    		}
	    	}
	    	if(c<b){
    			printf("%d %d %d\n",c,b,a);
	    	}
	}
	}
    return 0;
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int H, W, N;
    cin>>H>>W>>N;
    vector<pint> point; 
    map<pint, bool> p;
    REP(i, 0, N){
        int a, b;
        cin >> a >> b;
        a--; b--;
        point.push_back({a, b});
        p[{a, b}] = true;
    }
    vl ans(10);

    REP(i, 0, N){
        pint cur = point[i];
        REP(j, 0, 9){
            pint pad = {j/3-1, j%3-1};
            int count = 0;
            if(cur.first + pad.first < 1 || cur.second + pad.second < 1 || cur.first + pad.first > H-2 || cur.second + pad.second > W-2) continue;
            REP(k, 0, 9){
                pint search = {k/3-1, k%3-1};
                pint searchGrid = {cur.first + search.first + pad.first, cur.second + search.second + pad.second};
                if(p[{searchGrid.first, searchGrid.second}]) count++;
            }
            //cout << cur.first + pad.first << " " << cur.second + pad.second << " " << count << endl;;
            ans[count]++; 
        }
    }
    long sum = 0;
    REP(i, 1, 10){
        ans[i] /= i;
        sum += ans[i];
    }
    ans[0] = (long)(H-2) * (long)(W-2) - sum;
    REP(i, 0, 10){
        cout << ans[i] << endl;
    }
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B && B!=C){
    cout<<C<<endl;
  }
  if(A==C && C!=B){
    cout<<B<<endl;
  }
  if(B==C && C!=A){
    cout<<A<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD (1000000007)
typedef long long ll;

const int N=4010, D=N>>1, M=1e4, B=2e5+10;
int f[N][N];
int inv[M], fac[M];
int C(int i, int j) {
    return 1ll*fac[i]*inv[j]%MOD*inv[i-j]%MOD;
}
int a[B], b[B];

int main() {
    inv[0]=fac[0]=inv[1]=fac[1]=1;
    for(int i=2;i<M;i++) inv[i]=(-1ll*(MOD/i)*inv[MOD%i]%MOD+MOD)%MOD, fac[i]=1ll*fac[i-1]*i%MOD;
    for(int i=2;i<M;i++) inv[i]=1ll*inv[i]*inv[i-1]%MOD;
    
    ios::sync_with_stdio(false), cin.tie(0);
    int n, ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i]>>b[i];
        ans=(ans-C(a[i]*2+b[i]*2, 2*a[i])%MOD)%MOD;
        f[-a[i]+D][-b[i]+D]++;
    }
    for(int i=1;i<N;i++)
    for(int j=1;j<N;j++) f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%MOD;
    for(int i=1;i<=n;i++) ans=(ans+f[a[i]+D][b[i]+D])%MOD;
    printf("%d\n", (1ll*ans*inv[2]%MOD+MOD)%MOD);
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
using namespace std;


int main(){

	int n, k;
	cin >> n >> k;
	int a = 1;
	while(n --){
		a = min(a * 2, a + k);
	}
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n,K;
    scanf("%d%d", &n, &K);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    ll ans = LINF;
    for (i = 0; i <= n - K; i++) {
        int j = i + K - 1;
        ll ans0 = a[j] - a[i];
        ans0 += MIN(abs(a[i]), abs(a[j]));
        ans = MIN(ans, ans0);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

int main()
{
    int n, wMax;
    cin >> n >> wMax;
    vector<int> w(n), v(n);
    for(int i=0; i<n; ++i)
        cin >> w[i] >> v[i];

    int vMax = accumulate(v.begin(), v.end(), 0);
    vector<long long> dp(vMax+1, INF);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        for(int j=vMax-v[i]; j>=0; --j){
            dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
        }
    }

    int ans = vMax;
    while(dp[ans] > wMax)
        -- ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 
public class Main{
	class Node{
		ArrayList<Node> child;
		int c;
		public Node(){
			child = new ArrayList<>();
		}
	}
	Node current;
	String line;
	int idx;
	public void solve(){
		int N = nextInt();
		for(int i = 0; i < N; i++){
			Node root = new Node();
			line = next();
			idx = 1;
			out.println(recur());
		}
	}
	
	public int recur(){
		char c = line.charAt(idx++);
		ArrayList<Integer> list = new ArrayList<>();
		int num = 0;
		while(c != ']'){
			if(c == '['){
				list.add(recur());
			}else{
				num = num * 10 + (c - '0');
			}
			c = line.charAt(idx++);
		}
		if(list.size() > 1){
			Collections.sort(list);
			int l = list.size() / 2 + 1;
			for(int i = 0; i < l; i++){
				num += list.get(i);
			}
			return num;
		}else{
			return num / 2 + 1;
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

using namespace std;

template<class T> T reversed(T &c){
  T r;
  r.reserve(c.size());
  reverse_copy(c.begin(),c.end(), back_inserter(r));
  return r;
}


int main(){
  string s,f,l;
  cin >> s;
  f = s.substr(0,(s.length()-1)/2);
  l = s.substr((s.length()+3)/2-1);

  if(s == reversed(s) &&
     f == reversed(f) &&
     l == reversed(l)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// template <class... Args>
// auto create(size_t n, Args &&... args)
// {
//     if constexpr (sizeof...(args) == 1)
//         return vector(n, args...);
//     else
//         return vector(n, create(args...));
// }

// template <typename... T>
// void read(T &... args)
// {
//     ((cin >> args), ...);
// }

// template <typename... T>
// void write(T &&... args)
// {
//     ((cout << args), ...);
// }

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<int> dp(k + 1, false);
    for (int i = 1; i <= k; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i - arr[j] < 0)
            {
                break;
            }
            if (dp[i - arr[j]] == false)
            {
                dp[i] = true;
                break;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second");
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 3928
require 'pp'

s = gets.chomp.chars

sr = s.reverse

cnt = 0

i = 0
s.zip(sr).each do |(a1,a2)|
  cnt += 1 if a1 != a2
  i += 1
  break if i == s.size / 2
end
p cnt

# p s
# p sr
# 1 0 2


Measured memory_bytes: 2044
import java.util.*;
import java.lang.Math;

class Dice{
    public static int[] saikoro(String h, int[] d){
        int surface = 0;
            switch (h) {
            case "E":
                surface = d[4];
                d[4] = d[6]; d[6] = d[3]; d[3] = d[1]; d[1] = surface;
                break;
                
            case "W":
                surface = d[3];
                d[3] = d[6]; d[6] = d[4]; d[4] = d[1]; d[1] = surface; 
                break;
                
            case "S":
                surface = d[5];
                d[5] = d[6]; d[6] = d[2]; d[2] = d[1]; d[1] = surface; 
                break;
                
            case "N":
                surface = d[2];
                d[2] = d[6]; d[6] = d[5]; d[5] = d[1]; d[1] = surface; 
                break;
                
            }
        return d;
    }
}
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[7];
        int[] d = new int[7];
        for(int i=0;i<6;i++){
            a[i+1] = sc.nextInt();
        }
        for(int i=0;i<6;i++){
            d[i+1] = sc.nextInt();
        }
        String[] s = {"W", "E", "S", "N"};
        String h = "";
        int num =0;
        for(int i=0;i<1000;i++){
            num = (int)(Math.random()*4);
            h = s[num];
            Dice.saikoro(h, d);
            if(Arrays.equals(a,d)){
                System.out.println("Yes");
                break;
            }
            if(i==1000-1){
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 26452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) cout << C << "\n";
    if (B == C) cout << A << "\n";
    if (A == C) cout << B << "\n";
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




int i,n,a[23],b[23],c[23],ans;

int main()
{
    FAST();

    //    freopen("input.txt","r",stdin);
    //    freopen("input.txt","w",stdout);

    cin >> n;
    for(i=1; i<=n; i++)cin >> a[i];
    for(i=1; i<=n; i++)cin >> b[i];
    for(i=1; i<n; i++)cin >> c[i];
    ans=b[a[1]];
    for(i=2; i<=n; i++)
    {
        ans+=b[a[i]];
        if(a[i]-a[i-1] == 1)
        {
            ans+=c[a[i]-1];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if i==0 and a[i]==i+1:
        tmp=a[i]
        a[i]=a[i+1]
        a[i+1]=tmp
        ans+=1
    elif 0<i<n-1 and a[i]==i+1:
        if a[i+1]==i+2 or a[i-1]==i+1:
            tmp=a[i]
            a[i]=a[i+1]
            a[i+1]=tmp
            ans+=1
        else:
            tmp=a[i]
            a[i]=a[i-1]
            a[i-1]=tmp
            ans+=1
    elif i==n-1 and a[i]==i+1:
        tmp=a[i]
        a[i]=a[i-1]
        a[i-1]=tmp
        ans+=1
print(ans)

Measured memory_bytes: 52588
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int M;
  std::cin >> M;
  std::vector<int > d(M);
  std::vector<long long > c(M);
  long long ans = 0;
  long long sum = 0;
  for (int i=0; i<M; i++) {
    std::cin >> d[i] >> c[i];
    ans += c[i];
    sum += c[i]*(long long)d[i];
  }
  while(sum/10>0) {
    ans += sum/10;
    sum = sum%10 + sum/10;
  }
  ans--;
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 5172
#include<stdio.h>
	void swap(int *x,int *y){
		int m;
		if(*x<*y){
			m=*x;
			*x=*y;
			*y=m;
		}
}
		
	int main(){
		int a[5],i,j;
		scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
		for(i=0;i<5;i++)
			for(j=0;j<4;j++)
			swap(&a[j],&a[j+1]);
		printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
		return 0;
	}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

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

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(10006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


ll dp[4005][4005] = {};
ll dp2[4005][4005] = {};
int main(){
	//ios_base::sync_with_stdio(false);
	ll N, K, ans=0;

	cin >> N >> K;

	dp[0][0] = 1;
	rep(i,2*N) rep(j,2*N){
		dp[i][j] %= MOD;
		dp[i+2][j+1] += dp[i][j];
		dp[i+1][j+0] += dp[i][j];
	}
	// rep(i,2*N){
	// 	rep(j,2*N) cout << dp[i][j] << " ";
	// 	cout << endl;
	// }

	dp2[0][0] = 1;
	rep(i,2*K){
		rep(j,2*N) dp2[i+1][j] += dp2[i][j];
		rep(j,N){
			//int m = (N - 1 - i) / K;
			int m = (N - 1 - i) / K;
			if( i >= K ) m = (N - 1 - i + K) / K;
			reps(k,1,m+1){
				dp2[i+1][j+k] += dp2[i][j] * dp[m+1][k];
				dp2[i+1][j+k] %= MOD;
			}
		}
	}
	//rep(i,N+N) cout << dp2[2*K][i] << ", ";
	//cout << endl;

	rep(i,N+N){
		ans += MOD;
		ans += dp2[2*K][i] * (i%2 ? -1 : +1) * fact[N - i];
		ans %= MOD;
		//cout << i << " : " << dp2[2*K][i] * (i%2 ? -1 : +1) * fact[N - i] << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 250880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N,M; cin >> N >> M;
  int maxL = 0;
  int minR = 1e9;
  rep(i,M) {
    int L,R; cin >> L >> R;
    maxL = max(maxL,L);
    minR = min(minR,R);
  }

  cout << max(0,minR-maxL+1) << endl;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,k;
cin>>n>>k;
ll ans=k;
reps(i,n,1){
    ans*=(k-1);
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    String nn=String.valueOf(n);
	    StringBuilder sb=new StringBuilder();
        for (int i=0; i< nn.length();i++) {
        	if (nn.charAt(i)=='1') {
        		sb.append('9');
        	} else if (nn.charAt(i)=='9') {
        		sb.append('1');
        	} else {
        		sb.append(nn.charAt(i));
        	}
        }
	    
        System.out.println(sb.toString());
//        if () {
//        	System.out.print("No");
//        }else {
//        	System.out.print("Yes");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35484
N=input()
N=int(N)
arr=list(map(int,input().rstrip().split()))
aa=arr
n = len(aa) 
arr.sort() 
count = 0
for i in range(0, n-2): 
    k = i + 2
    for j in range(i + 1, n):
        for k in range(j+1,n):
            if aa[i]!=aa[j] and aa[i]!=aa[k] and aa[j]!=aa[k]:
                 if (arr[i] + arr[j] > arr[k] and 
                    arr[i] + arr[k] > arr[j] and 
                    arr[k] + arr[j] > arr[i]): 
                    count += 1
   
        
print(count)              

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans,last,x,n,c[200019];

int main() {
  cin >> n;
  ans=1;
  last=-1;

  for(int i=0; i<n; i++){c[i]=0;}
  
  for(int i=0; i<n; i++){
    cin >> x;
    if(x==last){continue;}
    last=x;
    ans = (1LL*ans+c[x])%1000000007;
    c[x]=ans;
  }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B,C,D; cin>>A>>B>>C>>D;
  rep(i,0,C-A) cout<<'R';
  rep(i,0,D-B) cout<<'U';
  rep(i,0,C-A) cout<<'L';
  rep(i,0,D-B) cout<<'D';
  cout<<'D';
  B--;
  rep(i,0,C-A+1) cout<<'R';
  rep(i,0,D-B) cout<<'U';
  cout<<'L';
  cout<<'U';
  rep(i,0,C-A+1) cout<<'L';
  rep(i,0,D-B) cout<<'D';
  cout<<'R'<<endl;
  }




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

using namespace std;

int main(){

	int n;
	bool f=false;
	while(cin>>n&&n!=0){
		if(f)
			cout<<endl;
		f=true;
		vector<pair<int,pair<int,string> > > v;
		string team;
		int w,l,d;
		for(int i = 0; i < n; i++){
			cin>>team>>w>>l>>d;
			v.push_back(make_pair(w*3+d*1,make_pair(-i,team)));
		}
		sort(v.begin(),v.end(),greater<pair<int,pair<int,string> > >());
		for(int i = 0; i < v.size(); i++){
			cout<<v[i].second.second<<","<<v[i].first<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int K;
	while(scanf("%d",&K)){
		if(K==0)
		break;
		int tp,sum=0;
		for(int i=0;i<(K*(K-1))/2;i++){
			scanf("%d",&tp);
			sum+=tp;
		}
		sum/=K-1;
		printf("%d\n",sum);
	}
}


Measured memory_bytes: 3120
using System;

namespace AtCoder20190601
{
	class ProgramA
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			A(N);
		}
		static void A(int N)
		{
			Console.WriteLine((N - 2) * 180);
		}
	}
}

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

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main()
{
    int n,a[100];
    scanf("%d",&n);

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

    qsort(a,n,sizeof(int),desc);

    int alice = 0,bob = 0;
    for (i = 0; i < n; i++)
    {
        if(i % 2 == 0)alice += a[i];
        else bob += a[i];
    }
    
    printf("%d",alice - bob);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>

using namespace std;

int h, w, a, b;

int main()
{
    scanf("%d%d%d%d", &h, &w, &a, &b);
    for(int i = 0; i < b; i++)
    {
        for(int j = 0; j < a; j++) printf("1");
        for(int j = a; j < w; j++) printf("0");
        puts("");
    }
    for(int i = b; i < h; i++)
    {
        for(int j = 0; j < a; j++) printf("0");
        for(int j = a; j < w; j++) printf("1");
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
using ll = long long;


int main(){
    int n,max;
    cin>>n;
    int b[n-1];
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    max=b[0];
    for(int i=0;i<n-2;i++){
        if(b[i]<=b[i+1]){
            max+=b[i];
        }
        else{
            max+=b[i+1];
        }
    }
    max+=b[n-2];
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
list = []
for i in range(n):
    s, t = input().split()
    list.append([s, int(t)])
x = input()

i = 0
time = 0
while list[i][0] != x:
    i += 1
else:
    for i in range(i + 1, n):
        time += list[i][1]
        i += 1
print(time)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, m;
  cin >> n >> m;
  vl x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  mint ax = 0, ay = 0;
  rep(i, n) ax += (2 * i + 1 - n) * x[i];
  rep(i, m) ay += (2 * i + 1 - m) * y[i];
  mint ans = ax * ay;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
      int a,b,flag;
      char ch;
      cin>>a>>b;
      for(int i= 0;i<a;i++){
            flag = -1;
            for(int j = 0 ; j < b;j++){
                  cin >> ch;
                  if(ch == 'c'){
                        cout << '0';
                        flag = 0;
                  }else{
                        if (flag == -1)cout << flag;
                        else cout << ++flag;
                 }
                  if(j!=b-1)cout << ' ';
            }
            cout<<endl;
      }
}

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

typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD = 1e9+7;

ll dp[105][5][5][5];

int main(){
	int n;
	cin >> n;
	
	dp[0][0][0][0] = 1;
	rep(i,n) rep(j,5) rep(k,5) rep(l,5){
		rep(m,4){
			dp[i+1][k][l][m+1] += dp[i][j][k][l];
			dp[i+1][k][l][m+1] %= MOD;
		}
		if((j==1&&k==3)||(j==1&&l==3)||(k==3&&l==1)||(k==1&&l==3)){
			dp[i+1][k][l][2] += MOD-dp[i][j][k][l];
			dp[i+1][k][l][2] %= MOD;
		}
	
		if(k==1&&l==2){
			dp[i+1][k][l][3] += MOD-dp[i][j][k][l];
			dp[i+1][k][l][3] %= MOD;
		}
	}

	ll ans = 0;
	rep(i,4) rep(j,4) rep(k,4) (ans+=dp[n][i+1][j+1][k+1])%=MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
string s[123];
int32_t main()
{
    ios::sync_with_stdio(0);
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    sort(s, s + n);
    for (int i = 0; i < n; ++i)
        cout << s[i];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=string(n)
    sn=0
    for i in s
        sn+=parseInt(i)
    end
    println(ifelse(n%sn==0,"Yes","No"))
end
main()

Measured memory_bytes: 165888
A, B, C, X, Y = map(int, input().split())
only_c = C * max(X, Y) * 2
not_c = A * X + B * Y
balance = C * X * 2 + B * (Y - X) if X < Y else C * Y * 2 + A * (X - Y)
print(min(only_c, not_c, balance))

Measured memory_bytes: 38384
memo = [0] * 200001 
def kitaichi(kazu):
    global memo
    ans = 0
    if memo[kazu] == 0:
        for i in range(1,kazu+1):
            ans += i * (1 / kazu)
        memo[kazu] = ans
    return memo[kazu]

n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
max_p = 0
for j in range(k):
    ans += kitaichi(p[j])
#print(ans)
max_p = ans
for i in range(n-k):
    #print(ans,kitaichi(p[i+k]),kitaichi(p[i]))
    ans = ans + kitaichi(p[i+k]) - kitaichi(p[i])
    #print(ans)
    max_p = max(ans,max_p)
print(max_p)

Measured memory_bytes: 33792
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    ll A[N];
    REP(i, N) cin >> A[i];

    REP(i, N) {
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = A[0];
    REP(i, N - 1) {
        ll prev = ans;
        ans *= A[i + 1];
        if (ans < prev || ans > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4428
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}



int main() {
    
    fastio;
    string s;
    ll n, k;
    cin >> n >> k;
    ll p[n+1], c[n+1];
    fr(i, 1, n)
    cin >> p[i];
    fr(i, 1, n)
    cin >> c[i];
    ll score = 0;
    vector<ll> sti[n+1];
    fr(i, 1, n)
    {
        //sti[i].pb(0);
        score = 0;
        ll pi = p[i];
        while(pi != i)
        {
            score += c[pi];
            pi = p[pi];
            sti[i].pb(score);
        }
        sti[i].pb(score+c[i]);
    }
    ll ans = sti[1][0];
    fr(i, 1, n)
    {
        
        ll maxSum = sti[i][0];
        
        ll need = sti[i].size();
        fr(j, 0, min(k-1, (ll)sti[i].size()-1))
        {
            //cout << sti[i][j] << " ";
            if(sti[i][j] > maxSum)
            {
                maxSum = sti[i][j];
                
            }

        }
        if(sti[i][need-1] <= 0 || k <= need)
            ans = max(ans, maxSum);
        
        else
        {
            ll xyz = 0;
            ll m = k % need;
            ll mm = k / need;
            fr(j, 0, m-1)
            {
                xyz = max(xyz, sti[i][j]);
            }
            ll sum = (mm-1) * sti[i][need-1] + maxSum;
            ll sum_dash = mm * sti[i][need-1] + xyz;

            ans = max(ans, sum);
            ans = max(ans, sum_dash);
            
        }



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

}

Measured memory_bytes: 218884