akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication23
{
    //ITP1_10-D

    class Distance
    {
        int v;
        int[] x, y;

        public Distance(int[] i,int[] j,int k)
        {
            x = i;
            y = j;
            v = k;
        }

        public double Dis(int a)
        {
            double sum = 0;
            for (int i = 0; i < v; ++i)
            {
                sum += Math.Pow(Math.Abs(x[i] - y[i]),a);
            }
            return sum;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] x = Console.ReadLine().Split(' ');
            int[] xArray = Array.ConvertAll(x, int.Parse);

            string[] y = Console.ReadLine().Split(' ');
            int[] yArray = Array.ConvertAll(y, int.Parse);


            Distance p = new Distance(xArray,yArray,n);         //????????????????????????????????????

            double p1, p2, p3;

            p1 = p.Dis(1);                      //????????????????????????
            p2 = Math.Pow(p.Dis(2), 1.0 / 2.0);
            p3 = Math.Pow(p.Dis(3), 1.0 / 3.0);


            double max = Math.Abs(xArray[0] - yArray[0]);       //p = ????????¨???
            for (int i = 1; i < n; ++i)
            {
                max = Math.Max((Math.Abs(xArray[i] - yArray[i])), max);
            }

            Console.WriteLine("{0:f8}", p1);
            Console.WriteLine("{0:f8}", p2);
            Console.WriteLine("{0:f8}", p3);
            Console.WriteLine("{0:f8}", max);
        }
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, X, Y, x[100], y[100];

int main() {
	cin >> n >> m >> X >> Y;
	inc(i, n) { cin >> x[i]; }
	inc(i, m) { cin >> y[i]; }
	
	int xma = x[0];
	inc(i, n) { setmax(xma, x[i]); }
	int ymi = y[0];
	inc(i, m) { setmin(ymi, y[i]); }
	
	xma++;
	
	cout << (xma <= ymi && X < ymi && xma <= Y ? "No War" : "War") << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
D = input().split(" ")
D = [int(i) for i in D]
D = sorted(D)
#print(D)
LEN = int(len(D))
DV = int(int(LEN)/2)
#print(DV)
#print(D[DV-1])
HALF_B = D[DV-1]
HALF_F = D[DV]
DIF = HALF_F - HALF_B
#print(HALF_B,HALF_F,DIF)
print(DIF)

Measured memory_bytes: 14396
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
using P = std::pair<ll, int>;

constexpr int MAX_N = 100000;
constexpr ll INF = 1e17, mod = 1000000007;

struct edge
{ int from, to; ll cost; };

int N, M;
int S, T;
std::vector<P> G[MAX_N+10];
ll d[2][MAX_N+10], dp[2][MAX_N+10];
ll ans;

void dijkstra( int s, int idx )
{
  std::fill( d[idx], d[idx]+N, INF );

  std::priority_queue<P, std::vector<P>, std::greater<P> > pque;

  pque.push( P( 0, s ) );
  d[idx][s] = 0;
  dp[idx][s] = 1;

  while( !pque.empty() )
  {
    P p = pque.top(); pque.pop();
    ll dist = p.first;
    int v = p.second;

    if( d[idx][v] < dist )
      continue;

    for( auto &e : G[v] )
    {
      ll cost = e.first;
      int u = e.second;

      if( d[idx][u] > d[idx][v]+cost )
      {
        dp[idx][u] = dp[idx][v];
        d[idx][u] = d[idx][v]+cost;
        pque.push( P( d[idx][u], u ) );
      }
      else if( d[idx][u] == d[idx][v]+cost )
        dp[idx][u] = (dp[idx][u]+dp[idx][v]) % mod;
    }
  }

  return;
}

ll sqr( ll x )
{ return x%mod*x%mod; }

int main()
{
  scanf( "%d%d%d%d", &N, &M, &S, &T );
  --S; --T;
  rep( i, M )
  {
    int U, V;
    ll D;
    scanf( "%d%d%lld", &U, &V, &D );

    --U; --V;
    G[U].push_back( P( D, V ) );
    G[V].push_back( P( D, U ) );
  }

  dijkstra( S, 0 );
  dijkstra( T, 1 );

  ans = (dp[0][T]*dp[0][T]) % mod;

  rep( i, N ) if( 2*d[0][i] == d[0][T] && d[0][i] == d[1][i] )
    ans = (ans-sqr(dp[0][i]*dp[1][i]%mod)+mod) % mod;

  rep( i, N ) for( auto &e : G[i] )
  {
    int u = i, v = e.second;
    ll D = e.first;
   
    if( 2*std::max( d[0][u], d[1][v] ) < d[0][T] && d[0][u]+D+d[1][v] == d[0][T] )
      ans = (ans-sqr(dp[0][u]*dp[1][v]%mod)+mod) % mod;
  }

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

  return 0;
}

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

int main(){
  int a,b,c,k,ans=0;cin>>a>>b>>c>>k;
  int A=min(a,k);
  ans+=A;k-=A;
  int B=min(b,k);k-=B;
  int C=min(c,k);ans-=C;
  cout<<ans<<endl;
}

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

#define all(v) v.begin(), v.end()
typedef long long ll;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<ll> k(m);
    vector<vector<ll>> s(m);
    vector<ll> p(m);
    for(i = 0;i < m;++i){
        cin >> k.at(i);
        for(j = 0;j < k.at(i);++j){
            ll tmp;
            cin >> tmp;
            --tmp;
            s.at(i).push_back(tmp);
        }
    }
    for(i = 0;i < m;++i){
        cin >> p.at(i);
    }
    ll bit;
    ll ans = 0;
    for(bit = 0;bit < (1 << n);++bit){
        vector<ll> light(n,0);
        for(i = 0;i < n;++i){
            if(bit & (1 << i)){
                light.at(i) = 1;
            }
        }
        bool flag = true;
        for(i = 0;i < m;++i){
            ll tmp = 0;
            for(j = 0;j < k.at(i);++j){
                if(light.at(s.at(i).at(j))) ++tmp;
            }
            if(tmp%2 != p.at(i)){
                flag = false;
                break;
            }
        }
        if(flag){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        if (N == 1) {
            System.out.println(0);
            return;
        }
        List<Integer>[] graph = new List[N];
        for (int i = 0; i < N; i++) {
            graph[i] = new ArrayList<>();
        }
        Edge[] edges = new Edge[N-1];
        for (int i = 0; i < N-1; i++) {
            int u = scan.nextInt()-1;
            int v = scan.nextInt()-1;
            int w = scan.nextInt();
            graph[u].add(i);
            graph[v].add(i);
            Edge e = new Edge();
            e.id = i;
            e.from = u;
            e.to = v;
            e.weight = w;
            edges[i] = e;
        }
        int max_degree = 0;
        int root = -1;
        for (int i = 0; i < N; i++) {
            if (max_degree < graph[i].size()) {
                max_degree = graph[i].size();
                root = i;
            }
        }
        int[] colors = new int[N];
        Arrays.fill(colors, -1);
        boolean[] visited = new boolean[N];
        Queue<Integer> queue = new LinkedList<>();
        queue.add(root);
        colors[root] = 0;
        while(!queue.isEmpty()) {
            int node = queue.poll();
            int color = colors[node];
            visited[node] = true;
            for (int edge_id : graph[node]) {
                Edge e = edges[edge_id];
                int next = e.from == node ? e.to : e.from;
                if (visited[next]) {
                    continue;
                }
                if (e.weight % 2 == 1) {
                    colors[next] = (color + 1) % 2;
                } else {
                    colors[next] = color;
                }
                queue.add(next);
            }
        }
        for (int i = 0; i < N; i++) {
            System.out.println(colors[i]);
        }
    }
    class Edge {
        int id;
        int from;
        int to;
        int weight;
    }
}


Measured memory_bytes: 108004
def main():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)
    def helper(t):
        k = K
        for a, f in zip(A, F):
            if a * f <= t:
                continue
            m = t // f
            k -= (a - m)
            if k < 0:
                return False
        return True

    l = 0
    r = A[-1] * F[0]
    while r != l:
        m = l + (r - l) // 2
        if helper(m):
            r = m
        else:
            l = m + 1
    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 120012
#include <iostream>

using namespace std;

int main()
{
	int a;

    int b;
	cin>>a>>b;

	for(int i=0;i<=a;i++)
	{
		for(int n=0;i+n<=a;n++)
		{
			int m=a-n-i;
			
			if(b==10000*i+5000*n+1000*m)
			{
				cout<<i<<" "<<n<<" "<<m<<endl;
				return 0;
			}
		}
	}
    cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;
	
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 150010
ll n;
vector<ll> g[N];
double down[N],up[N];
double dsum[N];
void dfs1(ll x,ll p){
    double sum=0,pa=0;
    for(auto y:g[x])if(y!=p){
	dfs1(y,x);
	sum+=down[y]; pa+=1;
    }
    if(pa==0)down[x]=0;
    else down[x]=sum/pa+1;
    if(~p)dsum[p]+=down[x]+1;
}
void dfs2(ll x,ll p){
    if(x==1)up[x]=0;
    else if(p==1){
	double sum=dsum[p]-(down[x]+1);
	double pa=g[p].size()-1;
	if(pa==0)up[x]=1;
	else up[x]=sum/pa+1;
    }
    else{
	double sum=dsum[p]-(down[x]+1)+up[p];
	double pa=g[p].size()-1;
	up[x]=sum/pa+1;
    }
    for(auto y:g[x])if(y!=p){
	dfs2(y,x);
    }
}
int main(){
    cin>>n; if(n>N)return 0;
    for(int i=0;i<n-1;i++){
	ll a,b;cin>>a>>b;
	g[a].push_back(b);
	g[b].push_back(a);
    }
    dfs1(1,0);
    dfs2(1,0);
    for(int i=1;i<=n;i++){
	double ans=(up[i]+dsum[i])/double(g[i].size());
	cout<<fixed<<setprecision(9)<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 19584
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
M = 200100
P = [-1 for i in range(M)]
NE = [-1 for a in range(N)]
for i in range(N):
    if P[A[i]] >= 0 and NE[P[A[i]]] < 0:
        NE[P[A[i]]] = i
    P[A[i]] = i
for i in range(N):
    if P[A[i]] >= 0 and NE[P[A[i]]] < 0:
        NE[P[A[i]]] = i
    P[A[i]] = i

i = 0
c = 1
while True:
    if NE[i] <= i: c += 1
    i = (NE[i] + 1) % N
    if i == 0:
        break
K %= c
ANS = []
i = 0
while K:
    while NE[i] > i:
        i = (NE[i] + 1) % N
    if K >= 2:
        i = (NE[i] + 1) % N
        K -= 1
    else:
        break
while i < N:
    if NE[i] > i:
        i = NE[i] + 1
    else:
        ANS.append(A[i])
        i += 1
print(*ANS)

Measured memory_bytes: 97208
n,k = map(int,input().split())
A = list(map(int,input().split()))
cnt = [0]*50
L = format(k, 'b').zfill(50)
S = [[0,0] for _ in range(50)]
for a in A:
    a_ = format(a, 'b').zfill(50)
    for i in range(50):
        if a_[i]=='1':
            S[i][0] += 1
        else:
            S[i][1] += 1
for i in range(len(S)):
    S[i][0] *= pow(2, 50-i-1)
    S[i][1] *= pow(2, 50-i-1)
dp = [[-1,-1] for _ in range(55)]
dp[0][0] = 0
for i in range(50):
    if L[i] == '1':
        if dp[i][1] != -1:
            dp[i+1][1] = dp[i][1] + max(S[i][0], S[i][1])
        if dp[i][0] != -1:
            dp[i+1][1] = max(dp[i+1][1], dp[i][0]+S[i][0])
            dp[i+1][0] = dp[i][0] + S[i][1]
    else:
        if dp[i][1] != -1:
            dp[i+1][1] = dp[i][1] + max(S[i][1], S[i][0])
        if dp[i][0] != -1:
            dp[i+1][0] = dp[i][0] + S[i][0]
print(max(dp[50]))

Measured memory_bytes: 68696
#include <stdio.h>

int main ()
{
  int x,y,z,a;

  while(1)
    {
      if(scanf("%d %d",&x,&y)!=2)
	break;
      if(x>y)
	{
	  a=x;
	  x=y;
	  y=a;
	}
      if(y<1)
	continue;

      while((z=x%y)!=0)
	{
	  x=y;
	  y=z;
	}
      printf("%d\n",y);
    }

  return 0;
}



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

void insertionSert(int *A, int N){
	for(int i=1; i<N; i++){
		int tmp = A[i];
		for(int j=i-1; j>=0; j--){
			if(A[j]>tmp){
				A[j+1] = A[j];
				A[j] = tmp;
			}
		}
		for(int k=0;k<N;k++)
			cout << A[k] << ((k==N-1)?"":" ");
		cout << endl;
	}
}

int main(){
	int N; cin >> N;
	int A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
		cout << A[i] << ((i==N-1)?"":" ");
	}
	cout << endl;
	insertionSert(A,N);
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {
}
vector<int> getDiv(int n){
  vector<int> res;
  for(int i=1;i*i<=n;i++)
    if(n%i == 0)
	{
	  res.push_back(i);
	  if(i*i != n) 
	    res.push_back(n/i);
	}
  return res;
}

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> res;
  for(ll i=2;i*i<=n;i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1)res[n] = 1;
  return res;
}


ll calcx(int v) {
  map<int,int> mp;
  REP(i,1,v+1) {
    map<ll,ll> pf = prime_factor(i);
    for(auto w : pf) mp[w.first] += w.second;
  }
  ll cnt = 1;
  //puts("");
  for(auto a : mp) {
    if( a.first == 1 ) continue;
    //cout << a.first << "," << a.second << " cnt = " << cnt << endl;
    cnt = cnt * ( a.second + 1LL );
  }
  return cnt;
}

int calc(int v) {
  int cnt = 0;
  REP(i,1,v+1) {
    if( v % i == 0 ) ++cnt;
  }
  return cnt;
}

ll dp[1000][100];
int main() {
  /*
  REP(i,1,20) {
    cout << i << "-th" << endl;
    ll v = 1;
    REP(j,1,i+1) v = v * (ll)j;
    cout << calc(v) << " == " << calcx(i) << endl;
    assert(calc(v)==calcx(i));
  }
  */
  int n;
  cin >> n;
  map<ll,ll> mp;
  REP(i,2,n+1) {
    map<ll,ll> pf = prime_factor(i);
    for(auto v : pf) {
      mp[v.first] += v.second;
    }
  }
  vector<int> vec;
  for(auto v : mp) {
    if( v.first == 1 ) continue;
    vec.push_back(v.second);
  }

  dp[0][1] = 1;
  rep(i,(int)vec.size()) {
    rep(j,80) {
      rep(k,vec[i]+1) {
	if( j * (k+1) <= 75 ) {
	  dp[i+1][j*(k+1)] += dp[i][j];
	}
      }
    }
  }
  cout << dp[(int)vec.size()][75] << endl;
  compute();
  return 0;
}


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

void solve(long long N, vector<long long> V, vector<long long> C){
	long long res = 0;
	for (int i=0; i<N; i++) if (V[i]-C[i]>0) res+=V[i]-C[i];
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> V(N-1+1);
	vector<long long> C(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&V[i]);
	}
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&C[i]);
	}
	solve(N, V, C);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){


    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    ll k = n-1;

    ll apx = a+k*c;
    ll apy = a+k*d;
    ll amx = a-k*c;
    ll amy = a-k*d;
    if((apx<=b&&b<=apy)||(amy<=b&&b<=amx)){
        cout<<"YES"<<endl;
        return 0;
    }
    for(ll i=1;i<k;i++){

        ll j = k-i;
        ll u1 = a+i*c-j*d;
        ll u2 = a+i*d-j*c;
        if(u1<=b&&b<=u2){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n;
    cin>>n;
    vector<int > v(n),c(n),diff(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int j=0;j<n;j++){
        cin>>c[j];
    }
    for(int i=0;i<n;i++){
        diff[i] = v[i]-c[i];
    }
    sort(diff.rbegin(),diff.rend());
    int dup = 0;
    for(int i=0;i<n;i++){
        if(diff[i] > 0)dup+=diff[i];
        else break;
        
    }
    cout<<dup<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner t = new Scanner(System.in);
        
        int a = t.nextInt();
        int b = t.nextInt();
        
        if (a <= 5){
            System.out.println("0");
        } else if (a <= 12){
            System.out.println(b/2);
        } else {
            System.out.println(b);
        }
    }   
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
     
    #ifdef DEBUG
    	#define freopen(...)
    #endif
     
    #define Min(_A, _B) (_A < _B ? _A : _B)
    #define Max(_A, _B) (_A > _B ? _A : _B)
     
    /*void Build_rmq(int p)
    {
    	for(int i = 1; i <= n; ++i) r[p][0][i] = b[i][p];
    	for(int i = 1; 1 << i <= n; ++i)
    		for(int j = 1; j + (1 << i) <= n; ++j)
    			r[p][i] = Max(r[p][i - 1][j], r[p][i - 1][j + (1 << i)]);
    }
    void Merge()
    {
    	for(int i = 1; i <= n; ++i)
    		for(int j = 1; j <= n; ++j)
    			
    }
    int RMQ(int Ls, int Rs, int p)
    {
    	int len = Log[Rs - Ls + 1];
    	int t1 = r[p][len][Ls], t2 = r[p][len][Rs - (1 << len) + 1];
    	return Max(t1, t2);
    }*/
    long long ans;
    int a[100010], d[100010], n, m;
    bool vis[100010];
    std::vector<int> b[100010];
    namespace bf
    {
    	void main()
    	{
    		for(int i = 1; i <= n; ++i)
    		{
    			long long tmp = 0;
    			int cnt = m;
    			for(int j = 0; j < m; ++j) 
    			{
    				tmp += b[i][j];
    				d[j] = b[i][j];
    				vis[j] = 1;
    			}
    			ans = Max(tmp, ans);
    			for(int j = i + 1; j <= n; ++j)
    			{
    				for(int k = 0; k < m; ++k) if(b[j][k] > d[k])
    				{
    					cnt -= vis[k];
    					vis[k] = 0;
    					tmp += b[j][k] - d[k];
    					d[k] = b[j][k];
    				}
    				tmp -= a[j - 1];
    				ans = Max(tmp, ans);
    				if(!cnt) break;
    			}
    		}
    		printf("%lld\n", ans);		
    	}
    }
    /*namespace test
    {
    	long long calc(int lim)
    	{
    		long long ans = 0;
    		for(int i = 1; i <= n; ++i) 
    		for(int i = 1; i <= n; ++i)
    		{
    			long long tmp = 0;
    			int cnt = m;
    			for(int j = 0; j < m; ++j) 
    			{
    				tmp += b[i][j];
    				d[j] = b[i][j];
    				vis[j] = 1;
    			}
    			ans = Max(tmp, ans);
    			for(int j = i + 1, lim = Min(i + 80, n); j <= lim; ++j)
    			{
    				for(int k = 0; k < m; ++k) if(b[j][k] > d[k])
    				{
    					cnt -= vis[k];
    					vis[k] = 0;
    					tmp += b[j][k] - d[k];
    					d[k] = b[j][k];
    				}
    				tmp -= a[j - 1];
    				ans = Max(tmp, ans);
    			//	if(!cnt) break;
    			}
    		}
    		printf("%lld\n", ans);		
    	}
    }*/
    int main()
    {
    	//freopen("restaurants.in", "r", stdin);
    	//freopen("restaurants.out", "w", stdout);
    	
    	scanf("%d %d", &n, &m);
    	for(int i = 1; i < n; ++i) scanf("%d", &a[i]);
    	for(int i = 1; i <= n; ++i)
    		for(int j = 1; j <= m; ++j)
    		{
    			int t; scanf("%d", &t);
    			b[i].push_back(t);
    		}
    	//if(1ll * n * n * m <= 2e8) 
    	bf::main();
    	//else test::main();
    	return 0;
    }

Measured memory_bytes: 9728
from collections import deque
N = int(input())
txy = [map(int, input().split()) for _ in range(N)]
t, x, y = [list(i) for i in zip(*txy)]
t = deque(t)
x = deque(x)
y = deque(y)
t.appendleft(0)
x.appendleft(0)
y.appendleft(0)
for i in range(N):
    direct = t[i+1] - t[i] - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])
    if direct < 0 or direct % 2 != 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 63736
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    A, B, C, K = [int(x) for x in input().strip().split()]
    if K <= A + B:
        print(min(K, A))
    else:
        print(A - (K - A - B))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<double> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    double avg = (a[0]+a[1])/2.0;
    for(int i=2;i<n;++i) {
        avg = (avg + a[i]) / 2.0;
    }

    cout << fixed << setprecision(10) << avg << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

ans = len(t)

for i in range(len(s) - (len(t) - 1)):
    cnt = len(t)
    for j in range(len(t)):
        if s[i + j] == t[j]:
            cnt -= 1
    if cnt < ans:
        ans = cnt

print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
/*ll f(ll x) {
  if (x == 1) return (ll)1;
  ll ans = x * f(x - 1) % MOD;
  return ans;
}*/
int main() {
  ll N, M;
  cin >> N >> M;
  ll ans = 1;
  for (ll i = 1; i <= N; i++) {
    ans *= i;
    ans %= MOD;
  }
  for (ll i = 1; i <= M; i++) {
    ans *= i;
    ans %= MOD;
  }
  if (N == M) ans = ans * 2 % MOD;
  if (1 < abs(N - M)) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3672
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	    String S=gs();
	    boolean f=false;
	    String k="keyence";
	    for (int i=0; i<k.length();i++) {
	    	String s1=k.substring(0,i);
	    	String s2=k.substring(i);
	    	if(S.startsWith(s1)&&S.endsWith(s2)) {
	    		f=true;
	    		break;
	    	}
	    }
	    if(f) {
	    	System.out.println("YES");
	    }else {
	    	System.out.println("NO");
	    }
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

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

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

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

Measured memory_bytes: 35520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
const ll inf = 2e15 + 7;

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

	int n;
	cin >> n;
	char s[15];
	string t;
	for (int i = 0; i <= n; ++i) {
		s[i] = 'a';
		if (i != n)t += 'a' + i;
	}
	if (n != 1) { for (int i = 0; i < n; ++i)cout << 'a'; cout << endl; }
	for (int i = 0; i < 1e7; ++i) {
		s[n]++;
		for (int j = n; j > 0; --j) {
			if (s[j] == 'a' + j) {
				s[j] = 'a';
				s[j - 1]++;
			}
		}
		int k = 1;
		string tt;
		tt.assign(s, 1, n);
		int a[10] = { 0 };
		int b[10], cnt = 0;
		for (int j = 0; j < n; ++j) {
			if (a[tt[j] - 'a'] == 0) {
				a[tt[j] - 'a'] = 1;
				b[cnt++] = tt[j] - 'a';
			}
		}
		/*for (int j = 0; j < cnt; ++j) {
			cout << b[j] << ' ';
		}cout << endl;*/
		for (int j = 0; j < cnt; ++j) {
			if (b[j] != j) {
				k = 0;
				break;
			}
		}

		if(k)cout << tt << endl;
		if (t == tt)break;
	}


	return 0;
}



Measured memory_bytes: 1536
/**
 * A Fifty-Fifty
 * https://atcoder.jp/contests/abc132/tasks/abc132_a
 * 
 * 方針
 * S 
 **/
#include<iostream>
#include<algorithm>
using namespace std;


string S;

void solve() {
    sort(S.begin(), S.end());
    if (S[0] == S[1] && S[1] != S[2] && S[2] == S[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin >> S;
    solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i = 0; i < values.length; i++){
			values[i] = i + 1;
		}
		for(int i = 0; i < n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int tmp;
			tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
		}
		for(int j = 0; j < values.length; j++){
			System.out.println(values[j]);
		}
	}
}

Measured memory_bytes: 17200
X = [input() for _ in range(5)]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
if elesnum:
  elesnum.sort(key = lambda x: x[-1])
  min_ = int(elesnum[0])
  for e in elesnum[1:]:
    endzero += (int(e)//10+1)*10
  print(endzero+min_)
else:
  print(endzero)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, bool> piib;
typedef pair<double, double> pdd;
typedef pair<int, pii> pipii;
typedef pair<ll, ll> pll;

void solve() {
  int r, c, a, b;
  cin >> r >> c >> a >> b;
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      if((i < b) == (j < a)) {
        cout << 0;
      }
      else {
        cout << 1;
      }
    }
    cout << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 1280
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void c_not_so_diverse(void) {
	int n, k;
	int *a;

	cin >> n >> k;

	a = (int*)(calloc(n, sizeof(int)));

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

	//int b[200000] = { 0 };
	int* b;
	b = (int*)(calloc(n+1, sizeof(int)));


	for (int i = 0; i < n; i++) b[a[i]]++;
	sort(b, b + n+1);

	int type_cnt = 0;
	int k_cnt = 0;
	for (int i = 0; i < n+1; i++) {
		if (b[i] == 0) continue;
		type_cnt++;
	}
	//cout << type_cnt << endl;
	int cnt = 0;
	for (int i = 0; i < n+1; i++) {
		if (k_cnt >= (type_cnt - k)) break;
		if (b[i] == 0)continue;
		//cout << b[i] << endl;
		cnt += b[i];
		k_cnt++;
	}

	cout << cnt << endl;

	//free(a);
	//free(b);
}

int main()
{
	c_not_so_diverse();
    return 0;
}

Measured memory_bytes: 5116
import bisect
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
q=int(input())
A=collections.Counter(a)
ans=sum(a)
for _ in range(q):
  b,c=map(int,input().split())
  k=A[b]
  ans=(c-b)*k+ans
  print(ans)
  del A[b]
  A[c]+=k


Measured memory_bytes: 90460
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
 
 
 
int main(){
    string S;
    cin >> S;
    
    for (int i = 0; i < S.size(); i++)
    {
        if(i%2 == 0){
            if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(i%2 == 1){
            if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
int c[mx], n, cnt = 0, is, bi, nbi;
vector < int > ad[mx];
bool mark[mx], b;
void dfs(int v){
	mark[v] = 1;
	for(auto u : ad[v]){
		if(c[u] == c[v])
			b = 0;
		if(!mark[u]){
			c[u] = 1 - c[v];
			dfs(u);
		}
	}
	return;
}
void dfs_all(){
	memset(c , -1 , sizeof c);
	for(int i = 0; i < n; i++){
		if(!mark[i]){
			cnt++;
			b = 1;
			c[i] = 1;
			if(sz(ad[i])){
				dfs(i);
				if(b)
					bi++;
				else
					nbi++;
			}
			else
				is++;
		}
	}
	return;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int m, u, v;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		u--, v--;
		ad[u].pb(v);
		ad[v].pb(u);
	}
	dfs_all();
//	cout << is << " " << bi << " " << nbi << endl;
	cout << (bi + nbi) * (bi + nbi) + bi * bi + 2 * n * is - is * is << endl;
	return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
}

int main(void){
    COMinit();
    int x, y;
    cin >> x >> y;
    ll ans = 0;
    if ((x+y)%3 == 0) {
        ll n = (2*y-x)/3;
        ll m = (2*x-y)/3;
        if (n >= 0 && m >= 0)
            ans = COM(n+m, n);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin >> n >> k;
	ll a[n];
	for(ll i = 0;i < n;i++){
		cin >> a[i];
	}
	ll b[n];
	b[n - 1] = 0;
	for(ll i = n - 2;i >= 0;i--){
		b[i] = LLONG_MAX;
		for(ll j = i + 1;j < n && j - i <= k;j++){
			b[i] = min(b[i],abs(a[i] - a[j]) + b[j]);
		}
	}
	cout << b[0] << "\n";
	return 0;
}

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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans;
  for (int i=0; i<a+1; i++){
    for (int j=0; j<b+1; j++){
      for (int k=0; k<c+1; k++){
        if ((500*i+100*j+50*k) == x) ans +=1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(lis[k-1])

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


int main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long A = a / x;
    long long B = b / x;

    long long total = B - A;
    if(a % x == 0){
        total++;
    }

    cout << total << endl;

}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main(void)
{
	float N, a=0;
	int i;
	
	scanf("%f", &N);
	
	lop(i, N){
		if(i%2!=0){ a++; }
	}
	
	printf("%f", (a/N));
	
	return 0;
}

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

int main() {
    int n,x,y;
    cin >> n;
    int c = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if(x==y) {
            c++;
            if(c>=3) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        else c = 0;
    }

    cout << "No" << endl;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////





int main() {

	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max(A*B, C*D);

	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;
using pci = std::pair<char, int>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	int* a = new int[n];
	int* b = new int[n];
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	int* num = new int[n];
	memset(num, 0, sizeof(int)*n);
	bool flag = false;
	rep(i, n) {
		++num[a[i] - 1];
		++num[b[i] - 1];

		if (num[a[i] - 1] > n || num[b[i] - 1] > n) {
			flag = true;
			break;
		}
	}
	delete[] num;

	if (flag) {
		cout << "No" << "\n";
		return 0;
	}

	int* c = new int[n + 1];
	int* d = new int[n + 1];
	memset(c, -1, sizeof(int)*(n + 1));
	memset(d, -1, sizeof(int)*(n + 1));
	rep(i, n) {
		c[a[i]] = i;
		d[b[i]] = i;
	}

	int x = 0;
	REP(i, 1, n + 1) {
		c[i] = max(c[i], c[i - 1]);
		d[i] = max(d[i], d[i - 1]);

		x = max(x, c[i] - d[i - 1]);
	}

	cout << "Yes" << "\n";
	rep(i, n) {
		cout << b[(i + n - x) % n] << " ";
	}

	cout << "\n";

	return 0;
}


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


void solve(long long A, long long B, long long N){
    long long ans;
    if (N < B) {
        ans = (A * N)/B;
    } else {
        ans = (A * (B - 1))/B;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n){
        int a;
        cin >> a;
        m[a]++;
    }
    ll ans = 0;
    for(auto t : m){
        if(t.second==0) continue;
        if(t.second < t.first){
            ans += t.second;
        }else{
            ans += t.second - t.first;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){
    int n, ans;
    string s;
    char nc[3] = {0,0,0};

    cin >> n >> s;

    ans = 0;

    for(int i=0; i<=999; i++){
        nc[2] = i%10 + '0';
        nc[1] = i/10%10 + '0';
        nc[0] = i/100 + '0';

        int pos = 0;
        bool found = true;
        for(int j=2; j>=0; j--){
            pos = s.find_first_of(nc[j], pos);
            if(pos >= s.length()){
                found = false;
                break;
            }
            pos++;
        }
        if(found){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S = list(input())
T = list(input())

list_a_z = [chr(i) for i in range(97, 97+26)]

flag = True

for a in list_a_z:
    try:
        i = S.index(a)
        b = T[i]
        if [s == a for s in S] != [t == b for t in T]:
            flag = False
            break
    except:
        pass

if flag == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9776
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ans int
	for i := 1; i <= n; i++ {
		if i%3 == 0 || i%5 == 0 {
		} else {
			ans += i
		}
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	fmt.Fprintln(w, ans)
}


Measured memory_bytes: 1828
def calculate(n, arr2):
    steps = [0]*(n)
    steps[0] = 1

    if arr2.get(0) == True:
        steps[0] = 0
    else:
        steps[0] = 1

    if n == 1:
        return steps

    if arr2.get(1) == True:
        steps[1] = 0
    else:
        steps[1] = 1 + steps[0]

    if n == 2:
        return steps

    for index in range(2,n):
        if arr2.get(index) == True:
            steps[index] = 0
        else:
            steps[index] = steps[index-1] + steps[index-2]

    return steps

S = input().split(" ")
N = int(S[0])
M = int(S[1])


arr2 = {}
for i in range(M):
    index = int(input())
    arr2.setdefault(index-1, True)

result = calculate(N, arr2)

print(result[N-1] % 1000000007)




Measured memory_bytes: 460020
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

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

  string s1,s2;
  bool addRight = true;
  while(s1.size() < n){
    bool f = false;
    rep(i,4){
      if(addRight){
	if(i==0) s1 += '.', s2 += '.';
	else if(i==1) s1 += '.', s2 += '#';
	else if(i==2) s1 += '#', s2 += '.';
	else s1 += '#', s2 += '#';
      }else{
	if(i==0) s1 = '.' + s1, s2 = '.' + s2;
	else if(i==1) s1 = '.' + s1, s2 = '#' + s2;
	else if(i==2) s1 = '#' + s1, s2 = '.' + s2;
	else s1 = '#' + s1, s2 = '#' + s2;
      }

      cout << s1 << '\n' << s2 << endl;
      string r; cin >> r;
      if(r == "end"){
	return 0;
      }else if(r == "T"){
	f = true; break;
      }
      if(addRight){
	s1.pop_back(); s2.pop_back();
      }else{
	s1 = s1.substr(1); s2 = s2.substr(1);
      }
    }

    if(!f){
      addRight = false;
    }
  }
}


Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  std::string s;
  cin >> s;

  int cnt {};

  rep(i, s.size()) {
    cnt += s[i] - '0';
    cnt %= 9;
  }
  if (cnt == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3748
//コメント付き。
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
static void Main(string[] args){
  var NY = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
  int N=NY[0];
  int Y=NY[1]/1000;
  //最初に-1,-1,-1を入れておけば、値が見つかれば更新され、なければ-1のまま。
  int[] ans=new int[]{-1,-1,-1};
  //indexがN+1まで必要ということに注意
  for(int i=0;i<N+1;i++){
  	for(int j=0;j<N-i+1;j++){
      for(int k=0;k<N-i-j+1;k++){
        if(i+j+k==N){
      		if(i*10+j*5+k*1==Y){
              //
          　　ans=new int[]{i,j,k};
              Console.WriteLine("{0} {1} {2}",ans[0],ans[1],ans[2]);
              //一個だけ見つければいいので、ここで抜けないと実行時間がかなり長くなる。
              //return;
              //もしくは、
              goto end;
            }
        }
      }
    }
  }
  Console.WriteLine("{0} {1} {2}",ans[0],ans[1],ans[2]);
  end:;
}
}


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

long long n;
vector<long long> p(1, 2);

int main()
{
	for (long long i = 3; i < 1000000; i += 2) {
		long long j = 0;
		bool f = 1;
		while(p[j] * p[j] <= i){
			if (i % p[j] == 0) {
				f = 0;
				break;
			}

			j++;
		}

		if (f)
			p.push_back(i);
	}

	while (cin >> n) {
		int m = 0;

		while (m < p.size() && p[m] <= n)
			m++;

		cout << m << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint a, b, x;

    scanf("%lld", &a);
    scanf("%lld", &b);
    scanf("%lld", &x);

    if (a == 0)
    {
        printf("%lld", b / x + 1);
        return 0;
    }

    printf("%lld", b / x - (a - 1) / x);
    return 0;
}


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

const int maxn = 5005, p = 1e9+7;
int n, k;
int a[maxn];
long long ans, x1, x2;
signed main(){
    scanf("%d%d", &n,&k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", a+i);
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if(a[i] > a[j]) {
                if(i < j) x1++;
                x2++;
            }
        }
    }
    if(k==1) ans = x1;
    else ans = x1*k%p+(long long)k*(k-1)/2%p*x2%p;
    ans %= p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;

int main(int argc, char **argv) {
    char ch;
    scanf("%c", &ch);
    switch (ch)
    {
        case 'A':
            printf("T\n");
            break;
        case 'T':
            printf("A\n");
            break;
        case 'G':
            printf("C\n");
            break;
        case 'C':
            printf("G\n");
            break;
    }
    
}

Measured memory_bytes: 128
import sys
import re
r = "keyence"
c1=re.compile("^.+?keyence$")
c2=re.compile("^k.+?eyence$")
c3=re.compile("^ke.+?yence$")
c4=re.compile("^key.+?ence$")
c5=re.compile("^keye.+?nce$")
c6=re.compile("^keyen.+?ce$")
c7=re.compile("^keyenc.+?e$")
c8=re.compile("^keyence.+?$")

for line in sys.stdin.readlines():
    target = line.strip()
    if len(target) == 7:
        if target == r:
            print("YES")
        else:
            print("NO")
    else:
        if re.search(c1, target) is not None or re.search(c2, target) is not None or re.search(c3, target) is not None or re.search(c4, target) is not None or re.search(c5, target) is not None or re.search(c6, target) is not None or re.search(c7, target) is not None or re.search(c8, target) is not None:
            print("YES")
        else:
            print("NO")


Measured memory_bytes: 3188
// 負の数の個数が偶数か、0が含まれていたらすべての要素を正の数にできるので
// 正の数の和を出力する?
// そうでない(0が含まれず、負の数の個数が奇数)時は
// 負の数の個数は1にできるので最も絶対値が小さい数を負の数、ほかを
// 正の数にして和をとればよい?
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n; cin >> n;
  int minus = 0, zero = 0;
  long long sum = 0;
  vector<long long> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
    if(v[i]==0) zero++;
    else if(v[i]<0) minus++;
    sum += abs(v[i]);
  }
  long long abs_min = abs(v[0]);
  for(int i=0;i<n;i++) abs_min = min(abs_min, abs(v[i]));
  
  if(minus % 2 == 0 || zero != 0){
    cout << sum << endl;
  }else{
    cout << sum - abs_min * 2;
  }
  
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

        int ans = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  int y;
  cin >> x >> y;
  int a=x+y;
  int b=x-y;
  int c=x*y;
  cout << max(max(a,b),c) << endl;
  
  
   
  
    
  
  
 }

Measured memory_bytes: 256
import itertools

n=int(input())
p=tuple(map(int, input().split()))
q=tuple(map(int, input().split()))

tmp=list()
for i in range(n):
    tmp.append(i+1)
perm=list(itertools.permutations(tmp))

print(abs(perm.index(p)-perm.index(q)))

Measured memory_bytes: 8052