akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
n = int(input())
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
list = make_divisors(n)
root = n**0.5
for i in range(len(list)-1):
    if (list[i] <= root and list[i+1] >root):
        a = list[i]
b = n //a
print(a+b-2)

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


int main () {
  int n, temp;
  set<int> a;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> temp;
    a.insert(temp);
  }
  if (n == a.size()){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 9600
def B():
    X=int(input())
    sum=0
    
    count500=int(X/500)
    sum+=count500*1000
  
    count5=int((X-(count500*500))/5)
    sum+=count5*5
    
    print(sum)
        
    
    
if __name__=='__main__':
    B()


Measured memory_bytes: 2940
n = gets.chomp.to_i
arr = gets.chomp.split
comulative_sum = 0
n.times do |i|
    arr[i] = arr[i].to_i
    comulative_sum += arr[i]
end

sum = 0
(0..n-2).each do |i|
    comulative_sum -= arr[i]
    sum += arr[i] * comulative_sum
end
puts sum % (10 ** 9 + 7)


Measured memory_bytes: 29596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    int e,f,g,h;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
    int x = a+b+c+d;
    int y = e+f+g+h;
    if(x>y){
        cout << x << endl;
    }
    else{
        cout << y << endl;
    }
    
    
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

    int a,b,c;
    int k;
    cin>>a>>b>>c;
    cin>>k;

    int t=0;
    while (b<=a) {
    	b*=2;
    	t++;
    }
    while (c<=b) {
    	c*=2;
    	t++;
    }

    if (t>k)
    	cout<<"No\n";
    else
    	cout<<"Yes\n";



    return 0;
}

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

using namespace std;
typedef long long ll;
int n,m;
ll ans;
ll d[52][7];
ll sx[110],sy[110],sd[110];
int main(){
	scanf("%d%d",&n,&m);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 6;j++){
			scanf("%lld",&d[i][j]);
			switch(j%3){
				case 0:
					sx[i*2+(j/3)] = d[i][j];
					break;
				case 1:
					sy[i*2+(j/3)] = d[i][j];
					break;
				case 2:
					sd[i*2+(j/3)] = d[i][j];
					break;
			}
		}
	}
	sort(sx,sx + 2*n);
	sort(sy,sy + 2*n);
	sort(sd,sd + 2*n);

	int six=2*n,siy=2*n,sid=2*n;
	int cnt = 0;
	int pre = sx[cnt++];
	for(int i = 1;i < 2*n;i++){
		if(pre != sx[i]){
			sx[cnt++] = sx[i];
			pre = sx[i];
		}
	}
	six = cnt; cnt = 0; pre = sy[cnt++]; 
	for(int i = 1;i < 2*n;i++){
		if(pre != sy[i]){
			sy[cnt++] = sy[i];
			pre = sy[i];
		}
	}
	siy = cnt; cnt = 0; pre = sd[cnt++];
	for(int i = 1;i < 2*n;i++){
		if(pre != sd[i]){
			sd[cnt++] = sd[i];
			pre = sd[i];
		}
	}
	sid = cnt;
	n = 2*n;
	for(int i = 0;i < six-1;i++){
		for(int j = 0;j < siy-1;j++){
			for(int k = 0;k < sid-1;k++){
				int co = 0;
				for(int l = 0;l < n/2;l++){
					if(sx[i] < d[l][0] || sx[i+1] > d[l][3] || sy[j] < d[l][1] || sy[j+1] > d[l][4] || sd[k] < d[l][2] || sd[k+1] > d[l][5])continue;
					co++;
				}
				if(co >= m)ans += (sx[i+1]-sx[i])*(sy[j+1]-sy[j])*(sd[k+1]-sd[k]);
			}
		}
	}
	printf("%lld\n",ans);
	//cout << "six:" << six << endl;
	return 0;
}


Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if(A*N>B){
    cout<<B<<endl;
  }else if (A*N<B){
    cout<<A*N<<endl;
  }else{
    cout<<B<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
#include<stdio.h>
#include<complex>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;
const int intINF = 1e9 * 2 + 3;
//--------------------------------------------------

ulli gcd(ulli a, ulli b) {return (b <= 0) ? a : gcd(b, a % b);}
ulli lcm(ulli a, ulli b) {return a * b / gcd(a, b);}

bool isPrime(int n)
{
	if (n <= 3)return n > 1;
	if (n % 2 == 0)return false;
	if (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;
}
//---------------------------------------------------



void Main()
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 200000
#define N_MAX 100000
#define M_MAX 100000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

ull n, m;
int h, w;
int i, j, k;

int a[N_MAX];
int b[M_MAX];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){
	ull result = 0;
	ull prev;

	for (i = 0; i < n; i++) {
		b[a[i] - 1]++;
	}

	for (i = 0; i < M_MAX; i++) {
		if (b[i]) result += (ull)(b[i] - 1);
	}

	printf("%llu\n", (ull)n - ((result >> 1) + (result & 1)) * 2);

	return;
}

int main (void) {
	char *t;
	scanf("%d", &n);

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

	solve();
	return 0;
}




Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sbA = new StringBuilder();
        for(int i = 0; i < a; i++)
        	sbA.append(b);

        StringBuilder sbB = new StringBuilder();
        for(int i = 0; i < b; i++)
        	sbB.append(a);
        String strA = sbA.toString();
        String strB = sbB.toString();
        System.out.println(strA.compareTo(strB) < 0 ? strA : strB);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n, k; cin >> n >> k;
    vi v(n);
    f(i, n) cin >> v[i];
    sort(all(v));
    partial_sum(all(v), v.begin());
    int i = sz(v) - 1 - k;
    cout << (i >=0?v[i]:0) << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
As = list(map(int, input().split()))

count_minus = 0
for i in range(N):
    if As[i] < 0:
        count_minus += 1
        As[i] *= -1

if count_minus % 2 == 0:
    print(sum(As))
else:
    print(sum(As) - 2*min(As))


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    ll k,x;cin>>k>>x;
    cout<<x-k+1;
    rep(i,x-k+2,x+k-1){
        cout<<' '<<i;
    }
    cout<<endl;
    
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    bool ans = false;
    rep(i, N + 1) {
        int X = N - 2 * i;
        int Y = K - i * M;

        if (X <= 0 || Y < 0) continue;
        if (Y % X != 0) continue;

        if (Y / X <= M) ans = true;
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

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

using namespace std;

int main()
{
	while (1){
		int n;
		cin >> n;
		if (!n){ break; }

		int m, counter = 0, sum = 0;
		string s;
		char want = 'I';
		cin >> m >> s;

		//from 1 to m-1
		for (int i = 0; i < m; i++){
			if (want == s[i]){
				counter++;
				want = (want == 'I') ? 'O' : 'I';
			}
			else{
				if ((counter - 1) / 2 - n + 1 > 0){
					sum += (counter - 1) / 2 - n + 1;
				}
				counter = 0;
				want = 'I';
				if (s[i] == 'I'){
					i--;
				}
			}
		}

		//last
		if ((counter - 1) / 2 - n + 1 > 0){
			sum += (counter - 1) / 2 - n + 1;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  int ans = 0;
  vector<int> A(N), B(N), C(N-1);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    ans += B[i];
  }
  for (int i = 0; i < N-1; i++) cin >> C[i];

  for (int i = 0; i < N-1; i++) {
    if (A[i] + 1 == A[i+1]) {
      ans += C[A[i]-1];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
# include <stdio.h>

int main(void){
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if(a<=0 || a>9 || b<=0 || b>9){
		printf("-1");
	}
	else{
		printf("%d", a*b);
	}
	
	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    cout << a[n-1]+b[0] << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
const int maxn = 51;
const int maxm = 10100;
const int INF = 0x3ffffff;
struct Side{
	int to,next,c;
}side[maxm];
int node[maxn],top;
void add_side(int u,int v,int c){
	side[top]=(Side){v,node[u],c};
	node[u]=top++;
}
int fee[maxn],h[maxn];
int dis[maxn][maxn];
long long vis_up[maxn][maxn];
long long vis_down[maxn][maxn];
long long vis[maxn][maxn];
int go_up[maxn][maxn];
int go_down[maxn][maxn];
int n,m;
bool inqueue[maxn];
queue<int>q;
int get_dis(int u,int dis[maxn],long long vis[maxn],bool big){
	for(int i=1;i<=n;i++){
		dis[i]=INF;
		inqueue[i]=false;
	}
	dis[u]=0;
	q.push(u);
	vis[u]=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		inqueue[u]=false;
		for(int i=node[u];i!=-1;i=side[i].next){
			int v=side[i].to;
			if(big&&h[v]<h[u])continue;
			if(!big&&h[v]>h[u])continue;
			if(dis[u]+side[i].c+fee[v]<dis[v]){
				vis[v]=vis[u]|(1ll<<v);
				dis[v]=dis[u]+side[i].c+fee[v];
				if(!inqueue[v]){
					inqueue[v]=false;
					q.push(v);
				}
			}
		}
	}
}
int main(){
	while(~scanf("%d%d",&n,&m)){
		if(n==0&&m==0)break;
		fee[1]=fee[n]=0;
		h[1]=0;
		h[n]=1000;
		top=0;
		memset(node,-1,sizeof(node));
		for(int i=2;i<n;i++){
			scanf("%d%d",&fee[i],&h[i]);
		}
		for(int i=0;i<m;i++){
			int u,v,w;
			scanf("%d%d%d",&u,&v,&w);
			add_side(u,v,w);
		}
		for(int i=1;i<=n;i++){
			get_dis(i,go_up[i],vis_up[i],true);
			get_dis(i,go_down[i],vis_down[i],false);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(i==j)dis[i][j]=0;
				else{
					dis[i][j]=go_up[i][j]+go_down[j][i];
					vis[i][j]=vis_up[i][j]|vis_down[j][i];
				}
			}
		}
		for(int k=1;k<=n;k++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					int val=dis[i][k]+dis[k][j];
					for(int m=1;m<=n;m++){
						if((vis[i][k]&(1LL<<m))&&(vis[k][j]&(1LL<<m)))val-=fee[m];
					}
					dis[i][j]=min(dis[i][j],val);
				}
			}
		}
		if(dis[1][n]>=INF)printf("-1\n");
		else printf("%d\n",dis[1][n]);
	}
}

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

using lint = unsigned long long int;

int main() {
    lint H, W;
    cin >> H >> W;

    if (H == 1 or W == 1) {
        cout << 1 << endl;
        return 0;
    }

    lint EH = H / 2;
    lint OH = H - EH;

    lint EW = W / 2;
    lint OW = W - EW;

    lint ans = EH * EW + OH * OW;
    cout << ans << endl;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b,c,d,k;
    cin >> a >> b >> c >> d >> k;
    int aa,bb,sa;
    if(a==c&&b>d){
        aa=a*60+b;
        bb=c*60+d+60*24;
        sa=bb-aa;
    }else if(a>c){
        aa=a*60+b;
        bb=c*60+d+60*24;
        sa=bb-aa;
    }else{
        aa=a*60+b;
        bb=c*60+d;
        sa=bb-aa;
    }
    
    cout << sa-k << endl;

    return 0;
}











Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

n = int(input())
S = input()
f = [0] * (n+1)
for i in range(n):
    f[i+1] = f[i] + (S[i] == '#')
g = [0] * (n+1)
for i in range(n):
    g[i+1] = g[i] + (S[i] == '.')
k = S.index('#') if '#' in S else 0
ans = min(f[n], g[n]-g[k])
lst = []
for i in range(n-1):
    if S[i:i+2] == '#.':
        lst.append(i)
for i, j in zip(lst, lst[1:]):
    ans = min(ans, f[i+1]+g[n]-g[j])
print(ans)


# N, M, K = map(int, input().split())
# A = list(map(int, input().split()))


Measured memory_bytes: 76252
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	long double a;
	long double b;
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
}

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

using namespace std;

typedef long long ll;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)

#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INFL ll(1e18)
#define INF  2000000000

#define N 100005

string s,t;
ll dp[4000][4000],ns,nt;
ll solve(int i,int j){
if(i == ns || j == nt) return 0;
if(dp[i][j] != -1) return dp[i][j];

ll c1 = -1*INF,c2= -1*INF;


if(s[i] == t[j]) return dp[i][j] = 1+ solve(i+1,j+1) ;
c1 = solve (i,j+1);
c2 = solve(i+1,j);

ll ret = max(c1,c2);
return dp[i][j] = ret;


}

void printlcs(int i,int j){

    string path ="";
    while(i&&j){

        if(s[i-1] == t[j-1]) {path += s[i-1] ; i--; j--; }

        else if(dp[i][j-1]>dp[i-1][j]) j--;
        else i--;
    }
    reverse(path.begin(),path.end());
    cout << path;
}
void LCS(){
    for(int i=0;i<=ns;i++)
        dp[i][0] = 0;
    for(int i=0;i<=nt;i++)
        dp[0][i] = 0;

    for(int i =1;i<=ns;i++)
        for(int j=1;j<=nt;j++){
            if(s[i-1] == t[j-1])  dp[i][j] = 1+ dp[i-1][j-1] ;
            else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);

    }


}

int main()
{
 _
    memset(dp,-1,sizeof dp);

    cin >> s;
    cin >> t;
    ns = s.size();
    nt = t.size();
    string ans ="";
//    cout << solve(0,0) <<endl;
    LCS();
    printlcs(ns,nt);


    return 0;
}


Measured memory_bytes: 125312
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
#define EPS 0.0001
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

ll power(ll x, ll n) {
    ll res = 1;
    if (n > 0) {
        res = power(x, n / 2);
        if (n % 2 == 0) res = (res * res) % mod;
        else res = (((res * res) % mod) * x) % mod;
    }
    return res;
}

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

    ll ans = power(10, n) % mod;
    ans = (ans - power(9, n)) % mod;
    if (ans < 0) ans += mod;
    ans = (ans - power(9, n)) % mod;
    if (ans < 0) ans += mod;
    ans = (ans + power(8, n)) % mod;
    cout << ans << endl;

}

Measured memory_bytes: 3632
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       L:i64,R:i64,d:i64
    }

    //println!("{}", R / d);
    //println!("{}", (L + d - 1) / d);
    println!("{}", (R / d - (L + d - 1) / d) + 1);
}


Measured memory_bytes: 2176
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

bool isW(char c) {
    return c == 'W';
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int>sumW(N + 2, 0), sumE(N + 2, 0);
    for (int i = 1; i <= N; i++) {
        sumW[i] += sumW[i - 1] + (S[i - 1] == 'W');
        sumE[i] += sumE[i - 1] + (S[i - 1] == 'E');
    }
    sumW[N + 1] = sumW[N]; sumE[N + 1] = sumE[N];

    int ans = N;
    for (int i = 1; i <= N; i++) {
        ans = min(ans, sumW[i - 1] + sumE[N+1] - sumE[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7;
#define el "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358
#define F first
#define S second
#define pb push_back 
#define mp make_pair
#define f(i,x,y) for(i=x;i<y;i++) 
#define fo(i,x,y) for(i=x;i>=y;i--)
#define all(v) v.begin(),v.end()
#define ss(v) sort(all(v))
//cout<<setprecision(9);
// sieve
/*bool prime[100000];
void sieve(ll n) 
{ 
    
    memset(prime, true, sizeof(prime)); 
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    

}
*/
void solve(){
 ll n,i;
 cin>>n;
 ll a[n],b[n];
 f(i,0,n)cin>>a[i];
 b[0]=0,b[1]=abs(a[1]-a[0]);
 f(i,2,n)
 b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
 cout<<b[n-1]<<el;
}

int main() {
fastio
ll _;
_=1;
//cin>>_;
while(_--)
{
solve();

}
return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
ll mod = 1000000007;


int main(){
    ll n;
    cin >> n;
    vll a(n);
    vll cnt(n + 1);
    for(ll i = 0; i < n; i++){
        cin >> a.at(i);
        cnt.at(a.at(i))++; 
    }

    ll ans = 0;
    for(ll i = 1; i < n + 1; i++){
        ans += cnt.at(i) * (cnt.at(i) - 1) / 2;
    }
    for(ll i = 0; i < n; i++){
        cout << ans - cnt.at(a.at(i)) + 1 << endl;
    }
}

Measured memory_bytes: 5760
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for k in range(n)]
 
count=0
 
for i in range(n):
       s=0
       for j in range(m):
        s += a[i][j]*b[j]
       
       ans=s+c
       if ans>0:
        count +=1
print(count) 

Measured memory_bytes: 3064
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_SM(n):
	return [tuple(INSTR_S()) for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

A, B = INNUM_S()
print((A + B) % 24)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef long long ll;

ll p = pow(10, 9) + 7;





int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod  998244353
#define pii pair<int, int>
#define PI 2*acos(0.0)
#define forn(i, n) for(int i = 0; i < n; i++)

int n;
vi pos;
int dp[100005];

int cnt(int i)
{
    if(i <= 0)
        return 0;
    if(dp[i] != -1)
        return dp[i];
    int va = INT_MAX, vb = INT_MAX;
    if(i-1>= 0)
        va = abs(pos[i] - pos[i-1]) + cnt(i-1);
    if(i-2>= 0)
        vb = abs(pos[i] - pos[i-2]) + cnt(i-2);
    return dp[i] = min(va, vb);
}

int main()
{
    io;
    cin>>n;
    for(int i = 0; i< n;i++)
    {
        int x;
        cin>>x;
        pos.pb(x);
    }
    memset(dp, -1, sizeof(dp));
    cout<<cnt(n-1);
    return 0;
}


Measured memory_bytes: 5880
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
 
ull B=10000007;
int n,d,len;
char s[200][17];
ull t[200];
int G[200][200];
bool f[200][200];
map<ull,bool> mp[200];
 
struct data{
  int fi,se;
  bool operator < (const data &d)const{
    return (G[fi][d.fi]!=0?G[fi][d.fi]<0:G[se][d.se]<0);
  }
};
 
vector< data > v;
 
ull Deleting(int x,char* ch){
  ull res=0;
  for(int i=0;i<len;i++)
    if(i!=x)res=res*B+ch[i];
  return res;
}
 
ull Inserting(int x,char y,char* ch){
  ull res=0;
  for(int i=0;i<=len;i++){
    if(i==x)res=res*B+y;
    if(i<len)res=res*B+ch[i];
  }
  return res;
}
 
ull Replacing(int x,char y,char* ch){
  ull res=0;
  for(int i=0;i<len;i++){
    if(i==x)res=res*B+y;
    else res=res*B+ch[i];
  }
  return res;
}
 
ull Swapping(int x,char* ch){
  ull res=0;
  for(int i=0;i<len;i++){
    if(i==x)res=res*B+ch[i+1];
    else if(i==x+1)res=res*B+ch[x];
    else res=res*B+ch[i];
  }
  return res;
}
 
void init(){
  for(int i=0;i<200;i++){
    mp[i].clear();
  }
  v.clear();
  memset(f,false,sizeof(f));
}
 
int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    init();
    scanf("%d",&d);
 
    for(int i=0;i<n;i++){
      scanf("%s",s[i]);
      len=strlen(s[i]);
 
      t[i]=Swapping(-10,s[i]);
       
      for(int j=0;j<len;j++){
        mp[i][Deleting(j,s[i])]=true;
      }
       
      for(int j=0;j<=len;j++){
        for(char k='a';k<='z';k++){
          mp[i][Inserting(j,k,s[i])]=true;
        }
      }
       
      for(int j=0;j<len;j++){
        for(char k='a';k<='z';k++){
          if(s[i][j]!=k){
            mp[i][Replacing(j,k,s[i])]=true;
          }
        }
      }
       
      for(int j=0;j+1<len;j++){
        mp[i][Swapping(j,s[i])]=true;
      }
    }
 
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        G[i][j]=strcmp(s[i],s[j]);
     
    for(int i=1;i<n;i++){
      for(int j=0;j<i;j++){
        int a=i,b=j;
        if(G[a][b]>0)swap(a,b);
        if( mp[a].count(t[b]) && !f[a][b] ){
          v.push_back( (data){a,b} );
          f[a][b]=true;
        }
        if(d==1)continue;
        map<ull,bool> :: iterator it;
        for(it=mp[b].begin();it!=mp[b].end();it++){
          if( mp[a].count(it->first) && !f[a][b] ){
            v.push_back( (data){a,b} );
            f[a][b]=true;
          }
        }
      }
    }
    sort( v.begin() , v.end() );
    for(int i=0;i<(int)v.size();i++){
      printf("%s,%s\n",s[v[i].fi],s[v[i].se]);
    }
    printf("%d\n",(int)v.size());
  }
  return 0;
}

Measured memory_bytes: 10572
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

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

    for (int i = 0; i < 11000; ++i) dp[i] = MINUSINF;

    dp[0] = "";

    for (int i = 0; i <= N; ++i) {
        if (dp[i] == MINUSINF) continue;
        for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 43776
N = int(input())

d = 10 ** 9 + 7

if N <= 50000:
    P= 1
    for x in range(1, N+1):
        P *= x
elif N > 50000:
    P = 737935835
    for x in range(50001, N + 1):
        P *= x
    
print(P%d)

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  int h[n];
  int dp[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<n;i++){
    dp[i]=INT_MAX;
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i+j<n){
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
}
    


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	const string str = "CODEFESTIVAL2016";
	string s; cin >> s;
	int sum = 16;
	for (int i = 0; i < 16; i++){
		if (s[i] == str[i])sum--;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

typedef long double lld;
typedef pair<lld,mp> lmp;
int w,h;

char dat[505][505];
lld ds[505][505];

int sy,sx,gy,gx;

int dd[5]={1,0,-1,0,1};

void calcd(lld m){
	pque(lmp) que;
	que.push(lmp(0,mp(gy,gx)));
	rep(y,h)rep(x,w){
		if(dat[y][x]=='*'){
			ds[y][x]=m;
			rep(i,4){
				int ty = y + dd[i],
					tx = x + dd[i+1];
				if(dat[ty][tx]!='.')continue;
				que.push(lmp(m+1,mp(ty,tx)));
			}
		}
		else ds[y][x]=-1;
	}
	
	while(!que.empty()){
		lmp pa = que.top();
		que.pop();
		lld d = pa.fir;
		int y = pa.sec.fir,
			x = pa.sec.sec;
		if(ds[y][x]>=0)continue;
		ds[y][x]=d;
		rep(i,4){
			int ty = y + dd[i],
				tx = x + dd[i+1];
			if(dat[ty][tx]!='.')continue;
			if(ds[ty][tx]>=0)continue;
			que.push(lmp(d+1,mp(ty,tx)));
		}
	}
}

int main(void){
	scanf("%d%d",&w,&h);
	rep(y,h)scanf("%s",dat[y]);
	rep(y,h)rep(x,w){
		if(dat[y][x]=='s'){
			sy=y; sx=x; dat[y][x]='.';
		}
		if(dat[y][x]=='g'){
			gy=y; gx=x; 
		}
	}
	
	lld l=1e-20,r=1e20;
	while((r-l)/l>1e-15){
		lld m = (l+r)/2.0;
		//printf("%Lf %Lf\n",l,r);
		calcd(m);
		int p = 0;
		lld s = 0;
		rep(y,h)rep(x,w){
			if(dat[y][x]=='.'){
				p++; s+=ds[y][x];
			}
		}
		s /= p;
		if(s>=m)l = m;
		else r = m;
	}
	
	calcd(l);
	printf("%.15Lf\n",ds[sy][sx]);
	
	return 0;
}

Measured memory_bytes: 8660
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	pair<int,int> s[6];
	for (int i=1;i<=m;i++) cin>>s[i].first>>s[i].second;
	int ans[6]={0};
	sort(s,s+m);
	for (int i=1;i<=m;i++){
		if (ans[s[i].first]==0) ans[s[i].first]=s[i].second;
		else
			if (ans[s[i].first]!=s[i].second){
				cout<<-1<<endl;
				return 0;
			}
	}
	for (int i=1;i<=m;i++){
		if (n>1&&s[i].first==1&&s[i].second==0){
			cout<<-1<<endl;
			return 0;
		}
	}
	for (int i=1;i<=n;i++){
		if (n>1&&ans[i]==0&&i==1) cout<<1;
		else cout<<ans[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int m, f, r;
  bool loop = true;
  while (loop) {
    cin >> m >> f >> r;
    int sum = m + f;
    //    cout << "sum = " << sum;
    if ((m == -1) && (f == -1) && (r == -1)) {
      loop = false;
    } else if ((m == -1) || (f == -1)) {
      cout << 'F' << endl;
    } else if (sum >= 80) {
      cout << 'A' << endl;
    } else if ((sum >= 65) && (sum < 80)) {
      cout << 'B' << endl;
    } else if ((sum >= 50) && (sum < 65)) {
      cout << 'C' << endl;
    } else if ((sum >= 30) && (sum < 50)) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else if (sum < 30) {
      cout << 'F' << endl;
    }
  }

    return 0;
}

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

bool contains(string &str, char c) { return str.find(c) != string::npos; }

int main() {
  string n, s;
  getline(cin, n);
  getline(cin, s);
  cout << (contains(s, 'Y') ? "Four" : "Three") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

 int main(){
  int N;
  cin >> N;
  long long x,y;
  x = y = 0;
  for(int i = 0; i < N; i++){
    int a,b;
    cin >> a >> b;
    if(a>=x&&b>=y){
      x=a;  y=b;
    }else{
      long long p,s,t;
      if(x%a==0) s=x/a;
      else s=x/a+1;
      if(y%b==0) t=y/b;
      else t=y/b+1;
      p = max(s,t);
      x=p*a;  y=p*b;
    // cout << x << " " << y << endl;
    }
  }
  cout << (x+y) << endl;

    return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int i;
    int g=n/2+n%2;
    if(g>=k)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


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

int main(){
    int n,q; cin >> n >> q;
    int ans[n];
    for(int i=0;i<n;i++){
        ans[i]=i+1;
    }
    for(int i=0;i<q;i++){
        int a,b; 
        scanf("%d,%d",&a,&b);
        a--; b--;
        swap(ans[a],ans[b]);
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int ans = 0;
	rep(i,s.size() - 1){
		if(s.at(i) != s.at(i + 1)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
using System;


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int a = Int32.Parse(args[0]);
		int b = Int32.Parse(args[1]);
		int c = Int32.Parse(args[2]);
			
		Console.WriteLine((a == b) && (b == c) ? "Yes" : "No");
	}	
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(){

  int i,j,temp,count=0,flag=1,n,x[100];

  scanf("%d",&n);

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

  }

  while(flag == 1){
  
    flag = 0;
  
    for(j = n-1 ; j > 0   ; j--){

      if(x[j] < x[j-1]){
   
	temp = x[j-1];
        x[j-1] = x[j];
	x[j] = temp;
        flag = 1;
        count++;
      }

    }

  }


  for(i = 0 ; i < n ; i++){
 

    printf("%d",x[i]);
    if(i ==  n-1){
      break;
    }
    printf(" ");

  }
  
  printf("\n");

  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
using AtCoderBeginnerContest144.Questions;
using AtCoderBeginnerContest144.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest144.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadLong();
            long a;

            for (a = (int)Math.Sqrt(n); a >= 1; a--)
            {
                if (n % a == 0)
                {
                    break;
                }
            }

            var b = n / a;

            yield return a + b - 2;
        }
    }
}


namespace AtCoderBeginnerContest144
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest144.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest144.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    int ans = n;
    akari<pair<i64, i64>> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i].first >> ps[i].second;
        ps[i].first += ps[i].second;
    }
    sort(ps.begin(), ps.end());
    i64 l = -1e15;
    for (int i = 0; i < n; i++)
    {
        i64 x = ps[i].first, lx = x - 2 * ps[i].second;
        if (l <= lx)
        {
            l = x;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
const int maxn=1e5+10;
int n,m;
int d[maxn],w[maxn*2],col[maxn];
vector<pair<int,int> > G[maxn];

void solve(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",d+i);
    }
    for(int i=0,u,v;i<m;++i){
        scanf("%d%d",&u,&v);
        --u;--v;
        G[u].push_back(mp(v,i));
        G[v].push_back(mp(u,i));
    }

    map<int,vector<int> > mp;
    memset(col,-1,sizeof col);
    for(int i=0;i<n;++i)mp[d[i]].push_back(i);

    for(auto &e: mp){
        for(auto u: e.second)if(!~col[u]){
            for(auto nxt: G[u]){
                if(d[nxt.first]<=d[u]){
                    w[nxt.second]=e.first;
                    if(col[nxt.first]==-1){
                        col[u]=0;
                        col[nxt.first]=1;
                    }
                    else col[u]=col[nxt.first]^1;
                    goto H;
                }
            }
            puts("-1");
            return;
            H:;
        }
    }
    for(int i=0;i<n;++i)
        putchar(col[i]?'B':'W');

    for(int i=0;i<m;++i){
        printf("\n%d",w[i]?w[i]:1000000000);
    }
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 22016
#include <iostream>

using namespace std;

int main()
{
    int A,guarda,comp;
    int soma = 0;
    ios::sync_with_stdio(false);
    cin >> A;
    guarda = A;
    while (A>0)
    {
        comp = A%10;
        soma += comp;
        A /= 10;
    }
    if(guarda%soma == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations as perm
from math import factorial

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

all_sum = 0
for a in perm(XY):
    sum_num = 0
    for j in range(N-1):
        x1, y1 = a[j]
        x2, y2 = a[j+1]
        r = (abs(x1-x2)**2 + abs(y1-y2)**2)**(1/2)
        sum_num += r
    all_sum += sum_num

print(all_sum / factorial(N))

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

int main(){
  int a, b, c, x, ans = 0;
  cin >> a >> b >> c >> x;
  
  for ( int i = 0; i <= a; i++ ){
    for ( int j = 0; j <= b; j++ ){
      for ( int k = 0; k <= c; k++ ){
        if ( 500 * i + 100 * j + 50 * k == x )
          ans ++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<ll> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<ll> suff(n);
    suff[n-1] = arr[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suff[i] = (suff[i+1] + arr[i])%mod;
    }
    long long ans = 0;
    for(int i=0;i<n-1;i++)
    {
        ans = (ans + (arr[i]*suff[i+1])%mod)%mod;
    }
    cout<<ans;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

ll n;
int ans = inf;
vector<ll> pow6, pow9;

void dfs(int d, int remain) {
  if (remain < 0) return;
  if (remain < 6 && remain < 9) {
    chmin(ans, d+remain);
    return;
  }
  auto f = [&](int x, int remain, vector<ll> &p) {
    int l = 0, r = p.size();
    while (l+1 < r) {
      int mid = (l+r)/2;
      if (p[mid] <= remain) l = mid; else r = mid;
    }
    remain -= p[l];
    return remain;
  };
  if (remain >= 6)
    dfs(d+1, f(6, remain, pow6));
  if (remain >= 9)
    dfs(d+1, f(9, remain, pow9));
}

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

  std::cin >> n;
  pow6.pb(0), pow9.pb(0);
  for (ll pv = 6; pv <= n; pv*=6)
    pow6.pb(pv);
  for (ll pv = 9; pv <= n; pv*=9)
    pow9.pb(pv);
  ll remain = n, d = 0;
  dfs(d, remain);
  std::cout << ans << "\n";
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
string S;

signed main()
{
  cin >> N;
  cin >> S;

  int ans = 1;
  char pre;
  REP(n,S.size()) {
    if(n == 0) {
      pre = S[n];
    } else {
      if(pre != S[n]) {
        ans++; pre = S[n];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{

    long long n;
    long long k;
    long long ans;

    cin >> n >> k;
    ans = n % k;
    while (ans > (ans - k) * -1)
        ans = (ans - k) * -1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int k,s,i,count=0,x,y;
    scanf("%d %d",&k,&s);
    for(x=0; x<=k; x++)
    {
        for(y=0; y<=k; y++)
        {
            if(0<=(s-x-y)&&(s-x-y)<=k)
            {
                count++;
            }
        }

    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 1700
#include<string>
#include<iostream>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  int n = s.size(), ans = 0;
 
  int cnt = 0;
  for(int i=0; i<n; i++){
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C') {
      cnt++;
      ans = max(ans, cnt);
    }
    else cnt = 0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
int n, k;
int[] w;

void main() {
	auto ip = readAs!(int[]);
	n = ip[0], k = ip[1];
	foreach(i; 0..n) w ~= ri;

	writeln(solve());
}

int check(long p) {
	int i = 0;
	foreach(j; 0..k) {
		// 載せた荷物の重量の合計s
		long s = 0;
		// 最大積載量を越えない間、荷物を載せつづける。	
		while(s + w[i] <= p) {
			s += w[i];
			i++;
			// 全部乗せ終わった場合
			if(i == n) return n;
		}

		// ここに来たら、次のトラックに載せることにする。
	}
	return i;
}

// 最大積載量Pについて二分法を用いる。
long solve() {
	long left = 0, right = long.max;
	// 二分法が終わってないとき
	// 終わるのは、leftが条件を満たさない最大のPの値をとり、
	// rightが条件を満たす最小のPの値をとるときである。
	// この「条件を満たす境界」は一箇所のみ
	while(right - left > 1) {
		long mid = (left + right) / 2;
		// Pをmidとしてやる
		int v = check(mid); // 載った荷物の数
		if(v >= n) right = mid;
		else left = mid;
	}
	return right;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 3736
#include<stdio.h>
#include<string.h>

#define MAXLEN 100

int main(){
  char s[MAXLEN+1];
  int i, len;
  
  scanf("%s", s);
  len = strlen(s);
  
  for(i=0; i<len; i++){
    printf("x");
  }
  
  return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map(String::toInt)
    val range = 1..n
    println(range.filter { sumKeta(it) in a..b }.sum())
}

fun sumKeta(num: Int): Int {
    val str = num.toString()
    var sum = 0
    str.forEach { sum += it.toString().toInt() }
    return sum
}

Measured memory_bytes: 38704