akhauriyash/Code-Regression huggingface dataset:
//---Vaidik Patel"---//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#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(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}
void solve()
{
    int n;
    cin>>n;
    vi a(n);
    FOR(i,0,n)
    {
        cin>>a[i];
    }

    int c=0;
    FOR(i,0,n)
    {
        if(i%2==0 && a[i]&1)
        {
            c++;
        }
    }
    cout<<c<<"\n";

}
signed main()
{
    #ifndef ONLINE_JUDGE
    
    #endif
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    int N,M,res,C,b,a,sum;
    vector<int> B,bv;

    cin >> N >> M >> C;
    
    REPI (M)
    {
        cin >> b;
        B.push_back(b);
    }
    
    res = 0;
    
    REPI (N)
    {
        sum = 0;
        REPJ (M)
        {
            cin >> a;
            sum += a * B[j];
        }
        if (sum + C > 0)
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<int> vec(N);
    for(int i=0; i<N; i++){
        vec.at(i) = i + 1;
    }

    long long int sum = 0;

    for(int i=0; i<N; i++){
        if(vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0){
            vec.at(i) = 0;
        }
        sum += vec.at(i);
    }

    cout << sum << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

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

  ull sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
    } else {
      sum += i;
    }
  }
  cout << sum;
}

Measured memory_bytes: 3624
n,k = map(int,input().split())
l = list(map(int,input().split()))
dp = [float("inf")]*(n+1)
for i in range(n):
  if i ==0:
    dp[0]=0
  for j in range(1,k+1):
    if i-j>=0:
    	dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
print(dp[n-1])


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

int main() {
    int A[5], ans = 1e9;
    rep(i, 5) cin >> A[i];
    do {
        int sum = 0;
        rep(i, 5) {
            while (sum % 10 != 0) sum++;
            sum += A[i];
        }
        ans = min(ans, sum);
    } while (next_permutation(A, A + 5));
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;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;
}
//******head by yjjr******
const ll mod=1e9+7;
int n,num[36];
ll ans=1;
int main(){
    n=read();
    rep(i,1,n){
        char ch=getchar();
        num[ch-'a']++;
    }
    rep(i,0,25)ans=(ans*(num[i]+1))%mod;
    ans-=1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#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];
  vector<int> C(N);
  for(int i = 0;i < N;i++)cin >> C[i];

  int value_sum = 0;
  int cost_sum = 0;

  for(int i = 0;i < N;i++){
    if(V[i] >= C[i] + 1){
      value_sum += V[i];
      cost_sum += C[i];
    }
  }

  cout << value_sum - cost_sum << endl;
}


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

using namespace std;

#define int long long
#define  B  (unsigned int)(1e9+7)

signed main(){
	unsigned int ans = 0;
	vector<unsigned int> hoge(30);
	string s, t;
	vector<unsigned int> ss, ss2;
	
	
	hoge[0] = B;
	for(unsigned int i = 1; i < hoge.size(); i++){
		hoge[i] = hoge[i-1] * B;
	}
	
	cin>>s>>t;
	
	ss.reserve(s.size() * s.size());
	ss2.reserve(s.size() * s.size());
	
	for(unsigned int i = 0; i < s.size(); i++){
		unsigned int con = 0;
		
		for(unsigned int j = i; j < s.size(); j++){
			con += (unsigned int)s[j] * hoge[s[j] - 'a'];
			ss.push_back(con);
		}
	}
	
	sort(ss.begin(), ss.end());
	
	for(unsigned int i = 0; i < t.size(); i++){
		unsigned int con = 0;
		
		for(unsigned int j = i; j < t.size(); j++){
			con += (unsigned int)t[j] * hoge[t[j] - 'a'];
			if(binary_search(ss.begin(), ss.end(), con) ) {
				ans = max(ans, j - i + 1);
			}
		}
	}
	
	cout<<ans<<endl;
}

//3997


Measured memory_bytes: 65552
#include <iostream>
#include <map>

int main(void){
    std::map<char, int> mp;
    mp['N'] = 0;
    mp['S'] = 0;
    mp['E'] = 0;
    mp['W'] = 0;
    std::string S, ans="No";
    std::cin >> S;

    for (char c: S){
        ++mp[c];
    }

    if ((mp['N'] == 0 && mp['S'] == 0) || (mp['N'] > 0 && mp['S'] > 0)){
        if((mp['E'] == 0 && mp['W'] == 0) || (mp['E'] > 0 && mp['W'] > 0)){
            ans = "Yes";
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main(){
  int n,m;cin >> n >> m;
  vector<pair<int,int>> p_y_s;
  vector<pair<int,int>> p_y;
  int y,p;
  for(int i=0; i<m; i++){
    cin >> p >> y;
    p_y_s.push_back(make_pair(p,y));
    p_y.push_back(make_pair(p,y));
  }
  sort(p_y_s.begin(),p_y_s.end());
  map<pair<int,int>,int> mp_py_id;
  
  int count=0;
  int pre_p=0;
  int np,ny;
  for(int i=0; i<m; i++){
    np = p_y_s.at(i).first;ny = p_y_s.at(i).second;
    if(np!=pre_p)count = 1;
    else count++;
    mp_py_id[make_pair(np,ny)] = count;
    pre_p = np;
  }
  
  for(int i=0; i<m; i++){
    cout << setfill('0') << right << setw(6) << p_y.at(i).first;
    cout << setfill('0') << right << setw(6) << mp_py_id[p_y.at(i)] << endl;
  }
}

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


int main() {

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long res1 = x*a + y*b;

    int x1 = x, y1 = y;
    int cKinteHobe = y*2;
    long long res2 = cKinteHobe*c;
    int aHoyeGese = y;
    x1 -= aHoyeGese;
    if(x1>0) res2 += x1*a;


    int x2 = x, y2 = y;
    cKinteHobe = x*2;
    long long res3 = cKinteHobe*c;
    int bHoyeGese = x;
    y1 -= bHoyeGese;
    if(y1>0) res3 += y1*b;

    cout << min(res1, min(res2, res3));




}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int a,b,c,d,s[1005]={0},ans=0;
cin>>a>>b>>c>>d;
rep(i,a,b-1)s[i]++;
rep(i,c,d-1)s[i]++;
rep(i,0,1004)if(s[i]==2)ans++;
ol(ans);
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n;cin >> n;
    int arr[n + 5];
    for(int i = 0;i < n;i++)cin >> arr[i];
    sort(arr, arr + n);
    double sum = arr[0];
    for(int i = 1;i < n;i++){
        sum = (sum + arr[i]) / 2.0;
    }
    cout << sum;
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val (x, a) = readLine()!!.split(" ").map(String::toInt)
	val X : Int = x.toInt()
	val A : Int = a.toInt()
	return if (X < A) {
		println("0")
	} else {
		println("10")
	}
}

Measured memory_bytes: 36028
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

l=[]
l.append([a,a%10])
l.append([b,b%10])
l.append([c,c%10])
l.append([d,d%10])
l.append([e,e%10])
for i in range(5):
  if l[i][1] == 0:
    l[i].append(l[i][0])
  else:
    l[i].append(l[i][0] + (10 - l[i][1]))
    
l.sort(key=lambda x:x[2] - x[0])
s = 0
for i in range(5):
  if i == 4 or l[i][1] == 0: s += l[i][0]
  else: s += l[i][0]+(10 - l[i][0]%10)
print(s)
  

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, x;
    cin >> x >> a;
    if(x<a) {
        cout << 0;
    }
    else{
        cout << 10;
    }
}


Measured memory_bytes: 256
from math import sqrt
N = int(input())
cond = []
for i in range(1, int(sqrt(N))+1):
    if N % i == 0:
        cond.append((i, N//i))

# print(cond)
ans = 11
for c in cond:
    a, b = map(str, c)
    f = max(len(a), len(b))
    ans = min(ans, f)
    
print(ans)

Measured memory_bytes: 3188
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var vec_A = input[1].map(e => parseInt(e, 10));
	var vec_B = input[2].map(e => parseInt(e, 10));
	var vec_C = input[3].map(e => parseInt(e, 10));
	function compareFunc(a, b) {
		return b - a;
	}
	vec_A.sort(compareFunc);
	vec_B.sort(compareFunc);
	vec_C.sort(compareFunc);

	var s = 0;
	var t = -1;
	var vec_sumB = Array.from({length: N}, () => 0);
	var tmpAdj = 0;  
	var ans = 0;
	for (var i = 0; i < N; i++){
		while (s < N && vec_B[s] > vec_A[i]){
			while (t < (N - 1) && vec_C[t + 1] > vec_B[s]){
				t ++;
			}
			if (s > 0) tmpAdj = vec_sumB[s - 1];
			else tmpAdj = 0;
			vec_sumB[s] = tmpAdj + t + 1;
			s ++;        
		}
		s = Math.max(0, s - 1);
		ans += vec_sumB[s];
	}	
	console.log(ans);
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 61572
#include<stdio.h>
#include<math.h>
int main(){
	const double PI=atan(1.0)*4;
	double a,b,c,S,L,h;
	scanf("%lf %lf %lf",&a,&b,&c);
	S=0.5*a*b*sin(c*PI/180.0);
	L=sqrt(a*a+b*b-2*a*b*cos(c*PI/180.0))+a+b;
	h=2*S/a;
	printf("%lf %lf %lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k=1,ans;
signed main(){
	cin>>n;
	cout<<n+n*n+n*n*n<<endl;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, m;
    cin >> n >> m;

    int d = n-1;
    set<int> s;
    for (int i = 1; i <= m; i++) {
        while (s.count(d) || s.count(n - d) || d == n-d) --d;
        cout << i << ' ' << (i-1 + d) % n + 1 << endl;
        s.emplace(d); s.emplace(n - d);
        d -= 2;
    }

    return 0;
%>

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

class BitComb {
 private:
  ll _digits;
  ll _base;
  ll _data[512];
  ll _finished;
  ll _i;

 public:
  BitComb(ll digits, ll base) {
    _digits = digits;
    _base = base;
    _finished = false;
    _i = 0;
    fill_n(_data, 512, 0);
  }

  void next() {
    if (_finished) {
      return;
    }
    for (ll i = 0; i < _digits; i++) {
      if (_data[i] + 1 < _base) {
        _data[i] += 1;
        break;
      } else {
        _data[i] = 0;

        if (i == _digits - 1) {
          _finished = true;
          break;
        }
      }
    }
  }

  ll* data() { return _data; }

  void print() {
    for (ll i = _digits - 1; i >= 0; i--) {
      cout << _data[i];
    }
    cout << endl;
  }

  bool finished() { return _finished; }
};

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W, K;
  scanf("%lld %lld %lld", &H, &W, &K);

  ll all_black_count = 0;

  vector<string> lines;
  for (ll y = 0; y < H; y++) {
    string line;
    cin >> line;
    lines.emplace_back(line);

    for (ll i = 0; i < W; i++) {
      if (line[i] == '#') {
        all_black_count++;
      }
    }
  }

  ll ans = 0;

  auto bc_h = BitComb(H, 2);

  while (!bc_h.finished()) {
    auto bc_w = BitComb(W, 2);
    while (!bc_w.finished()) {
      // bc_w.print();
      // bc_h.print();
      ll black_count = 0;

      for (ll y = 0; y < H; y++) {
        for (ll x = 0; x < W; x++) {
          if (lines[y][x] == '#') {
            if (bc_h.data()[y] || bc_w.data()[x]) {
              black_count++;
            }
          }
        }
      }

      if (all_black_count - black_count == K) {
        ans++;
      }

      bc_w.next();
    }
    bc_h.next();
  }

  cout << ans << endl;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    if(a[i]!=b[n-1]){
      cout<<b[n-1]<<endl;
    }else{
      cout<<b[n-2]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3200
import itertools
import math

n = int(input())
xy = []
z = [k for k in range(n)]
for i in range(n):
    x,y = map(int,input().split())
    xy.append(x)
    xy.append(y)

sum = 0
for j in itertools.permutations(z,n):
    j = list(j)
    for l in range(n-1):
        sum += ((xy[2*(j[l])]-xy[2*(j[l+1])])**2+(xy[2*(j[l])+1]-xy[2*(j[l+1])+1])**2)**0.5

print(sum/math.factorial(n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int inf=0x3f3f3f3f;
const int N=1e5+10;
int n;
int a[N],f[N];
int main( ){
	int x,y,z,k;
	int ans=0;
	n=read( );
	for(register int i=1;i<=n;++i)a[i]=read( );
	for(register int i=n-1;i>=1;--i){
		if(a[i]>=a[i+1])f[i]=f[i+1]+1;
		else f[i]=0;
		ans=max(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <unordered_map>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    int n;
    std::cin >>n;

    std::vector<int> d;

    std::unordered_map<int,bool> already;

    for(int i = 0;i<n;i++)
    {
        int buf;
        std::cin >> buf;
        d.push_back(buf);
    }

    std::sort(d.begin(),d.end());

    int cnt = 0;

    for(const auto dl : d)
    {
        if(already.count(dl) == 0)
        {
            cnt++;
        }

        already[dl] = true;
    }

    std::cout<<cnt<<std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int set_number(int);

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", set_number(n));
	}
	return 0;
}

int set_number(int x){
	int i, j, k, l, count=0;
	for(i=0; i<10; ++i){
		for(j=0; j<10; ++j){
			for(k=0; k<10; ++k){
				for(l=0; l<10; ++l){
					if(i+j+k+l == x){
						count++;
					}  				
				}
			}
		}
	}
	return count;
}

Measured memory_bytes: 596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int N;
    cin>>N;
    ll DP[N][N];
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            cin>>DP[i][j];
        }
    }
    bool ans = true;
    map<pair<int, int>, int> amap;
    for(int k=0;k<N;++k){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                if(DP[i][j] != min(DP[i][j], DP[i][k] + DP[k][j])) ans = false;;
                if((i<j) & (DP[i][j] == DP[i][k] + DP[k][j]) & (k!=i) & (k!=j)) {
                    amap[make_pair(i, j)]++;
                }
            }
        }
    }
    ll length = 0;
    if(ans){
        for(int i=0;i<N;++i){
            for(int j=i+1;j<N;++j){
                if(amap[make_pair(i, j)]>0) continue;
                length += DP[i][j];
            }
        }
        cout<<length<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 2e3+9;
int n, x, y;
int ans[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    


    cin >> n >> x >> y;
    for(int i = 1; i < n; i++) {
        for(int j = i+1; j <= n; j++) {
            int d = min(abs(x - i)+1+abs(j - y), abs(i - j));
            // cout << i << " " << j << " " << d << endl;
            if(d < n) ans[d]++;
        }
    }

    for(int i = 1; i < n; i++) {
        cout << ans[i] << "\n";
    }





    return 0;
    
}

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

using namespace std;

int isprime(int n)
{
    int i=3;
    while(i*i<=n){
        if(n%i==0) return false;
        i+=2;
    }
    return true;
}
int ans(int n)
{
    int i=1;
    int a=2;
    int k=3;
    while(i < n)
    {
        if(isprime(k))
        {
            a += k;
            ++i;
        }
        k+=2;
    }
    return a;
}
int main()
{
    int n;
    while(cin >> n && n) cout << ans(n) << endl;
}

Measured memory_bytes: 1160
use std::io::{self, Read};
use std::str::FromStr;
use std::ops::{
    Add,
    Sub,
    Mul,
};

fn read<T: FromStr>() -> T {
    let stdin = io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Debug,PartialEq,Eq,Clone,Copy)]
struct ModInt {
    value: i64
}

fn modu() -> i64 {1000000007}

impl ModInt {
    pub fn value(self) -> i64 {self.value}
}

impl From<i64> for ModInt {
    fn from (value: i64) -> Self {
        ModInt {
            value: value % modu()
        }
    }
}

impl Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: Self) -> Self {
        ModInt {
            value: (self.value + rhs.value) % modu()
        }
    }
}

impl Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: Self) -> Self {
        let value = if self.value >= rhs.value {
            self.value - rhs.value
        } else {
            modu() - self.value + rhs.value
        };
        ModInt {
            value: value
        }
    }
}

impl Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: Self) -> Self {
        ModInt {
            value: (self.value * rhs.value) % modu()
        }
    }
}

fn build_combo(n: usize) -> Vec<Vec<ModInt>> {
    let mut v: Vec<Vec<ModInt>> = Vec::new();
    v.push(Vec::new());  // C(0, 0)
    v[0].push(ModInt::from(1));
    for i in 1..n+1 {
        let mut w: Vec<ModInt> = Vec::new();
        w.push(ModInt::from(1));
        {
            let last = v.last().unwrap();
            for j in 0..i-1 {
                w.push(last[j] + last[j + 1]);
            }
            w.push(ModInt::from(1));
        }
        v.push(w);
    }
    return v;
}

fn main() {
    let n: i64 = read();
    let k: i64 = read();
    let combo = build_combo((n + 5) as usize);
    let combow = |p: i64, r:i64| {
        if r < 0 || r > p {
            ModInt::from(0)
        } else {
            combo[p as usize][r as usize]
        }
    };
    for i in 1..k+1 {
        println!("{}", (combow(k - 1, i - 1) * combow(n - k + 1, i)).value());
    }
}

Measured memory_bytes: 28924
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 
 
signed main() {
	fio();
	int n, m;
	cin >> n >> m;
	vi t(m), q(m);
	rep (i, m) {
 
		cin >> t[i] >> q[i];
	}
	rep (i, 1000) {
		string s = to_string(i);
		if (s.size() != n) continue;
		bool flag = true;
		rep (i, m) {
			if (s[t[i] - 1] != q[i] + '0') {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

typedef map<int, int> mii;
typedef long long ll;

#define CR const &

mii gen(int x){
    map<int, int> res;
    for (int i = 2; i <= x; i++){
        if (x%i == 0){
            int c = 0;
            while (x%i == 0)x /= i, c++;
            res[i] = c;
        }
    }
    return res;
}

ll rev(mii CR x){
    ll res = 1;
    for (auto & p : x){
        ll a, b;
        tie(a, b) = p;
        assert(b >= 0);
        for (int i = 0; i < b; ++i) {
            res *= a;
        }
    }
    return res;
}

mii mul(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] += p.second;
    }
    return a;
}

mii div(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] -= p.second;
    }
    return a;
}

mii gcd(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] = min(a[p.first], p.second);
    }
    return a;
}

mii lcm(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] = max(a[p.first], p.second);
    }
    return a;
}

int main(int argc, char ** argv) {
    int n;
    while (cin >> n && n){
        mii d[20], v[20];
        mii l1;
        for (int i = 0; i < n; ++i) {
            ll dd, vv;
            cin >> dd >> vv;
            d[i] = gen(dd);
            v[i] = gen(vv);
            l1 = lcm(l1, v[i]);
        }
        mii l2;
        for (int i = 0; i < n; ++i) {
            l2 = lcm(l2, div(mul(d[i],l1) , v[i]));
        }
        for (int i = 0; i < n; ++i) {
            mii ans = div(mul(v[i], l2), mul(d[i], l1));
            cout << rev(ans) << endl;
        }
    }
}

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

int arra[1000000 + 1];

int main()
{
    int n, ans = 0;
    cin >> n;
    map<int, int>m;
    map<int, int>::iterator it;
    int input[n+2];
    fr(i, n){
        cin >> input[i];
        m[ input[i] ]++;
    }
    for(it=m.begin(); it!=m.end(); it++){
        int vr = (*it).first;
        int len = (*it).second;
        for(int i=vr; i<=1000000; i+=vr)arra[i] += len;
    }
    for(int i=1; i<=n; i++){
        if(arra[input[i]]==1)ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 17688
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <iomanip>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;

int main(void) {
	int A, B,ans=0,cou=1;
	cin >> A >> B;
	for (int i = 0;; i++) {
		
		if (cou >= B) {
			ans = i;
			break;
		}
		cou += A - 1;
	}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;

	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    set<string> substs;
    for(int i=0;i<s.size();i++){
        vector<string> temp;
        string a ="";
        for(int j=i;j<s.size();j++){
            if(j-i==K){
                break;
            }
            a += s[j];
            substs.insert(a);
        }
    }
       
    vector<string> ans;
    for(auto itr =substs.begin();itr != substs.end();++itr){
        ans.push_back(*itr);
    }
    sort(ans.begin(),ans.end());
    cout << ans[K-1] << endl;

    return 0;
}

Measured memory_bytes: 1920
def main():
    s = input()
    group = []
    last = 0
    for i in range(len(s) - 1):
        if s[i:i + 2] == "LR":
            group.append(s[last:i + 1])
            last = i + 1
    group.append(s[last:])
    answer = [0 for _ in range(len(s))]
    accumulate_index = 0
    for g in group:
        gather = g.index("RL")
        length = len(g)
        if gather % 2:
            answer[accumulate_index + gather] = length // 2
            answer[accumulate_index + gather + 1] = length - answer[accumulate_index + gather]
        else:
            answer[accumulate_index + gather + 1] = length // 2
            answer[accumulate_index + gather] = length - answer[accumulate_index + gather + 1]
        accumulate_index += length
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 13732
/*
	Author: zxy_hhhh
	date: 2019/12/10
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
	ll _x=0;int _ch=getchar(),_f=1;
	for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
	if (_ch=='-'){_f=0;_ch=getchar();}
	for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
	return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 2005
#define mod 1000000007
int n,m,k;
int dp[maxn<<1][maxn<<1];

int main() {
	n=rd(),m=rd(),k=rd();
	int res=0;dp[0][0]=1;
	for(int i=0;i<=n;i++) {
		for(int j=0;j<=m;j++) if (dp[i][j]){
			for(int c=0;c<=k-1;c++) {
				(dp[i+c][j+(k-1-c)]+=dp[i][j])%=mod;
			}
			int nxw=(n-i)%(k-1)==0?k-1:(n-i)%(k-1);
			if (i+nxw<=n&&j+(k-nxw)<=m) {
				(res+=dp[i][j])%=mod;
			}
		}
	}
	wrt(res,'\n');
}

Measured memory_bytes: 61312
#include <stdio.h>

int main(){
    int n;
    int b,f,r,v;
    int house[4][3][10];
    int i,j,k;
    scanf("%d",&n);
    for(i=0;i<4;i++)for(j=0;j<3;j++)for(k=0;k<10;k++)house[i][j][k] = 0;
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        house[b-1][f-1][r-1] += v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++)printf(" %d",house[i][j][k]);
            printf("\n");
        }
        if(i-3)printf("####################\n");
    }
}

Measured memory_bytes: 1040
#include    <iostream>

using namespace std;

int main() {
    // stock[b][r][f]で、b棟r階のf番目の部屋を表す
    int stock[4][3][10] = {{{0}}};
    int n;

    cin >> n;
    for(int i = 0; i < n; i++) {
        int _b, _r, _f, _v;
        cin >> _b >> _r >> _f >> _v;

        stock[_b-1][_r-1][_f-1] += _v;
    }

    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 3; j++) { 
            for(int k = 0; k < 10; k++)
                cout << ' ' << stock[i][j][k];
            cout << endl;
        }
        cout << ((i != 3) ? "####################\n" : "");
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++)  cin >> h.at(i);

  vector<int> dp(N,1e9);
  dp.at(0)=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i-j<0) break;
      dp.at(i)=min(dp.at(i),dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
    }
  }
  cout << dp.at(N-1) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int n, m,sum=0;
	cin >> n >> m;
	int* a = new int[m];
	for (int i = 0;i < m;i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (sum > n) cout << -1 << "\n";
	else cout << n - sum << "\n";
}

Measured memory_bytes: 3196
import Data.Char

row [] = []
row (_:[]) = []
row (a:b:xs) =
  let
    n = (a + b) `mod` 10
  in
    n:(row (b:xs))

ans (x:[]) = x
ans x = ans $ row x

main = do
  c <- getContents
  let i = map (map digitToInt) $ lines c :: [[Int]]
      o = map ans i
  mapM_ print o
  

Measured memory_bytes: 3608
from collections import deque


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [set() for _ in range(N)]
    COST = {}
    for a, b, c in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
        COST[(a - 1, b - 1)] = c
        COST[(b - 1, a - 1)] = c
    return NEAR, COST


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    DIST = [-1 for _ in range(N)]  # 前処理
    DIST[S] = 0
    que, frag = deque([S]), set([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            DIST[i] = DIST[q] + cost[(q, i)]
            que.append(i), frag.add(i)
    return DIST


n = int(input())
abc = [list(map(int, input().split())) for _ in range(n - 1)]
q, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(q)]

near, cost = nearlist(n, abc)
dist = bfs(near, k - 1, n)
for x, y in xy:
    print(dist[x - 1] + dist[y - 1])


Measured memory_bytes: 178000
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979323846;

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

    int hJ = (a / c);
    hJ += ((a % c) != 0) ? 1 : 0;
    int hM = (b / d);
    hM += ((b % d) != 0) ? 1 : 0;
    int hr = (hJ < hM) ? hM : hJ;

    cout << l - hr << endl;

    return 0;
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int a,b;
    cin >> a >> b;
    cout << max(a-b*2,0);
}

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

int main(){
    int r;
    cin >> r;
    cout << 2*r*3.14 << endl;
}

Measured memory_bytes: 3788
#include <iostream>
using namespace std;
int main(void){
    string s,t,u;
    cin>>s>>t>>u;
    char dif='A'-'a';
    s[0]+=dif,t[0]+=dif,u[0]+=dif;
    cout<<s[0]<<t[0]<<u[0]<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[101][101];

void chain(int n,int *b){
  int i,j,k,l;

  for(i=1;i<n+1;i++) a[i][i]=0;

  for(l=2;l<n+1;l++){
    for(i=1;i<n-l+2;i++){
      j=i+l-1;
      a[i][j]=100000000;
      for(k=i;k<j;k++){
	if(a[i][j]>a[i][k]+a[k+1][j]+b[i-1]*b[k]*b[j]){
	  a[i][j]=a[i][k]+a[k+1][j]+b[i-1]*b[k]*b[j];
	}
      }
    }
  }
}

int main(){
  int i,b[101],n;
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d%d",&b[i-1],&b[i]);
  }
  chain(n,b);
  printf("%d\n",a[1][n]);

  return 0;
}

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

int main() {
	
	int x, a;
	cin >> x >> a;
	if(x<a) puts("0");
	else puts("10");
	
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	int n, mask;
	int[] time;
	int[][] item;
	int[] dp;

	int dp(int bit) {
		if (bit == mask) {
			return 0;
		}
		if (0 <= dp[bit]) {
			return dp[bit];
		}
		int[] opt = new int[n];
		for (int i = 0; i < n; i++) {
			opt[i] = time[i];
		}
		for (int i = 0; i < n; i++) {
			if ((bit & (1 << i)) == 0) continue;
			for (int j = 0; j < n; j++) {
				opt[j] = Math.min(opt[j], item[i][j]);
			}
		}

		int res = 1 << 20;
		for (int i = 0; i < n; i++) {
			if (0 < (bit & (1 << i))) continue;
			res = Math.min(res, dp(bit | (1 << i)) + opt[i]);
		}

		return dp[bit] = res;
	}

	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			time = new int[n];
			item = new int[n][n];
			dp = new int[1 << n];
			Arrays.fill(dp, -1);
			mask = (1 << n) - 1;
			for (int i = 0; i < n; i++) {
				time[i] = sc.nextInt();
				for (int j = 0; j < n; j++) {
					item[j][i] = sc.nextInt();
				}
			}

			System.out.println(dp(0));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 82804
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 100;

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int a, b; cin >> a >> b;
    a--, b--;
    vector<vector<char>> p(N);
    for (int i = 0; i < N / 2; i++) {
    	p[i].assign(N, '#');
    }
    for (int i = N / 2; i < N; i++) {
    	p[i].assign(N, '.');
    }
    vector<pair<int, int>> g1, g2;
    for (int i = 0; i < N; i += 2) {
    	for (int j = 0; j < N; j += 2) {
    		if (a > 0) {
    			a--;
    			p[i][j] = '.';
    		}
    	}
    }
    for (int i = N - 1; i >= 0; i -= 2) {
    	for (int j = 0; j < N; j += 2) {
    		if (b > 0) {
    			b--;
    			p[i][j] = '#';
    		}
    	}
    }
    cout << N << " " << N << endl;
    for (int i = 0; i < N; i++) {
    	for (int j = 0; j < N; j++) {
    		printf("%c", p[i][j]);
    	}
    	puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int

int main(){
    ll n;
    cin>>n;
    ll heights[n];
    for(ll i=0;i<n;i++){
        cin>>heights[i];
    }

    ll answer_array[n] = {0};
    answer_array[0] = 0;
    answer_array[1] = abs(heights[1] - heights[0]);
    for(ll i=2;i<n;i++){
        answer_array[i] = min(answer_array[i-1] + abs(heights[i] - heights[i-1]),answer_array[i-2] +abs(heights[i] - heights[i-2]));
    }
    cout<<answer_array[n-1]<<endl;
}

Measured memory_bytes: 5132
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    string T;cin>>T;
    for(int i=0;i<T.size();i++){
        if(T[i]=='?') T[i] = 'D';
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3756
/***** TheAnshul *****/

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  100500
ll dp[N];
ll a[N];
ll n,k;
ll fun(ll i)
{
	if(i==n)
		return 0;
	else if(i>n)
		return hell;
	if(dp[i]!=-1)
	{
		return dp[i];
	}
	ll vl=hell;
	rep(j,0,k)
	{
		vl=min(fun(i+1+j)+abs(a[i]-a[i+1+j]),vl);
		
	}
	dp[i]=vl;
	return dp[i];
}
void solve()
{
	cin>>n>>k;
	rep(i,1,n+1)
	{
		cin>>a[i];
	}
	rep(i,1,n+1)
	{
		dp[i]=-1;
	}
	cout<<fun(1);
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	time
	return 0;
}

Measured memory_bytes: 6528
L, R = map(int, input().split())
mod = 2019

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
   l_ = L % mod
   r_ = R % mod
   ans = 2019
   for i in range(l_, r_):
       for j in range(i+1, r_+1):
           a = i * j % mod
           ans = min(ans, a)
   print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, K;
	cin >> N >> K;
	int arr[N];
	
	REP(i, 0, N) cin >> arr[i];
	
	sort(arr, arr +N);
	
	int mi = INT_MAX;
	REP(i, 0, N-K+1) mi = min(mi, arr[i+K-1]-arr[i]);
	cout << mi;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
bool p(ll n){
    if(n<=1) return false;
    else if(n==2 || n==3) return true;
    else if(n%2==0 || n%3==0) return false;
    for(ll i=5;i*i<=n;i+=6){
        if(n%i ==0 || n%(i+2)==0) return false;
    }
    return true;
}
int main() {
   ll n,a,b,k;
   cin>>n;
   for(ll i=n;i<=1000000;i++){
       if(p(i)){ cout<<i;return 0;
       }
   }
    return 0;
    
}

Measured memory_bytes: 256
N, L = map(int, input().split())

ans = 0
flag = False
for i in range(N):
    if L + i == 0:
        flag = True
    ans += (L + i)
if not flag:
    if ans < 0:
        ans -= (L+N-1)
    else:
        ans -= L
print(ans)

Measured memory_bytes: 9108
n = int(input())
out = 1
an = list(map(int,input().split()))
check = True
if 0 in an:
  print(0)
else:
  for a in an:
    out *= a
    if out>1000000000000000000:
      check = False
      break
  if check:
      print(out)
  else:
      print(-1)

Measured memory_bytes: 21780
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(void) {

    int a, b;
    scanf("%d %d", &a, &b);

    if ((a <= 0 && b > 0) || (a < 0 && b >= 0)) {
        printf("Zero\n");
    }
    else if (a > 0 || ((-b) - (-a) + 1) % 2 == 0) {
        printf("Positive\n");
    }
    else {
        printf("Negative\n");
    }

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var K, sum int
	fmt.Scan(&K)
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				sum += gcd(gcd(a, b), c)
			}
		}
	}
	fmt.Println(sum)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1780
n = int(input())
ans = n
for i in range(n + 1):
  cnt, t = 0, i
  while t > 0:
    cnt += t % 6
    t //= 6
  t = n - i
  while t > 0:
    cnt += t % 9
    t //= 9
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3060