akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();

	int n, Y;
	cin >> n >> Y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int x = i;
			int y = j;
			int z = n - (i + j);
			if (z < 0) continue;
			if ((x * 10000 + y * 5000 + z * 1000) == Y) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pb push_back
#define inf 1e16
#define mod 1000000007
#define en '\n'
#define ld long double
ll pw(ll b, ll r){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%mod;
		b = (b*b)%mod;
		r>>=1;
	}
	return ans;
}
ll fact[100005];
ll ncr(ll n, ll r){
	if(n<r)return 0 ; 
	ll num = fact[n] ; 
	ll den = (fact[r]*fact[n-r])%mod;
	num = (num*pw(den,mod-2))%mod;
	return num;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;cin>>n>>k;
	ll arr[n];for(int i = 0 ; i < n ; i ++ )cin>>arr[i];
	ll sum = 0 ; 
	ll mx = 0 ; 
	for(int i = 0 ; i < n ; i ++ ){
		if(i<k)sum+=arr[i];
		else {
			sum-=arr[i-k];
			sum+=arr[i];
		}
		mx = max(mx,sum);
	}
	ld ans = (mx+k);
	ans/=2;
	cout<<setprecision(10)<<ans<<endl;

	return 0 ; 
}



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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL P,Q,R;
  cin >> P >> Q >> R;
  cout << min({P + Q, Q + R, P + R}) << endl;
}


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

const int N = 41;

typedef long long LL;

int G1[N][N];

LL f[N][N][N][N], g[N][N][N][N];

LL G(int a, int b, int c, int d);

LL F(int a, int b, int c, int d) {
    if (a > b && c > d) return 1;
    if (a > b || c > d) return 0;
    if (~f[a][b][c][d]) return f[a][b][c][d];
    LL &sum = f[a][b][c][d]; sum = 0;
    for (int i = a; i <= b; i++)
        for (int j = c; j <= d; j++) if (G1[i][j]) 
            sum += G(a, i - 1, i + 1, b) * G(c, j - 1, j + 1, d);
    return f[a][b][c][d] = sum;
}

LL G(int a, int b, int c, int d) {
    if (a > b && c > d) return 1;
    if (a > b || c > d) return 0;
    if (~g[a][b][c][d]) return g[a][b][c][d];
    LL &sum = g[a][b][c][d]; sum = 0;
    for (int i = a; i <= b; i++)
        for (int j = c; j <= d; j++) 
            sum += F(a, i, j, d) * G(i + 1, b, c, j - 1);
    return g[a][b][c][d] = sum;
}

char s[N];

int main() {
    memset(f, -1, sizeof(f)), memset(g, -1, sizeof(g));
    int n; scanf("%d", &n), n *= 2;
    for (int i = 1; i <= n; i++) {
        scanf("%s", s + 1);
        for (int j = 1; j <= n; j++) G1[i][j] = s[j] - '0';
    }
    LL res = 0;
    for (int i = 2; i <= n; i++) if (G1[1][i])
        res += G(2, i - 1, i + 1, n);
    printf("%lld\n", res);
}

Measured memory_bytes: 47976
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    cout<<s[0]<<Size(s)-2<<s[Size(s)-1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
stdin = gets.chomp.split(" ").map {|i| i.to_i}

n = stdin[0]
k = stdin[1]

result = ""
if n%2 == 0
if n/2 >= k
result = "YES"
else
result = "NO"
end
else
if (n/2+1) >= k
result = "YES"
else
result = "NO"
end
end

print(result)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, m, k, ans = 0;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  for(ll& x : a) cin >> x;
  for(ll& x : b) cin >> x;
  for(ll i=1;i<n; i++) a[i]+=a[i-1];
  for(ll i=1;i<m; i++) b[i]+=b[i-1];
  for(ll i=0; i<n; i++) {
    if(a[i]>k)
        break;
    ans = max(ans, i+1);
    if(b[0]+a[i]>k)
      continue;
    ll l =0, r = m;
    while (r-l>1) {
      ll mid = (l+r)/2;
      if(b[mid]+a[i]<=k)
        l = mid;
      else
        r = mid;
    }
    ans = max(ans, (l+1)+(i+1));
  }
  for(ll i=0; i<m; i++) {
    if(b[i]>k)
        break;
    ans = max(ans, i+1);
    if(a[0]+b[i]>k)
      continue;
    ll l =0, r = n;
    while (r-l>1) {
      ll mid = (l+r)/2;
      if(a[mid]+b[i]<=k)
        l = mid;
      else
        r = mid;
    }
    ans = max(ans, (l+1)+(i+1));
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	priority_queue<double, vector<double>, greater<double> > q;
	while (cin>>n)
	{
		for (int i=0;i<n;i++)
		{
			double t;
			cin>>t;
			q.push(t);
		}
		while(q.size()>1)
		{
			double a=q.top();
			q.pop();
			double b=q.top();
			q.pop();
			double c=(a+b)/2.0;
			q.push(c); 
			
		}
		cout<<q.top()<<endl;
		q.pop();		
	}
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <string>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define REP(i, x, y) for(int i = (int)x; i <= (int)y; i ++)
#define FOR(i, x, y) for(int i = (int)x; i <  (int)y; i ++)
#define PER(i, x, y) for(int i = (int)x; i >= (int)y; i --)
#define trace(x) cerr << #x << " " << x << endl;
#define dprintf(...) fprintf(stderr, __VA__ARGS__)
#define dln()        fprintf(stderr, "\n")
using namespace std;
typedef long long LL;
typedef long double db;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
const	int N = 100005;
const	int P = 1e9 + 7;
const	int inf = 1e9;
const	LL Inf = 1e15;

inline int IN(){
	char ch = getchar(); int x = 0, f = 0;
	while(ch < '0' || ch > '9') ch = getchar(), f = (ch == '-');
	while(ch >= '0' && ch <= '9'){
		x = (x << 1) + (x << 3) + ch - 48;
		ch = getchar();
	}
	return f ? (-x) : x;
}

inline int Pow(int x, int y, int p){
	int an = 1;
	for(; y; y >>= 1, x = (LL)x * x % p) if(y & 1) an = (LL)an * x % p;
	return an;
}

void renew(int &x, int y){
	x += y;
	if(x < 0) x += P;
	else if(x >= P) x -= P;
}

void setIO(string a){
#ifndef LOCAL
	freopen((a + ".in").c_str(), "r", stdin);
	freopen((a + ".out").c_str(), "w", stdout);
#else
	freopen("1.in", "r", stdin);
	freopen("1.out", "w", stdout);
#endif
}

template<typename T> inline void chkmin(T &a, const T &b) {if(a > b) a = b;}
template<typename T> inline void chkmax(T &a, const T &b) {if(a < b) a = b;}

int n, m;
int dp[405][405];

int main(){

	scanf("%d%d", &n, &m);
	REP(i, 1, n) dp[i][i] = 1;
	REP(i, 1, m){
		int x, y;
		scanf("%d%d", &x, &y);
		REP(i, 1, n){
			int u = dp[x][i], v = dp[y][i];
			dp[x][i] = dp[y][i] = min(2, u + v);
		}
	}

	int ans = 0;
	REP(i, 1, n) REP(j, i + 1, n){
		int flag = 1;
		REP(k, 1, n){
			int u = dp[i][k], v = dp[j][k];
			if(u + v >= 2) flag = 0;
		}
		ans += flag;
	}

	cout << ans << endl;

#ifdef LOCAL
	cerr << endl << endl << "Time Spec = " << clock() / 1000. << "ms" << endl;
#endif
	return 0;
}






















Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  char A[10];
  scanf("%s",&A);

int i,j,B[10];
for (i=0; i<10; i++) {
  if (A[i] == 'A' || A[i] == 'C' || A[i] == 'G' || A[i] == 'T') {
    B[i] = 1;
  } else {
    B[i] = 0;
  }
}

int ans = 0;int C;
for (i=0; i<10; i++) {
  C=0;
  for (j=i; j<10; j++) {
    if (B[j] == 1) {
      C++;
    } else {
      break;
    }
  }
  if (C > ans){
  ans =C;
  }

}
  printf("%d\n",ans);
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+5, mod = 1e9+7;

ll m = 1000, s = 0;

void buy(ll c) {
    s = m / c;
}

void sell(ll c, ll n) {
    m += (n - c) * s;
    s = 0;   
} 

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

    for (int i = 0; i < n - 1; ++i) {
        if (a[i] < a[i + 1]) {
            buy(a[i]);
            sell(a[i], a[i + 1]);
        }
    }
    
    cout << m << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int d,n; cin >> d >> n;
  ll ans = n;
  if( n == 100 ) ans = 101;
  rep(i,d){
    ans *= 100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    int arr[n]; for(int &i : arr) cin >> i;

    int _max = -1, ans = 0;
    for(int i = 0; i < n; ++i)
    {
        if(arr[i] >= _max)
        {
            _max = arr[i];
            ++ans;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define MP make_pair
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;
const int maxn = 1e3+9;
const int64 M = 1e9+7;
const int64 I = 1e9;

pii p[maxn * maxn];
int a[maxn], b[maxn], mx1[maxn], mx2[maxn];
bool vis1[maxn], vis2[maxn];
int n, m, ans = 1;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        p[a[i]].F = i;
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        p[b[i]].S = i;
    }
    int c1 = 0, c2 = 0, num = 0;
    for (int i = n * m; i >= 1; i--) {
        if (p[i].F && p[i].S) {
            if (vis1[p[i].F]) {
                ans = 0;
                continue;
            }
            if (vis2[p[i].S]) {
                ans = 0;
                continue;
            }
            vis1[p[i].F] = vis2[p[i].S] = true;
            c1++; c2++;
            continue;
        }
        if (p[i].F) {
            if (vis1[p[i].F]) {
                ans = 0;
                continue;
            }
            vis1[p[i].F] = true;
            ans = 1LL * ans * c2 % M;
            c1++;
            continue;
        }
        if (p[i].S) {
            if (vis2[p[i].S]) {
                ans = 0;
                continue;
            }
            vis2[p[i].S] = true;
            ans = 1LL * ans * c1 % M;
            c2++;
            continue;
        }
        ans = 1LL * ans * (c1 * c2 - (n * m - i)) % M;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int N;
  cin >> N;
  int A[N+1];
  int B[N];
  for(int i=0; i<N+1; i++) {
    cin >> A[i];
  }
  for(int i=0; i<N; i++) {
    cin >> B[i];
  }
  int ans=0;
  for(int i=0; i<N; i++) {
    if(A[i]<B[i]) {
      ans+=A[i];
      B[i]-=A[i];
      if(B[i]>=A[i+1]) {
        ans+=A[i+1];
      A[i+1]=0;
      }
      else {
        ans+=B[i];
        A[i+1]-=B[i];
      }
    }
    else {
      ans+=B[i];
    }
  }
  cout << ans << endl;
}

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

int memo[201][201];

void init(){
  
  for(int i=1;i<=200;i++){
    for(int j=1;j<=200;j++){
      memo[i][j] = __gcd( i, j );
    }
  }
  
}

signed main(){
  
  init();
  
  int K;
  cin>>K;
  
  int sum = 0;
  
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
	//sum += memo[memo[i][j]][k];
	sum += __gcd(__gcd(i,j),k);
      }
    }
  }
  
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 3940
# from math import gcd

def gcd(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 

n = int(input())
A = list(map(int, input().split()))

R = [0] + list(A) + [0]
L = [0] + list(A) + [0]
M = [0] * (n+2)


for i in range(n, 0, -1):
    R[i] = gcd(R[i], R[i+1])


for i in range(1,n+1):
    L[i] = gcd(L[i], L[i-1])

for i in range(1,n+1):
    M[i] = gcd(L[i-1], R[i+1])

# print("A   ", A, " ")
# print("L", L)
# print("R", R)
# print("M", M)
print(max(M))



Measured memory_bytes: 14428
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    char ch;
    while(1){
       scanf("%c",&ch);
       if('a' <= ch && ch <= 'z'){
           int ch1 = toupper(ch);
           printf("%c", ch1);
       }else if('A' <= ch && ch <= 'Z'){
           int ch2 = tolower(ch);
           printf("%c", ch2);
       }else printf("%c", ch);
       if(ch == '\n')break;
    }
    
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sorti(vi &a) {sort(a.begin(), a.end());}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) cout << 'x';
  cout << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

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

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

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    REP(i,n){
        cin>>a.at(i);
    }
    REP(i,n){
        cin>>b.at(i);
    }
    REP(i,n-1){
        cin>>c.at(i);
    }
    
    int sum = 0;
    REP(i,n){
        sum += b.at( a.at(i) - 1 );
        if( i > 0 ){
            if( a.at(i) == a.at(i-1) + 1 ){
                sum += c.at( a.at(i-1) - 1);
            }
        }
    }
    cout<<sum<<endl;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
double round(double r)
{
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

int num[300000];

int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s<d)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>

using namespace std;

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

    vector<bool> exists(1000000 + 1, false);
    for (int i = 0, a = s; ; i++, a = (a % 2 == 0 ? a / 2 : 3 * a + 1)) {
        if (exists[a]) {
            cout << i + 1 << endl;
            break;
        }

        exists[a] = true;
    }
}


Measured memory_bytes: 384
N = int(input())
H = list(map(int,input().split()))
m = 0
flg = True
for i in range(N-1):
  if m < H[i]:
    m = H[i]-1
  if m > H[i+1]:
    flg = False
    break
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 63984
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
#include<functional>


using namespace std;

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

	cout << str[0] << str.length()-2 << str[str.length() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    int n, m;
    cin >> n >> m;
    cout << (n+m)*(n+m-1)/2 - n*m << '\n';
    
    
    return 0;
}


Measured memory_bytes: 256
n,p = list(map(int,input().split()))
S = input()

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

def MS(i,s,pre):
  pre = (int(s)*i+pre)
  return pre%p
 
M = [0]*p
M[0] = 1
i = 1
pre = 0
for s in S[::-1]:
  pre = MS(i,int(s),pre)
  M[pre] += 1
  i = i*10%p

ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define db(x) cerr << #x << " == " << x << ";\n";
#define a(x) x.begin(),x.end()
#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]
typedef vector<int> vi;
typedef pair<int,int> pi;

const int nmax = 1e5+7;
const int mod = 1e9+7;
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

int countinv( vector<int> &arr, int s, int e) {

    if(s>=e) return 0;

    int mid = (s+e)/2;
    int left = countinv(arr,s,mid);
    int right = countinv(arr,mid+1,e);
    
    vector<int> l,r;
    for(int i = s; i<=mid;i++) l.push_back(arr[i]);
    for(int i= mid+1; i<=e;i++) r.push_back(arr[i]);

    int k = s; int i = 0, j = 0;
    int curr = 0;
    while(i<l.size() and j <r.size()) {

        if( l[i] <= r[j]) arr[k++] = l[i++];
        else {
            arr[k++] = r[j++];
            curr += l.size()-i;
        }
    }

    while(i<l.size()) arr[k++] = l[i++];
    while(j<r.size()) arr[k++] = r[j++];

    return curr+left+right;
}


void test() {

    cin >> n;
    vi arr;
    for ( int i = 0; i < n; i++ ) {
         int t;
         cin >> t;
         arr.push_back(t);
    }
    
    vi b(a(arr));
    sort(a(b));
    for(int i = 0; i < n; i++) {
        b[i] -= arr[i];
    }

    int cnt = count_if(a(b),[](int a ) {
        return a != 0;
    });
    //db(cnt);
    if( cnt <=2 ) cout << "YES";
    else cout << "NO";
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	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{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
} comb(2000005);

mint g(int r, int c){
	return comb(r+c+2, r+1) - 1;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	--r1; --c1;
	mint ans = g(r2, c2);
	ans -= g(r1, c2);
	ans -= g(r2, c1);
	ans += g(r1, c1);
	cout << ans.x << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
    v=a[i]
    j=i-1
    while j >=0 and a[j] > v:
        a[j+1] = a[j]
        j-=1
    a[j+1] = v
    print(*a)


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

int main(){
    int n, k, r, s, p;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    int ans = 0;
    vector<vector<int>> dp(n, vector<int>(3, 0));
    for (int i = 0; i < k; i++){
        int j = i;
        for (j = i; j < n; j += k){
            if (j > i){
                dp[j][0] = max(dp[j - k][1], dp[j - k][2]);
                dp[j][1] = max(dp[j - k][0], dp[j - k][2]);
                dp[j][2] = max(dp[j - k][0], dp[j - k][1]);
            }
            if (t[j] == 'r') dp[j][0] += p;
            else if (t[j] == 's') dp[j][1] += r;
            else dp[j][2] += s;
        }
        ans += *max_element(dp[j - k].begin(), dp[j - k].end());
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] x = new int[N];
        long ans = 0;
        for(int i = 0; i<N; i++) {
            x[i] = sc.nextInt();
            ans += Math.min(Math.abs(x[i]-0), Math.abs(x[i] -K));
        }
        System.out.println(ans*2);



    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x, n;
	cin >>x >>n;
	VI p(n);
	rep(i, n) cin >>p[i];
	set<int> st;
	rep(i, n) st.insert(p[i]);
	int ans = 0;
	rep(i, 10000){
		if(st.count(x-i)==0){
			cout << x-i <<"\n";
			return 0;
		}
		if(st.count(x+i)==0){
			cout << x+i <<"\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3612
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int a,v,b,w,t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    if(a<b)
    {
        int y=b+t*w;
        int x=a+t*v;
        if(x>=y)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    else
    {
        int y=b-t*w;
        int x=a-t*v;
        if(x<=y)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;

}





































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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(2*M);
  for(int i=0; i<2*M; i++){
    cin >> a.at(i);
  }
  for(int i=1; i<=N; i++){
    int counter = 0;
    for(int j=0; j<2*M; j++){
      if(a.at(j)==i){
        counter++;
      }
    }
    cout << counter << endl;
  }
  return 0;
}

Measured memory_bytes: 3660
<?php
 
$i = fgets(STDIN)%10;
  switch ($i) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:  
        echo "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:  
        echo "pon";
        break;
    case 3:
        echo "bon";
  }

Measured memory_bytes: 16108
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n;
int main()
{
	Very_fast;
	string s;
	cin>>s;
	int cnt=0,ans=0;
	s+=' ';
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')cnt++;
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = str(sys.stdin.readline().rstrip())

R,G,B = 0,0,0

for c in S:
    if c == 'R':
        R+=1
    elif c == 'G':
        G+=1
    else:
        B+=1

ans = R*G*B

for j in range(N):
    for i in range(N):
        if j-i < 0 or j+i >= N:
            break
        elif S[j-i] != S[j] and S[j+i] != S[j] and S[j+i] != S[j-i]:
            ans-=1

print(ans)

Measured memory_bytes: 67984
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

H,W = II()
A,B,C = [],[],[]
for i in range(H):
    A.append(III())
for i in range(H):
    B.append(III())
for i in range(H):
    C.append([abs(A[i][j]-B[i][j]) for j in range(W)])

def calc(n):
    return n+80*(H+W-1)

d = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if i==0 and j==0:
            d[i][j] = 2**calc(-C[i][j]) | 2**calc(C[i][j])
        elif i==0:
            d[i][j] = (d[i][j-1]<<C[i][j]) | (d[i][j-1]>>C[i][j])
        elif j==0:
            d[i][j] = (d[i-1][j]<<C[i][j]) | (d[i-1][j]>>C[i][j])
        else:
            d[i][j] = (d[i][j-1]<<C[i][j]) | (d[i][j-1]>>C[i][j]) | \
                        (d[i-1][j]<<C[i][j]) | (d[i-1][j]>>C[i][j])

ans = (H+W-1)*80+1
for i in range(160*(H+W-1)+1):
    if (d[H-1][W-1]>>i)&1:
        val = abs(i-80*(H+W-1))
        if val<ans:
            ans = val

print(ans)

Measured memory_bytes: 58588
H, W = map(int, input().split())
grid = []
for i in range(H):
    grid.append(list(map(int, input().split())))

ans = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if grid[i][j] % 2 == 1:
                if j != W-1:
                    grid[i][j+1] += 1
                    grid[i][j] -= 1
                    ans.append([i+1, j+1, i+1, j+2])
                elif i != H-1:
                    grid[i+1][j] += 1
                    grid[i][j] -= 1
                    ans.append([i+1, j+1, i+2, j+1])
    else:
        for j in range(W-1, -1, -1):
            if grid[i][j] % 2 == 1:
                if j != 0:
                    grid[i][j-1] += 1
                    grid[i][j] -= 1
                    ans.append([i+1, j+1, i+1, j])
                elif i != H-1:
                    grid[i+1][j] += 1
                    grid[i][j] -= 1
                    ans.append([i+1, j+1, i+2, j+1])

print(len(ans))
for i in range(len(ans)):
    print(" ".join(map(str, ans[i])))


Measured memory_bytes: 29864
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  for( int i = 0; i < N; i++ ){
    cin >> S.at(i);
    sort(S.at(i).begin(), S.at(i).end() );
  }
  
  unordered_map<string, int> smap;
  for( int i = 0; i < N; i++ ){
    smap[S.at(i)]++;
  }
  
  int ans = 0;
  for( auto sm: smap ){
    ans += sm.second * (sm.second-1) / 2;
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 17700
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

ll MOD = 1e9+7;

template <typename T>
T mypow(T a, T b) {
  if (b == 0) return 1;
  T tmp = mypow(a, b / 2);
  if (b % 2)
    return (((tmp * tmp) % MOD) * a) % MOD;
  else
    return (tmp * tmp) % MOD;
}


template <typename T>
T ext_gcd(T a, T b, T&x, T&y){
  if(b==0){
    x=1;y=0;return a;
  }
  T q=a/b;
  T g=ext_gcd(b,a-q*b,x,y);
  T z=x-q*y;
  x=y;y=z;
  return g;
}

// aは割る言、mがmod
template <typename T>
T invmod(T a, T m){
  T x,y;
  ext_gcd(a,m,x,y);
  x%=m;
  if(x<0)x+=m;
  return x;
}

ll solve(ll n, ll a){
    ll up = 1;
    ll down = 1;
    FOR(i,1,a+1){
        down = down*i%MOD;
        up = up*(n-i+1)%MOD;
    }
    return up * invmod(down, MOD)%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = mypow((ll)2,n) - 1;
    
    ans -= solve(n,a) + solve(n,b);
    ans = (ans+MOD+MOD)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int cnt=0;
    rep(i,d){
        rep(j,n){
            if(i%a[j]==0) cnt++;
        }
    }
    cout<<cnt+x;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> ps(n);
	for (auto &p : ps)
	{
		cin >> p;
	}

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if ((i + 1) != ps[i])
		{
			cnt++;
		}
	}

	cout << ((cnt <= 2) ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
mod_0 = []
mod_1 = []
mod_2 = []
for i in range(1, n + 1):
    if i % 3 == 0:
        mod_0.append(i)
    elif i % 3 == 1:
        mod_1.append(i)
    else:
        mod_2.append(i)
ans = [-1]*n
from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

d = bfs(0)

cnt = [[] for _ in range(2)]

for i in range(n):
    if d[i] % 2 == 0:
        cnt[0].append(i + 1)
    elif d[i] % 2 == 1:
        cnt[1].append(i + 1)

cnt = sorted(cnt, key=lambda x: len(x))

if len(mod_0) >= len(cnt[0]):
    for i in range(len(cnt[0])):
        ans[cnt[0][i] - 1] = mod_0.pop()
    for i in range(len(cnt[1])):
        if mod_0:
            ans[cnt[1][i] - 1] = mod_0.pop()
        elif mod_1:
            ans[cnt[1][i] - 1] = mod_1.pop()
        else:
            ans[cnt[1][i] - 1] = mod_2.pop()
    print(*ans)
    sys.exit()

for i in range(2):
    c = cnt[i]
    for j in range(len(c)):
        if mod_2 and i == 0:
            ans[cnt[i][j] - 1] = mod_2.pop()
        elif mod_1 and i == 1:
            ans[cnt[i][j] - 1] = mod_1.pop()
        elif mod_0:
            ans[cnt[i][j] - 1] = mod_0.pop()
        else:
            print(-1)
            sys.exit()
print(*ans)


Measured memory_bytes: 105420
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int N,M;
    while (cin >> N >> M) {
        set<int> factor;
        for (int i = 1; i*i <= M; i++) {
            if (M%i == 0) {
                factor.insert(i);
                factor.insert(M/i);
            }
        }
        int ans = 1;
        FOR_ALL(f,factor) {
            if (M/(*f) >= N)
                ans = *f;
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(void) {
    long long N, H;
    cin >> N >> H;
    vector< long long > a(N), b(N);
    for (long long i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    long long max_a = 0;
    for (long long i = 0; i < N; ++i) {
        if (a[i] > max_a) {
            max_a = a[i];
        }
    }
    vector< long long > big_b;
    for (long long i = 0; i < N; ++i) {
        if (b[i] > max_a) {
            big_b.push_back(b[i]);
        }
    }
    sort(big_b.begin(), big_b.end(), greater< int >());
    long long remain = H, count = 0;
    for (auto bb : big_b) {
        remain -= bb;
        ++count;
        if (remain <= 0) {
            break;
        }
    }
    if (remain > 0) {
        count += (remain + max_a - 1) / max_a;
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	bool flag = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] >= k)flag = true;
	}
	ll res = a[0];
	rep(i, n - 1) {
		res = gcd(res, a[i + 1]);
	}
	sort(a.begin(), a.end());
	if (flag == false) {
		puts("IMPOSSIBLE");
		return 0;
	}
	else {
		if (k % res) {
			puts("IMPOSSIBLE");
		}
		else {
			puts("POSSIBLE");
		}
	}
	return 0;
}

Measured memory_bytes: 3964
import collections
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

n, m = map(int, input().split())

if m != 0:
    edge = np.array([input().split() for _ in range(m)], dtype = np.int64).T
    tmp = np.ones(m, dtype = np.int64).T
    graph = csr_matrix((tmp, (edge[:] -1)), (n, n))

    cnt = collections.Counter(connected_components(graph)[1])

    print(max(cnt.values()))
else:
    print('1')

Measured memory_bytes: 111992
package main

import (
	"fmt"
)

// 2018-10-25T16:28:48+0800
// 2018-10-25T16:43:57+0800 # WA @see https://arc103.contest.atcoder.jp/submissions/3466776
// 2018-10-25T16:45:49+0800 # WA @see https://arc103.contest.atcoder.jp/submissions/3466791
// 2018-10-25T17:03:41+0800 # Failed to pause on fmt#Scanf() when debugging.
// 2018-10-25T17:07:57+0800
func main() {
	var n int
	fmt.Scanf("%d", &n)
	//v := make([]int, n)
	a := make([]int, n/2)
	b := make([]int, n/2)
	ma := make(map[int]int, n/2)
	aa1 := -1
	aa2 := -1
	mb := make(map[int]int, n/2)
	bb1 := -1
	bb2 := -1
	for i := 0; i < n/2; i++ {
		fmt.Scanf("%d", &a[i])
		ma[a[i]]++
		if aa1 != a[i] && ma[a[i]] >= ma[aa1] {
			aa2 = aa1
			aa1 = a[i]
		}
		fmt.Scanf("%d", &b[i])
		mb[b[i]]++
		if bb1 != b[i] && mb[b[i]] >= mb[bb1] {
			bb2 = bb1
			bb1 = b[i]
		}
	}
	if aa1 != bb1 {
		fmt.Println(n - ma[aa1] - mb[bb1])
		return
	}
	O1 := n - ma[aa1] - mb[bb2]
	O2 := n - ma[aa2] - mb[bb1]
	if O1 > O2 {
		fmt.Println(O2)
	} else {
		fmt.Println(O1)
	}
}

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

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

typedef long long int ll;

const ll INF=(ll)1e18;

int color[100000];
vector<vector<int> > edge(100000);
map<pair<int, int>, int> mp;
vector<pair<int, int> > edge_list;
int ans_size=0;

void dfs(int n, int parent, int p_col){
//  printf("%d %d %d\n",n,parent,p_col);
  ans_size = max(ans_size,p_col);
  mp[make_pair(min(n,parent), max(n,parent))] = p_col;

  int col=1;
  for(auto iter = edge[n].begin(); iter < edge[n].end(); iter++){
    if(*iter==parent)continue;
    if(col==p_col)col++;
    dfs(*iter,n,col);
    col++;
  }

}

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

  REP(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
    edge_list.push_back(make_pair(a,b));
  }


  int c=1;
  for(auto iter = edge[0].begin(); iter < edge[0].end(); iter++){
    dfs(*iter,0,c);
    c++;
  }
  cout << ans_size << endl;
  REP(i,N-1){
//    cout << edge_list[i].first << " " << edge_list[i].second << " " << mp[edge_list[i]] << endl;
    cout << mp[edge_list[i]] << endl;
  }

}



Measured memory_bytes: 13176
#include <stdio.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define getInt(n) scanf("%d", &n)
#define showAns(ans) printf("%d\n", ans)

int main(void){
    int N;
    getInt(N);

    int a;
    int ans = 0;
    rep(i,N){
        getInt(a);
        if(a%2!=0 && (i+1)%2!=0) ans++;
    }

    showAns(ans);

    return 0;
}

Measured memory_bytes: 1728