akhauriyash/Code-Regression huggingface dataset:
/// You just can't beat the person who never gives up
/// ICPC next year


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 2e5+ 10;

#define int long long
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}
int32_t main() {
    fio
    int h;
    cin >> h;
    int cnt = 0;
    while(h!=1){
        h = h / 2;
        cnt++;
    }
    int ans = 0;
    while(cnt > -1) {
        ans += (1ll << cnt);
        cnt--;
    }
    cout << ans << endl;

    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

const int Max = 1e7;
vector<int> mps(Max+1);

void mpsinit(){//O(NloglogN)
    for(int i = 0; i <= Max; i++) mps[i] = i;
    for(ll i = 2; i*i <= Max; i++){
        if(mps[i] == i){
            for(ll j = i*i; j <= Max; j += i){
                if(mps[j] == j) mps[j] = i;
            }
        }
    }
}
template<typename T>
vector<T> prime_factorization(T n){//O(logN)
    vector<T> ret;
    while(mps[n] != n){
        if(ret.size() != 0 && ret.back() == mps[n]){
            n /= mps[n];
        } else {
            ret.push_back(mps[n]);
            n /= mps[n];
        }
    }
    if(ret.size() == 0 || ret.back() != mps[n]) ret.push_back(mps[n]);
    return ret;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    mpsinit();
    vector<int> seen(Max,0);
    bool pc = true;

    for(int i = 0; i < n; i++){
        if(a[i] == 1) continue;
        vector<int> fp = prime_factorization(a[i]);
        for(auto p:fp){
            if(seen[p]) pc = false;
            seen[p] = true;
        }
    }

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

    if(pc) cout << "pairwise coprime" << endl;
    else if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var s = rs();
		Console.WriteLine(s.Substring(0,4)+" "+s.Substring(4));
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr int mod = 1e9 + 7, lim = 1e5;

int t[lim+2], a[lim+2], h[lim+2];

int main(){
  int n; cin >> n;
  for(int i=1; i<=n; i++) cin >> t[i];
  for(int i=1; i<=n; i++) cin >> a[i];

  for(int i=1; i<=n; i++){
    if(t[i] > t[i-1]){
      if(a[i] > a[i+1]){
        h[i] = (t[i] == a[i]);
      }
      else{
        h[i] = (t[i] <= a[i]);
      }
    }
    else{
      if(a[i] > a[i+1]){
        h[i] = (a[i] <= t[i]);
      }
      else{
        h[i] = min(t[i], a[i]);
      }
    }
  }

  ll ans = 1;
  for(int i=1; i<=n; i++){
    ans *= h[i];
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt=0,cnt2=0,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%4==0) cnt++;
        else if(a%2==0) cnt2++;
    }
    n-=cnt2==0?0:cnt2-1;
    if((int)n/2<=cnt) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  vector<vector<int>> coins(X + Y + Z, vector<int> (3));

  long long basic = 0LL;
  for (int i = 0; i < X + Y + Z; ++ i) {
    cin >> coins[i][0] >> coins[i][1] >> coins[i][2];
    coins[i][0] -= coins[i][2];
    coins[i][1] -= coins[i][2];
    basic += coins[i][2];
    coins[i][2] = 0;
  }

  sort(coins.begin(), coins.end(), [] (const vector<int>& a, const vector<int>& b) -> bool {
    return a[0] - a[1] < b[0] - b[1];
  });
                                             
  vector<long long> silver(X + Y + Z, 0);
  vector<long long> gold(X + Y + Z, 0);
  
  priority_queue<int, vector<int>, greater<int>> q;
  long long tmp = 0LL;
  for (int i = 0; i < X + Y + Z; ++ i) {
    int value = coins[i][1];
    if (q.size() == Y) {
      int pre = q.top();
      if (value > pre) {
        tmp -= pre; tmp += value;
        q.pop(); q.push(value);
      }
    } else {
      q.push(value);
      tmp += value;
    }

    if (q.size() == Y)
      silver[i] = tmp;
  }

  while (!q.empty()) q.pop();
  
  tmp = 0LL;
  for (int i = X + Y + Z - 1; i >= 0; -- i) {
    int value = coins[i][0];
    if (q.size() == X) {
      int pre = q.top();
      if (value > pre) {
        tmp -= pre; tmp += value;
        q.pop(); q.push(value);
      }
    } else {
      q.push(value);
      tmp += value;
    }

    if (q.size() == X)
      gold[i] = tmp;
  }
                                             
  long long ans = -1;
  for (int K = Y-1; (X+Y+Z-1) - (K+1) + 1 >= X; ++ K) {
    long long tmp = basic + silver[K] + gold[K+1];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7932
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n = I()
A = [I() for _ in range(n)]
ans = 0
# for i in range(n):
#     cnt += A[i]//2
#     A[i] -= (A[i]//2) * 2
# for i in range(n-1):
#     if A[i] >= 1 and A[i+1] >= 1:
#         cnt += 1
#         A[i] -= 1
#         A[i+1] -= 1
i = 0
SUM = 0
while i < n:
    if A[i] == 0:
        ans += SUM//2
        SUM = 0
    else:
        SUM += A[i]
    i += 1
ans += SUM//2
print(ans)


Measured memory_bytes: 11228
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	unordered_map<string, ll> mp;
	REP(_, n) {
		string s;
		cin >> s;
		SORT(s);
		mp[s]++;
	}

	ll ans = 0;
	REPC(p, mp) {
		auto& x = p.second;
		if (x == 0) { continue; }
		ans += (x - 1) * x / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;


	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif
			 
	     	ll k,a,b;
			cin>>k>>a>>b;

			ll x=b/k;
			x*=k;

			if(k>=a and k<=b)
			{
				cout<<"OK";
				return 0;
			}
			k=x;
			  if(k>=a and k<=b)
			{
				cout<<"OK";
				return 0;
			}
			else
			{
				cout<<"NG";
			}
			

			
			 
			return 0;
		 }	


Measured memory_bytes: 3652
l,r=map(int,input().split())
ll=2019*(l//2019)
rl=2019*(r//2019)
li=l%2019
ri=r%2019
ans=2019
wk=0
if ll==rl:
  for i in range(li, ri+1):
    for j in range(i+1, ri+1):
      wk=(i*j)%2019
      if wk<ans:
        ans=wk
      if ans==0:
        break
else:
  ans=0
print(ans)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl







void relax(int &x, int y) {
    x=min(x,y);
}



const int N = 18;
const int inf = 1e9 + 10;


int n;
int dp[1<<N][N];
int a[N], b[N];


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    for (int i=0; i<n; i++) {
	cin>>b[i];
    }

    for (int mask=0; mask<1<<n; mask++) {
	for (int i=0; i<n; i++) {
	    dp[mask][i]=inf;    
	}
    }
    
    for (int i=0; i<n; i++) {
	dp[1<<i][i]=0;
    }

    for (int mask=1; mask<1<<n; mask++) {
	for (int i=0; i<n; i++) {
	    if (mask>>i&1) {
		int pre = __builtin_popcount(mask);
		// odd distance means card is flipped, even vice versa
		int x = (i%2==(pre-1)%2 ? a[i] : b[i]);

		for (int j=0; j<n; j++) {
		    if (mask>>j&1) continue;
		    int y = (j%2==pre%2 ? a[j] : b[j]);
		    if (y<x) continue;
		
		    // # of inversions with j: # of elems < y that have idx > j.
		    int cost = dp[mask][i] + __builtin_popcount(mask>>j);
		    relax(dp[mask|(1<<j)][j], cost);
		}
	    }
	}
    }

    int res=inf;
    for (int i=0; i<n; i++) {
	relax(res, dp[(1<<n)-1][i]);
    }

    if (res==inf) res=-1;
    cout<<res<<endl;
    
    return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long sum=a[0];
  for(int i=1;i<n;i++){
    sum+=max(0,a[i]-a[i-1]);
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll sum = 0, m = 1e18;
bool flag = false;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    ll A, B; cin >> A >> B;
    if (A != B) flag = true;
    sum += A;
    if (A > B) m = min(m, B);
  }
  if (!flag) cout << 0 << endl;
  else cout << sum - m << endl;

  return 0;
}


Measured memory_bytes: 3632
n, m = [int(x) for x in input().split(' ')]
a = set(int(input()) for x in range(m))

m = [0] * n
m[0] = 1 if 1 not in a else 0

if n == 1:
    print(m[0])
    exit()

m[1] = 2 if 2 not in a else 0

if m[0] == 0 and m[1] == 2:
    m[1] = 1

for i in range(2, n):
    if i+1 not in a:
        m[i] = m[i-1] + m[i-2]

print(m[-1] % 1000000007)


Measured memory_bytes: 460020
#include <stdio.h>

int main(){

  int i,j,x=0,p=0,n,temp;

  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  x = A[n-1];
  
 
  i =p - 1;

   for(j=p;j<n-1;j++){
    if(A[j] <= x){ i = i+1;

      temp=A[i];
    A[i] = A[j];
    A[j] = temp;
    } 
  }

  temp = A[i+1];
  A[i+1] = A[n-1];
  A[n-1] = temp;

  for(j=0;j<n-1;j++){

    if(j==i+1){
      printf("[%d] ",A[j]);
      continue;
    }
      printf("%d ",A[j]);
  }
  printf("%d\n",A[n-1]);
  return 0;
}

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

using namespace std;
using ld = long double;
using ll = long long;

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int a, n;
    cin >> a >> n;
    for (int x = 0; x < n; x++) {
        int t;
        cin >> t;
        a -= t;
    }
    cout << max(-1, a);
}

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

from collections import deque
import heapq
import math
import bisect


def main():
    R, G, B, N = map(int, input().split())

    ans = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            r = N - R * i - G * j
            if 0<=r and r%B==0:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40684
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main( void ) {

    int A, B, count;
    cin >> A >> B;

    count = 0;

    string s;

    for ( int i = A; i <= B; i++ ) {
        s = to_string(i);

        if ( s[0] == s[s.size() - 1] ) {
            if ( s[1] == s[s.size() - 2] ) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

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

int main(){
  int sum=0;
  int wait=0;
  for(int i=0; i<5; i++){
    int tmp;
    cin >> tmp;
    sum+=tmp;
    if(tmp%10!=0){
      sum+=(10-tmp%10);
      if(wait<(10-tmp%10)) wait=10-tmp%10;
    }
  }
  cout << sum-wait << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

# define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;


typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    
    sort(d.begin(), d.end());
    int mid_idx = n / 2;
    int l = d[mid_idx - 1];
    int r = d[mid_idx];
    cout << r - l << endl;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < N; ++i) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// DPは、前探索のようで違うもの。
/*

*/







// atcoder_A-Frog 1 の問題です。
// 足場にたどり着くための
// 最小コスト＝min(cost.at(i-2)+abs(num.at(i)-num.at(i-2)),cost.at(i-1)+abs(num.at(i)-num.at(i-1)))
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<queue>

using namespace std;
using ll=long long;
using db=double;
#define rep(i,n) for(int i=2;i<n;i++)

int main()
{
	int n;
	cin >> n;
	vector<ll> num(n,0);
	for(int i=0;i<n;i++)
	{
	cin >> num.at(i);
	}
	vector<ll> cost(n,0);
	cost.at(1)=abs(num.at(0)-num.at(1));
	for(int i=2;i<n;i++)
	{
	cost.at(i)=min(cost.at(i-2)+abs(num.at(i)-num.at(i-2)),cost.at(i-1)+abs(num.at(i)-num.at(i-1)));
	}
	cout << cost.at(n-1) << endl;
	return(0);
}

Measured memory_bytes: 4752
#include<stdio.h>

const int N = 305;
const int M = 305;
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>c(n-1), s(n-1), f(n-1);
	rep(i, n-1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	rep(i, n-1) {
		int time = s[i] + c[i];
		FOR(j, i+1, n - 1) {
			int a = 0;
		//	cout << "tt" << time << endl;
			if (time <= s[j]) {
			}
			else {
				time -= s[j];
				if (time%f[j] == 0) {
					a = time / f[j];
				}
				else {
					a = time / f[j] + 1;
				}
				a*=f[j];
			}
			time = a + s[j]+c[j];
		//	cout <<"t"<< time << endl;
		}
		cout << time << endl;
	}
	puts("0");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  if(a+b>=10) co("error")
    else co(a+b)
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for(int i = (int)(n-1); i > -1; i--)

ull MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    ull ans = 0;
    vector<ull> numbers(N);
    rep(i,N){
        cin >> numbers[i];
    }

    rep(i,60){
        ll count = 0;
        rep(j,N) if( numbers[j] >> i & 1 ) count++;
        ll plus = count * (N-count) % MOD;
        rep(j,i) plus = plus * 2 % MOD;
        ans += plus;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc153/tasks/abc153_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, N, sum = 0;
    cin >> H >> N;
    REP(i, N) {
        int t;
        cin >> t;
        sum += t;
    }
    if (sum >= H) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] score = new int[10][10];
    int[][] input = new int[h][w];
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<10; i++) {
            for (int j=0; j<10; j++) {
                score[i][j] = sc.nextInt();
            }
        }

        floyd();

        Map<Integer, Integer> map = new HashMap<>();

        long ans = 0;

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                int tmp = sc.nextInt();
//                if (tmp>=0) ans += score[tmp][1];
                if (map.containsKey(tmp)) {
                    int val = map.get(tmp);
                    map.put(tmp, val+1);
                } else {
                    map.put(tmp, 1);
                }
            }
        }

//        System.out.println(map);

        for (Integer k: map.keySet()) {
            if (k==-1) continue;
            int val = map.get(k);
            ans += score[k][1] * val;
        }


//        for (int i=0; i<10; i++) {
//            for (int j=0; j<9; j++) {
//                System.out.print(score[i][j]+" ");
//            }
//            System.out.println(score[i][9]);
//        }

        System.out.println(ans);

    }

    void floyd() {
        for (int k=0; k<10; k++) {
            start:
            for (int i=0; i<10; i++) {
                if (score[i][k]==0) continue start;
                end:
                for (int j=0; j<10; j++) {
                    if (score[k][j]==0) continue end;
                    if (i==8 && k==4 && j==9) {
//                        System.out.println(score[i][j]);
//                        System.out.println(score[i][k]);
//                        System.out.println(score[k][j]);
                    }

                    score[i][j] = Math.min(score[i][j], score[i][k] + score[k][j]);
                }
            }
        }
    }

}


Measured memory_bytes: 46040
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int n = sc.nextInt();

        String result = "No";

        int t = 0;
        for (int i = 0; i < n; i++) {
            t += sc.nextInt();
            if (t >= h) {
                result = "Yes";
                break;
            }
        }


        System.out.println(result);
    }
}

Measured memory_bytes: 47676
a,b,c = map(int,input().split())
k = int(input())
for i in range(k):
    if a < b and b < c:
        print("Yes")
        exit()
    elif a >= b:
        b *= 2
    elif b >= c:
        c *= 2
if a < b and b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
import math
N,D = map(int,input().split(" "))
points = []
for i in range(N):
    points.append(list(map(int,input().split(" "))))
count = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        dist = 0
        for k in range(D):
            dist += (points[i][k] - points[j][k]) ** 2
        dist = math.sqrt(dist)
        if dist.is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int a,b;
    cin >> a>>b;
    cout << max(a+b,max(a-b,a*b)) << endl;
}


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


int main(){
    ll k;
    cin >> k;
    string s="";
    for(ll i=0;i<k;i++){
        s+="ACL";
    }
    cout << s << endl;
    return 0;
}  


Measured memory_bytes: 3560
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var cs []byte
	fmt.Scan(&cs)
	var cnt int
	jp := n - 1
	for i := 0; i < n-1; i++ {
		if cs[i] == 'W' {
			for j := jp; j > i; j-- {
				jp = j - 1
				if cs[j] == 'R' {
					cs[j] = 'W'
					cs[i] = 'R'
					cnt++
					break
				}
			}
		}
		if i >= jp {
			break
		}
	}

	fmt.Println(cnt)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 3408
#!/usr/bin/perl
#= CPAN mocules =====================================================#
require 5.8.8;			# Perl 5.8.8以降
use strict;				# strictモード
use warnings;			# 警告有効
use utf8;				# UTF8モード ON

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $input = <>;
	chomp $input;

	my ($length, $pos_a, $pos_b) = split(/ /, $input);
	my $move;

	# 動かさない判定
	if (
		(($pos_a <= $pos_b) && ($pos_b <= ($pos_a + $length)))
		|| (($pos_a <= ($pos_b + $length)) && (($pos_b + $length) <= ($pos_a + $length)))
	){
		$move = 0;
	}else{
		# 動かす場合
		if ($pos_b > ($pos_a + $length)){
			$move = $pos_b - ($pos_a + $length);
		}else{
			$move = $pos_a - ($pos_b + $length);
		}
	}
	print $move."\n";

	return 0;
}

#----- 実行 -----#
exit( main() );




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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b) cout << c << endl;
  if (b==c) cout << a << endl;
  if (a==c) cout << b << endl;
  return 0;
}


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

set<int> t={1,2,3};
int a,b;

int main(){

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

    cin>>a>>b;
    t.erase(a);
    t.erase(b);
    cout<<*t.begin()<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s; cin>>s;
    int r = 0, w = 0;
    rep(i,n) {
        if (s[i]=='R') r++;
        else w++;
    }

    string t;
    rep(i,r) t.push_back('R');
    rep(i,w) t.push_back('W');

    int ans = 0;
    rep(i,n) if (s[i] != t[i]) ans++;
    cout << ans/2 << '\n';
    return 0;
}

Measured memory_bytes: 3916
import math
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt1 = (A[0] - A[1]) / 2
cnt2= (A[0] - A[2]) / 2
#print(cnt1)
#print(cnt2)
d1 ,i1 = math.modf(cnt1)
d2 ,i2 = math.modf(cnt2)

if d1 + d2 == 1:
    both_increase = 1
elif d1 + d2 == 0.5:
    both_increase = 2
else:
    both_increase = 0
print(int(i1 + i2 + both_increase))


Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long h = scan.nextLong();
        long out = 1;
        while(h > 1){
            h = h / 2;
            out *= 2;
            out++;
        }
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 21972
s = input()
cnt_a = 0
cnt_b = 0

#case1
for i in range(len(s)):
  if i % 2 == 0 and s[i] != '0':
    cnt_a += 1
  if i % 2 == 1 and s[i] != '1':
    cnt_a += 1

#case2
for i in range(len(s)):
  if i % 2 == 0 and s[i] != '1':
    cnt_b += 1
  if i % 2 == 1 and s[i] != '0':
    cnt_b += 1    

print(min(cnt_a, cnt_b))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  ll ans = 0;
  for (int i = N - 1; i >= 0; i--)
  {
    A[i] += ans;
    ll amari = A[i] % B[i];
    if (amari != 0)
      ans += B[i] - amari;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,q,num[1000001],l,r,ac_cnt=0;
  string s;
  cin >> n >> q >> s;
  for(int i=1;i<n;i++){
    if(s[i]=='C'&&s[i-1]=='A'){
      ac_cnt++;
    }
    num[i]=ac_cnt;
  }
  for(int i=0;i<q;i++){
    cin >> r >> l;
    cout << num[l-1]-num[r-1]<<endl;
  }
} 


Measured memory_bytes: 3072
#include<iostream>
#include<cmath>
#include<algorithm>
#include<utility>
using namespace std;

double X[310],Y[310];

bool check(double x1, double y1, double x2, double y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) <= 1.0;
}

int main(){
    int N;
    while(1){
        cin>>N;
        if(!N) return 0;
        for(int i=1;i<=N;++i){
            cin >>X[i]>>Y[i];
        }

        int ans = 1;
        for(int i=1;i<=N;++i){
            for(int j=i+1;j<=N;++j){
                double t = (X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);

                if(t>=4.) continue;

                double s = sqrt(1./t - 1./4.);
                double p = (X[i]+X[j])/2., q = (Y[i]+Y[j])/2.;

                double x = p + (Y[j]-Y[i])*s;
                double y = q - (X[j]-X[i])*s;
                int cnt = 2;
                for(int k=1;k<=N;++k){
                    if(k==i || k==j) continue;
                    if(check(X[k],Y[k],x,y)) ++cnt;
                }
                ans=max(ans,cnt);

                x = p - (Y[j]-Y[i])*s;
                y = q + (X[j]-X[i])*s;
                cnt = 2;
                for(int k=1;k<=N;++k){
                    if(k==i || k==j) continue;
                    if(check(X[k],Y[k],x,y)) ++cnt;
                }
                ans=max(ans,cnt);
            }
        }
        cout<<ans<<endl;
    }

}



Measured memory_bytes: 3076
s=input()
if s=='SUN':
    print(7)
if s=='MON':
    print(6)
if s=='TUE':
    print(5)
if s=='WED':
    print(4)
if s=='THU':
    print(3)
if s=='FRI':
    print(2)
if s=='SAT':
    print(1)

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

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

bool isprime(int n){
	 REPS(i,n){
	 	if(i == 1)continue;
	 	if(n%i == 0)return 0;
	 }
	 return 1;
}

int compo(int n,int p){
	int res = 1;
	int cur = p;
	while(n >= cur){
		res += n/cur;
		res %= MOD;
		cur *= p;
	}
	return res;
}

void solve(){
	 int n;cin >> n;
	 int ans = 1;
	 RE(i,n){
	 	if(i == 1)continue;
	 	if(isprime(i)){ans *= compo(n,i);ans%=MOD;}
	 }
	 cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

class graph
{
public:
	struct edge
	{
		ll to,cost;
		bool operator<(const edge& e) const
    	{
        	return cost > e.cost;
    	}
	};

	vector<vector<edge> > e;  //隣接リスト
	vector<bool> used;
	vector<int> value;
	bool flag = true;

	graph(int n): e(n),used(n),value(n){}

	void dfs(ll r)
	{
		if(used[r]) return;
		used[r] = true;
		for(int i = 0; i < e[r].size(); i++){
			if(e[r][i].cost>=0){
				if(used[e[r][i].to]){
					if(value[e[r][i].to] - value[r] != e[r][i].cost) flag = false;
				}else{
					value[e[r][i].to] = value[r] + e[r][i].cost;
				}
			}else{
				if(used[e[r][i].to]){
					if(value[e[r][i].to] - value[r] != e[r][i].cost) flag = false;
				}else{
					value[e[r][i].to] = value[r] + e[r][i].cost;
				}
			}
			dfs(e[r][i].to);
		}
		return;
	}


	void add_edge(ll from,ll to,ll cost)
	{
		e[from].push_back((edge){to,cost});
		e[to].push_back((edge){from,-cost});  //undirected
	}
};

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> l(m),r(m),d(m);
	graph G(n);
	for(int i = 0; i < m; i++){
		cin >> l[i] >> r[i] >> d[i];
		l[i]--;
		r[i]--;
		G.add_edge(l[i],r[i],d[i]);
	}

	for(int i = 0; i < n; i++){
		if(!G.used[i]){
			G.value[i] = 0;
			G.dfs(i);
		}
	}

	cout << (G.flag?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 17536
n,d=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(n)]
cnt=0
x=0
for i in range(n-1):
  for j in range(i+1,n):
    for k in range(d):
      x+=(lis[i][k]-lis[j][k])**2
    if (x**0.5).is_integer():
      cnt+=1
    x=0
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
int main(void){
  int n,i,a,b,e[100010],k=0,c[100010]={};
  vector<int> g[100010];
  cin >> n;
  for (i=0;i<n-1;i++){
    cin >> a >> b;
    g[a].push_back(i);
    g[b].push_back(i);
    e[i]=a+b;
  }
  for (i=1;i<=n;i++) if (k<g[i].size()) k=g[i].size();
  cout << k << endl;
  
  int p;
  bool u[100010]={false};
  queue<int> que;
  que.push(1);
  while (!que.empty()){
    p=que.front();
    que.pop();
    u[p]=true;
    int t=1;
    bool h[100010]={false};
    for (i=0;i<g[p].size();i++) if (c[g[p][i]]!=0){
      h[c[g[p][i]]]=true;
      break;
    }
    for (i=0;i<g[p].size();i++){
      if (c[g[p][i]]!=0) continue;
      while (h[t]) t++;
      c[g[p][i]]=t++;
    }
    for (i=0;i<g[p].size();i++) if (!u[e[g[p][i]]-p]) que.push(e[g[p][i]]-p);
  }
  for (i=0;i<n-1;i++) cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;


ll solve() {
    int N;
    cin >> N;
    
    ll sum = 0;
    vector<int> a;
    REP(i, N) {
        int A;
        cin >> A;
        sum += (A-(i+1));
        a.push_back(A-(i+1));
    }
    const int W = 5;
    ll s[W] = {};
    sort(a.begin(), a.end());
    REP(i, N) {
        REP(j, W) {
            if (N/2+j-W/2 >=0 && N/2+j-W/2 < N)
                s[j] += abs(a[i]-(a[N/2+j-W/2]));
        }
    }
    ll ans = LLONG_MAX;
    REP(j, W) {
        if (N/2+j-W/2 >=0 && N/2+j-W/2 < N)
            ans = min(s[j], ans);
    }
    return ans;
}

int main() {
    cout << solve() << endl;
}


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

int main() {
    int a,b,c;
    cin>>a>>b>>c;

    bool flg =true;

    for (int i=1;i<=b;i++) {
        if((i*a)%b==c){
            cout<<"YES"<<endl;
            flg=false;
            break;
        }
    }

    if(flg){
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int n = s.length();
  rep(i,n-1) {
    if (s[i] == s[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  rep(i,n-2) {
    if (s[i] == s[i+2]) {
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

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

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

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

    int n;
    cin >> n;
    double p[n];
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
    }
    double dp[n + 1][n + 1] = {};
    dp[0][0] = 1;

    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j <= n; ++j) {
        dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
        if (j > 0)
          dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
      }
    }

    double ans = 0;
    for (int j = n; j * 2 > n; --j) {
      ans += dp[n][j];
    }
    cout << setprecision(10) << fixed<< ans << endl;

    return 0;
}


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

using namespace std;


int main() {
    int n, x;
    cin >> n >> x;
    int mi = 1145141919;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        x -= m;
        mi = min(mi, m);
    }
    cout << n + x / mi << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	ans := make([]int, n)
	var j, k int
	if len(a)%2 == 0 {
		j, k = n/2, n/2-1
		for i := 0; i < n; i++ {
			if i%2 == 0 {
				ans[j] = a[i]
				j++
			} else {
				ans[k] = a[i]
				k--
			}
		}
	} else {
		ans[n/2] = a[0]
		j, k = n/2+1, n/2-1
		for i := 1; i < n; i++ {
			if i%2 == 0 {
				ans[k] = a[i]
				k--
			} else {
				ans[j] = a[i]
				j++
			}
		}
	}
	for i := 0; i < len(ans); i++ {
		fmt.Print(ans[i], " ")
	}
	fmt.Println()
}


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

void maxor(int x, int y)
{
	if (x == y) cout << "a == b\n";
	if (x > y) cout << "a > b\n";
	if (x < y) cout << "a < b\n";
}

int main()
{
	int x = 0, y = 0;
	cin >> x >> y;
	maxor(x, y);
	return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    string str;
    cin >> n >> str >> k;
    char ch = str[k-1];
    for (int i = 0; (i < n); ++i) {
        if (str[i] != ch)
            str[i] = '*';
    }
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int a, n;

	static int getNumber(String a, char ch) {
		int index = a.indexOf(ch);
		int x = 0;
		if (index != -1) {
			x = 1;
			if (index != 0 && a.charAt(index - 1) >= '2'
					&& a.charAt(index - 1) <= '9') {
				x = a.charAt(index - 1) - '0';
			}
		}
		return x;
	}

	static String calc(String a, String b) {
		StringBuilder result = new StringBuilder();
		char[] charindex = { 'i', 'x', 'c', 'm' };

		int remain = 0;
		for (char c : charindex) {
			int anum = getNumber(a, c);
			int bnum = getNumber(b, c);
			int x = anum + bnum + remain;
			int reminder = x % 10;
			if (reminder != 0) {
				result.insert(0, c);
				if (reminder != 1) {
					result.insert(0, reminder);
				}
			}
			remain = x / 10;
		}

		return result.toString();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String a = sc.next();
			String b = sc.next();
			System.out.println(calc(a, b));
		}
	}
}

Measured memory_bytes: 38300
#include <stdio.h>
#define minz(p,q)((p)&&(p<q)?(p):(q))

int dp[50010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	while(m--){
		int t;
		scanf("%d",&t);
		for(int i=0;i+t<=n;i++)dp[i+t]=minz(dp[i+t],dp[i]+1);
	}
	printf("%d\n",dp[n]);
}


Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<ll> sum(N+1);
	rep(i,N) sum[i+1] = sum[i] + A[i];
	sort(sum.begin(),sum.end());
	ll ans = 0;
	ll now = 0;
	rep(i,N){
		if(sum[i] == sum[i+1]) now++;
		else{
			now++;
			ans += now*(now-1)/2;
			now = 0;
		}
	}
	now++;
	ans += now*(now-1)/2;
	cout << ans << endl;

}



Measured memory_bytes: 2688
while True:
    lst = list(map(int,input().split()))
    m, f, r = lst[0], lst[1], lst[2]
    if m == -1 and f == -1 and r == -1:
        break

    k = m + f

    if m == -1 or f == -1 or k < 30:
        print("F") 

    elif k >= 80:
        print("A")

    elif k >= 65:
        print("B")
    
    elif k >= 50 or r >= 50:
        print("C")
    
    else:
        print("D")



Measured memory_bytes: 5600