akhauriyash/Code-Regression huggingface dataset:
N, A, B = map(int, input().split())

def sum_of_digits(n):
   result   = 0
   quotient = n
   while quotient:
       result   +=  quotient % 10
       quotient //= 10
   return result

ans = 0
for i in range(1, N + 1):
    sd = sum_of_digits(i)
    if sd >= A and sd <= B:
        ans += i

print(ans, flush=True)


Measured memory_bytes: 9104
n,m=map(int,input().split())

G=[[0]*n for i in range(n)]
V=[0 for i in range(n)]

A=[]
B=[]
for i in range(m):
	a,b=map(int,input().split())
	A.append(a-1)
	B.append(b-1)
	G[a-1][b-1]=G[b-1][a-1]=1

def dfs(v):
	V[v]=1
	for v2 in range(n):
		if G[v][v2]==1 and V[v2]==0:
			dfs((v2))
			
ans=0
for i in range(m):
	G[A[i]][B[i]]=G[B[i]][A[i]]=0
	V=[0 for i in range(n)]
	dfs(0)
	if sum(V)!=n:
		ans+=1
	G[A[i]][B[i]]=G[B[i]][A[i]]=1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x;
	cin>>x;
	char u[20];
	int i=0;
	while(x!=0){
		x--;
		int j=x%26;
		u[i]=char(j+'a');
		x/=26;
		i++;
	}
	while(i--){
		cout<<u[i];
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll r,g,b;
	cin>>r>>g>>b;
	if(((r*100)+(g*10)+b)%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

int main(void){
  int n, m;
  while(cin >> n >> m, n){
    vector<int> a(n);
    for(auto& _a: a){
      cin >> _a;
    }
    int ans = -1;
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        if(a[i] + a[j] <= m){
          ans = max(ans, a[i] + a[j]);
        }
      }
    }
    if(ans == -1){
      cout << "NONE" << endl;
    }else{
      cout << ans << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3076
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = Integer.parseInt(sc.next());
        switch(D) {
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                break;
            case 23:
                System.out.println("Christmas Eve Eve");
                break;
            case 24:
                System.out.println("Christmas Eve");
                break;
            case 25:
                System.out.println("Christmas");
                break;
        }
    }
}

Measured memory_bytes: 21972
def main():
    S = input()
    cnt = 1
    bf = S[0]
    stmp = ''
    for i, s in enumerate(S):
        if i == 0:
            continue
        stmp += s
        if stmp == bf:
            continue
        cnt += 1
        bf = stmp
        stmp = ''

    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9048
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class MinCostFlow:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]


    def add_edge(self, fr, to, cap, cost):
        G = self.g
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr])-1])

    def flow(self, s, t, f):
        N = self.n
        G = self.g
        INF = 10**18

        prevv = [0]*N
        preve = [0]*N

        res = 0
        while f > 0:
            dist = [INF]*N
            dist[s] = 0
            update = True

            while update:
                update = False
                for v in range(N):
                    if dist[v] == INF: continue
                    for i in range(len(G[v])):
                        to, cap, cost, rev = G[v][i]
                        if cap > 0 and dist[to] > dist[v]+cost:
                            dist[to] = dist[v]+cost
                            prevv[to] = v
                            preve[to] = i
                            update = True

            if dist[t] == INF:
                return -1

            d = f
            v = t
            while v != s:
                d = min(d, G[prevv[v]][preve[v]][1])
                v = prevv[v]
            f -= d
            res += d*dist[t]

            v = t
            while v != s:
                e = G[prevv[v]][preve[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prevv[v]

        return res
            

V, E, F = MAP()
mcf = MinCostFlow(V)
for _ in range(E):
    u, v, c, d = MAP()
    mcf.add_edge(u, v, c, d)
print(mcf.flow(0, V-1, F))



Measured memory_bytes: 6984
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int rec(li x){
  return x%__builtin_popcount(x);
}

int f(li x){
  static vector<int> ans(x+2,-1);
  if(x==0) return 0;
  return f(rec(x))+1;
}

li div(string s,int a){
  int n=s.size(),r=0;
  rep(i,n){
    r*=2;
    r+=(s[i]-'0');
    r%=a;
  }
  return r;
}

int main(){
  
  
  
  int n; cin >>n;
  string x; cin >>x;
  int ppc=0;
  rep(i,n) if(x[i]=='1') ppc++;
  int flag=-1;
  if(ppc==1) rep(i,n) if(x[i]=='1') flag=i;
  vector<int> pp(n,1),p(n,1),pm(n,1);
  if(ppc-1==1) pm[0]=0;
  repa(i,1,n){
    pp[i]=pp[i-1]*2%(ppc+1);
    if(ppc-1) pm[i]=pm[i-1]*2%(ppc-1);
  }
  int sp=0,s=0,sm=0;
  rep(i,n){
    if(x[i]=='1'){
      (sp+=pp[n-1-i])%=ppc+1;
      if(ppc-1) (sm+=pm[n-1-i])%=ppc-1;
    }
  }
  if(df)print(ppc+1,":",pp);
  if(df)print(ppc-1,":",pm);
  if(df)print(sp,sm);
  rep(i,n){
    if(flag==i){
      print(0);
      continue;
    }
    int t=x[i]-'0';
    x[i]=t^1+'0';
    li a;
    if(t==0){
      a=(sp+pp[n-i-1])%(ppc+1);
    }else{
      a=(sm-pm[n-1-i]+ppc-1)%(ppc-1);
    }
    if(df)print("a",a);
    print(1+f(a));
    x[i]=t+'0';
  }

}


Measured memory_bytes: 6220
#include<bits/stdc++.h>
using namespace std;
int h,n,a[1001],b[1001],f[1001][10001];//用前i个打掉j点血最少要用的能量 
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int i=1;i<=h;i++)
		f[0][i]=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=h;j++)
		{
			if(j<=a[i])
				f[i][j]=min(b[i],f[i-1][j]);
			else
				f[i][j]=min(f[i-1][j],f[i][j-a[i]]+b[i]);
			
		}
	cout<<f[n][h]<<endl;
	return 0;
} 

Measured memory_bytes: 39296
sx,sy,tx,ty=map(int, input().split())  

ans=['R'*(tx-sx)+'U'*(ty-sy)+'L'*(tx-sx)+'D'*(ty-sy)+'D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+(tx-sx+1)*'L'+'D'*(ty-sy+1)+'R']
print(*ans)

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



int main(){
	int n;cin>>n;
	vector<vector<int> > arr(n,vector<int>(3));
	
	int a,b,c;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		arr[i][0] = a;
		arr[i][1] = b;
		arr[i][2] = c;
	}
	
	vector<int> dp(3);
	dp[0] = arr[0][0];
	dp[1] = arr[0][1];
	dp[2] = arr[0][2];
	
	for(int i=1;i<n;i++){
		vector<int> new_dp(3);
		new_dp[0] = max(dp[1] + arr[i][0], dp[2] + arr[i][0]);
		new_dp[1] = max(dp[0] + arr[i][1], dp[2] + arr[i][1]);
		new_dp[2] = max(dp[1] + arr[i][2], dp[0] + arr[i][2]);
		swap(dp,new_dp);		
	}	
	int ans = max(dp[0],max(dp[1],dp[2]));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

const int mod = TEN(9)+7;

ll inv[200010];
ll fac[200010], fac_inv[200010];
ll C(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}
void comb_init()
{
    int N = 200005;
    inv[1] = 1;
    for (int i = 2; i <= N; ++i) {
        inv[i] = mod - (mod / i) * inv[mod % i] % mod;
    }
    fac[0] = fac_inv[0] = 1;
    for (int i = 1; i <= N; ++i) {
        fac[i] = (fac[i - 1] * i) % mod;
        fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
    }
}

signed main()
{
    comb_init();
    int S; cin >> S;

    int ans = 0;
    int cur = 0;

    while (S - 2 > 0) {
        S -= 2;

        ans += C(S - 1, cur);
        ans %= mod;

        cur++;
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 8464
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    lint mod = 1e+9 + 7;
    int n;
    cin >> n;
    int temp;
    vector<int> c(1);
    cin >> c[0];
    for (int i = 1; i < n; i++) {
        cin >> temp;
        if (c.back() != temp) {
            c.push_back(temp);
        }
    }
    int m = c.size();
    // last[i]:今まで見た中で、右端の色がiなる最後のdp
    unordered_map<int, lint> last;
    // dp[i]:[0,i)までの答え
    vector<lint> dp(m + 1);
    dp[0] = 1;
    for (int i = 0; i < m; i++) {
        dp[i + 1] = (dp[i] + last[c[i]]) % mod;
        last[c[i]] = dp[i + 1];
    }
    cout << dp[m] << endl;
}

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

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

using namespace std;
using ll = long long;

void solve();

bool comp(pair<int, int> a, pair<int, int> b){
    return (a.first > b.first || (a.first == b.first && a.second > b.second)); 
}

int main(void){
    int N, M; cin >> N >> M;
    priority_queue<int, vector<int>, greater<int>> A;
    rep(i, N){
        int a; cin >> a;
        A.push(a);
    }

    vector<pair<int, int>> K(M);
    rep(i, M){
        int b, c; cin >> b >> c;
        K[i] = make_pair(c, b);
    }
    sort(K.begin(), K.end(), comp);
    rep(i, M){
        int trial = 0;
        while(trial < K[i].second && A.top() < K[i].first){
            A.pop();
            A.push(K[i].first);
            trial++;
        }
    }

    ll ans = 0;
    rep(i, N){
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;

    return 0;
}

void solve(){}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  string s;cin>>s;

  int r = 0,l = 0;
  rep(i,n){
    if(s[i] == '('){
      ++r;
      //else --l;
    }else{
      if(r == 0)++l;
      else --r;
    }
  }
  
  rep(i,l)cout<<'(';
  rep(i,s.size())cout<<s[i];
  rep(i,r)cout<<')';

  cout<<endl;

  return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << (w * h % 2 == 1 ? ".5" : ".0") << " " << (2 * x == w && 2 * y == h);

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	char name[6]={"ABCDE"};
	int i,j,k,a,b,sum,mx,cnt;
	while(1) {
		cin>>a>>b;
		if(!a&&!b) break;
		cnt=0;
		mx=a+b;
		for(i=1;i<5;i++) {
			cin>>a>>b;
			if(mx<a+b) mx=a+b,cnt=i;
		}
		cout<<name[cnt]<<" "<<mx<<endl;
	}
}

Measured memory_bytes: 3084
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}


void solve()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<int> c(n);
	input(a);
	input(b);
	for (int i = 1; i <= n; i++)
		c[i - 1] = i;
	
	vector<int> ans;

	int t = 1;
	if (c == a)
		ans.pb(t);
	if (c == b)
		ans.pb(t);

	while (next_permutation(all(c)))
	{
		t++;
		if (c == a)
			ans.pb(t);
		if (c == b)
			ans.pb(t);
	}
	cout << abs(ans[0] - ans[1]);


}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static String[] map;
	public static int[][] steps;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			String wh = sc.nextLine();
			String[] sp = wh.split("\\s+");
			int w = Integer.parseInt(sp[0]);
			int h = Integer.parseInt(sp[1]);
			if(w == 0) break;
			
			int num = 2 * h - 1;
			map = new String[num];
			for(int i = 0; i < num; i++) {
				map[i] = sc.nextLine();
			}

			steps = new int[h][w];/* 歩数 */
			walk(0, 0, 0);
			
			System.out.println(steps[h-1][w-1]);
		}
	}
	
	public static void walk(int h, int w, int depth) {
		depth++;
		if(steps[h][w] == 0) {
			steps[h][w] = depth;
		} else {
			if(steps[h][w] > depth) {
				steps[h][w] = depth;
			} else {
				return;/* コスト同or大のため終了 */
			}
		}

		/* 上 */
		if(h * 2 - 1 > 0) {
			if(map[h*2-1].charAt(w*2) == '0') {
				walk(h-1, w, depth);
			}
		}
		/* 右 */
		if(w*2+1 < map[0].length()) {
			if(map[h*2].charAt(w*2+1) == '0') {
				walk(h, w+1, depth);
			}
		}
		/* 下 */
		if(h * 2 + 1 < map.length) {
			if(map[h*2+1].charAt(w*2) == '0') {
				walk(h+1, w, depth);
			}
		}
		if(0 < w*2-1) {/* 左 */
			if(map[h*2].charAt(w*2-1) == '0') {
				walk(h, w-1, depth);
			}
		}
	}

}



Measured memory_bytes: 48808
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
int main()
{
    IOS
    string str; cin>>str;
    int n = str.length();
    int ans = 0,temp = 0;
    for(int i=0;i<n;i++)
    {
        if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T')
        {
            temp++;
        }
        else{
            ans = max(ans,temp);
            temp = 0;
        }
    }
    ans = max(ans,temp);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

x, move, d = map(int, input().split())

num = int(abs(x)/d)
ans = 0

if move <= num:
    if np.sign(x) == 1:
        ans = x-d*move
    else:
        ans = x+d*move

elif (move-num)%2==0:
    if np.sign(x) == 1:
        ans = x-d*num
    else:
        ans = x+d*num

elif (move-num)%2!=0:
    if np.sign(x) == 1:
        ans = x-d*(num+1)
    else:
        ans = x+d*(num+1)


print(abs(ans))


Measured memory_bytes: 27004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 = 1LL << 60;
const int MAX = 1000000;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> left(n, 0);
    vector<int> right(n, 0);
    left[0] = 0;
    right[n - 1] = 0;
    for (int i = 1; i < n; i++) {
        left[i] += left[i - 1];
        if (s[i - 1] == 'W') left[i]++;
    }
    for (int i = n - 2; i >= 0; i--) {
        right[i] += right[i + 1];
        if (s[i + 1] == 'E') right[i]++;
    }
    int ans = MAX;
    for (int i = 0; i < n; i++) {
        chmin(ans, left[i] + right[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
list_s = ["S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13"]
list_h = ["H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13"]
list_c = ["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13"]
list_d = ["D1","D2","D3","D4","D5","D6","D7","D8","D9","D10","D11","D12","D13"]

num = int(input())

for i in range(num):
	c,cn = input().split(" ")
	if c == "S":
		if str(c+cn) in list_s:
			a = list_s.index(str(c+cn))
			list_s.pop(a)
	if c == "H":
		if str(c+cn) in list_h:
			a = list_h.index(str(c+cn))
			list_h.pop(a)
	if c == "C":
		if str(c+cn) in list_c:
			a = list_c.index(str(c+cn))
			list_c.pop(a)

	if c == "D":
		if str(c+cn) in list_d:
			a = list_d.index(str(c+cn))
			list_d.pop(a)

[print(i[0:1],i[1:]) for i in list_s]
[print(i[0:1],i[1:]) for i in list_h]
[print(i[0:1],i[1:]) for i in list_c]
[print(i[0:1],i[1:]) for i in list_d]



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=(int)n; i++)
#define FF(i,n) for (int i=0; i<(int)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < int , int >
#define re(x) (int)x.size()
#define y1 u228
using namespace std;
typedef long long ll;
const int N = 2e5+228;
const int big = 2e9;
const int md = 1e9 + 7;
int k,n;
ll ans;
ll go(int x,int n){
    if (x>n) return 0ll;
    return (n-x)/k+bool(x!=0);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    cin>>n>>k;
    F(i,n){
        if ((k-i%k)%k!=i%k) continue;
        //cout<<i<<endl;
        ans+=go((k-i%k)%k,n)*1ll*go(i%k,n);
    }
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_V = 100000;
const int MAX_LOG_V = 17;

vector<int> g[MAX_V]; //??°???????????£??\?????????
int root;

int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    rep(i,g[v].size()){
        if(g[v][i] != p) dfs(g[v][i], v, d + 1);
    }
}

void init(int v){
    dfs(root, -1, 0);
    rep(i,MAX_LOG_V - 1){
        rep(j,v){
            if(parent[i][j] < 0) parent[i + 1][j] = -1;
            else parent[i + 1][j] = parent[i][parent[i][j]];
        }
    }
}

int lca(int u, int v){
    if(depth[u] > depth[v]) swap(u, v);
    rep(i,MAX_LOG_V){
        if((depth[v] - depth[u]) >> i & 1){
            v = parent[i][v];
        }
    }
    if(u == v) return u;

    //????????¢?´¢
    for(int i = MAX_LOG_V - 1; i >= 0; i--){
        if(parent[i][u] != parent[i][v]){
            u = parent[i][u];
            v = parent[i][v];
        }
    }
    return parent[0][u];
}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int v;
            cin >> v;
            g[i].emplace_back(v);
            g[v].emplace_back(i);
        }
    }

    init(n);

    int q;
    cin >> q;
    rep(i,q){
        int u, v;
        cin >> u >> v;
        cout << lca(u,v) << endl;
    }
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

int main()
{
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  queue<P> que;
  que.push(make_pair(0,0));
  vector<vector<int>> dist(H,vector<int> (W,-1));
  dist[0][0]=1;
  while(!que.empty()){
    P v = que.front();
    que.pop();
    REP(i,4){
      if(v.second+dy[i]<0||v.first+dx[i]<0||v.second+dy[i]>H-1||v.first+dx[i]>W-1||A.at(v.second+dy[i]).at(v.first+dx[i])=='#'||dist.at(v.second+dy[i]).at(v.first+dx[i])!=-1) continue;
      que.push(make_pair(v.first+dx[i],v.second+dy[i]));
      dist.at(v.second+dy[i]).at(v.first+dx[i])=dist.at(v.second).at(v.first)+1;
    }
  }

  int cnt = 0;
  REP(i,H){
    REP(j,W){
      if(A[i][j]=='#'){
        cnt++;
      }
    }
  }

  if(dist[H-1][W-1]==-1){
    cout << -1 << endl;
  }else{
    cout << H*W-dist[H-1][W-1]-cnt << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;

#define MAX 1000000005

int main(){
  string s; cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size()-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
// #define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}



 
    
void test_case() {

    
    int n,X,Y;
	cin>>n>>X>>Y;
 
	vector<vector<int> >v(n);
	for(int i=0;i<n-1;i++)
	{
		v[i].push_back(i+1);
		v[i+1].push_back(i);
	}
	v[X-1].push_back(Y-1);
	v[Y-1].push_back(X-1);
 
 
	vector<int> R(n+1,0);
	for(int s=0;s<n;s++)
	{
		queue<int>Q;
		Q.push(s);
		vector<int>d(n,INF);d[s]=0;
		while(!Q.empty())
		{
			int p=Q.front();Q.pop();
			for(int j=0;j<v[p].size();j++)
			{
				if(d[v[p][j]]>d[p]+1)
				{
					d[v[p][j]]=d[p]+1;
					Q.push(v[p][j]);
 
				}
			}
		}
		for(int i=0;i<n;i++)
			if(d[i]!=INF)R[d[i]]++;
	}
 
	for(int i=1;i<n;i++)
		cout<<R[i]/2<<endl;

    




}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------
ll n, m, x;
ll c[13];
ll a[13][13];

int main(){
    cin>>n>>m>>x;
    for(ll i=0;i<n;++i){
        cin>>c[i];
        for(ll j=0;j<m;++j){
            cin>>a[i][j];
        }
    }
    ll ans = INF;
    for(ll bit=0;bit<(1<<n);++bit){
        vector<ll> s(m, 0);
        ll num = 0;
        for(ll i=0;i<n;++i){
            if((1<<i) & bit){
                num += c[i];
                for(ll j=0;j<m;++j){
                    s[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        for(ll i=0;i<m;++i){
            if(s[i] < x){
                flag = false;
                break;
            }
        }
        if(flag){
            ans = min(ans, num);
        }
    }
    if(ans == INF){
        ans = -1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3640
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }

    let d = b - a;
    let mut sum = 0;
    for i in 1..d {
        sum += i;
    }
    sum -= a;
    println!("{}", sum);
}

Measured memory_bytes: 4352
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    string S = Console.ReadLine();
    int min = int.MaxValue;
    for (int i = 0; i < S.Length-2; i++) {
      min = Math.Min(min, Math.Abs(753-int.Parse(S.Substring(i, 3))));
    }
    Console.WriteLine(min);
  }

  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
}


Measured memory_bytes: 13140
// ????????°????????????????????????????????????????±???????O(|V|^2)?:cycledetectDirected()
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

// ????????°????????§??°
#define MAX_V 100000
// ??°????????????????????°
int V;
vector <int> graph[MAX_V];
bool vis[MAX_V];
vector <int> list;
int indeg[MAX_V];

void topologicalsort() {
  memset(indeg, 0, sizeof(indeg));
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      int p = graph[i][j];
      indeg[p]++;
    }
  }

  for (int i = 0; i < V; i++) {
    if (indeg[i] == 0 && !vis[i]) {
      queue<int> que;
      que.push(i);
      vis[i] = true;
      while (!que.empty()) {
	int p = que.front(); que.pop();
	list.push_back(p);

	for (int j = 0; j < graph[p].size(); j++) {
	  int np = graph[p][j];
	  indeg[np]--;
	  if (vis[np]) continue;
	  if (indeg[np] == 0) {
	    vis[np] = true;
	    que.push(np);
	  }
	}
      }
    }
  }
}

int main() {
  int E;
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    graph[s].push_back(t);
  }
  topologicalsort();

  for (int i = 0; i < list.size(); i++) {
    cout << list[i] << endl;
  }
}

Measured memory_bytes: 4468
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let k = get!();
    
    let mut ans = 0.0;
    
    for i in 1 .. n+1 {
        if i >= k {
            ans += 1.0 / n as f64;
        } else {
            let mut p = 1.0 / n as f64;
            let mut e = i;
            while e < k {
                p *= 0.5;
                e *= 2;
            }
            ans += p;
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector <int> edges[100005];

void dfs(vector <int> &dist, int cur, int par, int k = 0) {
    dist[cur] = k;
    for (int ch : edges[cur]) {
        if (ch == par) continue;
        dfs(dist, ch, cur, k + 1);
    }
}

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

    int n, u, v;
    cin >> n >> u >> v;
    u--, v--;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector <int> u_dist(n), v_dist(n);
    dfs(u_dist, u, -1);
    dfs(v_dist, v, -1);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (u_dist[i] < v_dist[i]) {
            ans = max(ans, v_dist[i] - 1);
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,x;cin>>n;
    // int a,b,c;cin>>a>>b>>c;
    string str;cin>>str;

    // vector<int> l(n);
    // vector<string> s(n);
    if(n>=3200)cout<<str;
    else cout<<"red";
    // for(int i=0;i<n;i++){

    // }



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<LL,LL>
#define MAX 100006
#define CASE(i) printf("Case %d: ", i);
#define CSH(i) printf("Case #%d: ", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)
#define CHECK_BIT(var,pos) ((var & (1 << pos)) == (1 << pos))


LL MOD = 1000000007;

using namespace std;

LL bigmod(LL b, LL p, LL m)
{
    if(p==0)  return 1;
    if(p%2==0)
    {
        LL x = bigmod(b,p/2,m);
        return (x%m * x%m)%m;
    }
    else return ((b%m)*bigmod(b,p-1,m)%m)%m;
}


LL MODINVERSE(LL a)
{
    return bigmod(a, MOD-2, MOD);
}

int main()
{
    LL n;
    scanf("%lld", &n);
    printf("%lld", n*(n+1)/2);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int g[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int a,b;

    cin >> a >> b;

    if(g[a] == g[b]){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
func main() {
    let N = Int(readLine()!)!
    let S = Array(readLine()!)
    
    var count: [Character: Int] = ["R": 0, "G": 0, "B": 0]
    for c in S {
        count[c]! += 1
    }
    
    var ans = 1
    for c in "RGB" {
        ans *= count[c]!
    }
    
    let rgb: Set<Character> = ["R", "G", "B"]
    for i in 1...((N - 1) / 2) {
        var first = 0
        while first + 2 * i < N {
            let mid = first + i
            let last = first + 2 * i
            if rgb.isSubset(of: [S[first], S[mid], S[last]]) {
                ans -= 1
            }
            first += 1
        }
    }
    
    print(ans)
}

main()


Measured memory_bytes: 8108
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { A: number, B: number} => {
  const [A, B] = lines[0].split(' ').map(line => +line)
  const obj = { A, B }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines)
  const sum: number = A + B
  const diff: number = A - B
  const multi: number = A * B
  const result: number[] = [sum, diff, multi].sort((a, b) => b - a)
  return `${result[0]}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7628
from math import factorial

n = int(input())

pos = [tuple(map(int, input().split())) for _ in range(n)]

def dist(a, b):
    return ((pos[a][0] - pos[b][0]) ** 2 + (pos[a][1] - pos[b][1]) ** 2) ** (1/2)

ans = 0
def calc(status, total, prev):
    global ans
    if status == (1<<n) - 1:
        ans += total
        return
    for i in range(n):
        if status>>i&1:
            continue
        else:
            calc(status|(1<<i), total + dist(prev, i), i)

for i in range(n):
    calc(1<<i, 0, i)

print('{:.6f}'.format(ans/factorial(n)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int a, b; cin >> a >> b;
    cout << a*b - a - b + 1;
}


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

int main() {
    int a,b,c,x;
    cin >> a >> b >> c;
    
    if(a > b) {
        x = b;
        b = a;
        a = x;
    }
    
    if(b > c) {
        x = c;
        c = b;
        b = x;
    }
    
    if(a > b) {
        x = b;
        b = a;
        a = x;
    }
    
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3048
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				B[i][j] = scan.nextInt();
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					C[i][j] += (long) A[i][k] * (long) B[k][j];
				}
				if(j != l -1){
					System.out.printf("%d ", C[i][j]);
				} else{
					System.out.printf("%d\n", C[i][j]);
				}
			}
		}
	}
}

Measured memory_bytes: 70796
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		for(int i=0; i<K; i++) {
			if(A >= B) {
				B *= 2;
			}else if(B >= C) {
				C *= 2;
			}
		}

		if(A < B && B < C) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}


}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;

    vi a(n);
    vi b(n - 1);
    fo(i, n - 1) cin >> b[i];

    int soma = b[0];
    fo(i, n - 2) {
        soma += min(b[i], b[i + 1]);
    }
    soma += b[n - 2];

    cout << soma << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> P(M),Y(M);
  for(int i=0;i<M;i++)cin >> P[i] >> Y[i];
  vector<pair<pair<int,int>,int>> q(M);
  for(int i=0;i<M;i++){q[i]=make_pair(make_pair(P[i],Y[i]),i);}
  sort(q.begin(),q.end());
  q[0].first.second=1;
  for(int i=1;i<M;i++){
    if(q[i].first.first==q[i-1].first.first){q[i].first.second=q[i-1].first.second+1;}
    else{q[i].first.second=1;}
  }
  vector<pair<int,pair<int,int>>> w(M);
  for(int i=0;i<M;i++){w[i]=make_pair(q[i].second,make_pair(q[i].first.first,q[i].first.second));}
  sort(w.begin(),w.end());
  for(int i=0;i<M;i++){
    int f=w[i].second.first; int s=w[i].second.second;
    printf("%06d%06d\n",f,s);
  }
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long dp[6000];
int a[6000];
void add(int x){
	for(int i=k-1;i>=x;i--)
		dp[i]+=dp[i-x];
}
void del(int x){
	for(int i=x;i<=k-1;i++)
		dp[i]-=dp[i-x];
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		add(a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		del(a[i]);
		bool need=false;
		for(int j=0;j<k;j++){
			if(dp[j]&&j+a[i]>=k)
				need=true;
		}
		ans+=!need;
		add(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;
llong mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,c1,c2;
  int cnt=0;
  cin>>n;

    for(int i=1;i<=9;i++){
      for(int j=1;j<=9;j++){
        c1=0;
        c2=0;
        for(int k=1;k<=n;k++){
          int m=k%10;
          int q=log10(k);
          int l=pow(10,q);
          l=k/l;
        if(i==m&&j==l)c1++;
        if(j==m&&i==l)c2++;
        }
        cnt+=c1*c2;
      }
    }

  cout<<cnt<<endl;
  return 0;
  }


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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n, greater<int>());
  int ans = 0;
  for(int i=0; i<n; i++){
    if(i%2==0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a,b[110],c[110],ans =0;
   
    cin >> a;
   
    for (int i = 0; i < a; ++i) cin >> b[i];
  
  for(int i=0;i<a;i++) cin >> c[i];  
  
  for(int i=0;i<a;i++){
    int ant =0;
    
    for(int k =0;k<=i;k++){
      ant += b[k];
    }
    for(int j=i;j<a;j++){     
      ant +=c[j];
    }
    
    ans =max(ans,ant);
    
  }
  
  cout << ans << endl;
}
      
  
  
  

   

Measured memory_bytes: 256