akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  
  int nx;
  int cnt=0;
  int px[4]={1,-1,4,-4};
  string str="        ";
  map<string,int>m;
  queue<int>q;
  queue<string>sq;

  q.push(0);
  sq.push("01234567");

  while(!q.empty()){
    int siz=q.size();
    for(int nsiz=0; nsiz<siz; nsiz++){
      nx=q.front();
      q.pop();
      str=sq.front();
      sq.pop();

      if(m.count(str)==0){
	m[str]=cnt;
	for(int i=0;i<4;i++){
	  if(i<2 && nx+px[i]>=0 && nx+px[i]<8 && nx/4 == (nx+px[i])/4 ){
	    swap(str[nx],str[nx+px[i]]);
	    q.push(nx+px[i]);
	    sq.push(str);
	    swap(str[nx],str[nx+px[i]]);
	  }
	  if(i>1 && nx+px[i]>=0 && nx+px[i]<8){
	    swap(str[nx],str[nx+px[i]]);
	    q.push(nx+px[i]);
	    sq.push(str);
	    swap(str[nx],str[nx+px[i]]);
	  }
	}
      }

    }
    cnt++;
  }

  while(1){
    for(int i=0;i<8;i++){
      if(!(cin>>str[i])) return 0;
    }
    cout<<m[str]<<endl;
  }

  return(0);
}

Measured memory_bytes: 3516
n=int(input())
b=list(map(int,input().split()))
a=[]
for i in range(n):
  if b[i]-1>len(a):
    print(-1)
    break;
  else:
    a.insert(b[i]-1,b[i])
if len(a)==n:
  for i in range(n):
    print(a[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main()
{
	int n;
	cin>>n;
	string ar[n];
	int t[n];
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
	cin>>t[i];	
	}int ans=0;
	string tk;
	cin>>tk;
	int flag=0;
	for(int i=0;i<n;i++)
	{
	if(ar[i]==tk)
	{
		flag=1;
	}
	if(flag==1 && ar[i]!=tk)
	ans+=t[i];
}
cout<<ans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int ans=0;
  REP(i,3){
    if(s[i]=='1')ans++;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    float c = 2 * M_PI * n;
    printf("%.3f", c);    
    return 0;
}


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

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int ai;
  rep(i,n){
    cin >> ai;
    x += (d-1)/ai + 1;
  }
  
  cout << x << endl;
  
  return 0;
}


Measured memory_bytes: 256
#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;
  	string s, t;	cin >> s >> t;
  	rep(i,s.size()){
    	cout << s.at(i) << t.at(i);
    }
  	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}





#define int long long

int x,y;


signed main(){
	read(x);read(y);
	if(x*500>=y) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n;
double x,sum=0.0;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>x;
    sum+=1.0/x;
}
sum=1.0/sum;

printf("%.7lf\n",sum);

return  0;
}


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

int main(){
    long long N, K; std::cin >> N >> K;
    std::vector<long long> h(N);
    for (auto& r : h)std::cin >> r;
    std::sort(h.begin(), h.end());
    long long ans = 10000000000;
    for (int i = 0; i + K - 1 < N; ++i) 
        ans = std::min(ans, h[i + K - 1] - h[i]);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i, N)cin >> x[i];
  rep(i, M)cin >> y[i];
  sort(all(x));
  sort(all(y));
  bool war = false;
  for(int i = x[N - 1] + 1; i <= y[0]; i++){
    if(X < i && i <= Y) war = true;
  }

  if(!war)cout << "War" << endl;
  else cout << "No War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int n;
void solve() {  
    cin >> n;
    string ans = "";
    while (n) {
        int r = n % 26;
        if (!r)
            ans += 'z';
        else
            ans += char('a' + r - 1);
        --n;
        n /= 26;
    }    
    reverse(all(ans));
    cout << ans;
}       

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

using i32 = int;
using i64 = long long;

#define REP(i, stop) for (int i = 0; i < stop; ++i)

template<typename T>
T read() {
  T a = 0;
  register int c;
  for(;;) {
    c = getchar_unlocked();
    if (c & 16) {
      a = a * 10 + c - 48;
    } else {
      return a;
    }
  }
}

void writeln(i64 a) {
  char buf[20];
  register int i = 0;
  // if (a <= 0)
  while (a > 0) {
    buf[i] = a % 10;
    a = a / 10;
    ++i;
  }
  while (i > 0) {
    --i;
    putchar_unlocked(buf[i] + 48);
  }
  putchar_unlocked('\n');
}

i64 A[1000], B[1000], C[1000];
i64 AB[3000];
signed main() {
  i32 X = read<i32>(),
      Y = read<i32>(),
      Z = read<i32>(),
      K = read<i32>();
  REP(i, X) A[i] = -read<i64>();
  REP(i, Y) B[i] = -read<i64>();
  REP(i, Z) C[i] = -read<i64>();
  sort(A, A + X);
  sort(B, B + Y);
  sort(C, C + Z);
  using P = pair<i64, i32>;
  set<P> Q, R;
  Q.insert({A[0] + B[0], 0});
  i32 L = min(K, X * Y);
  REP(i, L) {
    i64 p = (*Q.begin()).first;
    i64 q = (*Q.begin()).second;
    AB[i] = p;
    Q.erase(Q.begin());
    i32 u = q >> 10;
    i32 v = q & 1023;
    if (u + 1 < X && (u + 1) * v < L) Q.insert({A[u + 1] + B[v], q + 1024});
    if (v + 1 < Y && u * (v + 1) < L) Q.insert({A[u] + B[v + 1], q + 1});
  }
  R.insert({AB[0] + C[0], 0});
  REP(_, K) {
    i64 p = (*R.begin()).first;
    i64 q = (*R.begin()).second;
    // printf("%lld\n", -p);
    writeln(-p);
    R.erase(R.begin());
    i32 u = q >> 10;
    i32 v = q & 1023;
    if (u + 1 < L && (u + 1) * v < K) R.insert({AB[u + 1] + C[v], q + 1024});
    if (v + 1 < Z && u * (v + 1) < K) R.insert({AB[u] + C[v + 1], q + 1});
  }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());

    int res = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < i; j++) {
            for(int k = 0; k < j; k++) {
                if(vec[k] != vec[j] && vec[i] != vec[j] &&
                   vec[k] + vec[j] > vec[i]) {
                    res++;
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3640
n = int(input())
p = list(map(int,input().split()))
q = sorted(p)

for i in range(n):
    for j in range(i,n):
        p[i],p[j] = p[j],p[i]
        if q == p:
            print('YES')
            exit()
        p[i],p[j] = p[j],p[i]
print('NO')

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

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }





int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,w;
	cin>>n>>w;
	std::vector<int> wet(n) , val(n);
	REP(i,n) cin>>wet[i]>>val[i];
	ll dp[n+2][w+2];
	for (int i = 0; i <n; ++i)
	{
		dp[i][0] = 0;
	}
	for (int j = 1; j <= w; ++j)
	{
		if(wet[0] > j) dp[0][j] = 0;
		else dp[0][j] = val[0];
	}
	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			if(wet[i] >= j) dp[i][j] = dp[i-1][j];
			else{
				dp[i][j] = max(dp[i-1][j] , val[i]+dp[i-1][j - wet[i]]);
			}
		}
	}
	cout<<dp[n-1][w]<<"\n";
	return 0;
}


Measured memory_bytes: 81728
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int res = 0;
    for (int i = 1; i <= N; i++) {
        int c = 0;
        int d = i;
        while (d > 0) {
            c += d % 10;
            d /= 10;
        }
        if (A <= c && B >= c) {
            res += i;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using P = pair<int, int>;
using ll = long long;
vector<int> to[100005];
int cost[100005];

signed main(){
    int n, m;
    cin >>n >>m;
    vector<P> arr(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }

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

    long now = 0;
    long ans = 0;
    rep(i,n) {
        //cout << arr[i].first << endl;
        long next = min(m-now,(long)arr[i].second);
        now += next;
        ans += next*arr[i].first;
    }

    cout <<  ans << endl;

    return 0;
}



Measured memory_bytes: 3328
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
int main(int argc, char **argv) {
  int A, B, K;
  cin >> A >> B >> K;
  int i = max(A, B);
  int k = 0;
  while (true) {
    if (A % i == 0 && B % i == 0) {
      ++k;
      if (k == K) {
        cout << i << endl;
        return 0;
      }
    }
    --i;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main(int argc, const char * argv[]) {
    
    ll N,K; cin >> N >> K;
    vector<ll> p(N);
    for(ll i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    
    ll sum=0;
    for(ll i=0;i<K;i++){
        sum += p[i];
    }
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 6228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int ans = pow(n, 1.0/2.0);
    out(ans*ans);
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("odometer.in" , "r" , stdin );freopen("odometer.out", "w" , stdout );}

const int N = 1e6 + 7;

int dp[N], c[N];

void solve(){
    string s, t;
    cin >> s >> t;
    long mn = 1e9;
    for (int i = 0; i <= s.size() - t.size(); ++i){
        long a = 0, k = i;
        for (int j = 0; j < t.size(); ++j){
            if( s[k] == t[j] ) a ++;
            k ++;
        }
        mn = min(mn, int(t.size()) - a);
    }
    cout << mn;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";    
}

Measured memory_bytes: 3816
#include<stdio.h>

void insertionSort(int A[],int N){
    int i,j,k,v;
    
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(k=0;k<N;k++){
            printf("%d",A[k]);
            if(k!=N-1) printf(" ");
            else putchar('\n');
        }
    }
}

int main(void){
    int i,N;
    scanf("%d",&N);
    
    int A[N];
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    for(i=0;i<N;i++){
        printf("%d",A[i]);
        if(i!=N-1) printf(" ");
        else putchar('\n');
    }
    insertionSort(A,N);
    
    return(0);
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static int H;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            List<int> A = new List<int>();
            A.Add(-1);
            
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');

                if (input[0] == "end") break;

                if (input[0][0] == 'i')
                {
                    Insert(A, int.Parse(input[1]));
                }
                else
                {
                    sb.AppendLine(Extract(A).ToString());
                }
            }
            Console.Write(sb);
        }

        static int Extract(List<int> A)
        {
            int ret;

            if (H < 1) return int.MinValue;

            ret = A[1];
            A[1] = A[H];
            A.RemoveAt(H);
            H--;

            MaxHeapify(A, 1);

            return ret;
        }

        static void Insert(List<int> A,int key)
        {
            H++;
            A.Add(int.MinValue);

            IncreaseKey(A, H, key);
        }

        static void IncreaseKey(List<int> A, int i, int key)
        {
            if (key < A[i]) return;
            A[i] = key;

            while (i > 1 && A[i / 2] < A[i])
            {
                int temp = A[i];
                A[i] = A[i / 2];
                A[i / 2] = temp;

                i /= 2;
            }
        }

        static void MaxHeapify(List<int> A, int i)
        {
            int l = i * 2;
            int r = i * 2 + 1;

            int largest = (l <= H && A[l] > A[i]) ? l : i;

            if (r <= H && A[r] > A[largest]) largest = r;

            if (largest != i)
            {
                int temp = A[i];
                A[i] = A[largest];
                A[largest] = temp;

                MaxHeapify(A, largest);
            }
        }
    }
}

Measured memory_bytes: 31228
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >>arr[i];
    long long int ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            ans += (arr[i] * arr[j]);
        }
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int m = sc.nextInt();
	
		int count =0 ;
		for(int i=l ;i<=r;i++) {
			if(i%m == 0)
				count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26976
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 500000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int main()
{
    int n=read(),k=read(),ans=0;
    math_init();
    rep(i,n,k)
    {
        int t=i-(n-1);
        if (i==k-i) ans=add(ans,dec(C(k-1,i),C(k-1,i+t)));
        else if (i>k-i) ans=add(ans,dec(C(k,i),C(k,i+t)));
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <math.h>
using namespace std;
#define MAX (300000+2)

int main(int argc, const char * argv[]) {
    int N, l[MAX] = {0},r[MAX] = {0};
    string s;
    cin >> N >> s;
    for (int i =1; i<N-1; i++) {
        if (s[i-1] == 'W') {
            l[i]++;
        }
        l[i+1]+=l[i];
    }
    for (int i = N-1; i>0; i--) {
        if (s[i+1] == 'E') {
            r[i]++;
        }
        r[i-1]=r[i];
    }
    int MIN = N;
    for (int i =0; i<N; i++) {
        MIN = min(MIN,l[i]+r[i]);
    }
    cout << MIN << endl;
}

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

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

    int len = s.length();
    char a = s[0];
    int frag = 0;
    len--;
    s.erase(0,1); 

    for(int i = 0; i < len; i++){
        if(a == s[i]){
            frag = 1;
            break;
        }

        if(i == len - 1){
            a = s[0];
            len--;
            s.erase(0,1);
            i = 0;
        }
    }

    if(frag == 0){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>
 
void mode(int h[],int n,int *index,int *index2,int *counter1,int *counter2) {
	int i, j, temp, temp_c, temp_i;
	*counter1 = 0, *counter2 = 0;
	*index = 0;
	for (i = 0; i < n; i++) {
		temp_i = i;
		temp = h[i];
		temp_c = 0;
		for (j = i; j < n; j++) {
			if (temp == h[j]) {
				temp_c++;
				i = j;
			}
			else {
				break;
			}
		}
		if (*counter1 < temp_c) {
			*counter2 = *counter1;
			*index2 = *index;
			*index = temp_i;
			*counter1 = temp_c;
		}
		else if (*counter2 < temp_c) {
			*index2 = temp_i;
			*counter2 = temp_c;
		}
	}
	
}
int main()
{
	int i, n;
	int *even, *odd;
	int even_c1 = 0;
	int even_c2 = 0;
	int odd_c1 = 0;
	int odd_c2 = 0;
	int even_i1;
	int even_i2;
	int odd_i1;
	int odd_i2;
	scanf("%d", &n);
	even = (int *)malloc(n / 2 * sizeof(int));
	odd = (int *)malloc(n / 2 * sizeof(int));
 
	for (i = 0; i < n; i++) {
		if (i % 2 == 0) {
			scanf("%d", &even[i/2]);
		}
		else {
			scanf("%d", &odd[i/2]);
		}
	}
	std::sort(even, even + n / 2);
	std::sort(odd, odd + n / 2);
	mode(even, n / 2, &even_i1, &even_i2, &even_c1, &even_c2);
	mode(odd, n / 2, &odd_i1, &odd_i2, &odd_c1, &odd_c2);
	if (even[even_i1] == odd[odd_i1]) {
		if ((even_c1 + odd_c2) > (even_c2 + odd_c1)) {
			printf("%d\n", n - even_c1 - odd_c2);
		}
		else {
			printf("%d\n", n - even_c2 - odd_c1);
		}
	}
	else {
		printf("%d\n", n - even_c1 - odd_c1);
	}
	return 0;
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N; cin >> N; 
  vector<vector<pair<ll, ll>>> leng(N+1);
  for (int i = 0; i < N-1; i++) {
    ll a,b,c; cin >> a >> b >> c;
    leng[a].push_back(make_pair(b,c));
    leng[b].push_back(make_pair(a,c));
  }
  ll Q,K; cin >> Q >> K;
  
  vector<ll> d(N+1,9e18);
  d[K] = 0;
  priority_queue <pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
  pq.push(make_pair(0, K));
  vector<bool> check(N+1,false);
  
  while (!pq.empty()) {
    pair<ll, ll> f = pq.top(); pq.pop();
    int u = f.second;
    
    check[u] = true;
    if(d[u] < f.first) continue;
    
    for (int j = 0; j < leng[u].size(); j++) {
      int v = leng[u][j].first;
      if (check[v]) continue;
      if (d[v] > d[u] + leng[u][j].second) {
        d[v] = d[u] + leng[u][j].second;
        pq.push(make_pair(d[v], v));
      }
    }
  }
  
  for (int i = 0; i < Q; i++) {
    ll x,y; cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
}

Measured memory_bytes: 11120
#include <stdio.h>

int n, m;
char a[64][64];
char b[64][64];

int same(int y, int x)
{
    int i, j;

    for (i = 0; i < m; ++i){
        for (j = 0; j < m; ++j){
            if (a[y + i][x + j] != b[i][j]){
                return 0;
            }
        }
    }

    return 1;
}

int main(void)
{
    int i, j;

    scanf("%d %d", &n, &m);
    for (i = 0; i < n; ++i) scanf("%s", a[i]);
    for (i = 0; i < m; ++i) scanf("%s", b[i]);

    for (i = 0; i <= n - m; ++i){
        for (j = 0; j <= n - m; ++j){
            if (same(i, j)){
                puts("Yes");
                return 0;
            }
        }
    }

    puts("No");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>

int a,b,c,d;
int sum=0;

int main(void){
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	
	if(a>b)	sum+=b;
	else	sum+=a;
	if(c>d)	sum+=d;
	else	sum+=c;

	printf("%d", sum);
}


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


int main(){
	int l=-1,r=-1;
	string s;
	cin >> s;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			l=i;
			r=i+1;
		}
	}
	for(int i=2;i<s.size();i++){
		if(s[i]==s[i-2]){
			l=i-1;
			r=i+1;
		}
	}
	cout << l << " " << r << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		char[] s = sc.next().toCharArray();
		int roop = s.length / 2;
		for (int i = 0; i < roop; i++) {
			if (s[i] != s[s.length  - 1- i])
				cnt++;
		}
		out.print(cnt);
	}
}

Measured memory_bytes: 22604
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    char *s;
    int n, i, j, c;
    int *list;
    int mode;
    cin >> n;
    s = (char *)malloc(n + 1);
    list = (int *)malloc(sizeof(int) * n);
    cin >> s;
    i = n - 1;
    mode = 0; // white
    c = 0;
    j = 0;
    int ab = 0;
    int aw = 0;
    // for (i = 0; i < nlist; i += 2) {
    //     aw += list[i];
    // }
    // for (i = 1; i < nlist - 1; i += 2) {
    //     ab += list[i];
    // }
    for (i = 0; i < n; i++) {
        if (mode == 0) {
            // white
            if (s[i] == '.') {
                c++;
                aw++;
            } else {
                list[j] = c;
                j++;
                mode = 1;
                c = 1;
                ab++;
            }
        } else {
            // black
            if (s[i] == '#') {
                c++;
                ab++;
            } else {
                list[j] = c;
                j++;
                mode = 0;
                c = 1;
                aw++;
            }
        }
    }
    if (0 < c) {
        list[j] = c;
        j++;
        if (mode == 1) {
            list[j] = 0;
            j++;
        }
    }
    int nlist = j;
    // for (i = 0; i < nlist; i++) {
    //     cout << list[i] << endl;
    // }
    if (nlist == 1) {
        // all whilte
        cout << 0 << endl;
    } else {
        int cost = -1;
        // for (j = 1; j < nlist - 1; j += 2) {
        //     int lb = 0;
        //     int lw = 0;
        //     for (i = 1; i < j; i += 2) {
        //         lb += list[i];
        //     }
        //     for (i = j + 1; i < nlist; i += 2) {
        //         lw += list[i];
        //     }
        //     if (cost < 0) {
        //         cost = lb + lw;
        //     } else if (lb + lw < cost) {
        //         cost = lb + lw;
        //     }
        // }
        int lb = 0;
        int lw = aw - list[0];
        for (j = 1; j < nlist - 1; j += 2) {
            if (cost < 0) {
                cost = lb + lw;
            } else if (lb + lw < cost) {
                cost = lb + lw;
            }
            lb += list[j];
            lw -= list[j + 1];
        }
        ab = min(ab, aw);
        if (cost < 0)
            cout << ab << endl;
        else
            cout << min(cost, ab) << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int INF = 1001001001;
int n, m, r;
VI rv;
int dp[201][201];
bool visited[9] = {};
int ans = INF;

void dfs(int depth, int current, int cost){
    if(depth == r){
        ans = min(ans, cost);
        return;
    }
    FOR(next, 1, r)if(!visited[next]){
        visited[next] = true;
        if(current == 0) dfs(depth + 1, next, 0);
        else dfs(depth + 1, next, dp[rv[current]][rv[next]] + cost);
        visited[next] = false;
    }
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> r;
    rv.push_back(-1);
    REP(i, r){
        int temp;
        cin >> temp;
        rv.push_back(temp);
    }
    fill_n((int*)dp, 201 * 201, INF);
    FOR(i, 1, n) dp[i][i] = 0;
    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        dp[a][b] = c;
        dp[b][a] = c;
    }

    FOR(k, 1, n)FOR(i, 1, n)FOR(j, 1, n)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

    dfs(0, 0, 0);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 // #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define mod        1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

void solve()
{
  
  int x,y,z;
  cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);

  cout<<x<<" "<<y<<" "<<z<<endl;

}

int32_t main()
{
  //pr_init();
  fastio;
  solve();

 }


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, k;
    cin >> n >> k;
    int v[n];
    rep (i, 0, n) cin >> v[i];
    int ans = 0;
    rep (i, 0, min (n, k) + 1) {
        for (int j = 0; i + j <= min (n, k); j++) {
            int sum = 0;
            vector<int> vec;
            rep (l, 0, i) {
                vec.push_back (v[l]);
                sum += v[l];
            }
            rep (l, 0, j) {
                vec.push_back (v[n - l - 1]);
                sum += v[n - 1 - l];
            }
            sort (vec.begin(), vec.end());
            rep (l, 0, min (k - i - j, (int)vec.size())) {
                if (vec[l] < 0) sum -= vec[l];
            }
            ans = max (ans, sum);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pll;
//typedef boost::multiprecision::cpp_int bigint;

ll N, A, B, C, D;

bool judge(ll n) {
	ll x = B - A + (N - 2 * n - 1) * C;
	ll up = n * (D - C);
	ll down = -(N - 1 - n) * (D - C);
	if (up >= x && x >= down)return true;
	else return false;
}

int main() {
	cin >> N >> A >> B >> C >> D;
	for (ll n = 0; n < N; n++) {
		if (judge(n)) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] N=cin.ArrayInt(2,0);
        int ans=10;
        if(N[0]<N[1])ans=0;
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}










Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int H, W;
int h_count[2000][2000], w_count[2000][2000];
string S[2000];

int main() {
    cin >> H >> W;
    REP(i, H) cin >> S[i];

    REP(i, H) REP(j, W) {
        if (S[i][j] == '.') {
            int c = 0;
            for (int k = j; k < W && S[i][k] == '.'; k++) c++;
            for (int k = j; k < W && S[i][k] == '.'; k++) w_count[i][k] = c;
            j += c - 1;
        }
    }
    REP(i, W) REP(j, H) {
        if (S[j][i] == '.') {
            int c = 0;
            for (int k = j; k < H && S[k][i] == '.'; k++) c++;
            for (int k = j; k < H && S[k][i] == '.'; k++) h_count[k][i] = c;
            j += c - 1;
        }
    }
    int ans = 0;
    REP(i, H) REP(j, W) ans = max(ans, h_count[i][j] + w_count[i][j] - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){

  int n;
  cin >> n;

  if (n>81){
    cout << "No" << endl;
    return 0;
  }

  for (int i=1;i<=9;++i){
    if (n % i == 0){
      if (n / i < 10){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


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

int main() {
    string s; cin >> s;
    string t;
    t = "CODEFESTIVAL2016";

    int ans = 0;
    rep(i, t.size()) {
        if (s.at(i) != t.at(i))
            ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <climits>

using namespace std;

#define MAX_V 5010

typedef pair<int, int> P;

struct edge{
  int to, cost;
  edge(int _to, int _cost){
    to = _to;
    cost = _cost;
  }  
};

struct node{
  int cost, mincost, v, n;
  bool operator < (const node a) const{
    return a.mincost < mincost;
  }
};

vector<int> G[MAX_V];
vector<node> Node;
vector<int> can[MAX_V];
int d[MAX_V];

int N, K;

void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
  }
}

void dijkstra(int s){
  priority_queue<node> que;
  fill(d, d+MAX_V, INT_MAX);
  
  que.push(Node[0]);  
  d[s] = 0;
  
  while(!que.empty()){
    node p = que.top(); que.pop();
    int v = p.v;
    if(d[v] < p.mincost) continue;

    for(int i = 0 ; i < can[v].size() ; i++){
      int e = can[v][i];

      if(d[e] > d[v] + Node[v].cost){
	d[e] = d[v] + Node[v].cost;
	node tmp;
	tmp.v = can[v][i];
	tmp.mincost = d[e];
	que.push(tmp);
      }
    }
  }
}

vector<edge> G2[MAX_V];
int d2[MAX_V];

void dijkstra2(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  
  fill(d2, d2+MAX_V, (1<<29));
  d2[s] = 0;  
  que.push(P(0, s));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d2[v] < p.first) continue;
    for(int i = 0 ; i < G2[v].size() ; i++){
      edge e = G2[v][i];
      if(d2[e.to] > d2[v] + e.cost){
	d2[e.to] = d2[v] + e.cost;
	que.push(P(d2[e.to], e.to));
      }
    }
  }  
}

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

  for(int i = 0 ; i < N ; i++){
    node tmp;
    tmp.v = i;
    cin >> tmp.cost >> tmp.n;
    Node.push_back(tmp);
  }  
  int from, to;
  for(int i = 0 ; i < K ; i++){
    cin >> from >> to;
    from--;
    to--;
    
    G[from].push_back(to);
    G[to].push_back(from);
    
    G2[to].push_back(edge(from, 1));
    G2[from].push_back(edge(to, 1));    
  }

  for(int i = 0 ; i < N ; i++){
    dijkstra2(i);
    for(int j = 0 ; j < N ; j++){
      if(d2[j] <= Node[i].n) can[i].push_back(j);
    }
  }
  
  dijkstra(0);
  
  
   cout << d[N-1] << endl;
  
  return 0;
}

Measured memory_bytes: 69676
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

A = list(map(int, input().split()))

limit = 1 / (4*M)

A.sort(reverse=True)
ans = 0
sum_A = sum(A)
for i in range(len(A)):
    if (A[i] / sum_A) >= limit:
        ans += 1
    if ans == M:
        print("Yes")
        exit()

print('No')

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <fstream>
#include <complex>

using namespace std;
typedef long long LL;


int main() {
	string s;
	int a;
	cin >> a;
	cin >> s;
	
	for (int i = 0; i < s.size(); i++) {
		s[i] += a;
		if (s[i] > 'Z') {
			s[i] -= 'Z'-'A'+1;
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int inv[1000005],mod=1e9+7;
int c(int x,int y){
	int t=x+1,sum=t;
	FOR(i,2,y+1){
		t=t*(x+i)%mod*inv[i]%mod;
		sum=(sum+t)%mod;
	}
	RE sum;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	inv[1]=1;
	FOR(i,2,1000001)inv[i]=mod-inv[mod%i]*(mod/i)%mod;
	int c1,c2,r1,r2;
	cin>>r1>>c1>>r2>>c2;
	cout<<(c(c2,r2)-c(c1-1,r2)-c(c2,r1-1)+c(c1-1,r1-1)+2*mod)%mod;
	RE 0;
}



Measured memory_bytes: 8192
<?php
fscanf(STDIN, "%d%d%d", $N, $X, $Y);

if($X > $Y){
    $temp = $X;
    $X = $Y-1;
    $Y = $temp-1;
}else{
    $X--;
    $Y--;
}
for($i=0;$i<$N-1;$i++) {
    $map[$i] = [];
    $k=0;
    for($j=$i;$j>=0;$j--){
        $map[$i][$j] = $k;
        $k++;
    }
    $k=0;
    for($j=$i;$j<$N;$j++){
        $map[$i][$j] = $k;
        $k++;
    }
    if($map[$i][$X] - $map[$i][$Y] > 1){
        $startv = $map[$i][$Y] + 1;
        $startn = $X;
        while($map[$i][$startn] > $startv){
            $map[$i][$startn] = $startv;
            $startv++;
            $startn++;
            if($startn >= $N){
                break;
            }
        }
        $startv = $map[$i][$X] + 1;
        $startn = $X-1;
        while($map[$i][$startn] > $startv){
            $map[$i][$startn] = $startv;
            $startv++;
            $startn--;
            if($startn < 0){
                break;
            }
        }
    }elseif($map[$i][$Y] - $map[$i][$X] > 1){
        $startv = $map[$i][$X] + 1;
        $startn = $Y;

        while($map[$i][$startn] > $startv){
            $map[$i][$startn] = $startv;
            $startv++;
            $startn++;
            if($startn >= $N){
                break;
            }
        }
        $startv = $map[$i][$Y] + 1;
        $startn = $Y-1;
        while($map[$i][$startn] > $startv){
            $map[$i][$startn] = $startv;
            $startv++;
            $startn--;
            if($startn < 0){
                break;
            }
        }
    }
}
$ans = [];
for($i=0;$i<$N-1;$i++){
    for($j=$i+1;$j<$N;$j++){
        $score = $map[$i][$j];
        @$ans[$score]++;
    }
}

for($i=1;$i<$N;$i++){
    if(isset($ans[$i])){
        echo $ans[$i].PHP_EOL;
    }else{
        echo "0".PHP_EOL;
    }
}

Measured memory_bytes: 150008
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b;
    cin>>a>>b;
    cout<<(a*b-a-b+1);
}


Measured memory_bytes: 256
s = list(input())
ss = s[::]

for i in range(len(s)):
	if len(ss) == 1:
		break
		
	ss.pop()
	if len(ss) % 2 == 0:
		n = len(ss) // 2
		if ss[:n] == ss[n:]:
			break

if len(ss) == 1:
	print(-1)
else:
	print(len(ss))
		

Measured memory_bytes: 2940