akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 998244353;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    VV<ll> dp(c+1,V<ll>(d+1, 0));
    dp[a][b] = 1;
    srepn(i, a, c) srepn(j, b, d) {
        if(i == a && j == b) continue;
        dp[i][j] += dp[i][j-1] * i;
        dp[i][j] += dp[i-1][j] * j;
        dp[i][j] %= MOD;
        dp[i][j] -= dp[i-1][j-1]*(i-1)*(j-1)%MOD;
        dp[i][j] += MOD;
        dp[i][j] %= MOD;
    }
    cout << dp[c][d] << endl;
}

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

#define int long long

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

// idx, (未処理, 偶数左, 奇数, 偶数右)
const int VARI = 5;
int dp[200010][VARI];

signed main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }

  const int one = 0; // 左のゼロ区間
  const int two = 1; // 右のゼロ区間
  const int three = 2; // 左の偶数区間
  const int four = 3; // 右の偶数区間
  const int five = 4; // 奇数区間

  // 初期化
  fill(dp[0], dp[N+1], INF);
  dp[0][one] = 0;
  // dp[0][two] = 0;
  // dp[0][three] = 0;
  // dp[0][four] = 0;
  // dp[0][five] = 0;

  // DP
  for (int i = 0; i < N; i++) {
    // 左のゼロ区間
    int cost1 = v[i];
    chmin(dp[i+1][one], dp[i][one] + cost1);

    // 左の偶数区間
    int cost2 = v[i] == 0 ? 2 : v[i] % 2;
    chmin(dp[i+1][two], min(dp[i][one], dp[i][two]) + cost2);

    // 奇数区間
    int cost3 = v[i] == 0 ? 1 : (v[i] % 2 == 0);
    chmin(dp[i+1][three], min({dp[i][two], dp[i][three], dp[i][one]}) + cost3);

    // 右の偶数区間
    int cost4 = v[i] == 0 ? 2 : v[i] % 2;
    chmin(dp[i+1][four], min({dp[i][three], dp[i][four], dp[i][two], dp[i][one]}) + cost4);

    // 右のゼロ区間
    int cost5 = v[i];
    chmin(dp[i+1][five], min({dp[i][four], dp[i][three], dp[i][two], dp[i][one], dp[i][five]}) + cost5);
  }

  int ans = INF;
  for (int i = 0; i < VARI; i++) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
static inline int Min(const int a,const int b){return a<b?a:b;}
static inline int F(int x)
{
  int p=-1,q=1,y=x;
  if(!(x&1)){y=y/2;while(!(x&1))x/=2;}
  if(x%3==0){y=y/3*2;while(x%3==0)x/=3;}
  while(q*q<=x)
  {
    p+=6,q+=6;
    if(x%p==0){y=y/p*(p-1);while(x%p==0)x/=p;}
    if(x%q==0){y=y/q*(q-1);while(x%q==0)x/=q;}
  }
  if(x>1)y=y/x*(x-1);
  return y;
}
static inline int ModPow(int a,int b,int p){return b?1l*ModPow(1l*a*a%p,b>>1,p)*(b&1?a:1)%p:1;}
int main(void)
{
  int K=IN(),x=0x7fffffff,y=F(9*K/GCD(K,7));if(!(K&1)||(K%5)==0)return puts("-1"),0;
  for(int i=0;i*i<=y;i++)
  {
    if(!i)i=1;
    if(y%i==0)
    {
      if(ModPow(10,i,9*K/GCD(K,7))==1)x=Min(x,i);
      if(i*i==y)continue;
      if(ModPow(10,y/i,9*K/GCD(K,7))==1)x=Min(x,y/i);
    }
  }
  return printf("%d\n",x),0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

   int a[2][n];
   f(i,0,2) f(j,0,n) cin >> a[i][j];

   int dp[2][n];
   memset(dp , 0 , sizeof(dp));

   dp[0][0] = a[0][0];
   dp[1][0] = a[0][0] + a[1][0];

   f(i,1,n) {
      dp[0][i] = dp[0][i-1] + a[0][i];
      dp[1][i] = max(dp[1][i-1] , dp[0][i]) + a[1][i];
   }

   cout << dp[1][n-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct BIT{
private:
  vector<ll> vec;
  ll siz;
public:
  BIT(ll n){
    siz=n+1;
    vec.resize(siz,0);
  }
  void upd(int pos,ll x){
    while(pos<siz){
      vec[pos]+=x;
      pos+=pos&(-pos);
    }
  }
  ll sum(ll pos){
    ll ret=0;
    while(pos>=1){
      ret+=vec[pos];
      pos-=pos&(-pos);
    }
    return ret;
  }
};
int main(){
  ll n,k;
  cin>>n>>k;
  BIT b1=BIT(n+5);
  vector<ll> vec,array;
  array.push_back(0);
  vec.push_back(0);
  ll rsum=0;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    a-=k;
    rsum+=a;
    array.push_back(rsum);
    vec.push_back(rsum);
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  ll ans=0;
  for(int i=0;i<=n;i++){
    ll val=array[i];
    int idx=lower_bound(vec.begin(),vec.end(),val)-vec.begin();
    idx++;
    ans+=b1.sum(idx);
    b1.upd(idx,1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5100
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

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

int main() {
  int n, x; std::cin >> n >> x;
  std::vector<int> xs(n, 0);
  for (int i = 0; i < n; i++) std::cin >> xs[i];

  int all_gcds = std::abs(xs[0] - x);
  for (int i = 1; i < n; i++) {
    all_gcds = gcd(all_gcds, std::abs(xs[i] - x));
  }
  std::cout << all_gcds << std::endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> vp;
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        vp.push_back(make_pair(x,y));
    }
    sort(vp.begin(),vp.end());
    long long ans=0;
    int next=0;
    priority_queue<int> pq;
    for(int i=0;i<=M;i++){
        while(next<N&&vp[next].first==i){
            pq.push(vp[next].second);
            next++;
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1908
package main

import (
	"fmt"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, t, a int
	fmt.Scan(&n, &t, &a)
	t *= 1000
	a *= 1000

	ans := 0
	temp := 600000
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		ht := abs((t - h*6) - a)
		if ht < temp {
			ans = i + 1
			temp = ht
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int max_value(std::map<string, int> m) {
  int max = 0;
  for (std::map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
    if (max < it->second) max = it->second;
  }
  return max;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<string, int> yen{};
  int N,M;
  cin >> N;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(yen.count(s)) yen[s] += 1;
    else yen.insert(make_pair(s,1));
  }
  cin >> M;
  for(int i=0;i<M;i++){
    string s;
    cin >> s;
    if(yen.count(s)) yen[s] -= 1;
    else yen.insert(make_pair(s,-1));
  }
  int max_yen = max_value(yen);
  if( max_yen > 0) cout << max_yen << endl;
  else cout << 0 << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[N];

    for (int i = 0; i < Q; i++) {
      int i_ = sc.nextInt();
      A[i_ - 1]++;
    }

    sc.close();

    PrintWriter out = new PrintWriter(System.out);
    
    for (int i = 0; i < N; i++) {
      if (0 < A[i] + K - Q) {
        out.println("Yes");
      } else {
        out.println("No");
      }
    }

    out.flush();

  }

}

Measured memory_bytes: 52812
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;

int check(int n,int x,set<int> s){
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int xi=x-i-j;
            if(xi>i && xi>j){
                if(s.count(xi)) cnt++;
            }
        }
    }

    return cnt;
}

int main(){
    vector<int> result;
    while(1){
        int n,x; cin>>n>>x;
        if(n==0 && x==0) {
            for(int i=0;i<result.size();i++) cout << result[i]<<endl;
            return 0;
        }
        set<int> s;
        for(int i=1;i<=n;i++) s.insert(i);

        result.push_back(check(n,x,s));
    }

}


Measured memory_bytes: 3084
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2,l;
    cin >> x1 >> y1 >> x2 >> y2;
    l = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%lf\n",l);
    return 0;
}


Measured memory_bytes: 3216
N,K = map(int,input().split())
dice_list = [int(i) for i in input().split()]
wa_list = [0]
for dice in dice_list :
    # prob = 0
    # for i in range(dice) :
    #     prob += (i+1) * (1/(dice))
    prob = (1+dice) / 2
    wa_list.append(wa_list[-1] + prob)

max_p = -1
for i in range(N-K+1) :
    p = wa_list[i+K] - wa_list[i]
    if (max_p < p) :
        max_p = p

print(max_p)





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

int main(){
	long long a=1,b=1;
	cin >> a >> b;
	long long gcf=1;

	if (a>b){
		for (long long  n=b;gcf==1 and n!=1;--n){
			if(b%n==0 and a%n==0){
				gcf=n;
				break;
			}

		}
		if(gcf!=1){
			cout << (a/gcf)*b;
		}
		else{
			cout << a*b << endl;
		}
		
		
	}
	else{
		for (long long n=a;gcf==1 and n!=1;--n){
			if(a%n==0 and b%n==0){
				gcf = n;
				break;
			}
		}
		if(gcf!=1){
			cout << (b/gcf)*a;

		}
		else{
			cout << a*b << endl;
		}
		
	}
	

}

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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;

  if (A % K == 0) {
    cout << "OK" << endl;
    return 0;
  }
  int next = K * (A / K) + K;
  if (next <= B) {
    cout << "OK" << endl;
    return 0;
  }

  cout << "NG" << endl;
  
}


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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n + 1];
    for (int32_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    a[n] = 0;

    int64_t answer = 0;
    int64_t t = 0;
    for (int32_t i = 0; i < n; i++) {
        t += a[i];
        if (a[i + 1] == 0) {
            answer += t / 2;
            t = 0;
        }
    }
    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

int main(){
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(s.compare(u) == 0) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<iostream>
using namespace std;
int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);}
int main(void){
	int a,b,c;
	cin>>a>>b>>c;
	if(c%gcd(a,b)==0){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
	return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    long long n; cin >> n;
    long long pw = 1;
    long long ima = 0;
    long long c = 1;

    while(1){
        if(ima + pw * 26 >= n) break;
        c++;
        pw = pw * 26;
        ima = ima + pw;
    }
  //  cout << c << endl;
  //  cout << pw << endl;
   // cout << n - ima << endl;
    ll ppw = 1; rep(i,c-1) ppw *= 26;
    n = n - ima - 1;
  // cout << ppw << endl;
    string s;
    rep(i,c){
        long long ch = n / ppw;
        n = n % ppw;
        s += ((char)ch) + 'a';
        ppw = ppw / 26;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    string S, T; cin >> S >> T;
    int N = S.size();

    bool ok = false;
    for (int i = 0; i < N; i++) {
        swap(S[0], S[N - 1]);
        for (int j = N - 1; j >= 2; j--) {
            swap(S[j], S[j - 1]);
        }

        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
int a[100000];
int b[100000];
int compare_with_b(const void *i, const void *j){
    return b[*(int*)i] - b[*(int*)j];
}
int main(void){
    int n, h;
    int index[100000];
    scanf("%d%d", &n, &h);
    for(int i=0; i<n; i++) {
        scanf("%d%d", &a[i], &b[i]);
        index[i] = i;
    }
    qsort(index, n, sizeof(int), compare_with_b);
    int max_a = 0;
    for(int i=0; i<n; i++)
        if(a[i] > max_a)
            max_a = a[i];

    int ans = 0;
    for(int i=0; i<n && b[index[n-1-i]] > max_a; i++){
        h -= b[index[n-1-i]];
        ans++;
        if(h<=0){
            printf("%d\n", ans);
            return 0;
        }
    }
    ans += h/max_a;
    if(h % max_a != 0)
        ans++;
    printf("%d\n", ans);
}


Measured memory_bytes: 1788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	VI a(5);
	int N;
	cin >> N;
	REP(i, 5) {
		cin >> a[i];
	}

	SORT(a);
	int ans = N / a[0] + 5;
	if (N % a[0]==0)ans--;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = sorted(A)

    cnt = 0
    for a, b in zip(A, B):
        if a != b:
            cnt += 1

    if cnt <= 2:
        return 'YES'
    return 'NO'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
s = int(input())
l = [s]
max=s

while 1:
  if s %2 == 0:
    l.append(s/2)
    s = int(s/2)
  else:
    l.append(3*s + 1)
    s = 3*s+1
    max = s
  
  if any(l.count(i) >= 2 for i in range(s+1)):
    print(len(l))
    break

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main()
{
	int n, i;
	i = 0;
	while(1)
		{
			cin >> n;
			if ( n == 0 )break;
			else
			{
				while(1)
				{
						if ( n == 1 )break;
						else if ( n % 2 == 1 )
						{
							n = (n * 3) + 1;
							i++;
						}
					else if ( n % 2 == 0 )
						{
							n = n / 2;
							i++;
						}
				}
			cout << i << endl;
			i = 0;
			}	
		}
	return 0;
}

Measured memory_bytes: 1160
n=int(input())-3
l=[2,3,25]
i=2
while n>=2:
  if i!=2 and i!=3 and i!=25 and(i%2==0 or i%3==0 or i%25==0):
    l.append(30000-i)
    l.append(i)
    n-=2
  i+=1
if n==1:
  l.append(30000)
print(*l)

Measured memory_bytes: 4448
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
A = readInts()
cum = list(accumulate(A))
ans = 0
for i in range(n-1):
    ans += A[i] * (cum[n-1]-cum[i])
    ans%=mod
print(ans%mod)


Measured memory_bytes: 32860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	string s; cin >> s;
	ll c = 0, ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')
			c++;
		else
		{
			ans = max(ans, c);
			c = 0;
		}
	}
	ans = max(ans, c);
	cout << ans;

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define VMAX 100000
#define MAXLOOP 200000000
void solve(long long N, long long W, vector<long long> w, vector<long long> p){
  long long vmax = (MAXLOOP/N)/14;
  vector<vector<long long>> dp(N, vector<long long>(vmax+1, LLONG_MAX));
  dp[0][0] = 0;
  dp[0][p[0]] = w[0];

  for(long long i = 1; i < N; i++) {
    for(long long j = 0; j <= vmax; j++) {
      long long source = j - p[i];
      if(source < 0 || dp[i-1][source] == LLONG_MAX) {
        dp[i][j] = dp[i-1][j];
        continue;
      }

      dp[i][j] = min(dp[i-1][j], dp[i-1][source] + w[i]);
    }
  }


  #ifdef DEBUG
  for(long long i = 0; i < N; i++) {
    for(long long j = 0; j <= VMAX; j++) {
      if(dp[i][j] != LLONG_MAX) {
        cout << "[" << i << "][" << j << "]=" << dp[i][j] << " ";
      }
    }

    cout << endl;
  }
  #endif

  for(long long j = vmax; j >= 0; j--) {
    if(dp[N-1][j] <= W) {
      cout << j << endl;
      break;
    }
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long W;
  scanf("%lld",&W);
  vector<long long> ws;
  vector<long long> ps;
  long long w, p;
  for(int i = 0 ; i < N ; i++){
    cin >> w >> p;
    ws.push_back(w);
    ps.push_back(p);
  }
    solve(N, W, std::move(ws), std::move(ps));
    return 0;
}


Measured memory_bytes: 223488
#include<stdio.h>
void insersion(int *a,int n);

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

	return 0;
}


void insersion(int *a,int n){
	int i,j,v,k;
	for(i=0;i<=n-1;i++){
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		k=0;
		while(1){
			printf("%d",a[k]);
			k++;
			if(k==n){
				printf("\n");
				break;
			}
			printf(" ");
		}
	}

}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	n%=k;
	cout<<min(n,k-n)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

ll modpow(int n) {
    ll mul = 2;
    ll ret = 1;
    while (n) {
        if (n&1) ret = (ret*mul)%MOD;
        mul = mul*mul%MOD; 
        n >>= 1;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> cs(n, 0); 
    rep(i, n) {
        int a; cin >> a;
        cs[a]++;
    }
    bool fail = false;
    if (n%2) {
        if (cs[0] != 1) fail = true;
        rep(i, n/2) {
            if (cs[2+i*2] != 2) fail = true;
        }
    } else {
        rep(i, n/2) {
            if (cs[1+i*2] != 2) fail = true;
        }
    }
    ll ret = fail ? 0 : modpow(n/2); 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    int r;

    cin >> r;

    cout << 3 * r * r << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 120000
typedef long long LL;
LL A[maxn], B[maxn];
vector<LL> v;
int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i += 1) cin >> A[i];
	for(int i = 0; i < N; i += 1) cin >> B[i];
	LL ans = 0, sum = 0;
	for(int i = 0; i < N; i += 1){
		if(A[i] < B[i]){
			sum += B[i] - A[i];
			ans += 1;
		}
		if(A[i] > B[i]) v.push_back(A[i] - B[i]);
	}
	sort(v.begin(), v.end(), greater<int>());
	for(LL x : v){
		if(sum <= 0) break;
		sum -= x;
		ans += 1;
	}
	if(sum > 0) cout << - 1;
	else cout << ans;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
ll edge[201][201];
int R;
int r[9];
bool checked[9];
int res;
void dfs(int c,int last,int dist){
    if(c==R+1){
        res=min(res,dist);
        return;
    }else{
        REP1(i,R){
            if(checked[i]==false){
                checked[i]=true;
                if(last==-1){
                    dfs(c+1,i,0);
                }else{
                   
                    dfs(c+1,i,dist+edge[r[last]][r[i]]);
                }
                checked[i]=false;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    R=in();
    REP1(i,R)cin>>r[i];
    REP(i,9)checked[i]=false;
    REP1(i,N){
        REP1(j,N){
            if(i==j){
                edge[i][j]=0;
            }else{
                edge[i][j]=INF;
            }
        }
    }
    int a,b,c;
    REP(i,M){
        cin>>a>>b>>c;
        edge[a][b]=c;
        edge[b][a]=c;
    }

    REP1(k,N){
        REP1(i,N){
            REP1(j,N){
                edge[i][j]=min(edge[i][k]+edge[k][j],edge[i][j]);
            }
        }
    }
    res=INF;
    dfs(1,-1,0);
    print(res);
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000000

void unite(int, int, int);
int find(int, int);

PPI cities[MAX_N];

int main(){
    cin.sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;

    rep(i, n + 1) {
        cities[i].fi.fi = cities[i].fi.se = i;
        cities[i].se = i;
    }

    int p, q;
    rep(i, k) {
        cin >> p >> q;
        unite(p, q, 0);
    }

    rep(i, l) {
        cin >> p >> q;
        unite(p, q, 1);
    }

    repl(i, 1, n + 1) {
        cities[i].fi.fi = find(cities[i].fi.fi, 0);
        cities[i].fi.se = find(cities[i].fi.se, 1);
    }

    sort(cities + 1, cities + n + 1);

    int j = 1, ans[n + 1];
    repl(i, 1, n + 1) {
        int road = cities[i].fi.fi, train = cities[i].fi.se;
        int cnt = 0;
        for (; j <= n && road == cities[j].fi.fi && train == cities[j].fi.se; j++){
            cnt++;
        }
        repl(k, i, j) {
            ans[cities[k].se] = cnt;
        }
        i = j - 1;
    }

    repl(i, 1, n) {
        cout << ans[i] << " ";
    }
    cout << ans[n] << endl;

    return 0;
}

void unite(int p, int q, int sw) {
    int a = find(p, sw);
    int b = find(q, sw);
    if (a == b) return;

    if (sw == 0) {
        cities[b].fi.fi = a;
    } else {
        cities[b].fi.se = a;
    }
}

int find(int p, int sw) {
    if (sw == 0) {
        return (cities[p].fi.fi == p) ? p : cities[p].fi.fi = find(cities[p].fi.fi, sw);
    } else {
        return (cities[p].fi.se == p) ? p : cities[p].fi.se = find(cities[p].fi.se, sw);
    }
}

Measured memory_bytes: 3840
#include <iostream>
int W, H, N;

void printRect(int rect[100][100]) {
  for (int i = 0; i < W; ++i) {
    for (int j = 0; j < H; ++j) {
      std::cout << rect[i][j];
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
}

int main(int argc, char *argv[]) {
  std::cin >> W >> H >> N;
  int rect[100][100];
  for (int i = 0; i < W; ++i)
    for (int j = 0; j < H; ++j)
      rect[i][j] = 1;

  for (int i = 0; i < N; ++i) {
    // printRect(rect);
    int x, y, a;
    std::cin >> x >> y >> a;
    int xmin = 0, xmax = W, ymin = 0, ymax = H;
    switch (a) {
    case 1:
      xmax = x;
      break;
    case 2:
      xmin = x;
      break;
    case 3:
      ymax = y;
      break;
    case 4:
      ymin = y;
      break;
    }
    for (int i = xmin; i < xmax; ++i)
      for (int j = ymin; j < ymax; ++j)
        rect[i][j] = 0;
  }
  // printRect(rect);
  int sum = 0;
  for (int i = 0; i < W; ++i)
    for (int j = 0; j < H; ++j)
      sum += rect[i][j];

  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)

int main() {
    int N; cin >> N;
    vector<pair<ll,ll>> v;
    REP(i,N) {
        ll x, l; cin >> x >> l;
        v.push_back(make_pair(x-l,x+l));
    }
    sort(all(v),[](pair<ll,ll> x, pair<ll,ll> y){return x.second<y.second;});
    int ans = 0;
    ll now = -INF;
    REP(i,N) {
        if(v[i].first >= now) {
            ans ++;
            now = v[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
cnt = 0
for i in range(1, n-1):
  if li[i-1] < li[i] < li[i+1] or li[i-1] > li[i] > li[i+1]:
    cnt += 1
print(cnt)










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

int main() 
{
	
	string v; 
	cin>>v;
	
	int flag = 0;
	for (int i = 0; i <=v.length()-1 ;i++)
	{
	    if ((i!=(v.length()-1))&&(v[i]!=v[i+1]))
	    {
	        flag = flag +1;
	    }
	}
	cout<<flag;
    
}
	


Measured memory_bytes: 640
#D
n,k = map(int,input().split())

l = [i for i in range(n+1)]

mod = 10**9 + 7

cnt = 0

for i in range(k,n+2):
    mi = i*(i-1) // 2
    ma = i*(2*n-i+1) // 2
    #print('min:',min)
    #print('max:',max)
    cnt += ma - mi + 1
print(cnt % mod)

Measured memory_bytes: 17016
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if(x==0&&y==0){
            return 0;
        }
        else if(x<=y){
        cout<<x<<" "<<y<<endl;
        }
        else{
        cout<<y<<" "<<x<<endl;
        }
    }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
map<P,int> m;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		int x,y,w;
		cin>>x>>y>>w;
		m[P(x-1,y-1)]+=w;
		m[P(x,y-1)]+=w;
		m[P(x-1,y)]+=w;
		m[P(x,y)]+=w;
	}
	int res=0;
	each(it,m){
		maxch(res,it.second);
	}
	cout<<res<<" / 1"<<endl;
	return 0;
}

Measured memory_bytes: 28184
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

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

	int n,i,j,x,a=0;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> x;
		if(i % 2  && x % 2)
		{
			a++;
		}
	}

	cout << a;


	return 0;
}

Measured memory_bytes: 3684
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

N,M = ln()

AA = list(ln())
A = np.array(AA)

SUM = np.zeros(N+1,dtype = int)
for i in range(N):
    SUM[i+1] = (SUM[i] + A[i]) % M

ans = 0
dic = dict()
# for i in range(N):
#     dic[SUM[i]] = 1
for i in range(N+1):
    if SUM[i] in dic:
        dic[SUM[i]] += 1
    else:
        dic[SUM[i]] = 1
    ans += dic[SUM[i]] -1


print(ans)


Measured memory_bytes: 24720
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif




int r, d, x;

cin>>r>>d>>x;
int max=x;
for (int i = 0; i < 10; ++i)
{
	/* code */
	max=r*max-d;
	cout<<max<<endl;

}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[])
{
    int  N;
    cin >> N;

    vector<int> A(N);

    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i] -= (i+1);
    }
    long long ans = 0;

    sort(A.begin(), A.end());

    int b = A[N/2];

    for(int i=0; i<N; i++){
        ans += abs(A[i] - b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
use std::io::{stdout, Write};

//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let out = stdout();
    let mut out = out.lock();

    input!{
        n: i32,
    };

    let mut ans: i64 = 0;
    for i in 1..(n+1) {
        match i {
            v if v % 15 == 0 => {},
            v if v % 5 == 0 => {},
            v if v % 3 == 0 => {},
            v => {
                ans += v as i64;
            }
        }
    }

    writeln!(out, "{}", ans).unwrap()
}

Measured memory_bytes: 2136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int a, b, c, f = 0, s = 0;
  cin >> a >> b >> c;
  if (a == 5) f++;
  if (a == 7) s++;
  if (b == 5) f++;
  if (b == 7) s++;
  if (c == 5) f++;
  if (c == 7) s++;
  if (f == 2 && s == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
LL a[200010];
LL sum[200010];
int l[200010];
int r[200010];

void init() {

}

void input() {
	cin >> n;
	REP(i, n) cin >> a[i];
}

LL ssum(int l, int r) {
	return sum[r] - sum[l];
}

void solve() {
	sum[0] = 0;
	REP(i, n) sum[i+1] = sum[i] + a[i];

	l[2] = 1;
	int pl = 1;
	for (int i = 3; i <= n-2; i++) {
		while(1) {
			LL sumll = ssum(0, pl);
			LL sumlr = ssum(pl, i);
			LL next_sumll = ssum(0, pl+1);
			LL next_sumlr = ssum(pl+1, i);
			if (abs(sumll-sumlr) < abs(next_sumll-next_sumlr)){
				l[i] = pl;
				break;
			}
			pl++;
		}
	}

	r[n-2] = n-1;
	int pr = n-1;
	for (int i = n-2; i >= 2; i--) {
		while(1) {
			LL sumrl = ssum(i, pr);
			LL sumrr = ssum(pr, n);
			LL next_sumrl = ssum(i, pr-1);
			LL next_sumrr = ssum(pr-1, n);
			if (abs(sumrl-sumrr) < abs(next_sumrl-next_sumrr)){
				r[i] = pr;
				break;
			}
			pr--;
		}
	}

	LL res = 1LL<<60;
	for (int i = 2; i <= n-2; i++) {
		LL sumll = ssum(0, l[i]);
		LL sumlr = ssum(l[i], i);
		LL sumrl = ssum(i, r[i]);
		LL sumrr = ssum(r[i], n);
		LL mx = max({sumll, sumlr, sumrl, sumrr});
		LL mn = min({sumll, sumlr, sumrl, sumrr});
		chmin(res, mx-mn);
	}
	cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n-r+1;
	int sum = 1;
	for(int i =s;i<=n;i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string s, t,a="Yes";
	cin >> s;
	t = s.substr(0, 4);
	if (t != "YAKI")
		a = "No";
	cout << a;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char s[210];
  scanf("%s",&s);
  for(int i = strlen(s) - 2;i > 0;i--){
    if(i % 2 > 0){
      int check = 1;
      for(int j = 0;j < (i + 1) / 2;j++){
        if(s[j] != s[j + (i + 1) / 2]){
          check = 0;
        }
      }
      if(check > 0){
        printf("%d\n",i + 1);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 100
using namespace std;
int main() {
	// your code goes here
	int N;
	cin>>N;
	
	int cnt = 0;
	for(int n=1;n<=N;n++){
		int digits = (int)floor(log10((double)n)) + 1;
		if(digits&1) cnt++;
	}
  
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 512
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var inning = +lines.shift();

var out = 0;
var score = 0;
var runner = 0;

var line;
while (line = lines.shift()) {
    if (line == 'HIT') {
        runner++;
        if (runner > 3) {
            score++;
            runner--;
        }
    } else if (line == 'HOMERUN') {
        score += runner + 1;
        runner = 0;
    } else {
        out++;
        if (out == 3) {
            console.log(score);
            out = 0;
            score = 0;
            runner = 0;
            continue;
        }
    }
}

Measured memory_bytes: 7636
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string n;
	cin >> n;
	for(int i=0;i<3;i++) if(n[i]=='9') cout << 1; else cout << 9;
	cout << endl;
	return 0;
}

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

typedef long long ll;
const ll mod=1e9+7;
ll fact[200010];
ll invfact[200010];

ll power(ll b, ll e) {
	ll c=1;
	while(e) {
		if(e&1LL)
			c=(c*b)%mod;
		b=(b*b)%mod;
		e/=2LL;
	}
	return c;
}

ll C(ll n, ll k) {
	ll ans=0;
	ans=(fact[n]*invfact[k])%mod;
	ans=(ans*invfact[n-k])%mod;
	return ans;
}

int main() {
	// your code goes here
	ll i,j, h, w, a, b;
	fact[0]=invfact[0]=1;
	for(i=1; i<=200000; ++i) {
		fact[i]=(fact[i-1]*i)%mod;
		invfact[i]=power(fact[i], mod-2LL);
	}
	cin>>h>>w>>a>>b;
	ll ans=0;
	for(i=1; i<=h-a; ++i) {
		ans=(ans+(C(i-1+b-1, i-1)*C(h+w-b-i-1, h-i))%mod)%mod;
		//cout<<ans<<" "<<i<<endl;
	}
	cout<<ans;
	return 0;
}

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

#define MAX_SIZE 100100
#define NIL -1

vector< vector<int> > G(MAX_SIZE);
vector<int> seen(MAX_SIZE, NIL);

int id;

void dfs(int v) {
    stack<int> st;
    st.push(v);
    seen[v] = id;
    while (!st.empty()) {
        int u = st.top();
        st.pop();
        for (int i = 0; i < (int)G[u].size(); i++) {
            int t = G[u][i];
            if (seen[t] != NIL) continue;
            seen[t] = id;
            st.push(t);
        }
    }
    return;
}

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

    int s, t;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    id = 1;
    for (int i = 0; i < n; i++) {
        if (seen[i] == NIL) {
            dfs(i);
            id++;
        }
    }

    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (seen[s] == seen[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8680