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

int main() {
    int N, K;

    cin >> N >> K;

    int sum = 1;
    for (int i = 0; i < N; i++) {
        if (sum * 2 < sum + K) {
            sum *= 2;
        }
        else
            sum += K;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 200000

int max(int x,int y){
  if(x>y) return x;
  else return y;
}

int min(int x,int y){
  if(x>y) return y;
  else return x;
}

int main(){

  int R[SIZE],n;
  int minv,maxv,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  maxv=-2000000000;
  minv=R[0];

  for(i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
}

  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;
int i,j,n,x,mx=0,a;
map<int,int>m;
int main()
{
    cin>>n;
    for(j=1;j<=n;j++)
    {cin>>x;
       for(i=2;i*i<=x;i++)
       {
        a=0;
        while(x%i==0)
          {x/=i;
          if(!a){
             m[i]++;a++;}
           mx=max(m[i],mx);
          }
       }
       if(x!=1){m[x]++;mx=max(m[x],mx);}
    }
    if(mx==1||mx==0)cout<<"pairwise coprime";
    else if(mx<n)cout<<"setwise coprime";
    else cout<<"not coprime";
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  string s; cin>>s;
  map<char,ll> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ans=m['R']*m['G']*m['B'];
  
  ll span=1;
  ll tmp=0;
  while(span*2<n){
    rep(i,n){
      if(i+span*2>=n) break;
      if(s[i]!=s[i+span] && s[i+span]!=s[i+span*2] && s[i]!=s[i+span*2]){
        tmp++;
      }
    }
    span++;
  }
  cout<<ans-tmp<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int a, b, x, y;
scanf("%d%d%d%d", &a, &b, &x, &y);
printf("%lf ", double(a)*double(b) / 2);
if(2*x==a && 2*y==b) cout<<1<<endl;
else cout<<0<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    int l = 0;
    while (a[l] != 1) ++l;
    int r = n - 1 - l;
    int ans = INF;
    forn(l1, 0, k) {
        int r1 = k - 1 - l1;
        if (l1 <= l && r1 <= r) {
            setmin(ans, 1 + (l - l1 + k - 2) / (k - 1) + (r - r1 + k - 2) / (k - 1));
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1]
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1)
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod

def query(x,d,n):
    if x==0:
        return 0
    if d==0:
        return pow(x,n,mod)
    k=(x*modinv(d))%mod
    if k+n-1>=mod:
        return 0
    ans=Fact[k+n-1]*Finv[k-1]%mod
    ans*=pow(d,n,mod)
    ans%=mod
    return ans

q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    print(query(x,d,n))

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

int main() {
	long a,b,c;
  	cin >> a >> b >> c;
  	if(a*b*c==175){
      cout << "YES" << endl;
    }
  	else{
      cout << "NO" << endl;
    }
  	
}


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

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<string> input = Console.ReadLine().Split(' ').ToList();
        List<int> v = new List<int>();

        input.ForEach(x => v.Add(int.Parse(x)));

        int ans = int.MaxValue;
        for(int i = 1; i < 100; i++)
        {
            int sum = 0;
            v.ForEach(x => sum += (i - x) * (i - x));
            ans = Math.Min(ans, sum);
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<math.h>
#include<limits.h>
using namespace std;

int getDistance(int* student,int* check){
  int x,y;
  return abs(student[0] - check[0]) + abs(student[1] - check[1]);
}

int getPos(int* student,int check[][2],int m){
  int min,pos,ii,ret;
  min = INT_MAX;
  for(ii=0;ii<m;ii++){
	ret = getDistance(student,check[ii]);

	if(ret < min){
	  min = ret;
	  pos = ii;
	}
	
  }
  return pos + 1;
}



int main(){
  int n,m,ii;
  cin >> n >> m;
  int student[n][2];
  int check[m][2];
  int pos[n];
  for(ii=0;ii<n;ii++){
	cin >> student[ii][0];
	cin >> student[ii][1];
  }

  for(ii=0;ii<m;ii++){
	cin >> check[ii][0];
	cin >> check[ii][1];
  }

  for(ii=0;ii<n;ii++){
	pos[ii] = getPos(student[ii],check,m);
	cout << pos[ii] << endl;
  }
  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> lis(1e5+10, 0);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        lis[a]++;
        lis[a+1]++;
        lis[a+2]++;
    }
    int ma = 0;
    for(int i = 0; i < 1e5+5 ;i++){
        ma = max(lis[i], ma);
    }
    cout << ma << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		boolean[][] grid = new boolean[100][50];
		
		for(int x = 0; x < 100; x++)
			for(int y = 20; y < 50; y++)
				grid[x][y] = true;
		a--;
		b--;
		
		for(int x = 0; x < 100 && b > 0; x+=2)
			for(int y = 0; y < 20 && b > 0; y+=2)
			{
				grid[x][y] = true;
				b--;
			}
		
		for(int x = 0; x < 100 && a > 0; x+=2)
			for(int y = 31; y < 50 && a > 0; y+=2)
			{
				grid[x][y] = false;
				a--;
			}
		
		StringBuilder sb = new StringBuilder();
		for(int y = 0; y < 50; y++)
		{
			for(int x = 0; x < 100; x++)
			{
				sb.append(grid[x][y]?'#':'.');
			}
			sb.append('\n');
		}
		System.out.println("50 100");
		System.out.println(sb);
	}

}


Measured memory_bytes: 23764
#include <stdio.h>
int main(){
  int n,ans=0,v[20],c;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&v[i]);
  for(int i=0;i<n;i++){
    scanf("%d",&c);
    if(v[i]-c>0)ans+=v[i]-c;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int isPalindrome(string str,int l,int h) 
{  
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
    return 1;
} 
  

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int n1=(n-1)/2;
	int n2=(n+3)/2;
	bool s1=isPalindrome(s,0,n-1);
	bool s2=isPalindrome(s,0,n1-1);
	bool s3=isPalindrome(s,n2-1,n-1);
	if(s1 && s2 && s3)
	cout<<"Yes";
	else
	cout<<"No";
	
}

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

int main() {
    using vi = vector<int>;
    
    int n,m;
    cin >> n >> m;
    vi h(n);
    vi a(m);
    vi b(m);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,m){
        cin >> a[i] >> b[i];
    }
    vector<vi> x(n);
    rep(i,m){
        x[a[i]-1].push_back(b[i]-1);
        x[b[i]-1].push_back(a[i]-1);
    }
    int count = 0;
    rep(i,n){
        int hh = h[i];
        int f = 0;
        rep(j,x[i].size()){
            if(hh <= h[x[i][j]]){
                f = 1;
            }
        }
        //cout << i << "," << f << endl;
        if(f == 0){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

int main() {
    //freopen("in", "r", stdin);
    long long n;
    cin >> n;
    string s = "";
    while (n) {
        --n;
        s = char(int('a') + n%26) + s;
        n /= 26;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b))cout<<"B"<<endl;
    else cout<<"A"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

ll dp[55][5010]={};

signed main(){
  ll n,a;cin>>n>>a;

  rep(i,n){
    ll x;cin>>x;
    x-=a;
    dp[i+1][x+2500]++;

    for(ll j=0;j < 5001;j++)
    {
      dp[i+1][j]+=dp[i][j];
      if(0<=j+x && j+x<5000)dp[i+1][j+x]+=dp[i][j];
    }
  }

  cout<<dp[n][2500]<<endl;
}


Measured memory_bytes: 2176
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

b = []
for i in range (n):
	b.append(int(input()))


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
	print('Yes')
	quit()
if a[1][0] in b and a[1][1] in b and a[1][2] in b:
	print('Yes')
	quit()
if a[2][0] in b and a[2][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][0] in b and a[2][0] in b:
	print('Yes')
	quit()
if a[0][1] in b and a[1][1] in b and a[2][1] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][2] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
	print('Yes')
	quit()
print('No')
 

Measured memory_bytes: 62080
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = acos(-1); // cos(pi) = -1 <=> pi = arccos(-1)

/* global variables */
vector<int> dice(6);
/* function */

struct Dice{

  int s[6];

  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0]; s[0]=s[3]; s[3]=s[5]; s[5]=s[2]; s[2]=b;
    }
    if(c=='W'){
      b=s[0]; s[0]=s[2]; s[2]=s[5]; s[5]=s[3]; s[3]=b;
    }
    if(c=='N'){
      b=s[0]; s[0]=s[1]; s[1]=s[5]; s[5]=s[4]; s[4]=b;
    }
    if(c=='S'){
      b=s[0]; s[0]=s[4];s[4]=s[5]; s[5]=s[1]; s[1]=b;
    }
  }

  void shift() {
      int b;
      b=s[1]; s[1]=s[2]; s[2]=s[4]; s[4]=s[3]; s[3]=b;
  }

  int top() {
    return s[0];
  }

  void print_dice() {
        for (int i = 0; i < 6; i++) {
            cout << s[i] << ' ';
        } cout << '\n';
  }


};

Dice d1, d2;

bool check() {
    bool flag = true;
    for (int i = 0; i < 6; i++) {
        if (d1.s[i] != d2.s[i]) flag = false;
    }
    return flag;
}

/* main */
int main(){

    for (int i = 0; i < 6; i++) cin >> d1.s[i];
    for (int i = 0; i < 6; i++) cin >> d2.s[i];

    bool same = false;
    for (int i = 0; i < 4; i++) {
        d2.roll('S');
        for (int j = 0; j < 4; j++) {
            d2.shift();
            same = check();
            if (same) {
                cout << "Yes" << '\n';
                return 0;
            }
            // d2.print_dice();
        }
    }
    d2.roll('E'); 
    for (int j = 0; j < 4; j++) {
            d2.shift();
            same = check();
            if (same) {
                cout << "Yes" << '\n';
                return 0;
            }

            // d2.print_dice();
    }
    d2.roll('W'); 
    d2.roll('W'); 
    for (int j = 0; j < 4; j++) {
            d2.shift();
            same = check();
            if (same) {
                cout << "Yes" << '\n';
                return 0;
            }
            // d2.print_dice();
    }

    cout << "No" << '\n';


}




Measured memory_bytes: 3096
q = int(input())

n = 10**5+1
flag = [True]*n
flag[1] = False
for i in range(4, n, 2): flag[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if flag[i]:
    for j in range(i+i, n, i): flag[j] = False

nums = [0]*n
for i in range(1,n):
  if i%2 == 1:
    if flag[i] and flag[(i+1)//2]: nums[i] = nums[i-1]+1
    else: nums[i] = nums[i-1]
  else: nums[i] = nums[i-1]

for _ in range(q):
  l,r = map(int, input().split())
  print(nums[r]-nums[l-1])

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	if(n%10==7||n/100==7||(n%100)/10==7)
	cout<<"Yes";
	else
	cout<<"No";
	re 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int a, b, c, d, e, f, s = 0, w = 0;
	double mx = 0;    
	cin >> a >> b >> c >> d >> e >> f;

	for (int i = 0; i <= 31; i++) {
		for (int j = 0; j <= 31; j++) {
			for (int k = 0; k <= 101; k++) {
				for (int l = 0; l <= 101; l++) {
					int x = 100 * a*i + 100 * b*j;
					int y = c*k + d*l;
					if (x + y <= f && y <= e*i*a+e*j*b) {
						if ((100*y) != 0 && mx < (100.0*y)/(y+x)) {
							mx = (100.0 * y) / (y + x);
							s = y;
							w = x + y;
						}
					}
				}
			}
		}
	}
	if (w == 0)w = a * 100;
	cout << w << " " << s << endl;
	return	0;
}


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

const int N = 1 << 17;
const long long inf = 0x3f3f3f3f3f3f3f3f;

int n, m;
int cnt;
vector <int> g[N * 5], cost[N * 5];

void add_edge(int u, int v, int w) {
	g[u].push_back(v);
	cost[u].push_back(w);
}

struct SegT {
	int siz;
	int id[N + N];

	void assign(int tp) {
		memset(id, -1, sizeof(id));
		for (int i = 1; i < N; ++ i) id[i] = cnt ++;
		for (int i = 0; i < n; ++ i) id[i + N] = i;
		for (int i = 1; i < N; ++ i)
			if (tp) {
				if (~id[i + i]) add_edge(id[i], id[i + i], 0);
				if (~id[i + i + 1]) add_edge(id[i], id[i + i + 1], 0);
			} else {
				if (~id[i + i]) add_edge(id[i + i], id[i], 0);
				if (~id[i + i + 1]) add_edge(id[i + i + 1], id[i], 0);
			}
	}

	void add(int i, int a, int b, int l, int r, int tp, int u, int w) {
		if (l <= a && b <= r) {
			if (tp)
				add_edge(u, id[i], w);
			else
				add_edge(id[i], u, w);
			return;
		}
		if (r <= a || b <= l) return;
		int m = (a + b) >> 1;
		add(i + i, a, m, l, r, tp, u, w);
		add(i + i + 1, m, b, l, r, tp, u, w);
	}
} from, to;

long long dis[N * 5];
priority_queue <pair <long long, int> > pq;

void dij() {
	memset(dis, 0x3f, sizeof(dis));
	pq.push(make_pair(0, 0));
	dis[0] = 0;
	while (!pq.empty()) {
		long long d = -pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dis[u] != d) continue;
//		printf("%d %lld\n", u, dis[u]);
		for (int i = 0; i < g[u].size(); ++ i) {
			int v = g[u][i], w = cost[u][i];
			if (dis[v] > d + w) {
				dis[v] = d + w;
				pq.push(make_pair(-dis[v], v));
			}
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);
	cnt = n;
	from.assign(0); to.assign(1);
	for (int i = 0; i < m; ++ i) {
		int l, r, c;
		scanf("%d %d %d", &l, &r, &c); -- l;
		from.add(1, 0, N, l, r, 0, cnt, c);
		to.add(1, 0, N, l, r, 1, cnt ++, 0);
	}
	dij();
	if (dis[n - 1] >= inf)
		puts("-1");
	else
		printf("%lld\n", dis[n - 1]);
	return 0;
}


Measured memory_bytes: 92792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int n,S,col;
	char table[8][6];
	bool First = true;

	while(scanf("%d",&n)!=EOF){

		if(!First)printf("\n");

		S = 10;
		for(int i=0; i < 8; i++)table[i][5] = '\0';
		col=4;

		for(int i = 0; i < 5; i++){
			switch(n%S){

			case 0:
				table[0][col] = '*';
				table[1][col] = ' ';
				table[2][col] = '=';
				table[3][col] = ' ';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 1:
				table[0][col] = '*';
				table[1][col] = ' ';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = ' ';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 2:
				table[0][col] = '*';
				table[1][col] = ' ';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = ' ';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 3:
				table[0][col] = '*';
				table[1][col] = ' ';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = ' ';
				table[7][col] = '*';
				break;
			case 4:
				table[0][col] = '*';
				table[1][col] = ' ';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = ' ';
				break;
			case 5:
				table[0][col] = ' ';
				table[1][col] = '*';
				table[2][col] = '=';
				table[3][col] = ' ';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 6:
				table[0][col] = ' ';
				table[1][col] = '*';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = ' ';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 7:
				table[0][col] = ' ';
				table[1][col] = '*';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = ' ';
				table[6][col] = '*';
				table[7][col] = '*';
				break;
			case 8:
				table[0][col] = ' ';
				table[1][col] = '*';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = ' ';
				table[7][col] = '*';
				break;
			case 9:
				table[0][col] = ' ';
				table[1][col] = '*';
				table[2][col] = '=';
				table[3][col] = '*';
				table[4][col] = '*';
				table[5][col] = '*';
				table[6][col] = '*';
				table[7][col] = ' ';
				break;
			}
			n /= 10;
			col--;
		}

		for(int i=0; i < 8; i++){
			printf("%s\n",table[i]);
		}

		if(First)First = false;
	}

    return 0;
}

Measured memory_bytes: 2584
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
template<class T>inline void read(T &res)
{
    char c;T flag=1;
    while((c=getchar())<'0'|c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
bitset<50>bit;
/*
bit.reset(); bit=n; bit.count();
*/
#define _for(i,a,b) for( int i=(a); i<(b); ++i)
#define rof(i,a,b)  for( int i=b-1;i>=a;i--)
#define rep(i,a,b)  for( int i=(a); i<=(b); ++i)
#define per(i,a,b)  for( int i=(b); i>=a; --i)
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d %d",&n,&m)
#define sddd(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define pd(n)    printf("%d\n",n)
#define pd_(n)   printf("%d ",n)
#define pdd(n,m) printf("%d %d",n,m)
#define pddd(n,m,k) printf("%d %d %d",n,m,k)
#define pld(n) printf("%lld\n",n)
#define pldd(n,m) printf("%lld %lld\n",n,m)
#define sld(n)   scanf("%lld",&n)
#define sldd(n,m) scanf("%lld %lld",&n,&m)
#define slddd(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define sf(n)    scanf("%lf",&n)
#define sff(n,m) scanf("lf",&n,&m)
#define sfff(n,m,k) scanf("%lf %lf %lf",&n,&m,&k)
#define ss(str)  scanf("%s",str)
#define mm(a,n)  memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define fi first
#define se second
#define mod(x) ((x)%MOD)
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
typedef long double ld;
const int N=1e6+7;
const int MOD = 1e9 + 7;
//const double eps = 1e-9;
const double PI=atan(1.0)*4;
const int maxn=3e5+5;

ll pow(ll a,ll b,ll p)
{
    ll res=1%p;
    while(b)
    {
        if(b&1)
            res=(res*a)%p;
        a=(a*a)%p;
        b>>=1;
    }
    return res;
}
int a[N];
int b[N];

int main()
{
    int n;
    int x;
    sd(n);
    int k;
    for(int i=1;i<=n;i++)
    {
        sd(k);
        b[k]++;
    }
    int flag=0;
    int tot=0;
    if(n%2==1)
        x=2;
    else
        x=1;
    for(;x<n;x=x+2,tot++)
    {
        //debug(x);
        //debug(b[x]);

        if(b[x]!=2)
        {
            flag=1;
            break;
        }

    }
    //debug(flag);
    if(!flag)
        {
        cout << pow(2,tot,MOD) << endl;
        }
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string A = strArray[0];
            string B = strArray[1];
            string C = strArray[2];
            if((A == B && B == C) || (A != B && B != C && C != A))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 26352
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	long long X, Y; cin >> X >> Y;
	int ans = 0;
	while (Y >= X) {
		X *= 2;
		ans++;
	}
	cout << ans << endl;
}



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

int main(int argc, char const *argv[]) {
  int n, max_t;
  cin >> n >> max_t;
  vector<int> t(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> t[i];
  }

  long long result = 0;
  for (i = 1; i < n; i++) {
    result += max_t - abs(min(0, t[i] - t[i - 1] - max_t));
  }
  result += max_t;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<Pi> Vp;
typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n,m,ans=0; cin>>n; map<string,int> a={};
    for (int i = 0; i < n; i++){
        string s; cin>>s; a[s]++;
    }
    cin>>m;
    for (int j = 0; j < m; j++){
        string s; cin>>s; a[s]--;
    }
    for(auto k:a)cmax(ans,k.second);
    END
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n //=f
        else:f +=2
    if n!=1:a.append(n)
    return a


n=int(input())
prime=make_divisors(n)
prime=[i for i in prime if len(set(prime_factorize(i)))==1]
A=set()
for i in prime:
    if i==1:continue
    num,e=i,1
    while num<=n:
        A.add(num)
        e +=1
        num=i**e
cnt=0
for i in sorted(A):
    if n%i==0:
        cnt +=1
        n //=i
print(cnt)

Measured memory_bytes: 68640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

#define ll long long
const ll  modu = 1e9 + 7;
using namespace std;

//int gcd(int a, int b) {
//	return b == 0 ? a : gcd(b, a % b);
//}
//
//int lcm(int a, int b) {
//	return a * b / gcd(a, b);
//}
//
//bool comp(vector<int> a, vector<int> b)
//{
//	return a[2] < b[2];
//}
//bool isPal(string s)
//{
//	int start = 0; int end = s.size() - 1;
//	while (start < end)
//	{
//		if (s[start] != s[end]) return false;
//		start++;
//		end--;
//	}
//	return true;
//}
////s && l
////bool comp(vector<int> v1, vector<int> v2)
////{
////	return v1[0] < v2[0];
////}
vector<int> findDuplicates(vector<int>& nums) {

}

int main()
{
	int x; cin >> x;
	if (x == 3 || x == 5 || x == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{
	    var input = Array.ConvertAll(Console.ReadLine().Split(), ulong.Parse);
		ulong ans = 0;
	 	ans += (input[0]/(input[1]+input[2]))*input[1];
	 	ulong n = input[0];
	 	n %= (input[1]+input[2]);
	 	ans += Math.Min(n,input[1]);
    	Console.WriteLine(ans);
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

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

vector<vector<ll>> adj;
vector<ll> color;

bool dfs(ll n) {
  if (color[n]==-1) color[n] = 0;
  bool result = true;
  for (auto x: adj[n]) {
    if (color[x]==-1) {
      color[x] = !color[n];
      result &= dfs(x);
    }
    else result &= color[x]!=color[n];
  }
  return result;
}

int main() {
  ll N, M; cin >> N >> M;
  adj.resize(N);
  UnionFind uf(N);
  rep(i,M) {
    int u, v; cin >> u >> v; u--; v--;
    uf.unite(u,v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  color.resize(N,-1);
  ll one = 0, bi = 0, nbi = 0;
  rep(i,N) {
    if (uf.root(i)!=i) continue;
    if (uf.size(i)==1) one++;
    else {
      if (dfs(i)) bi++;
      else nbi++;
    }
  }
  // cout << one << " " << bi << " " << nbi << endl;

  ll result = (N*N-(N-one)*(N-one)) + bi*bi*2 + nbi*bi*2 + nbi*nbi;
  cout << result << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,a,b;
    cin>>n>>a>>b;

    if((b-a)%2==0){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Borys"<<endl;
    }
    return  0;
}


Measured memory_bytes: 256
import itertools

n,m,q = map(int, input().split())
A = list(itertools.combinations_with_replacement(range(1, m+1), n))
qs = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for t in A:
  temp = 0
  for a,b,c,d in qs:
    if t[b-1] - t[a-1] == c:
      temp += d
  ans = max(ans, temp)
print(ans)

Measured memory_bytes: 21580
#include <iostream>
#include <math.h>
#define f(x, y) (x-y)*(x-y)

using namespace std;

double distance_of(int n, int m, int **x, int d) {
    int i, j;
    double sum = 0;
    for (i = 0; i < d; i++) {
        sum += f(x[n][i], x[m][i]);
    }
    return sqrt(sum);
}

int main() {
    int ans = 0;
    int n, d;
    cin >> n >> d;
    int **x;
    x = new int*[n];
    for (int i = 0; i < n; i++)
        x[i] = new int[d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++)
            cin >> x[i][j];
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            double y, l;
            y = modf(distance_of(i, j, x, d), &l);
            if (y == 0)
                ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main() {
  int N, A, B;
  int sum=0;
  cin >> N >> A >> B;
  for (int i=1; i<=N; ++i) {
    int digit_sum = i/10000;
    digit_sum += (i%10000)/1000;
    digit_sum += (i%1000)/100;
    digit_sum += (i%100)/10;
    digit_sum += i%10;
    if ((digit_sum >= A) && (digit_sum <= B)) {
      sum += i;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       double r = in.nextDouble();
       System.out.printf("%f %f\n", Math.PI * r * r,
		       		    2 * Math.PI * r);
    }
}

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

int sum[22];
ll A[202020];

int main(){
  int N; cin>>N;
  rep(i,N) cin>>A[i];
  ll ans=0;
  int l=0;
  rep(r,N){
    bool flag=0;
    rep(j,22){
      if((A[r]>>j)&1==1) sum[j]++;
      if(sum[j]>1) flag=1;
    }
    if(flag){
      ans+=1LL*(r-l+1)*(r-l)/2;
      int tmp=l;
      while(1){
        rep(j,22) if((A[l]>>j)&1==1) sum[j]--;
        l++;
        bool flag2=1;
        rep(j,22) if(sum[j]>1) flag2=0;
        if(flag2) break;
      }
      ans-=1LL*(r-l+1)*(r-l)/2;
    }
  }
  ans+=1LL*(N-1-l+2)*(N-1-l+1)/2;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  map<int,int> A;
  for(int i=1; i<=N; i++){
    int x;
    cin>>x;
    A[x]=i;
  }
  for(int i=1; i<=N; i++){
    cout<<A[i]<<" ";
    if(i==N){
      cout<<endl;
    }
  }
}

Measured memory_bytes: 8260
A=list(input())
for i in range(4):
  A[i]=int(A[i])

for bit in range(8):
  flag=["+","+","+"]
  for i in range(3):
    if not bit>>(2-i) & 1 :
      A[i+1]=-A[i+1]
      flag[i]="-"
  if sum(A)==7:
    print("{}{}{}{}{}{}{}=7".format(A[0],flag[0],abs(A[1]),flag[1],abs(A[2]),flag[2],abs(A[3])))
    exit()
  for i in range(4):
    A[i]=abs(A[i])

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

int main(){
   
    int N,M;
    cin>>N>>M;
    vector<int> S[M],T(M);
    for(int i=0;i<M;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int s;cin>>s;
            S[i].push_back(s-1);
        }
    }
    for(int i=0;i<M;i++){
        cin>>T[i];
    }
    int sum=0;
    for(int bit=0;bit<(1<<N);bit++){
        int ans=0;
        for(int j=0;j<M;j++){
            int cnt=0;
            for(int i=0;i<S[j].size();i++){
                    if(bit&(1<<S[j][i])) cnt++;
                }
            if(cnt%2==T[j]) ans++;
        }
        if(ans==M) sum++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
n = input()
m = input().split()
m = [int(i) for i in m]
mx = max(m)
ind = m.index(mx)
 
c = 0
j = len(m)
for i in reversed(m[ind:]):
    if i < mx:
        d = mx - i
        c += d
        
ind_i = 0
for i in m[1:ind]:
    #print(i)
    if m[ind_i] > i:
        num = m[ind_i] - i
        m[ind_i+1] += num
        c+= num
    
    ind_i += 1
    
print(c)

Measured memory_bytes: 32208
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,k; 
    cin>>n>>k;
    int ans=0;
    while (n--){
        int a; cin>>a;
        ans += min(a*2,abs(k-a)*2);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll res=0;
ll cal(string s)
{
	ll ans=0;
	for(int i=0;i<s.size();i++)
		ans=ans*10+(s[i]-'0');
	return ans;
}
int main()
{
	cin>>s;
	int n=s.size();
	for(int i=0;i<(1<<(n-1));i++)
	{
		vector<int> v;
		v.push_back(0);
		for(int j=0;j<n;j++)
			if(1&(i>>j))
				v.push_back(j+1);
		v.push_back(n);
		for(int j=0;(j+1)<v.size();j++)
			res+=cal(s.substr(v[j],v[j+1]-v[j]));
	}
	cout<<res<<endl;
	return 0;
}

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

/*/---------------------------Defines----------------------/*/
 
#define ll long long
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(v) (v).begin(),(v).end()

typedef pair<ll,ll> pi;
/*/-----------------------Modular Arithmetic---------------/*/
 
const long long INF = 1ll << 32; 
const int mod=1e9+7;
inline int add(int x,int y){
    x+=y;
    if (x>=mod) return x-mod;
    return x;
}
inline int sub(int x,int y){
    x-=y;
    if (x<0) return x+mod;
    return x;
}
inline int mul(int x,int y){
    return (x*1ll*y)%mod;
}
inline int power(int x,int y){
    int ans=1;
    while(y){
        if (y&1) ans=mul(ans,x);
        x=mul(x,x);
        y>>=1;
    }
    return ans;
}
inline int inv(int x){
    return power(x,mod-2);
}
/*/-----------------------------Code begins----------------------------------/*/
const int N=2e5+100;


void solve()
{
	ll i,j,k;
	ll n,m;
    cin>>n;
    if(n==1) cout<<"0"<<endl;
    else cout<<"1"<<endl;
}



int main()
{
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3628
//ABC 171 A
#include<bits/stdc++.h>
using namespace std;

int main(){
    char a;
    cin >> a;
    string vec,Ve;
    vec="abcdefghijklmnopqrstuvwxyz";
    Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i=0;i<26;i++){
        if(vec.at(i)==a){
            cout << "a";
            break;
        }
        if(Ve.at(i)==a){
            cout <<"A";
            break;
        }
    }
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;
    string s; cin >> s;

    if (N % 2) {
        return cout << "No" << "\n", 0;
    }

    else {
        cout << (s.substr(0, s.length() / 2) == s.substr(s.length() / 2, s.length() / 2)
                ? "Yes" : "No") << "\n";
    }

    return 0;
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int a;
    string s;
    cin>>a>>s;
    int b=stoi(s.substr(0,s.size()-3));
    b*=100;
    b+=stoi(s.substr(s.size()-2,2));
    a*=b;
    a/=100;
    cout<<a;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();	
		String a = S.substring(0, S.length()-1);
		
		while(a.length()>0) {
			if(a.length()%2==0) {
				String[] z = new String[2];
				z[0] = S.substring(0, a.length()/2);
				z[1] = S.substring(a.length()/2, a.length());
			
				if(z[0].equals(z[1])) {
					System.out.println(a.length());
					break;
				}
			}
			a = a.substring(0, a.length()-1);
		}
	}

}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
const double EPS = 1e-9/10;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n,k;
	cin >> n >> k;
	double ans = 0.0;
	for(int i = 1; i <= n; i++){
		double plus = 1.0 / n;
		int jou = i;
		while(jou < k){
			jou *= 2;
			plus /= 2;
		}
		ans += plus;
	}
	cout << fixed << setprecision(20) << ans << endl;
	return 0; 
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];

    int res = 0;
    for (int left = 0; left <= K; left++) {
        for (int right = 0; right <= K - left; right++) {
            if (left + right > N) break;

            int sum = 0;
            priority_queue<int, vector<int>, greater<int>> que;
            for (int i = 0; i < left; i++) {
                que.push(V[i]);
                sum += V[i];
            }
            for (int i = N - 1; i >= N - right; i--) {
                que.push(V[i]);
                sum += V[i];
            }

            int removeCnt = K - (left + right);
            for (int i = 0; i < removeCnt; i++) {
                if (que.empty() || que.top() >= 0) break;
                sum -= que.top();
                que.pop();
            }
            res = max(res, sum);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string s;
int n = 700;

void solve() {

    cin >> s;

    for (int j = 0; j < 3; j++) {
        if (s[j] == 'o') n += 100;
    }

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

Measured memory_bytes: 256