akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt();
            var N = line[0];
            var K = line[1];

            long baisu = N / K;
            long res = baisu * baisu * baisu;

            if (K % 2 == 0)
            {
                long half = (N + K / 2) / K;
                res += half * half * half;
            }

            return res;
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int i;
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	int dp[3][n];
	memset(dp,0,sizeof(dp));
	dp[0][0]=a[0];
	dp[1][0]=b[0];
	dp[2][0]=c[0];
	for(i=1;i<n;i++)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
		dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, c, x, y;
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	if(a+b<=2*c){
		printf("%d\n", a*x+b*y);
	}else if(x>y){
		if(2*c>=a){
		printf("%d\n", a*(x-y)+2*y*c);
		}else{
		printf("%d\n", 2*x*c);
		}
	}else{
		if(2*c>=b){
		printf("%d\n", b*(y-x)+2*x*c);
		}else{
		printf("%d\n", 2*y*c);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vl a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    vl dp(n + 1, -1);
    for (int i = 0; i < m; ++i) {
        dp[a[i]] = 0;
    }
    dp[0] = 1;
    if (dp[1] != 0)
        dp[1] = 1;

    for (int i = 2; i <= n; ++i) {
        if (dp[i] != 0) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        }
    }
    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
def main():
    N=int(input())
    edge = [[]for _ in range(N)]
    for _ in range(N-1):
        u,v,w = map(int,input().split())
        u,v = u-1,v-1
        edge[u].append((v,w))
        edge[v].append((u,w))
    color = [-1]*N
    color[0]=0
    stack = [(0,0)]
    while stack:
        v,col = stack.pop()
        for to,dist in edge[v]:
            if color[to]!=-1:
                continue
            c = (col+dist)%2  # 色
            color[to] = c
            stack.append((to,c))
    print(*color,sep="\n")
            

if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin >> s;
  if (s == "RRR")
    cout << 3 << endl;
  else if (s == "SSS")
    cout << 0 << endl;
  else if (s == "RRS") {
    cout << 2 << endl;
  } else if (s == "SRR") {
    cout << 2 << endl;
  } else
    cout << 1 << endl;
}


Measured memory_bytes: 3624
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    ans = "No"
    for i in range((n // 4) + 1):
        for j in range((n // 7) + 1):
            if 4 * i + 7 * j == n:
                ans = "Yes"
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll x, n, ans;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  set<ll> p;
  REP(i, n) {
    ll tmp;
    cin >> tmp;
    p.insert(tmp);
  }

  ll t = INF;
  REP(j, 105) {
    ll i = j - 2;
    if (!p.count(i + 1)) {
      if (t > abs(i+1 - x)) {
        t = abs(i+1 - x);
        ans = i + 1;
      }
    }
  }

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


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
	int A,B,K,c,ans;
  	cin >> A >> B >> K;
  	c=0;
  	for(int i=100;i>0;i--){	
      if(A%i==0&&B%i==0){
     
        	c++;
       
        	if(K==c){
              	ans = i;
            	break;
            }

        }

    }

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll calc(ll x){
    return x*(x+1)/2;
}
void solve(){
    string s;
    cin>>s;
    int n=s.size();
    vector<ll>a(n+1);
    rep(i,n){
        if(s[i]=='<')chmax(a[i+1],a[i]+1);
    }
    for(int i=n;i>0;--i){
        if(s[i-1]=='>')chmax(a[i-1],a[i]+1);
    }
    cout<<accumulate(a.begin(),a.end(),0LL)<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4764
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
class Solver {
public:
  int N, K;
  int a[200005];
  int b[200005] = {};

  void solve() {
    cin >> N >> K;
    rep(i, N) {
      cin >> a[i];
      a[i] -= 1;
      b[a[i]] += 1;
    }
    sort(b, b+N, greater<int>());

    int cnt = 0;
    rep2(i, K, N) {
      cnt += b[i];
    }
    cout << cnt << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


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

const int N = (int) 500 + 10 ;
const int inf = (int) 2e9 ;

int d[N][N] , color[N][N] ;
int n , c ;
vector< int > grp[4] ;
int cost[4][50] ;

int G( int g , int col ) {
    if( cost[g][col] != -1 ) return cost[g][col] ;
    int sum = 0 , len = (int) grp[g].size() ;
    for( int i = 0 ; i < len ; i++ ) {
        sum += d[ grp[g][i] ][ col ] ;
    }
    cost[g][col] = sum ;
    return sum ;
}

int F( int x , int y , int z ) {
    int sum = G(0 , x) + G(1 , y) + G(2 , z) ;
    return sum ;
}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    memset( cost , -1 , sizeof(cost) ) ;
    scanf("%d %d" , &n , &c ) ;
    for( int i = 1 ; i <= c ; i++ ) {
        for( int j = 1 ; j <= c ; j++ ) {
            scanf("%d" , &d[i][j] ) ;
        }
    }
    for( int i = 1 ; i <= n ; i++ ) {
        for( int j = 1 ; j <= n ; j++ ) {
            scanf("%d" , &color[i][j] ) ;
            grp[(i + j) % 3].push_back( color[i][j] ) ;
        }
    }
    int ans = inf ;
    for( int i = 1 ; i <= c ; i++ ) {
        for( int j = 1 ; j <= c ; j++ ) {
            for( int k = 1 ; k <= c ; k++ ) {
                if( i == j || i == k || j == k ) continue ;
                ans = min( ans , F(i , j , k) ) ;
            }
        }
    }
    printf("%d\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 2544
#include <iostream>

using namespace std;
int a[40];
int main(){
	int i,j,n,m,cnt = 0;
	cin >> n >> m;
	for(i=0;i<n;i++){
		int k; cin >> k;
		for(j=0;j<k;j++){
			int b; cin >> b; b--;
			a[b]++;
		}
	}
	for(i=0;i<m;i++){
		if(a[i]==n){
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#define pii pair<int,int>
#define pb push_back
using namespace std;

int grid[555][555];
int D[1111][1111];

int n,c;

int iromod[3][33];

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

  for(int i=1;i<=c;i++){
    for(int j=1;j<=c;j++){
      cin>>D[i][j];
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cin>>grid[i][j];
    }
  }

  for(int cc=1;cc<=c;cc++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	iromod[(i+j)%3][cc]+=D[grid[i][j]][cc];
      }
    }
  }

  int res=1e9;

  for(int i=1;i<=c;i++){
    for(int j=1;j<=c;j++){
      for(int k=1;k<=c;k++){
	if(i==j || j==k || k==i) continue;
	res=min(res,iromod[0][i]+iromod[1][j]+iromod[2][k]);
      }
    }
  }
  cout<<res<<endl;
  /*
  for(int i=0;i<3;i++){
    printf("%d: ",i);
    for(int cc=1;cc<=c;cc++){
      printf("%d ",iromod[i][cc]);
    }
    printf("\n");
  }
  */
  return 0;
}


Measured memory_bytes: 1408
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main()
{

    ll n,i,ans=0,t,d,a;

    cin>>t;

    for(i=1;i<=t;++i)
    {
        n = t/i;
        a=i;
        d=i;

        ans += (n*(2*a+(n-1)*d))/2;

    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<a/b<<' '<<a%b<<' ';
  printf("%.5f\n",(double)a/(double)b);
  return 0;
}



Measured memory_bytes: 3196
import math
global K
N, K = map(int, input().split())


prob_sum = 0
die_prob = 1/N

def find_flips(i):
    score = i
    flips = 0
    while score < K:
        score *=  2
        flips += 1
    return flips

for i in range(1,N+1):
        #print(i, find_flips(i), math.ceil(math.log2(K/2)))    
        prob_sum += die_prob * (1/2)**(find_flips(i))

print(prob_sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_lim=(n); i<i##_lim; ++i)
#define FOR(i, a, b) for (int i=(a), i##_lim=(b); i<i##_lim; ++i)
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;

bool pair_comparator(const pi& p1, const pi& p2)
{
    return (p1.second != p2.second) ? p1.second < p2.second : p1.first < p2.first;
}

int main()
{
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    REP(i, M) cin >> A[i] >> B[i];

    pi c[M];
    REP(i, M) c[i] = mp(A[i], B[i]);
    sort(c, c+M, pair_comparator);

    int ret = 1;
    int lastidx = c[0].second;
    FOR(i, 1, M)
    {
        if (c[i].first >= lastidx) { ++ret; lastidx = c[i].second; }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;



const int N = 1e5 + 100;

int main() {
	LL n, x;
	RD(n), RD(x);
	LL ans = n;
	LL len = n - x, d = x;
	while(d) {
		if(len % d == 0) ans += d + (len - d) / d * 2 * d;
		else ans += len / d * 2 * d;
		LL tmp = len % d;
		len = d;
		d = tmp;
	}
	printf("%lld\n", ans);
}	


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N, a, ans = 0, tmp[9] = {0}, i;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%d", &a);
		if (a >= 3200) ++tmp[8];
		else ++tmp[a / 400];
	}
	for (i = 0; i < 8; ++i) {
		if (tmp[i] > 0) ++ans;
	}
	if (ans == 0) printf("1");
	else printf("%d", ans);
	printf(" %d", ans + tmp[8]);
	return 0;
}

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

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll t=n/(a+b);
    ll tt=n%(a+b);
    if(tt>a) tt=a;
    cout<<1ll*t*a+tt<<endl;
    return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

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

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {
    ll n, k;
    cin >> n >> k;

    mint ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll start = i * (0 + i - 1) / 2;
        ll end = i * (n + (n - i + 1)) / 2;
        ll now = end - start + 1;
        ans += now;
    }
    cout << ans << endl;

}



Measured memory_bytes: 3640
# coding: utf-8
N = int(input())
A = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]
MAX_LENGTH = len(A)
dp = [[-1 for i in range(max(m) + 1)] for j in range(MAX_LENGTH + 1)]
# i番目以降の値を使ってmを作ればTrueを返す
def fullSearch(i, m):
    # 終了条件
    if m < 0:
        return False
    elif dp[i][m] != -1:
        return dp[i][m]
    elif m == 0:
        return True
    elif i >= MAX_LENGTH:
        return False
    else:
        # 全探索かっこわるい
        res = fullSearch(i + 1, m) or fullSearch(i + 1, m - A[i])
    # のでメモ化
    dp[i][m] = res
    return res
for mi in m:
    print("yes" if fullSearch(0, mi) else "no")

Measured memory_bytes: 8144
// atcoder/abc079/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    cout <<  (s.size() == 4 && (s[0] == s[1] && s[0] == s[2] || s[1] == s[2] && s[1] == s[3]) ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSumOfGcdOfTuplesEasy solver = new CSumOfGcdOfTuplesEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSumOfGcdOfTuplesEasy {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int k = s.nextInt();
            long ans = 0;
            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    for (int l = 1; l <= k; l++) ans += func.gcd(func.gcd(i, j), l);
                }
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class func {
        public static int gcd(int a, int b) {
            int t;
            while (b != 0) {
                t = b;
                b = a % b;
                a = t;
            }
            return a;
        }

    }
}



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

max_index = 1
max_abs = abs(A[0])
if A[0] >= 0:
    pos = True
else:
    pos = False

for i in range(1, N):
    if max_abs < abs(A[i]):
        max_abs = abs(A[i])
        max_index = i + 1
        if A[i] >= 0:
            pos = True
        else:
            pos = False

if pos:
    print(2*N - 2)
    for n in range(N):
        if max_index - 1 != n:
            print(max_index, n+1)
    for n in range(2, N+1):
        print(n-1, n)
else:
    print(2 * N - 2)
    for n in range(N):
        if max_index - 1 != n:
            print(max_index, n + 1)
    for n in reversed(range(2, N + 1)):
        print(n, n-1)

Measured memory_bytes: 3064
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) {
    readLine()
    val inputs:Array[String] = readLine().split(" ")
    val a: Int = inputs.map(_.toInt).sorted.zipWithIndex.filter(_._2 % 2 == 0).map(_._1).sum
    printf(s"%d\n", a)
  }
}

Measured memory_bytes: 25412
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=0;
	for(ll i=a;i<a*b;i+=a) {
		if(i%b==c) {
			ans++;
			break;
		}
	}
	if(ans) {
		cout<<"YES"<<endl;
	}
	else {
		cout<<"NO"<<endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int a, b, c, d;

double f(double x) {
    return a * x * x * x + b * x * x + c * x + d;
}

int judge(double x) {
    if(x > 1e-9) return 1;
    if(x < -(1e-9)) return -1;
    return 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
}


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


int main(){
    string s;
    cin >> s;
    int n = s.size();

    ll ans = 0;

    for(int bit = 0; bit < (1 << (n-1)); bit++){
        ll tmp = 0;
        for(int i = 0; i < n; i++){
            if(i == n - 1){
                tmp = tmp*10 + s[i] - '0';
            }else if(bit & (1 << i)){
                ans += tmp*10 + s[i] - '0';
                tmp = 0;
            }else{
                tmp = tmp*10 + s[i] - '0';
            }
        }
        if(tmp > 0) ans += tmp;
    }

    cout << ans << endl;
}

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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    // turn off sync
    std::ios::sync_with_stdio(false);
    // untie in/out streams
    std::cin.tie(nullptr);
    return nullptr;
}();

int main(int argc, char *argv[]) {
  int n;

  ll x;
  cin >> n >> x;

  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  SORT(a);
  ll sum = 0;
  int cnt = 0;
  REP(i, n) {
    if (sum + a[i] <= x) {
        sum += a[i]; cnt++;
    }
  }

  if (cnt == n && sum != x) cnt--;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

class Practice
{
    public static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int h = int.Parse(str[0]);
            int w = int.Parse(str[1]);
            if (h == 0 && w == 0) break;
            for (int i = 0; i < h; ++i)
            {
                for (int j = 0; j < w; ++j)
                {
                    Console.Write(Math.Abs(i - j) % 2 == 1 ? '.' : '#');
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15956
#include<iostream> 
#include<algorithm> 

using namespace std;
int main(){
	
	long long x,y,z;	
	long long change;
	long long a[3];
	while(cin>>x>>y>>z) {
		
		if(x%2==0||y%2==0||z%2==0){
			change =0;
		}else{
			a[0]=x;a[1]=y;a[2]=z;
			sort(a,a+3);
			change=a[0]*a[1];
		}
		
		cout<<change<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$as = [];
for ($i=1; $i <=$n; $i++) { 
	$as[$i] = (int)$input[$i-1];
}
asort($as);
$res = [];
foreach ($as as $k => $v) {
	$res[] = $k;
}
echo implode(' ', $res);

Measured memory_bytes: 23024
N, M = map(int,input().split())
AC = 0
WA = 0
ACdata = [0]*100001
WAdata = [0]*100001
for i in range(M):
    x, y = map(str,input().split())

    if ACdata[int(x)] == 1:
        continue
    if y == 'WA':
        WAdata[int(x)] += 1
    else:
        AC += 1
        ACdata[int(x)] = 1
        WA += WAdata[int(x)]
print(AC,WA)


Measured memory_bytes: 53208
N = int(input())
A = list(map(int,input().split()))
a,b,c = 0,0,0
for x in A:
    if x % 4 == 0:
        c += 1
    elif x % 2 == 0:
        b += 1
    else:
        a += 1

if a <= c:
    print("Yes")
else:
    if a - c == 1:
        if c > 0 and b == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 15020
#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 int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll X;
  cin >> X;
  ll num = 100;
  int year = 0;
  while (num < X) {
    year++;
    num += num / 100;
  }
  cout << year << endl;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	p := make([]int, N)
	q := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
		q[i] = p[i]
	}
	sort.Ints(q)

	d := 0
	for i := 0; i < N; i++ {
		if p[i] != q[i] {
			d++
		}
	}
	if d == 0 || d == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		no2();
	}

	static void no2() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			BigInteger f0 = new BigInteger("2");
			BigInteger f1 = new BigInteger("1");
			BigInteger f2 = null;

			if (n == 1) {
				System.out.println(f1);
				return;
			}

			for (int i = 3; i <= n+1; i++) {
				f2 = f0.add(f1);
				f0 = f1;
				f1 = f2;
			}

			System.out.println(f2);
		}
	}
}

Measured memory_bytes: 22100
#include <stdio.h>
int n,a[2000];

int select(int, int);

int main(){
  int q, m, i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(select(0,m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int select(int i, int b){
  if(b==0) return 1;
  if(i>=n) return 0;
  int res = select(i+1,b) || select(i+1,b-a[i]);
  return res;
}



Measured memory_bytes: 2048
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
    let input = read::<i32>();
    let h: i32 = input / 3600;
    let m: i32 = (input % 3600) / 60;
    let s: i32 = input % 60;
    println!("{}:{}:{}", h, m ,s);
}


Measured memory_bytes: 5024
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int line = sc.nextInt();
        System.out.println((line/2)*((line+1)/2));
    }
}

Measured memory_bytes: 21332
#include <iostream>
using namespace std;
int main() {
    int ac = 0; //青木くんのクッキーの枚数
    int tc = 0; //高橋くんのクッキーの枚数
    int n = 0;  //交換する回数
    cin >> tc >> ac >> n;
    for (int i = 0; i < n; ++i) {
        //高橋くんのターン
        if(tc % 2 != 0){
            tc--;
        }
        int wtc = tc /2;    //高橋くんが渡すクッキーの個数
        tc -= wtc;  //高橋くんのクッキーヘル個数
        ac += wtc;  //青木くんにクッキーを渡す個数

        if(i == n-1)break;
        i++;

        //青木くんのターン
        if(ac % 2 != 0){
            ac--;
        }
        int wac = ac /2;
        ac -= wac;
        tc += wac;
    }
    cout << tc << " " << ac;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i,j,k,jud[101];
    double x[4],y[4];
    scanf("%d",&n);
    for(j=0;j<n;j++){
        for(i=0;i<4;i++){
            scanf("%lf",&x[i]);
            scanf("%lf",&y[i]);
        }
    if((y[0]-y[1])/(x[0]-x[1]) == (y[2]-y[3])/(x[2]-x[3]))jud[j]=0;
    else jud[j]=1;
    }
    for(k=0;k<n;k++){
        if(jud[k]==0){
            printf("YES\n");
        }
        else if(jud[k]==1){
            printf("NO\n");
        }
    }
return 0;
}

Measured memory_bytes: 620
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long M, K;
	cin >> M >> K;
	long long lim  = ((long long)1) << M;
	if (K>= lim) {
		cout << -1 << endl;
		return 0;
	}
	if (0 == M) {
		if (0 == K) {
			cout <<"0 0"<<endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if (1==  M) {
		if (0 == K) {
			cout << "0 0 1 1" << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	vector<int>Ans;
	for (int i = 0;i<lim; ++i) {
		if (K !=i) {
			Ans.push_back(i);
		}
	}
	Ans.push_back(K);
	for (int i = lim-1;i>=0; --i) {
		if (K != i) {
			Ans.push_back(i);
		}
	}
	Ans.push_back(K);
	for (int i = 0;i<Ans.size();++i) {
		if (0 != i) {
			cout << " ";
		}
		cout << Ans[i];
	}
	return 0;
}



Measured memory_bytes: 4308
s = input()

import string
ans = 9999
for char in string.ascii_lowercase:
    count = 0
    maxi = 0
    for j in range(len(s)):
        if s[j] == char:
            maxi = max(count, maxi)
            count = 0
        else:
            count += 1
        maxi = max(count, maxi)
    ans = min(ans, maxi)

print(ans)


Measured memory_bytes: 3768
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int q = n / 1000;
  int ans = 0;
  if(n % 1000 != 0){
    ans = (q + 1) * 1000 - n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


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

	if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3))
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    String[] D = new String[K];

    for (int i = 0; i < K; i++) {
      D[i] = sc.next();
    }

    sc.close();

    for (int i = N; i < 100000; i++) {

      String s = String.valueOf(i);
      
      boolean result = true;
      
      for (int j = 0; j < K; j++) {
        if (0 <= s.indexOf(D[j])) {
          result = false;
          break;
        }
      }

      if (result) {
        System.out.println(i);
        break;
      }

    }

  }

}

Measured memory_bytes: 26452
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, int> mp;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		mp[s] += 1;
	}

	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int dp[n][2];
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[1][0] = abs(a[1] - a[0]);
    dp[1][1] = 0;
    for(int i=2;i<n;++i)
    {
        dp[i][0] = min(dp[i-1][0]+abs(a[i]-a[i-1]),dp[i-1][1]+abs(a[i]-a[i-2]));
        dp[i][1] = dp[i-1][0];
    }
    // for(int i=0;i<n;++i)
    // {
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    // }
    cout<<dp[n-1][0];

    
    return 0;

}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>l(n);
    int maxx=0;
    int sum=0;
    rep(i,n){
        cin>>l[i];
        maxx=max(maxx,l[i]);
        sum+=l[i];
    }
    sum-=maxx;
    if(maxx<sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    const int ALPH = 'z' - 'a' + 1;
    VI cnt(ALPH, 0);
    
    for (char c : s) {
        cnt[c - 'a']++;
    }
    
    ll n = SIZE(s);
    ll ans = n * (n + 1) / 2;
    
    for (int x : cnt) {
        ans -= (ll) x * (x + 1) / 2;
    }
    
    cout << ans + 1;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    string s;
    map<string,int> mp;
    int m{};
    fr(i,n){
        in>>s;
        m=max(m,++mp[s]);
    }
    for(auto&p:mp) if(p.second==m) cout<<p.first<<endl;
}

Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        if( m1 != m2 ){
            System.out.println(1);
            return;
        }else{
            System.out.println(0);
        }

    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int n,m,k;cin>>n>>m>>k;
    rep(i,n+1){
        rep(j,m+1){
            int a=i*(m-j)+j*(n-i);
            if(a==k){
                cout<<"Yes"<<"\n";
                return 0;
            }
        }
    }
    cout<<"No"<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    string s; int x,y;
    cin >> s >> x >> y;
    vector<int> numx(s.size(),0);
    vector<int> numy(s.size(),0);
    int num1=0;
    bool f=1;
    bool tox=1;
    int a=0,b=-1;
    rep(i,s.size()){
        if(s[i]=='T'){
            f=0;
            if(tox){
                tox=0;
                b++;
            }
            else{
                tox=1;
                a++;
            }
        }else{
            if(f) num1++;
            else if(tox) numx[a]++;
            else numy[b]++;
        }
    }
    //x,y部分和問題
    bool okx[a+2][17000];
    bool oky[b+2][17000];
    memset(okx,0,sizeof(okx));
    memset(oky,0,sizeof(oky));
    x+=8500; y+=8500;
    x-=num1;
    okx[0][8500]=1;
    oky[0][8500]=1;
    rep(i,a+1){
        rep(j,17000){
            if(okx[i][j]){
                if(j-numx[i]>=0)okx[i+1][j-numx[i]]=1;
                if(j+numx[i]<17000)okx[i+1][j+numx[i]]=1;
            }
        }
    }
    rep(i,b+1){
        rep(j,17000){
            if(oky[i][j]){
                if(j-numy[i]>=0)oky[i+1][j-numy[i]]=1;
                if(j+numy[i]<17000)oky[i+1][j+numy[i]]=1;
            }
        }
    }
    if(okx[a+1][x]&&oky[b+1][y]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
////////////////

int const N = 1e5 + 41;
int const MOD = 1e9 + 7;

int f[N];

void solve(){
	int n, m;
	cin >> n >> m;
	int ans = 0;
	f[0] = 1;
	fr(i, 1, N) f[i] = f[i-1] * 1LL * i % MOD;
	
	if(n == m || n == m + 1) ans += f[n] * 1LL * f[m] % MOD;
	swap(n, m);

	if(n == m || n == m + 1) ans += f[n] * 1LL * f[m] % MOD;
	ans %= MOD;
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 640