akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;



int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int cnt = 0;

    rep(j, n){
        if (j == a[a[j]]) cnt++;
    }
    cout << cnt / 2 << endl;
    return 0;
}

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

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

	if (N[0] != N[1] && N[1] == N[2] && N[2] == N[3]) {
		cout << "Yes" << endl;
	}
	else if (N[0] == N[1] && N[1] == N[2] && N[2] == N[3]) {
		cout << "Yes" << endl;
	}
	else if (N[0] == N[1] && N[1] == N[2] && N[2] != N[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i, j;
  cin >> N;
  vi L(N);
  REP(0, N, i) {
    cin >> L[i];
  }
  sort(all(L));

  i64 ans = 0;
  REP(2, N, i) {
    REP(1, i, j) {
      i64 d = L[i] - L[j];
      auto it = upper_bound(all(L), d);
      ans += max(0LL, j - i64(distance(L.begin(), it)));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define all(x) x.begin(),x.end()
#define ms(obj,val) memset(obj,val,sizeof(obj))

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;
char s[MAXN];
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	scanf("%s",s);
	ll ans = 0; int b = 0;
	FOR(i,0,(int)strlen(s)){
		if(s[i]=='B') b++;
		else ans += b;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    vector<int> as(n, INT_MAX);
    rep(i, n) cin>>as[i];
    rep(i, n) {
        int p = as[(i - 1) / 2];
        int l = as[i * 2 + 1];
        int r = as[i * 2 + 2];

        cout<<"node "<<i + 1<<": key = "<<as[i]<<", ";
        if (i - 1 >= 0) {
            cout<<"parent key = "<<p<<", ";
        }
        if (i * 2 + 1 < n) {
            cout<<"left key = "<<l<<", ";
        }
        if (i * 2 + 2 < n) {
            cout<<"right key = "<<r<<", ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3224
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e9+7;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);

int a[2030];

int main()
{
    TB
    int n;
    cin>>n;
    fd(n) cin>>a[i+1];
    int sum=0;
    fdd(1,n+1){
        if(i%2&&a[i]%2) sum++;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main ()
{
	int i,k=0,g=0;
	scanf("%d",&i);
	int a[i+1];
	for(int b=1;b<=i;b++)
	{
		scanf("%d",&a[b]);
	}
		for(int d=1;d<i;d++)
		{
			for(int c=d+1;c<=i;c++)
			{
				k+=a[d]*a[c];
			}
			g+=k;
			k=0;
		}
		printf("%d",g);
}

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

void solve(long long N, long long M, vector<long long> a, vector<long long> b){
  int memo1[200001] = {0};
  int memo2[200001] = {0};
	for ( long long i = 0; i < M; i++ ) {
    if (a[i] == 1) {
      memo1[b[i] - 1] = 1;
    }
    if (b[i] == N) {
      memo2[a[i] - 1] = 1;
    }
  }
  string ans = "IMPOSSIBLE";
	for ( long long i = 0; i < N; i++ ) {
    if (memo1[i] == 1 && memo2[i] == 1) {
      ans = "POSSIBLE";
      break;
    }
  }
  cout << ans << endl;

}

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



Measured memory_bytes: 8064
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main(){
    string a,b;
    int c,d;
    string e;
    cin>>a>>b>>c>>d>>e;
    if (a==e) c--;
    else d--;
    cout<<c<<" "<<d<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(ll i = (ll)(a); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

unsigned gcd(unsigned a, unsigned b){
    if(a < b) gcd(b,a);
    unsigned r;
    while((r=a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N;
    ll A[100010];
    REP(i,N) cin >> A[i];
    ll ans = gcd(A[0], A[1]);
    FOR(i,2,N){
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    }

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

	/**
	 * @param args
	 * @throws IOException
	 */
	 static int m =(int) (1e9+7);
	 static long mod(long x) {
		 
		 return ((x%m+m)%m);
	 }
	 static long add(long x,long y) {
		 return mod((mod(x)+mod(y)));
	 }
	 static long mul(long x,long y) {
		 return mod((mod(x)*mod(y)));
	 }
	 
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt();
	
		System.out.println(3*n*n);
	}
}
	



Measured memory_bytes: 32688
import java.util.*;
public class Main{ 
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in); 
		while(sc.hasNext()){
		long a = sc.nextLong();
		long b = sc.nextLong();
		long cost = 0;
		if(a == 1){ cost = 6000 * b;}
		if(a == 2){ cost = 4000 * b;}
		if(a == 3){ cost = 3000 * b;}
		if(a == 4){ cost = 2000 * b;}
		System.out.println(cost);
		}
		
	}
	}	

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

void run(int N, int K) {
    int answer;
    int cnt = 1;
    int n;
    for(;;){
        n = std::pow(K, cnt);
        if(N < n){
            answer = cnt;
            break;
        }
        cnt++;
    }
    std::cout << answer << std::endl;
}

int main(){
    int a, b;
    std::cin >> a >> b;
    run(a, b);
}



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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, b;
    cin >> a >> b;
    if(a > b) rep(i, a-'0') cout << b;
    else rep(i, b-'0') cout << a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  Vi mv(n);
  VIN(mv)
  x -= VSUM(mv);
  SORT(mv);
  while(true){
    if(mv[0] <= x){
      x -= mv[0];
      c++;
    } else {
      break;
    }
  }
  OUT(c + n);
}

Measured memory_bytes: 768
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int sugar_max_num_c = F / C;
    int sugar_max_num_d = F / D;

    float limit_density = (float)E / (100 + E);
    float max_density = 0.0;
    float max_sugar = -1;
    float max_water = -1;

    FOR(i, 0, 31){
        FOR(j, 0, 31){
            int water = 100 * A * i + 100 * B * j;

            FOR(k, 0, sugar_max_num_c + 5){
                FOR(l, 0, sugar_max_num_d + 5){
                    int sugar = C * k + D * l;

                    // weight check
                    if(water + sugar <= F){

                        // density check
                        float density = (float)sugar / (water + sugar);
                        if(density <= limit_density){
                            // 候補
                            if(density > max_density){
                                max_density = density;
                                max_sugar = sugar;
                                max_water = water;
                            }
                        }
                    }
                }
            }
        }
    }

    if(max_density == 0.0){
        p2(100 * A, 0);
    }else{
        p2(max_water+max_sugar, max_sugar);
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N;
LL s=1e6+1;
int main(){
	cin>>N;
	LL ans=0;
	REP(i,sqrt(N)){
		if(N%(i+1)==0){
			if((i+1)>N/(i+1))continue;
			LL m=N/(i+1)-1;
			if(m<=0)continue;
			if(N/m==(N%m)){
				ans+=(N/(i+1)-1);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string s;
	cin >> s;
	if (s == "AKIHABAR" || s == "AKIHABRA" || s == "AKIHBARA" || s == "KIHABARA" ||
		s == "AKIHABR" || s == "AKIHBAR" || s == "KIHABAR" ||
		s == "AKIHBRA" || s == "KIHABRA" ||
		s == "KIHBARA" ||
		s == "AKIHBR" || s == "KIHABR" || s == "KIHBAR" || s == "KIHBRA" ||
		s == "KIHBR" ||
		s == "AKIHABARA") {
		O("YES");
	}
	else {
		O("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100010;
bool prime[MAX_N];
int Sum[MAX_N];

int main(){
    fill(prime + 2, prime + MAX_N, true);
    for (int i = 2; i < MAX_N; i++){
        if (prime[i]){
            for (int j = 2 * i; j < MAX_N; j += i){
                prime[j] = false;
            }
        }
    }

    for (int i = 3; i < MAX_N; i += 2){
        Sum[i] = Sum[i - 2];
        if (prime[i] && prime[(i + 1) / 2]) Sum[i] += 1;
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", Sum[r] - Sum[l - 2]);
    }

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    cin>>N;
    if(N%1000==0) cout<<0<<endl;
    else cout<<1000-N%1000<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 998244353;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int a, b;
    cin >> a >> b;
    string s(a, b+'0'), t(b, a+'0');
    if (s<t) print(s);
    else print(t);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int d[ 6 ] = { 1, 2, 3, 5, 4, 6 };
    int res = 1;
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    while ( n-- )
    {
      char cmd[ 8 ];

      scanf ( " %s", cmd );
      if ( *cmd == 'N' )
      {
        swap ( d[ 3 ], d[ 0 ] );
        swap ( d[ 0 ], d[ 1 ] );
        swap ( d[ 1 ], d[ 5 ] );
      }
      else if ( *cmd == 'E' )
      {
        swap ( d[ 2 ], d[ 0 ] );
        swap ( d[ 0 ], d[ 4 ] );
        swap ( d[ 4 ], d[ 5 ] );
      }
      else if ( *cmd == 'W' )
      {
        swap ( d[ 4 ], d[ 0 ] );
        swap ( d[ 0 ], d[ 2 ] );
        swap ( d[ 2 ], d[ 5 ] );
      }
      else if ( *cmd == 'S' )
      {
        swap ( d[ 1 ], d[ 0 ] );
        swap ( d[ 0 ], d[ 3 ] );
        swap ( d[ 3 ], d[ 5 ] );
      }
      else if ( *cmd == 'R' )
      {
        rotate ( d + 1, d + 2, d + 5 );
      }
      else if ( *cmd == 'L' )
      {
        rotate ( d + 1, d + 4, d + 5 );
      }

      res += *d;
    }
    
    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  n, m;
long long ans; //答案可能非常大 
// 贪心，每一张折扣券可以让一个商品价格折半
// 于是：优先队列，每次从商品中取最贵的物品进行折半，直到折扣券用完 

// x/y/z = x/(y*z)

int main()
{
	cin >> n >> m;
	priority_queue<int> pq;
	int x;
	while(n--)
	{
		cin >> x;
		pq.push(x);
	}
	
	while(m--)
	{
		x = pq.top();
		pq.pop();
		pq.push(x/2);
	}
	
	while(!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

// 全局变量
const int N = 100010 , M = N + N;
int x[N],y[N],id[N],n;

typedef struct ufset *UFset;
struct ufset
{
  int *parent;
  int *root;
};
UFset UFinit(int size)
{
  int e;
  UFset U=(UFset)malloc(sizeof *U);
  U->parent=(int*)malloc((size+1)*sizeof(int));
  U->root=(int*)malloc((size+1)*sizeof(int));
  for(e=1; e<=size; e++)
  {
    U->parent[e]=1;
    U->root[e]=1;
  }
  return U;
}
int UFfind(int e,UFset U)
{
  int i,j = e;
  while(!U->root[j]) j = U->parent[j];
  while(j!=e){
    i = U->parent[e];
    U->parent[e]=j;
    e=i;
  }
  return j;
}
int UFunion(int i,int j,UFset U)
{
  if(U->parent[i]<U->parent[j])
  {
    U->parent[j]+=U->parent[i];
    U->root[i]=0;
    U->parent[i]=j;
    return j;
  }
  else
  {
    U->parent[i]+=U->parent[j];
    U->root[j]=0;
    U->parent[j]=i;
    return i;
  }
}

// 记录优化后的边集数
struct Edge
{
  int u, v, cost;
  bool operator <(const Edge&b) const
  {
    return cost < b.cost;
  }
} edge[M];
int tot;
// 按照X轴排序
bool cmpX(int a, int b)
{
  return x[a] < x[b];
}
// 按照Y轴排序
bool cmpY(int a, int b)
{
  return y[a] < y[b];
}
void add(int c, int a, int b)
{
  edge[tot].cost = c;
  edge[tot].u = a;
  edge[tot++].v = b;
}
int main()
{
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; ++i)
  {
    scanf("%d%d", x + i, y + i);
    id[i] = i;
  }
  std::sort(id + 1 , id + n + 1, cmpX);
  for (i = 2; i <= n; ++i)
    add(x[id[i]] - x[id[i - 1]], id[i], id[i - 1]);
  std::sort(id + 1 , id + n + 1, cmpY);
  for (i = 2; i <= n; ++i)
    add(y[id[i]] - y[id[i - 1]], id[i], id[i - 1]);
  UFset UFS = UFinit(n);

  // 按照花费排序
  std::sort(edge, edge + tot);
  long long totcost = 0;
  for (i = 0; i < tot; ++i)
  {
    int u = edge[i].u, v = edge[i].v;
    u = UFfind(u,UFS), v = UFfind(v,UFS);
    if (u != v)
    {
      UFunion(u,v,UFS);
      totcost += edge[i].cost;
    }
  }
  printf("%lld\n", totcost);
  return 0;
}

Measured memory_bytes: 4480
#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; }
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
ll a[200010];

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<n;i++) a[i] -= (i+1);
    sort(a, a+n);
    ll sum = 0;
    if(n%2==1){
        for(int i=0;i<n;i++) sum += abs(a[i] - a[(n-1)/2]);
    }
    else{
        for(int i=0;i<n;i++) sum += abs(a[i] - a[n/2]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main() {
    int x, y, z, tmp;
    scanf("%d %d %d", &x, &y, &z);
    
    tmp = x;
    x = y;
    y = tmp;
    
    tmp = x;
    x = z;
    z = tmp;
    
    printf("%d %d %d\n",x , y, z);
    return 0;
}


Measured memory_bytes: 1728
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C := getString(), getString(), getString()

	ans := "NO"
	if A[len(A)-1] == B[0] && C[0] == B[len(B)-1] {
		ans = "YES"
	}
	out(ans)
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int input[3];
	int i;
	int five_number = 0;
	int seven_number = 0;

	scanf("%d %d %d", &input[0], &input[1], &input[2]);

	for(i = 0; i < 3; i++){
		if(5 == input[i]){
			five_number++;
		}
		if(7 == input[i]){
			seven_number++;
		}
	}

	if(2 == five_number && 1 == seven_number){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

char maze[1010][1010];
int dp[1010][1010];
int h,w;

int rec(int ny,int nx){

    if(dp[ny][nx]!=-1)return dp[ny][nx];

    if(ny==1 && nx==1)return 1;

    if(ny<1 || ny >h || nx<1 ||nx>w )return 0;

    if(maze[ny][nx]=='#')return dp[ny][nx]=0;
    return dp[ny][nx]=(rec(ny-1,nx)+rec(ny,nx-1))%mod;


}


int main(){

    cin>>h>>w;
    rep2(i,h){
        rep2(k,w){
        cin>>maze[i][k];
        dp[i][k]=-1;
        }
    }
    cout<<rec(h,w)<<endl;


    return 0;

}
/*


*/


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

int main(void) {
	// your code goes here
	
	int n,k;
	int sum =0;
	cin>>n>>k;
	
	sum += k;
	
	for(int i=1;i< n;i++){
		sum *= k-1;
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;
int dp[100010];

int main(){
	int X; cin >> X;
	dp[0] = 1, dp[100] = 1,dp[101] = 1, dp[102] = 1, dp[103] = 1, dp[104] = 1, dp[105] = 1;
	for(int i=106; i<=X; i++){
		if(dp[i-100] == 1) dp[i] = 1;
		if(dp[i-101] == 1) dp[i] = 1;
		if(dp[i-102] == 1) dp[i] = 1;
		if(dp[i-103] == 1) dp[i] = 1;
		if(dp[i-104] == 1) dp[i] = 1;
		if(dp[i-105] == 1) dp[i] = 1;
	}
	cout << dp[X] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<bool> have (N, false);
    for (int i = 0;i < K;i++) {
        int d;
        cin >> d;
        for (int j = 0;j < d;j++) {
            int A;
            cin >> A;
            have[A-1] = true;
        }
    }
    int count = 0;
    for (int i = 0;i < N;i++) {
        if(!have[i]) {
            count ++;
        }
    }
    cout << count << endl;
}


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

const ll mod=1e9+7;

ll a[2005];

int main(){
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
    ll num=0,ans=0;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++) if(a[j]<a[i]) num++;
    }
    ans=(ans+k*num)%mod;
    num=0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            if(a[j]>a[i]) num++;
        }
    }
    ll res=(1+k-1)*(k-1)/2;
    res%=mod;
    ans=(ans+res*num)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = ['.' * (w+2)]
for i in range(h):
    s.append('.' + input() + '.')
s.append('.' * (w+2))
from itertools import product
for y, x in product(range(1, h + 1), range(1, w + 1)):
    if s[y][x] == '#':
        if True in [s[y + i][x + j] == '#' for i, j in [(0, -1), (0, 1), (-1, 0), (1, 0)]]:
            continue
        print('No')
        import sys
        sys.exit()
print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main ()
{
    int N,M;cin>>N>>M;//N島の数，Mは要望の数
    vector<p> cut(M);
    REP(i,M){
        int a,b;cin>>a>>b;
        cut[i] = make_pair(b,a);//last first の順番
    }
    sort(cut.begin(),cut.end());
    int last = 0;
    int cnt = 0;
    REP(i,M){
        if(last <= cut[i].second){//firstが大きい
            last = cut[i].first;//lastを更新
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n), p(n), q(n);

  rep(i, n) { v.at(i) = i + 1; }
  rep(i, n) { cin >> p.at(i); }
  rep(i, n) { cin >> q.at(i); }

  int idx = 1, pc = -1, qc = -1;
  do
  {
    if (v == p)
    {
      pc = idx;
    }
    if (v == q)
    {
      qc = idx;
    }

    if (pc != -1 && qc != -1)
    {
      break;
    }

    idx++;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(pc - qc) << 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;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

int main(int argc, char *argv[]) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    P p1(x1, y1), p2(x2, y2);
    int d = norm(p1 - p2);

    for (int x3 = -300; x3 <= 300; x3++) {
        for (int y3 = -300; y3 <= 300; y3++) {
            if (x3 == x1 && y3 == y1) continue;
            if (x3 == x2 && y3 == y2) continue;
            if (sqr(x3 - x2) + sqr(y3 - y2) != d) continue;
            if (ccw(p1, p2, P(x3, y3)) != 1) continue;
            for (int x4 = -300; x4 <= 300; x4++) {
                for (int y4 = -300; y4 <= 300; y4++) {
                    if (x4 == x1 && y4 == y1) continue;
                    if (x4 == x2 && y4 == y2) continue;
                    if (x4 == x3 && y4 == y3) continue;

                    if (sqr(x3 - x4) + sqr(y3 - y4) == d &&
                        sqr(x4 - x1) + sqr(y4 - y1) == d &&
                        sqr(x1 - x3) + sqr(y1 - y3) == sqr(x2 - x4) + sqr(y2 - y4)) {
                        cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
                    }
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void)
{
  int N, M, C;
  cin >> N >> M >> C;
  int count = 0;

  int *B = new int[M];
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  for (int i = 0; i < N; ++i) {
    int *A = new int[M];
    int sum = C;

    for (int j = 0; j < M; j++) {
      cin >> A[j];
      sum += B[j]*A[j];
    }

    if (sum > 0) {
      ++count;
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[202], p[102];
	int i, j, l, n, f, g = 0;

	fgets(s, 102, stdin);
	fgets(p, 102, stdin);
	for (l = 0; s[l] != '\n' && s[l] != '\0'; l++) ;
	for (n = 0; p[n] != '\n' && p[n] != '\0'; n++) ;
	for (i = l + 1; i >= 0; i--) s[l + i] = s[i];
	for (i = 0; i < l; i++) {
		f = 0;
		for (j = 0; j < n; j++) {
			if (s[i + j] == p[j]) f++;
			else break;
		}
		if (f == n) {
			g = 1;
			break;
		}
	}
	if (g == 1) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
int a[2*maxn];
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int minn=INF,ans=0;
	for(int i=1;i<=n;i++)
	{
		minn=min(minn,a[i]);
		if(minn>=a[i])
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int N,X,f=0;
	scanf("%d",&N);
	X=N;
	do{
		f=f+(X%10);
		X=X/10;
	}while(X>=1);
	if(N%f==0) printf("Yes\n");
	else printf("No\n");
return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int h,a,cnt=0;
    cin>>h>>a;
    while(h>0)
    {
    	h-=a;
    	cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#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 k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a.at(i);

	int lsum = 0, lmax = 0, diff;
	for (int i = 0; i < n; i++) {
		if (i < n - 1)
			diff = a.at(i+1) - a.at(i);
		else
			diff = a.at(0)+k - a.at(n-1);
		if (diff > lmax)
			lmax = diff;
		lsum += diff;
	}
	lsum -= lmax;
	cout << lsum << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << pair_var.first << " " << pair_var.second ;return os;}
template<class tContainer>
long long sum(tContainer const& iContainer) {return  std::accumulate(std::begin(iContainer), std::end(iContainer), 0LL);}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[2100000] = {};
int d[2100000] = {};
int dp[1000000];
set<int> ch;

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  
  n%=k;
  n = min(abs(n-k),n);
  cout << n << '\n';
}



Measured memory_bytes: 51200
/*
stones numbered 1-n
ith stone has height hi
from ith stone can jump to i+1 or i+2 with cost |diff(stone j - stone i)|
find min cost to go from i to n

Approach =
state : dp[i] = min(dp[i-1]+(h[i]-h[i-1]) or dp[i-2]+(h[i]-h[i-2]))
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader sc=new FastReader();
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),dp[i-2]+Math.abs(h[i]-h[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 31256
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forf(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>b;i--)
#define mp make_pair
#define f first
#define s second
#define pb(x) push_back(x)
typedef  long long  int ll;
typedef std::vector<ll> vi;

#define input(vec,a,b) for(ll i =a;i<b;i++) cin>>vec[i]
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" " ;cout<<endl;
#define all(a) a.begin(),a.end()
using namespace std;


void solve(){
        ll i,j,n,z;
        cin>>n;
        ll h[n][3],mh[n][3];
        for(i=0;i<n;i++)
        {
                 for(j=0;j<3;j++)
                 cin>>h[i][j];
        }
        mh[0][0]=h[0][0];
        mh[0][1]=h[0][1];
        mh[0][2]=h[0][2];
        for(i=1;i<n;i++)
        {
                 
                 for(j=0;j<3;j++)
                 {
                          ll ma=0;
                          for(z=0;z<3;z++)
                          {
                                   if(j==z)
                                   continue;
                                   ma=max(mh[i-1][z],ma);
                          }
                          mh[i][j]=ma+h[i][j];
                 }
        }
        ll ma=0;
        for(i=0;i<3;i++)
        {
             ma=max(ma,mh[n-1][i]);    
        }
        cout<<ma;
}

int main()
{
      IO;
      ll t=1;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}

Measured memory_bytes: 8208
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  map<string,ll> t;

  rep(i,n)
  {
    string buf;
    cin >> buf;
    t[buf]++;
  }

  ll p = 0;
  for(auto itr = t.begin(); itr != t.end(); itr++)
  {
    p = max(p,itr->second);
  }

  for(auto itr = t.begin(); itr != t.end(); itr++)
  {
    if(p == itr->second)
      cout << itr->first << endl;
  }
  

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 25216
import Control.Applicative
import Data.List
import Data.Array.Unboxed

main = do
  n <- readLn :: IO Int
  s <- lines <$> getContents :: IO [[Char]]

  print $ sum $ map (\x -> if isSymmetrical (listArray ((1,1),(n,n)) (concat x)) n then n else 0) (take n (iterate rotate s))


isSymmetrical :: Array (Int,Int) Char -> Int -> Bool
isSymmetrical s n = and [s!(i,j) == s!(j,i) | i<-[1..n], j<-[i..n]]

rotate :: [a] -> [a]
rotate xs = last xs : init xs


Measured memory_bytes: 15740
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int main(){
	double l;
	scanf("%lf",&l);
	pf("%.12lf",1.0*l*l*l/3/3/3);	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC156
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            int k = s[1];
            int ans = 0;
            while(n>0){
                n = n/k;
                ans++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
#define rep(i,s,n)for(ll i = s;i<n;i++)

char s[Z];
int main() {
	cin >> s;

	ll i = 0;
	bool c[26] = {};

	while (*(s + i)) {
		c[*(s + i++) - 'a'] = true;
	}

	i = 0;
	do {
		if (i >= 26) {
			break;
		}

		if (!c[i]) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	} while (c[i++]);

	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 384