akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const int N = 5e2+9, M = 1e5+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
int n;
LL memo[N][N],csum[N];
LL solve(int l=1,int r=n)
{
  if(l==r) return 0;
  LL &ret = memo[l][r];
  if(~ret) return ret;

  ret = LONG_LONG_MAX;
  for(int i=l;i<r;++i)
  {
    ret = min(ret,solve(l,i)+solve(i+1,r)+(csum[r]-csum[l-1]));
  }
  
  return ret; 
}

int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d",&n);
  for(int i=1;i<=n;++i)
  {
    LL x;
    scanf("%lld",&x);
    csum[i]+=csum[i-1]+x;
  }
  printf("%lld\n",solve());
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100001 ;
vector<pll>v ;
int main()
{
   fast ;
   ll tests=1 ;
   ///cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     /// cout<<"Case #"<<testcase<<": " ;
     ll n ;
     cin>>n ;
     char s[n+1] ;
     for(ll i=1;i<=n;i++)
     {
         cin>>s[i] ;
     }
     ll p[n+1],sf[n+2] ;
     p[0]=0 ;
     for(ll i=1;i<=n;i++)
     {
         p[i]=p[i-1] ;
         if(s[i]=='W')
            p[i]++ ;
     }
     sf[n+1]=0 ;
     for(ll i=n;i>=1;i--)
     {
         sf[i]=sf[i+1] ;
         if(s[i]=='E')
            sf[i]++ ;
     }
     ll ans=INT_MAX ;
     for(ll i=1;i<=n;i++)
     {
         ans=min(ans,p[i-1]+sf[i+1]) ;
     }
     cout<<ans ;
     cout<<endl ;
   }
}


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

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("ARC99E.in","r",stdin);
	freopen("ARC99E.out","w",stdout);
}

const int maxn=700+10;
const int maxm=maxn*maxn;
const int inf=0x3f3f3f3f;
int n,m,beg[maxn],last[maxm],to[maxm],cnte=1;
int a[maxn],b[maxn],tot;
bool G[maxn][maxn],vis[maxn],c[maxn];
bitset<maxn>dp;

void add(int u,int v){
	last[++cnte]=beg[u];
	beg[u]=cnte;
	to[cnte]=v;
}

bool dfs(int u,int fr){
	vis[u]=1;
	c[u]=c[fr]^1;
	if(!c[u])++a[tot];
	else ++b[tot];
	for(int i=beg[u];i;i=last[i]){
		if(vis[to[i]] && c[to[i]]==c[u])return false;
		if(!vis[to[i]] && !dfs(to[i],u))return false;
	}
	return true;
}

int main(){
	//File();
	scanf("%d%d",&n,&m);
	REP(i,1,m){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u][v]=G[v][u]=1;
	}
	REP(i,1,n)REP(j,1,n)if(!G[i][j] && i!=j)
		add(i,j);
	REP(i,1,n){
		if(vis[i])continue;
		++tot;
		if(!dfs(i,0)){			
			printf("-1\n");
			return 0;
		}
	}
	dp[0]=1;
	REP(i,1,tot)dp=(dp<<a[i])|(dp<<b[i]);
	for(int i=n/2;i;--i)if(dp[i]){
		printf("%d\n",i*(i-1)/2+(n-i)*(n-i-1)/2);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 4096
import java.util.*;
public class Main {
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}

Measured memory_bytes: 23124
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>

#define ll  long long
using namespace std;

const ll mx = 10e5 + 9;
ll n, m;
string st1, st2, st;
ll dp[ 3005 ][ 3005 ];


void solve( )
{
    cin >> st1 >> st2;
    n = st1.size();
    m = st2.size();

    for ( ll i = 0; i <= n; ++i )
        for ( ll j = 0; j <= m; ++j ) {
            if( i == 0 || j == 0 )
                dp[ i ][ j ] = 0;
            else if ( st1[ i - 1 ] == st2[ j - 1 ] )
                dp[ i ][ j ] = 1 + dp[ i - 1 ][ j - 1 ];
            else
                dp[ i ][ j ] = max( dp[ i - 1 ][ j ], dp[ i ][ j - 1 ] );
        }

    ll i = n, j = m;
    while (i && j ) {
        if ( dp[ i ][ j ] == dp[ i ][ j - 1 ] )
            j--;
        else if( dp[ i ][ j ] == dp[ i - 1 ][ j ] )
            i--;
        else {
            st = st2[ j - 1 ] + st;
            i--;
            j--;
        }
    }

    cout << st << endl;;
}

int main()         // Md. Inzamam-ul Haque
{
    solve();
}

/*
AGGTAB
GXTXAYB

abcde
bdgek
*/


Measured memory_bytes: 74120
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: b.cpp
Time: 15-08-2019T12:49:24+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch;

int solve(){
	return 0;
}

int main(){
	// scanf("%d", &t);
	while(t--){
		scanf("%d%d", &n,&m);
        FOR(i, m-n+1, m+n){
            printf("%d ", i);
        }
        printf("\n");
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<Integer> d = new HashSet<>();
    for (int i = 0; i < n; i++) {
        d.add(sc.nextInt());
    }
    System.out.println(d.size());
  }
}

Measured memory_bytes: 35836
#include<iostream>

using namespace std;

int main(void)
{
	int n,k;
	cin >> n >> k;
	
	int ans = 1;

	for(int i=1;i<=n;i++)
	{
		if(k<=ans)
			ans+=k;
		else
			ans*=2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int mincount=100000;
  int p[n+1];
  for(int i=1;i<=n;i++){
    cin >> p[i];
  }
  for(int k=0;k<=p[1];k++){
    int count=0;
    int c[n+1];
    for(int i=1;i<=n;i++){
      c[i]=p[i];
    }
    c[1]-=k;
    count+=k;
    for(int i=1;i<=n-1;i++){
      if(c[i]<=0){
        continue;
      }
      count+=c[i]*2;
      c[i+1]-=c[i];
    }
    if(c[n]>0){
      count+=c[n];
    }
    mincount=min(count,mincount);
  }


  cout <<mincount <<endl;
  return 0;
}



Measured memory_bytes: 3128
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int a[300001]={};
  int n;
  //mkgr
  a[1]=2;
  for(int i=2;i<=300000;i++){
    if(i%7==1||i%7==6){
      a[i]=1;
      for(int j=2;j*j<=i;j++){
	if(a[j]!=0){
	  if(i%j==0){
	    a[i]=2;
	    break;
	  }
	}
      }
    }
  }
  // cout << "point1"<< endl;
  while(1){
    cin >> n;
    if(n==1)break;
    cout << n << ":";
    for(int i=2;i<=n;i++){
      if(a[i]==1)
	if(n%i==0)
	  cout  << " " << i;
    }
    cout << endl;
  }
  return 0;
}
  

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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n;
	cin >> n;
	int hlist[445];
	int pos = -1;
	for (int i = 0;i < 446;i++) {
		hlist[i] = ((i+1)*(i+2))/2;
		if (n == hlist[i]) {
			pos = i + 2;
		}
	}
	if (pos == -1) {
		cout << "No" << endl;
	} else {
		vector<int> ans[pos];
		int count = 1;
		for (int i = 0;i < pos;i++) {
			for (int j = i + 1;j < pos;j++) {
				ans[i].push_back(count);
				ans[j].push_back(count);
				count++;
			}
		}
		cout << "Yes" << endl;
		cout << pos << endl;
		for (int i = 0; i < pos; i++) {
			cout << pos-1 << " ";
			for (int j = 0;j < pos-1;j++) {
				cout << ans[i].at(j) << " ";
			}
			cout << endl;
		}
	}
}

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


Measured memory_bytes: 2304
import numpy as np

n,m = map(int,input().split())
l = []
for _ in range(m):
    a = list(map(int,input().split()))
    l.append(a)

memo = np.zeros((n,2))
memo[0][1] = 1

for i in range(n):
    memo[i][0] = 1

tmp1 = 0
tmp2 = 0

for j in range(m):
    tmp1 = l[j][0]-1
    tmp2 = l[j][1]-1
    memo[tmp1][0] -= 1
    memo[tmp2][0] += 1
    
    if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:
        memo[tmp2][1] = 1
    
    if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:
        memo[tmp1][1] = 0

ans = 0
for k in range(n):
    ans += memo[k][1]

print(int(ans))


Measured memory_bytes: 46620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

struct Combination {
	vector<long long> inv,finv,fac;
	Combination(int n, int kmax) : inv(kmax+1),finv(kmax+1),fac(kmax){
		if(kmax>=1){
			inv.at(1)=1;
			finv.at(1)=1;
			fac.at(0) = n;
		}
	for(int i=2; i<=kmax; i++) inv.at(i) = MOD - inv.at(MOD%i) * (MOD/i) %MOD;
	for(int i=2; i<=kmax; i++) finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
	for(int i=1; i<kmax; i++) fac.at(i) = fac.at(i-1) * (n-i) % MOD;
	}
	int comb(int k) {return (k ? fac.at(k-1) * finv.at(k) % MOD : 1 );}
};
ll exgcd(ll a,ll b,ll &x,ll &y){
	while(b){
		ll t{a/b};
		swap(a-=t*b, b);
		swap(x-=t*y, y);
	}
	return a;
}
ll exgcd(ll a,ll b){
	ll x{1},y{0};
	return exgcd(a,b,x,y);
}
ll inverse(ll a,ll mod){
	ll x{1},y{0};
	exgcd(a,mod,x,y);
	return (x%mod+mod)%mod;
}
int main(){
	int n,m,k; cin>>n>>m>>k;
	ll sum{};
	Combination c(n*m-2,k-2);
	for(ll i=0; i<n; i++){
		for(ll j=0; j<m; j++){
			sum += (i*(i+1)/2+(n-i)*(n-i-1)/2)*m;
			sum %= MOD;
			sum += (j*(j+1)/2+(m-j)*(m-j-1)/2)*n;
			sum %= MOD;
		}
	}
	sum *= c.comb(k-2);
	sum %= MOD; 
	sum *= inverse(2,MOD);
	sum %= MOD;
	cout << sum << endl;
	
}

Measured memory_bytes: 4992
#!/usr/bin/env python
# coding: utf-8


def func(L, pairs):
    if pairs:
        a, b = pairs.pop(0)
        L[a], L[b] = L[b], L[a]
        return func(L, pairs)
    else:
        return L


def main():
    w = int(raw_input())
    L = range(w + 1)
    n = int(raw_input())
    pairs = []
    for i in xrange(n):
        pairs.append([int(x) for x in raw_input().split(",")])

    for i in func(L, pairs)[1:]:
        print i


if __name__ == '__main__':
    main()

Measured memory_bytes: 4248
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
      string s, t;
      cin >> s >> t;
      int ans = INT_MAX;
      int n = s.length(), m = t.length();
      for(int i = 0; i + m - 1 < n; i++){
          int ch = 0; //cout << i << anal;
          for(int j = i, k = 0; j < n && k < m; j++, k++){
               if(s[j] == t[k]) continue;
               else ch++;
          }
          //pr(ch)
          ans = min(ans, ch);
      }
      cout << ans << anal;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int m = Integer.valueOf(arr01[1]);

        String arr_result[] = mylist.get(1).split(" ");

        int mindata = Integer.valueOf(arr_result[0]);
        int maxdata = Integer.valueOf(arr_result[1]);

        for (int i = 2; i < 1 + m; i++) {
            String arr02[] = mylist.get(i).split(" ");
            int l = Integer.valueOf(arr02[0]);
            int r = Integer.valueOf(arr02[1]);

            if (mindata < l) {
                mindata = l;
            }
            if (maxdata > r) {
                maxdata = r;
            }

//            System.out.println(mindata + " " + maxdata);

        }

        System.out.println(maxdata - mindata >= 0 ? maxdata - mindata + 1 : 0);
    }

}


Measured memory_bytes: 50224
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=300005;
int n;
int main() {
	cin>>n;
	cout<<1LL*3*n*n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  if(a < 105)
    cout << '0' << endl;
    else if(105<=a&&a<135)
    cout << 1<< endl;
       else if(135<=a&&a<165)
    cout << 2 << endl;
         else if(165<=a&&a<189)
    cout << 3 << endl;
           else if(189<=a&&a<195)
    cout << '4' << endl;
             else if(195<=a&&a<=200)
    cout << '5' << endl;

} 
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main()
{
	int n, p;
	scanf("%d%d", &n, &p);
	int m = 0; //要素数m
	rep(i, n) {
		int a;
		scanf("%d", &a);
		if(a % 2 == 1) m++;
	}
	if(m == 0) {
		if(p == 0) printf("%lld\n", 1ll << n); //2^n
		else printf("0\n");
	}
	else {
		printf("%lld\n", 1ll << (n - 1)); //2^n-1
	}
	return 0;
}

Measured memory_bytes: 3804
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CModuloSummation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            out.println(IntStream.of(a).reduce(0, (x, y) -> x + y - 1));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 28372
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define N 200050
#define Mo 1000000007
int n, a[N];
LL f[N];
unordered_map<int, LL> m;

int main() {
    //freopen("sample.in", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int tot = 1;
    for(int i = 2; i <= n; i++)
        if (a[i] != a[i - 1]) a[++tot] = a[i];
    f[0] = 1;
    for(int i = 1; i <= tot; i++) {
        f[i] = (f[i - 1] + m[a[i]]) % Mo;
        m[a[i]] = f[i];
    } 
    cout << f[tot] << endl;
}

Measured memory_bytes: 10824
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	cout<<(n+1)/2-1<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().rstrip().split())
*h, = map(int, input().rstrip().split())
dp = [0] + [float('inf')]*(N-1)
for j in range(1,N):
    for i in range(max(0,j-K),j):
        dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]))
        # print("j -> {} || i -> {} || dp -> {} || h[j] -> {} || h[i] -> {}".format(j, i, dp, h[j], h[i]))
print(dp[-1])

Measured memory_bytes: 59104
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var m = int.Parse(inputs[1]);

            var list = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            list.Sort();

            var diffs = new List<int>();
            for (var i = 1; i < m; i++)
            {
                diffs.Add(list[i] - list[i - 1]);
            }
            diffs.Sort((a, b) => b - a);

            var result = 0;
            for (var i = n - 1; i < m - 1; i++)
            {
                result += diffs[i];
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 37520
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int inf = 1e9 + 5;
const int nax = 1e6 + 5;



int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		puts("0");
		return 0;
	}
	ll ans = (ll) b * c;
	mini(ans, (ll) a * c);
	mini(ans, (ll) a * b);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 764
N = int(input())
H = list(map(int, input().split(' ')))

is_trimmed = [False] * N
max_v = 0
max_ids = []
succeed = True
for i in range(N):
    diff = max_v - H[i]
    if diff > 1:
        print('No')
        succeed = False
        exit(0)
    elif diff == 1:
        for j in max_ids:
            if is_trimmed[j]:
                print('No')
                succeed = False
                exit(0)
            is_trimmed[j] = True
        max_ids.append(i)
        max_v -= 1
    elif diff == 0:
        max_ids.append(i)
    elif diff < 0:
        max_v = max(max_v, H[i])
        max_ids = [i]
    # print(max_v, max_ids, is_trimmed)

if succeed:
    print('Yes')


Measured memory_bytes: 14396
import collections
n = int(input())
s = [''] + list(input())
cnt_1 = collections.Counter(s)

sub = 0
for j in range(1, (n+1)//2):
    for i in range(1, n-2*j+1):
        tmp = s[i] + s[i+j] + s[i+j*2]
        cnt_2 = collections.Counter(tmp)
        if cnt_2['R'] == 1 and cnt_2['G'] == 1 and cnt_2['B'] == 1:
            sub += 1

print((cnt_1['R']*cnt_1['G']*cnt_1['B'])-sub)

Measured memory_bytes: 72276
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long

using namespace std;
int n=0;
int arr[10001];
unordered_map<int, int> mm[10001];
unordered_map<int, int> Map;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;		
	for (int i=0; i<n; i++)
		cin >> arr[i];
	for (int i=0; i<n; i++)
	{
		int sqrtN = round(sqrt(arr[i]));
		for (int j=2; j<=sqrtN; j++)
		{
			while (arr[i]%j==0){
				mm[i][j]++;
				arr[i]/=j;
			}
		}
		if (arr[i]!=1)
			mm[i][arr[i]]++;
		arr[i] = 1;
	}
	for (int i=0; i<n; i++)
	{
		for (auto p : mm[i])
			Map[p.first] = max(Map[p.first], p.second);
	}
	int sum=0;
	for (int i=0; i<n; i++)
	{
		for (auto p : mm[i])
			Map[p.first]-=p.second;
		int x = 1;
		for (auto p : Map)
		{
			for (int j=0; j<p.second; j++)
			{
				x = x*p.first%MOD;
			}
		}	
		sum = (sum+x)%MOD;
		for (auto p : mm[i])
			Map[p.first]+=p.second;
	}
	cout << sum;
	return 0;
}



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

int main(){
  string T,W;
  int i,count = 0;

  cin >> T;

  while(1){
    cin >> W;
    if(W == "END_OF_TEXT") break;
    for(i = 0; i < W.length(); i++){
      W[i] = tolower(W[i]);
    }
    if(W == T) count++;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1192
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N = I()
    C = [0] * (N-1)
    S = [0] * (N-1)
    F = [0] * (N-1)

    for i in range(N-1):
        C[i], S[i], F[i] = MI()

    for i in range(0, N-1):
        ans = S[i]
        # show(ans)
        for j in range(i, N-1):
            ans = max(ans, S[j])
            diff = S[j] - ans
            ans += diff % F[j]
            ans += C[j]
            # show(j, ans)
        print(ans)
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66028
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod =1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vi h(n+1);
    Fo(i,1,n+1) cin>>h[i];
    int dp[n+1];
    dp[0]=1e9;
    dp[1]=0;

    for(int i =2;i <=n;i++){
        dp[i] = INT_MAX;
        for(int j=1;j <=k;j++){
            if(i-j<0) break;
            dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4744
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define int long long
 const int MAX_N=1e5+2;
int cnt[MAX_N],n,suf[MAX_N];
int ans=0;

void dfs(int x,int now)
{
	ans+=now;//cout<<now<<"\n";
	if(x==n)
    {
		if(cnt[x]!=now) ans=-1;
		return ;
	}
	now-=cnt[x];
	if(now<=0)
    {
        ans=-1;
        return ;
	}
	dfs(x+1,min(now*2,suf[x+1]));
}

signed main()
{
    cin>>n;
	for(int i=0;i<=n;i++)
    {
        cin>>cnt[i];
        suf[i]=cnt[i];
    }

	for(int i=n;i>=0;i--) suf[i]+=suf[i+1];
	dfs(0,1);
	cout<<ans;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int Ans=1;
  for(int i=0; i<N; i++){
    if(Ans<K){
      Ans*=2;
    }
    else{
      Ans+=K;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
A,B,T = gets.chomp.split(" ").map(&:to_i)
ans = 0
baisuu = []
for i in 1..20 do
    baisuu[i] = A * i
end
for i in 1..T do 
    if baisuu.any? {|w| w == i }
        ans = ans + B
    end
end

puts ans

Measured memory_bytes: 1788
/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll MOD = 1e9 + 7;
void  icchhipadey()
{
  ll x;
  cin >> x;
  cout << 1 - x << endl;
}
int main()
{


#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  boost;

  icchhipadey();




}









Measured memory_bytes: 3688
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x2 x123456789
#define y2 y123456789

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=1e5+5;

int n,k;
int a[maxn];
vector<int> g[maxn];
priority_queue<pii,vector<pii>,greater<pii> > q;

int main(){
	scanf("%d",&n);
	FOR(i,0,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		--u;--v;
		g[u].PB(v);
		g[v].PB(u);
	}
	memset(a,-1,sizeof(a));
	scanf("%d",&k);
	FOR(i,0,k){
		int v,p;
		scanf("%d%d",&v,&p);
		--v;
		a[v]=p;
		q.PH(MP(p,v));
	}
	while(!q.empty()){
		int u=q.top().snd;
		q.pop();
		FOR(i,0,g[u].size()){
			int v=g[u][i];
			if(a[v]==-1){
				a[v]=a[u]+1;
				q.PH(MP(a[v],v));
			}
		}
	}
	FOR(i,0,n){
		FOR(j,0,g[i].size()){
			if(abs(a[i]-a[g[i][j]])!=1){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	FOR(i,0,n) printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 7924
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,M;
	cin >> N >> M;
	
	vector< map<int,int> > num(M);
	map<int,int> amaSum;
	int X;
	for(int i=0;i<N;++i){
		cin >> X;
		num[X%M][X]++;
		amaSum[X%M]++;
	}

	int ans = 0;
	map<int,int>::iterator itr,end;

	for(int i=0;i<M;++i){
		int ter = M-i;
		if( ter < i ) break;

		if( i == 0 ){
			ans += amaSum[0]/2;
		}else if(i == ter){
			int A = amaSum[i];
			ans += A/2;
		}else{
			int A = amaSum[i];
			int B = amaSum[ter];
			if( A > B ){
				int nokori = A-B;
				ans += B;
				itr = num[i].begin();
				end = num[i].end();
				for(;itr!=end && nokori;++itr){
					int sub = (itr->second)/2;
					int res = ( min(nokori,sub*2) ) /2 ;
					ans += res;
					nokori -= res*2;
				}
			}else if( B > A ){
				//A > Bと同等の処理
				int nokori = B-A;
				ans += A;
				itr = num[ter].begin();
				end = num[ter].end();
				for(;itr!=end && nokori;++itr){
					int sub = (itr->second)/2;
					int res = ( min(nokori,sub*2) ) /2 ;
					ans += res;
					nokori -= res*2;
				}
			}else{//A==B
				ans += A;
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int b = 0, w = 0;
    rep(i, n) {
        if (s.at(i) == '.') w++;
    }
    int ans = w;
    rep(i, n) {
        if (s.at(i) == '.') w--;
        if (s.at(i) == '#') b++;
        ans = min(ans, b + w);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3716
N, W = map(int, input().split())
values = []
weights = []
for _ in range(N):
    vi, wi = map(int, input().split())
    values.append(vi)
    weights.append(wi)

dp = [0 for _ in range(W+1)]
for i in range(N):
    for w in range(W, 0, -1):
        if w - weights[i] >= 0:
            dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
print(dp[W])


Measured memory_bytes: 5724
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 1000000001
#define MAXW 1000000007
#define INF 1000000007
#define MAXN 100001
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, ll> P;


template<typename T>
T pow(T i, T n){
    T re;
    if(n == 0) return 1;
    re = pow(i, n / 2);
    if(n % 2 == 0){
        return re * re;
    }else{
        return i * re * re;
    }
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll N, T;
ll A[MAXN], B[MAXN] ;

int main(){
    string A, S, C;
    cin >> A >> S >> C;
    printf("A%cC\n", S[0]);
    return 0;
}

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

int main() {
	int count, n;
	while (cin >> n) {
		count = 0;
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				for (int k = 0; k < 10; ++k) {
					for (int l = 0; l < 10; ++l) {
						if ((i + j + k + l) == n) count++;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include<bitset>


using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = 6-a-b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w;
  cin>>h>>w;
  char s[h+2][w+2];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>s[i][j];
    }
  }
  
  int ans[h+2][w+2];
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      ans[i][j]=0;
    }
  }
  
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s[i][j]=='#'){
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            ans[i+k][j+l]++;
          }
        }
      }
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s[i][j]=='#'){
        cout<<s[i][j];
        continue;
      }
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  
}

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

typedef complex<double> P;

int f[10][10];
void g(int x,int y){
	if( x < 0 or y < 0 or x >= 10 or y >= 10 ) return;
	f[y][x]++;
}
int main(){
	int x,y,s;
	while( scanf("%d,%d,%d",&x,&y,&s) != -1 ){
		if( s == 1 ){
			for(int i = -1 ; i <= 1 ; i++)
				for(int j = -1 ; j <= 1 ; j++)
					if( abs(i)+abs(j) <= 1 )
						g(y+i,x+j);
		}else if( s == 2 ){
			for(int i = -1 ; i <= 1 ; i++)
				for(int j = -1 ; j <= 1 ; j++)
					g(y+i,x+j);
		}else{
			for(int i = -2 ; i <= 2 ; i++)
				for(int j = -2 ; j <= 2 ; j++)
					if( abs(i)+abs(j) <= 2 )
						g(y+i,x+j);
		}
	}
	int sum = 0;
	int mx = 0;
	for(int i = 0 ; i < 10 ; i++){
		for(int j = 0 ; j < 10 ; j++){
			if( f[i][j] ) sum++;
			mx = max(f[i][j],mx);
		}
	}
	cout << 100-sum << endl;
	cout << mx << endl;
			
			
}

Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {

    int D, N;
    cin >> D >> N;

    if (N == 100) {
        if (D == 0) cout << 101 << endl;
        else if (D == 1) cout << 101 * 100 << endl;
        else cout << 101 * 10000 << endl;
    }
    else {
        if (D == 0) cout << N << endl;
        else if (D == 1) cout << N * 100 << endl;
        else cout << N * 10000 << endl;
    }

}


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

using namespace std;

const int maxn = 1e5+10;

int num[maxn], dp[maxn];

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

	for (int i = 1; i <= n; i++)
		cin >> num[i];

	dp[1] = 0, dp[2] = abs(num[2]-num[1]);
	for (int i = 3; i <= n; i++)
	{
		dp[i] = dp[i-1]+abs(num[i]-num[i-1]);
		dp[i] = min(dp[i], dp[i-2]+abs(num[i]-num[i-2]));
	}

	cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
N = int(input())

A = [int(input()) for _ in range(N)]
A.sort()
B = A[::-1]

l1 = []
l2 = []
for i in range((N + int(N % 2 == 0)) // 2):
    l1.append(A[i])
    l1.append(B[i])
    l2.append(B[i])
    l2.append(A[i])

a, b = 0, 0
for i in range(N - int(N % 2 == 1) - 1):
    a += abs(l1[i] - l1[i + 1])
    b += abs(l2[i] - l2[i + 1])

# print(a)
# print(b)
if N % 2 == 0:
    a -= abs(l1[-1] - l1[-2])
    b -= abs(l2[-1] - l2[-2])
    a += max(abs(l1[0] - l1[-1]), abs(l1[-2] - l1[-1]))
    b += max(abs(l2[0] - l2[-1]), abs(l2[-2] - l2[-1]))
else:
    a += max(abs(l1[0] - A[(N - 1) // 2]), abs(l1[-1] - A[(N - 1) // 2]))
    b += max(abs(l2[0] - A[(N - 1) // 2]), abs(l2[-1] - A[(N - 1) // 2]))
res = max(a, b)

# print(l1)
# print(l2)
print(res)


Measured memory_bytes: 89328
#include<stdio.h>
long long gcd(long long a,long long b){
	while(b){
		a%=b;
		long long c=a;
		a=b;
		b=c;
	}
	return a;
}
long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}
int main(){
	int a,b,c,d,e,f;
	while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a){
		long long g=0;
		int p=1;
		do{
			p=p*a%b;
			g++;
		}while(p-1);
		long long h=0;
		p=1;
		do{
			p=p*c%d;
			h++;
		}while(p-1);
		long long i=0;
		p=1;
		do{
			p=p*e%f;
			i++;
		}while(p-1);
		printf("%lld\n",lcm(lcm(g,h),i));
	}
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		list[i] = i + 1
	}

	total := 0
	for i := 0; i < n; i++ {
		if list[i]%3 == 0 && list[i]%5 == 0 {

		} else if list[i]%3 == 0 {

		} else if list[i]%5 == 0 {

		} else {
			total += list[i]
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 9884
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    while(a>=0 && c>=0){
      c -= b;
      if(c <= 0){
        System.out.println("Yes");
        return;
      }
      a -= d;
      if(a <= 0){
        System.out.println("No");
        return;
      }
    }
  }
}


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

using namespace std;

const int INF = (int)2e9;
bool isBad = false;
vector< vector< pair<int, int> > > g;
vector<int> dist;

void dfs(int v, int path){

    dist[v] = path;

    if(isBad){
        return;
    }

    for(int i = 0; i < g[v].size(); i++){
        int u = g[v][i].first;
        int len = g[v][i].second;

        int new_dist = len + path;

        if(dist[u] == INF){
            dfs(u, new_dist);
        } else if(dist[u] == new_dist){
            //it's ok
            continue;
        } else if(dist[u] != INF && dist[u] != new_dist){
            isBad = true;
        }

        if(isBad)
            return;
    }
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);

    g.resize(n + 1);

    for(int i = 0; i < m; i++){
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);

        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }

    dist.assign(n + 1, INF);

    for(int v = 1; v <= n; v++){
        if(dist[v] == INF){
            dfs(v, 0);
        }

        if(isBad){
            printf("No");
            return 0;
        }
    }

    printf("Yes");




}


Measured memory_bytes: 11008
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    vector<int> a;
    int tmp;
    /*for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }*/
    map<int, int> x;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        x[tmp]++;
    }
    int ans = 0;
    for (map<int, int>::iterator i = x.begin(); i != x.end(); ++i)
    {
        if (i->first <= i->second)
        {
            ans += (i->second - i->first);
        }
        else
        {
            ans += i->second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> pq;
  for(int i = 0; i < n; i++){
    int t;cin>>t;
    pq.push(t);
  }

  while(m){
    int t = pq.top();pq.pop();
    pq.push(t/2);
    m--;
  }
  long long res = 0;
  while(pq.size()){
    res+=pq.top();pq.pop();
  }
  cout<<res;
  
}


Measured memory_bytes: 892
import math 

def prime(n):
    
    while n % 2 == 0: 
        if 2 in lis:
            lis[2] = lis[2] + 1
        else:
            lis[2] = 1
            
        n = n // 2

    for i in range(3,int(math.sqrt(n))+1,2): 
          
        while n % i== 0: 
            if i in lis:
                lis[i] = lis[i] + 1
            else:
                lis[i] = 1
            n = n // i 

    if n > 2: 
        if n in lis:
            lis[n] = lis[n] + 1
        else:
            lis[n] = 1


x = int(input())
lis = {}
prime(x)
total = 0

for i in lis:
    temp = 0
    rSum = 0

    while lis[i] > rSum:
        temp = temp + 1
        rSum = rSum + temp

    if lis[i] == rSum:
        total = total + temp
    else:
        total = total + temp-1

print(total)
        




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

const int SIZE = 2e5 + 10;

ll s[SIZE] = {0};

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

    int n;
    ll t;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> t;
        s[i] = s[i - 1] + t;
    }
    ll res = LONG_MAX;
    for (int i = 1; i <= n - 1; i++)
        res = min(res, abs(s[n] - 2 * s[i]));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
    ll n;
    ll a,b;
    ll ans=0;
    cin >>n;
    cin>>a>>b;
    ll t=n/(a+b);
    ll r=n-(t*(a+b));
    ans=t*a+(r >a?a:r);
  //  cout<<t<<" "<<r<<" ";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (C, S, F): (Vec<i64>, Vec<i64>, Vec<i64>) = {
        let (mut C, mut S, mut F) = (vec![], vec![], vec![]);
        for _ in 0..(N - 1) {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            C.push(iter.next().unwrap().parse().unwrap());
            S.push(iter.next().unwrap().parse().unwrap());
            F.push(iter.next().unwrap().parse().unwrap());
        }
        (C, S, F)
    };

    fn bis<P: Fn(i64) -> bool>(ok: i64, ng: i64, p: P) -> i64 {
        let mid = (ok + ng) / 2;
        if (ok - ng).abs() == 1 { ok }
        else if p(mid) { bis(mid, ng, p) }
        else { bis(ok, mid, p) }
    }
    const INF: i64 = 1e15 as i64;

    let ans = (0..N).map(|i| {
        if i == N - 1 {
            0.to_string()
        } else {
            let mut x = 0;
            for j in i..(N - 1) {
                x = S[j] + bis(INF, -1, |k| x <= S[j] + k * F[j]) * F[j];
                // println!("j={}, k={}, x={}", j, bis(INF, -1, |k| x <= S[j] + k * F[j]), x);
                x += C[j];
            }
            x.to_string()
        }
    }).collect::<Vec<String>>().join("\n");

    println!("{}", ans);
}

Measured memory_bytes: 4352
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if n==N-1 or n==N-2:
        continue
    elif A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)


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

bool upOrder(vector<int> s){
    for(int i=0;i<s.size()-1;i++){
        if(s[i]>s[i+1]) return false;
    }
    return true;
}

void swap(int* a,int* b){
    int t;
    t=*a;
    *a=*b;
    *b=t;
}

int main(){
    int n;
    vector<int> p;
    cin>>n;
    for(int i=0;i<n;i++){
        int tp;
        cin>>tp;
        p.push_back(tp);
    }
    bool flag=upOrder(p);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            swap(p[i],p[j]);
            if(upOrder(p)){
                flag=true;
                break;
            }
            swap(p[i],p[j]);
        }
    }
    if(flag) printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(n + 1, 0);
    for(int a = 1; a <= n; a++) {
        for(int b = 1; a * b <= n; b++) {
            cnt[a * b]++;
        }
    }
    ll ans = 0;
    for(int c = 1; c < n; c++) {
        ans += cnt[n - c];
    }
    cout << ans << endl;
}

Measured memory_bytes: 11116