akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
F = Array.new(N) { gets.split.map(&:to_i) }
P = Array.new(N) { gets.split.map(&:to_i) }
max = -1.0 / 0
(1...1024).to_a.each {|i| ret = 0; N.times {|n| cnt = 0; 10.times {|j| cnt += 1 if F[n][j] == 1 && i & 2 ** j > 0 }; ret += P[n][cnt] }; max = ret > max ? ret : max }
puts max

Measured memory_bytes: 1916
n = int(input())
a = []
for i in range(n):
    arr = list(map(int,input().split()))
    a.append(arr)
a.sort(key = lambda x: x[1])
time = 0
for i in range(n):
    time += a[i][0]
    if time > a[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 53716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool ariv[101][101];
static const int dx[4] = {1,0,-1,0};
static const int dy[4] = {0,-1,0,1};
int H,W;
void dfs(vector<string> grid, int x, int y, char s){
  ariv[y][x] = true;
  REP(r,4){
    if(x+dx[r]>=0&&x+dx[r]<W&&y+dy[r]>=0&&y+dy[r]<H&&ariv[y+dy[r]][x+dx[r]]==false
        &&grid[y+dy[r]][x+dx[r]]==s){
      dfs(grid,x+dx[r],y+dy[r],s);
    }
  }
}
int main(void){
  while(cin>>H>>W){
    if(H==0) break;
    vector<string> grid;
    memset(ariv,0,sizeof(ariv));
    REP(i,H){
      string tmp;
      cin>>tmp;
      grid.push_back(tmp);
    }
    int ans = 0;
    REP(y,H)REP(x,W){
      if(ariv[y][x]==false){
        ans++;
        dfs(grid,x,y,grid[y][x]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    auto B = A;
    for(int k=0; k<N; k++) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
            }
        }
    }

    if(A == B) {
        int64_t ans = 0;
        for(int i=0; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                bool flag = true;
                for(int k=0; k<N; k++) {
                    if(i == k || j == k) continue;
                    if(B[i][j] == B[i][k] + B[j][k]) flag = false;
                }
                if(flag) {
                    ans += B[i][j];
                }
            }
        }
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    //int a,b,c;
    //string s;
    int a;
    cin>>a;
    
    int b = a / 500;
    int c = (a % 500) / 5;
    
    cout << b * 1000 + c * 5 << endl;
    return 0;
    
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
string S = "";

int main() {
	scanf("%lld %lld", &N, &K);
	cin >> S;
	S[K - 1] = tolower(S[K - 1]);
	cout << S << " ";
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
N, K = map(int, input().split())
dice = list(map(int, input().split()))
expected = []
for i in range(N):
    expected.append((dice[i] + 1) / 2)

ans = sum(expected[:K])
tmp = ans
for i in range(N - K):
    tmp = tmp + expected[i + K] - expected[i]
    ans = max(ans, tmp)

print(ans)


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3556
class Graph:
    class Edge:
        def __init__(self, to, cost, fare):
            """
            :param to:  終点ノード
            :param cost: 辺の重み
            """
            self.to, self.cost, self.fare = to, cost, fare

    def __init__(self, n, directed=False, decrement=True, edges=[]):
        self.n = n
        self.directed = directed
        self.decrement = decrement
        self.edges = [[] for _ in range(self.n)]
        self.parent = [-1]*self.n
        self.info = [-1]*self.n
        self.fare_max = 0
        for x, y, cost, fare in edges:
            self.add_edge(x, y, cost, fare)
            if fare > self.fare_max:
                self.fare_max = fare

    def add_edge(self, x, y, cost, fare):
        if self.decrement:
            x -= 1
            y -= 1
        self.edges[x].append(self.Edge(y, cost, fare))
        if self.directed == False:
            self.edges[y].append(self.Edge(x, cost, fare))
        if fare > self.fare_max:
            self.fare_max = fare

    def cut(self, x):
        return min2(x, self.fare_max * (self.n - 1))

    def dijkstra(self, start, S, INF=10**18):
        """
        :param start: スタート地点
        :return: スタート地点から各点への距離のリスト
        備考: heqpq の比較のための key は第一引数である点に注意（ =　heappush(heapq, (key,value))　）
        """
        res = [[INF] * (self.fare_max*self.n+1) for _ in  range(self.n)]
        if self.decrement:
            start -= 1
        money = self.cut(S)
        res[start][money] = 0
        next_set = [(0, start, money)]
        while next_set:
            dist, p, money = heappop(next_set)
            if res[p][money] < dist:
                continue
            for edge in self.edges[p]:
                q, cost, fare = edge.to, edge.cost, edge.fare
                temp_d = dist + cost
                if temp_d < res[q][self.cut(money-fare)] and money >= fare:
                    res[q][self.cut(money-fare)] = temp_d
                    heappush(next_set, (temp_d, q, self.cut(money - fare)))
        if self.decrement:
            return [[0]] + res
        else:
            return res

def max2(x,y):
    return x if x > y else y

def min2(x,y):
    return x if x < y else y



##############################################################################################################

import sys
input = sys.stdin.readline
from heapq import *
INF = 10**18  # 大きい数字

C, D = [], []
N, M, S = map(int, input().split())

graph = Graph(N, directed=False, decrement=True)
for _ in range(M):
    x, y, fare, cost = map(int, input().split())
    graph.add_edge(x, y, cost, fare)
for i in range(1,N+1):
    fare, cost = map(int, input().split())
    graph.add_edge(i,i, cost, -fare)
d = graph.dijkstra(1,S,INF=INF)
for i in range(2,N+1):
    print(min(d[i]))

Measured memory_bytes: 94996
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int x,y;
    cin>>x>>y;
    bool ok=false;
    vi a={1,3,5,7,8,10,12};
    vi b={4,6,9,11};
    vi c={2};
    rep(i,7) {
        rep(j,7) {
            if(a[i]==x&&a[j]==y) {
                ok=true;
                break;
            }
        }
    }
    rep(i,4) {
        rep(j,4) {
            if(b[i]==x&&b[j]==y) {
                ok=true;
                break;
            }
        }
    }
    if(x==2&&y==2) ok=true;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/

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

/*
use these format of input when number of inputs not provided
while(scanf("%lld",&n)!=EOF)
*/

#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< ll , ll >
#define vpii vector< pii >
#define mii unordered_map< ll , ll >
#define mci map< char , ll >
#define pq priority_queue
#define str string
#define len length()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl cout <<  endl
#define sp " "
#define all(ar) ar.begin(), ar.end()
#define itern(n) for (int i=0; i<n; i++)
#define ritern(n) for (int i=n-1; i>=0; i--)
#define sz(x) ((int)(x).size())
#define pi acos(1);                   /* pi */
#define inf (int(1e9+7))
#define fl(x) int(x)
#define mod %(inf)
#define yes "YES"
#define no "NO"
#define null NULL
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
//functions
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}


//#------------------------------complete template------------------------------#//



int main()
{
	fast;
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	vi a(n,0);
	for (int i=1; i<n; i++)
	{
		if (s[i]=='C' and s[i-1]=='A')a[i]=a[i-1]+1;
		else a[i]=a[i-1];
	}
	while(q--)
	{
		int x,y;
		cin >> x >> y;
		cout << a[y-1]-a[x-1];nl;
	}
	return 0;
}

Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
int main(){
  string s; cin >> s;
  int ss = (int)s.size();
  int ans = INF;
  rep(i,ss-1){
    if(s[i] != s[i+1])
      ans = min(ans,max(i+1,ss-i-1));
  }
  if(ans == INF) ans = ss;
  cout << ans << endl;
}

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

int main(){
	int N;
	cin >> N;
	vector<ll> B(N-1);
	rep(i,N-1){
		cin >> B[i];
	}
	
	vector<ll> A(N);
	A[0] = B[0];
	
	rep(i,N-2){
		A[i+1] = min(B[i],B[i+1]);
	}
	A[N-1] = B[N-2];
	
	ll ans = 0;
	rep(i,N){
		ans += A[i];
	}
	
	cout << ans << endl;
    return 0;
}



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



void solve(string N, long long K){
	vector<vector<vector<int>>> dp(N.size()+1, vector<vector<int>>(2, vector<int>(4, -1)));
	function<int(int, int, int)> f = [&](int i, int j, int k) -> int{
		if(k > 3){
			return 0;
		}
		if(i == N.size())return k == K;

		if(dp[i][j][k] != -1)return dp[i][j][k];
		int NN = N[i] - '0';
		int ma;
		if(j)ma = N[i] - '0';
		else ma = 9;
		dp[i][j][k] = 0;
		for(int l = 0;l <= ma;l++){
			dp[i][j][k] += f(i + 1, j && l == ma,k + (l == 0 ? 0 : 1));
		}
		return dp[i][j][k];
	};
	cout<<f(0, 1, 0)<<endl;
}

int main(){
    string N;
    cin >> N;
    long long K;
    scanf("%lld",&K);

    solve(N, K);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
signed main(){
    int n,k;cin>>n>>k;
    if((n+1)/2>=k)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);
A = A[1].split(' ').map(Number);

cnt = sort(A);
console.log(A.join(' '));
console.log(cnt);

function sort(A) {
  var cnt, flag, j, tmp;
  cnt = 0;
  flag = 1;
  while (flag) {
    flag = 0;
    for (j = A.length - 1; j > 0; j--) {
      if (A[j] < A[j-1]) {
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        cnt++;
      }
    }
  }
  return cnt;
}

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

int main(void)
{
 int a,b;
 cin >> a >> b;
 if(a<b) cout << "a < b" << endl;
 else if(a>b) cout << "a > b" << endl;
 else cout << "a == b" << endl;
 
 return 0;
}

Measured memory_bytes: 1156
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] a = new int[n];
        int xor = 0;
        for(int i=0;i<n;i++){
            a[i] = fs.nextInt();
        }
        StringJoiner sj = new StringJoiner(" ");
        if(n%2==0){
            for(int i=0;i<n;i++){
                xor^=a[i];
            }
            for(int i=0;i<n;i++){
                sj.add(String.valueOf(xor^a[i]));
            }
        }
        System.out.println(sj.toString());
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	long long sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	

	long long mindiff=10000000000;
	long long sunuke=a[0];
	long long diff;
	long long tanuki=sum-a[0];
	for (int i = 0; i < n-1; ++i)
	{
		diff=sunuke-tanuki;
		if (abs(diff)<mindiff){
			mindiff=abs(diff);
		}
		sunuke+=a[i+1];
		tanuki-=a[i+1];

	}
	cout<<mindiff<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);

  rep(i, N){
    cin >> a[i];
  }
  
  bool flag = true;
  rep(i, N){
    if (a[i]%2 == 0){
      if(a[i]%3!=0 && a[i]%5!=0) flag = false;
    }
   }
  
  if (flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main() {
    int n;
    cin>>n;
    int a[n+1];
    int b[n+1];
    int pre[n+1];
    int suf[n+2];
    pre[0]=0;
    for(int i=1 ; i<=n ; i++) {
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    for(int i=1 ; i<=n ; i++) {
        cin>>b[i];
    }
    suf[n+1]=0;
    for(int i=n ; i>=1 ; i--) {
        suf[i]=suf[i+1]+b[i];
    }
    int ans=0;
    for(int i=1 ; i<=n ; i++) {
        ans=max(ans,pre[i]+suf[i]);
    }
    cout<<ans;
}


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

using namespace std;
int main(){
  int i;
  cin>>i;
  int res=0;
  if(i<2){
    res=1;
  }else if(i<4){
    res=2;
  }else if(i<8){
    res=4;
  }else if(i<16){
    res=8;
  }else if(i<32){
    res=16;
  }else if(i<64){
    res=32;
  }else{
    res=64;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    ans_onaji = 0
    ans_dif = 0
    for i in range(1, n):
        for j in range(i, n):
            if i == j and i*j <= n-1:
                ans_onaji += 1
            elif i != j and i*j <= n-1:
                ans_dif += 1
            elif i*j > n-1:
                break
    print(ans_dif * 2 + ans_onaji)






if __name__ == "__main__":
    main()

Measured memory_bytes: 73440
int main(){
    int a,b,x,c=0;
    scanf("%d%d%d",&a,&b,&x);
    x=(x+499)/500; //[ml]→[本(500ml)]
    c+=fmin(a,2*b)*(x/2); //1000mlあたりの金額
    c+=fmin(a,b)*(x%2); //もう1本買う場合の金額
    printf("%d\n",c);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x1fffffffffffffff;
template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& i : a) cin >> i;
    const ll skip = 1 + (n & 1);
    vector<vector<ll>> dp(n + 2, vector<ll>(skip + 1, -INF));
    dp[0][0] = 0;
    for(ll i = 0; i <= n; i++) for(ll j = 0; j <= skip; j++){
        if(j < skip) chmax(dp[i + 1][j + 1], dp[i][j]);
        if(i < n) chmax(dp[i + 2][j], dp[i][j] + a[i]); // 1個選んだら1個選ばないのもセット
    }
    cout << dp[n + 1][skip] << endl; // なので floor(n / 2) * 2 + skip == n + 1 に答えが入る
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++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; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main(){
ll N;
cin >> N;

if(N == 1){
  print(0);
  return 0;
}

ll x = N - 1;
ll ans = 1;
for(int i = 1; i < x; i++) ans += i + 1;

print(ans);

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D=sc.nextInt();
		int x=sc.nextInt();
		int i=0;
		
		for(i=1;i<=10;i++) {
			x=r*x-D;
			System.out.println(x);
		}
		
	}
}



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

int A,B;

int main(){
	cin>>A>>B;
	if((A==1)&&(B==1)){
		cout<<"Draw"<<endl;
	}else if(A==1){
		cout<<"Alice"<<endl;
	}else if(B==1){
		cout<<"Bob"<<endl;
	}else if(A==B){
		cout<<"Draw"<<endl;
	}else if(A<B){
		cout<<"Bob"<<endl;
	}else if(A>B){
		cout<<"Alice"<<endl;
	}
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {
        
        public static void Main() {
            Console.WriteLine(Line()[0].ToString() + Line()[1].ToString() + Line()[2].ToString());
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n;
int ans = 0;

void dfs(ll x, int a, int b, int c) {
    if (x > n) return;
    if (a && b && c) ans++;
    dfs(10 * x + 3, 1, b, c);
    dfs(10 * x + 5, a, 1, c);
    dfs(10 * x + 7, a, b, 1);
}

int main() {
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int n,i,x;
scanf("%d",&n);
for(i=1;i <= n;i++){
if (i%3 == 0 || i%10 == 3){
printf(" %d",i);
}else{
x=i;
while(1){
x /= 10;
if (x == 0)break;
else if (x%10 == 3){
printf(" %d",i);
break;
}
}
}
}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    string word;
    int length, poz = -1, numberOfStrings = 0, weHaveAStringWith3 = 0, jumpOver;

    cin >> word;
    length = word.length() - 1;

    while(poz <= length - 1)
    {
        poz++;
        numberOfStrings++;
        jumpOver = 1;
        if (word[poz] != word[poz + 1])
        {
          //  numberOfStrings++;
        }
        else
        {
            //numberOfStrings++;

            if (weHaveAStringWith3 == 0)
            {
                weHaveAStringWith3 = 1;
                poz++;
            }
            else
            {
                weHaveAStringWith3 = 0;

            }

            continue;
            jumpOver = 0;
            numberOfStrings--;
        }
        if (jumpOver == 1)
        {
            weHaveAStringWith3 = 0;
        }

    }


    cout << numberOfStrings;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(10000, prime);

    vector<int> ret(10001);
    for(int i=5; i<=10000; ++i){
        if(prime[i] && prime[i-2])
            ret[i] = i;
        else
            ret[i] = ret[i-1];
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        cout << (ret[n]-2) << ' ' << ret[n] << endl;
    }
}

Measured memory_bytes: 952
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int K;
	cin >> K;

	vector<Int> ans;

	for (Int N = 2; N < 51; N++) {
		if (K / N > 1e16 + 1000)continue;
		ans.resize(N);
		for (Int i = 0; i < N; i++) {
			ans[i] = i+K/N;
		}
		for (Int j = 0; j < K%N; j++) {
			ans[j] += N;
			for (Int k = 0; k < N; k++) {
				if (j==k) {
					continue;
				}
				ans[k]--;
			}
		}

		Int flag = 1;
		for (Int i = 0; i < N; i++) {
			if (ans[i]>1e16+1000) {
				flag = 0;
			}
		}

		if (flag) {
			cout << N << "\n";
			for (Int i = 0; i < N; i++) {
				cout << ans[i] << " ";
			}
			return 0;
		}
	}

}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 120000;

int n;
ll d[MAXN];
int sz[MAXN];
map<ll, int> mm;
vector<int> eds[MAXN];
int was[MAXN];

vector<pair<int, int>> ed;

void no() {
	cout << -1 << "\n";
	exit(0);
}

void add_edge(int a, int b) {
	if (a == b)
		no();
	if (a > b)
		swap(a, b);
	eds[a].push_back(b);
	eds[b].push_back(a);
	ed.emplace_back(a, b);
}

ll go;

void dfs1(int v) {
	was[v] = 1;
	sz[v] = 1;
	for (int u: eds[v])
		if (!was[u])
			dfs1(u), sz[v] += sz[u], go += sz[u];
}

void dfs2(int v, int p, ll cur) {
	if (d[v] != cur)
		no();
	for (int u: eds[v]) {
		if (u == p)
			continue;
		dfs2(u, v, cur + (n - 2 * sz[u]));
	}
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> d[i], sz[i] = 1, mm[d[i]] = i;
	vector<pair<ll, int>> vv;
	for (int i = 0; i < n; ++i)
		vv.emplace_back(d[i], i);
	sort(ALL(vv));
	reverse(ALL(vv));
	for (int i = 0; i + 1 < vv.size(); ++i) {
		ll go = vv[i].first - (n - 2 * sz[vv[i].second]);
		int p = mm[go];
		add_edge(vv[i].second, p);
		sz[p] += sz[vv[i].second];
	}
	dfs1(0);
	for (int i = 0; i < n; ++i)
		if (!was[i])
			no();
	if (d[0] != go)
		no();
	dfs2(0, -1, go);
	sort(ed.begin(), ed.end());
	for (auto p: ed)
		cout << p.first + 1 << " " << p.second + 1 << "\n";
	return 0;
}




Measured memory_bytes: 20724
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            return new string(CR.Get().Select(x => 'x').ToArray());
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=998244353;
signed main(){
    int n,x[8],y[8],a[8];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i]>>y[i];
    iota(a,a+n,0);
    double sum=0,tmp=0;
    do{
        tmp++;
        for(int i=1;i<n;i++)
            sum+=hypot(x[a[i]]-x[a[i-1]],y[a[i]]-y[a[i-1]]);
    }while(next_permutation(a,a+n));
    cout<<fixed<<setprecision(20)<<sum/tmp<<endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
//template<typename T> using vec=std::vector<T>;

const ll inf=1<<30;
const long long unsigned int infll=1LL<<63;
const double eps=1e-9;
const ll dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

typedef string::const_iterator state;

map<char,ll> pri;

ll expr(state& begin);

ll number(state& begin){
    ll res=0;
    while(isdigit(*begin)){
        res*=10;
        res+=*begin-'0';
        ++begin;
    }
    return res;
}

ll factor(state& begin) {
    if (*begin=='('){
        begin++;
        ll res=expr(begin);
        begin++;
        return res;
    }else return number(begin);
}

ll term_(state &begin){
    ll res=factor(begin);
    while(true){
        if(*begin=='+' and pri['+']>pri['-'] and pri['+']>pri['*']){
            ++begin;
            res+=factor(begin);
        }else if(*begin=='-' and pri['-']>pri['+'] and pri['-']>pri['*']){
            ++begin;
            res-=factor(begin);
        }else if(*begin=='*' and pri['*']>pri['+'] and pri['*']>pri['-']){
            ++begin;
            res*=factor(begin);
        }else break;
    }
    return res;
}

ll term(state& begin){
    ll res=term_(begin);
    while(true){
        if(*begin=='+' and ((pri['+']<=pri['-'] and pri['+']>pri['*']) or (pri['+']>pri['-'] and pri['+']<=pri['*']))){
            ++begin;
            res+=term_(begin);
        }else if(*begin=='-' and ((pri['-']<=pri['+'] and pri['-']>pri['*']) or (pri['-']>pri['+'] and pri['-']<=pri['*']))){
            ++begin;
            res-=term_(begin);
        }else if(*begin=='*' and ((pri['*']<=pri['+'] and pri['*']>pri['-']) or (pri['*']>pri['+'] and pri['*']<=pri['-']))){
            ++begin;
            res*=term_(begin);
        }else break;
    }
    return res;
}

ll expr(state& begin){
    ll res=term(begin);
    while(true){
        if(*begin=='+' and pri['+']<=pri['-'] and pri['+']<=pri['*']){
            ++begin;
            res+=term(begin);
        }else if(*begin=='-' and pri['-']<=pri['+'] and pri['-']<=pri['*']){
            ++begin;
            res-=term(begin);
        }else if(*begin=='*' and pri['*']<=pri['+'] and pri['*']<=pri['-']){
            ++begin;
            res*=term(begin);
        }else break;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    ll ans=-infll;
    rep(i,0,3) rep(j,0,3) rep(k,0,3){
        pri['+']=i;
        pri['-']=j;
        pri['*']=k;
        state begin=s.begin();
        ans=max(ans,expr(begin));
    }
    cout << ans << endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

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

typedef long long ll;
typedef tuple<ll, int, int> tlii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
#define mkt make_tuple
#define print(out) cout << (out) << endl
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

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

    int N, Q;
    ll s, t, x, d;
    bool flag;
    unordered_map<ll, vector<pair<ll, bool>>> A;
    set<ll> D;
    set<ll> S;
    unordered_map<ll, ll> B;
    map<ll, ll> C;

    cin >> N >> Q;
    rep(i, 0, N) {
        cin >> s >> t >> x;
        // 全ての工事を同じ時系列に持ってくる
        S.insert(s-x);
        S.insert(t-x);
        A[s-x].pb(mkp(x, 0));
        A[t-x].pb(mkp(x, 1));
    }
    rep(i, 0, Q) {
        cin >> d;
        D.insert(d);
        S.insert(d);
    }
    // 人か工事のある箇所だけ見る
    for (ll key: S) {
        // 工事の状態に変化のある時
        if (A.find(key) != A.end()) {
            for (auto p: A[key]) {
                x = p.first;
                flag = p.second;
                // 工事の本来の開始時期毎に値を増減させる
                if (flag == false) {
                    C[x] ++;
                } else {
                    C[x] --;
                }
                if (C[x] == 0) {
                    C.erase(x);
                }
            }
        }
        // 人が出発する時
        if (D.find(key) != D.end()) {
            // この時点で存在する工事の最も早いものを使いたいので、先頭位置を取得
            auto itr = C.begin();
            if (itr != C.end()) {
                B[key] = itr->first;
            } else {
                // 工事が1つもなければその人は止まらない
                B[key] = -1;
            }
        }
    }
    for (ll x: D) {
        print(B[x]);
    }
    return 0;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x, t;
	cin>>n>>x>>t;
	int w = (n+(x-1)) / x * t;
	cout<<w;
}


Measured memory_bytes: 3632
import sys
N = int(input())
A = [0] + [int(n) for n in input().split()] + [0]
sumA = 0
for i in range(1,N+2):
    sumA += abs(A[i]-A[i-1])

for i in range(1,N+1):
    print(sumA - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))


Measured memory_bytes: 14048
N = int(input())
A = list(map(int, input().split()))

pos = 0
left = A[0]
if left <= 0:
    pos += 1 - left
    left = 1
for a in A[1:]:
    if left * (left + a) < 0:
        left += a
    else:
        if left + a == 0:
            if left < 0:
                left += a + 1
            else:
                left += a - 1
            pos += 1
        else:
            pos += abs(left + a) + 1
            if left < 0:
                left = 1
            else:
                left = -1

neg = 0
left = A[0]
if left >= 0:
    neg += left + 1
    left = -1
for a in A[1:]:
    if left * (left + a) < 0:
        left += a
    else:
        if left + a == 0:
            if left < 0:
                left += a + 1
            else:
                left += a - 1
            neg += 1
        else:
            neg += abs(left + a) + 1
            if left < 0:
                left = 1
            else:
                left = -1

print(min(neg, pos))

Measured memory_bytes: 14504
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int k,n;
   cin >> k >> n;
   vector<int> a(n);
   f(i,0,n){
      cin >> a[i];
   }
   int ans = 0;
   f(i,0,n-1){
      ans = max(ans,abs(a[i]-a[i+1]));
   }
   ans = max(ans,a[0]+k-a[n-1]);
   cout << k-ans << '\n';
   return 0;
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
 
const int L=2*1e5;
int N,K;
LL a[L];
LL f(int s, int e){
	if(s+1==e){
		return a[s]>=0?1:0;
	}
	int m=(s+e)/2;
	LL ret=f(s,m)+f(m,e);
	LL l=0,r=0;
	vector<LL> ls,rs;
	for(int i=m-1;i>=s;i--){
		l+=a[i];
		ls.push_back(l);
	}
	for(int i=m;i<e;i++){
		r+=a[i];
		rs.push_back(r);
	}
	sort(ls.begin(),ls.end());
	sort(rs.begin(),rs.end());
	int q=rs.size();
	for(auto v:ls){
		while(q>0&&rs[q-1]+v>=0){
			q--;
		}
		ret+=rs.size()-q;
	}
	return ret;
}
int main() {
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
      	scanf("%lld",a+i);
		a[i]-=K;
	}
	printf("%lld", f(0,N));
 
	return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main(){
    vector<char> s(3);
    
    rep(i,3){
        cin >> s.at(i);

    }
    if(s.at(0)==s.at(1)&&s.at(0)==s.at(2))
        cout << "No" << endl;
        else
        {
            cout << "Yes" << endl;
        
        }
        

}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<vector<int>> graph(n);
  for (int i = 0; i < m; ++i) {
    int src, dest;
    cin >> src >> dest;
    src--;
    dest--;
    graph[src].push_back(dest);
  }

  int s, t;
  cin >> s >> t;
  s--;
  t--;

  int ans = -1;
  vector<vector<int>> dists(n, vector<int>(3, -1));
  queue<pair<int, int>> q;
  q.push({s, 0});
  while (!q.empty()) {
    int node_idx = q.front().first, dist = q.front().second;
    q.pop();

    if (dists[node_idx][dist % 3] != -1) {
      continue;
    }

    dists[node_idx][dist % 3] = dist;
    for (auto &neighbor : graph[node_idx]) {
      q.push({neighbor, dist + 1});
    }
  }

  cout << (dists[t][0] < 0 ? dists[t][0] : dists[t][0] / 3) << '\n';

  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long 
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define setbit(x,k) (x |= (1 << k))
#define clearbit(x,k) (x &= ~(1ll << k))
#define checkbit(x,k) (x & (1ll << k))
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define pii pair<int,int> 
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nn printf("\n") 
#define mod 10000007
using namespace std;    

ll n,k;
ll h[100005];
ll dp[100005];
ll solve(int pos)
{
    if(pos>=n-1) return 0;
    if(dp[pos]!=-1) return dp[pos];
    ll res = LONG_LONG_MAX;
    for(int i=1; i<=k && pos+i<n; i++) 
    {
        res = min(res, abs(h[pos] - h[pos+i]) + solve(pos+i));
    }
    
    return dp[pos] = res;
    
}

int main() 
{
   memset(dp, -1 , sizeof(dp));
   cin>>n>>k;
   for(int i=0; i<n; i++) cin>>h[i];
   cout<<solve(0); nn;
}

Measured memory_bytes: 12980
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
#include<cstring>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	//freopen("hussien.in", "r", stdin);
	int a, b, c, d, c1 = 0;
	cin >> a >> b >> c >> d;
	while (a > 0 && b > 0) {
		c = c - b;
		a = a - d;
	}
	if (c>0)
		cout << "No";
	else
		cout << "Yes";
	return 0;

}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
static const int INFTY = (1 << 21);
int n,M[100][100];

int prim(){
  int u,v,d[100],p[100],color[100],mincost;
  for (int i = 0; i < n; i++) {
    color[i] = 0;
    d[i] = INFTY;
    p[i] = -1;
  }
  d[0] = 0;

  while (1) {
    mincost = INFTY;
    u = -1;
    for (int i = 0; i < n; i++) {
      if (color[i] != 2 && d[i] < mincost) {
        u = i;
        mincost = d[i];
      }
    }
    if (u == -1) break;
    color[u] = 2;
    for (v = 0; v < n; v++) {
      if (color[v] != 2 && M[u][v] != INFTY) {
        if (M[u][v] < d[v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = 1;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] != -1) sum += M[i][p[i]];
  }
  return sum;
}

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int e; cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  cout << prim() << endl;
  return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a, b, s;
    int n, m;
    cin >> a >> b;
    cin >> n >> m;
    cin >> s;
    if (s == a) n--;
    if (s == b) m--;
    cout << n << " " << m << "\n";

    return 0;
}


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

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	vector<int> ans(N - 1);
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (i < X - 1) {
				if (j < X - 1) {
					ans.at(j - i - 1)++;
				} else if (j > Y - 1) {
					int tmp = (X - 1 - i) + (j - (Y - 1));
					ans.at(tmp)++;
				} else {
					int tmp_1 = j - (X - 1), tmp_2 = (Y - 1) - j + 1;
					int tmp = (X - 1 - i) + min(tmp_1, tmp_2);
					tmp--;
					ans.at(tmp)++;
				}
			} else if (i > Y - 1) {
				ans.at(j - i - 1)++;
			} else {
				if (j > Y - 1) {
					int tmp_1 = (i - (X - 1)) + 1, tmp_2 = (Y - 1) - i;
					int tmp = j - (Y - 1) + min(tmp_1, tmp_2);
					tmp--;
					ans.at(tmp)++;
				} else {
					int tmp_1 = i - (X - 1) + 1 + (Y - 1) - j, tmp_2 = (j - i);
					int tmp = min(tmp_1, tmp_2);
					tmp--;
					ans.at(tmp)++;
				}
			}
		}
	}

	for (int i = 0; i < N - 1; i++) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

long long go(std::vector<long long> a) {
	int n = (int) a.size();
	long long ans = 0;
	while(1) {
		long long got = 0;
		for(auto &x : a) {
			got += x / n;
			x = (x % n) - x / n;
		}
		ans += got;
		if(got == 0) break;
		for(auto &x : a) {
			x += got;
		}
	}
	return ans;
}

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define ford(i,n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i,l,r) for (int i = int(l); i <= int(r); i++)
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second
 
template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
 
typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
 
const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
 
string s;
int n;
inline bool read() {
	cin >> s;
	n = sz(s);
	return true;
}
 
int cnt[26];
   
inline void solve() {   
	forn (i, n)
		cnt[s[i] - 'a']++;
	li ans = 1;
	forn (i, 26)
		forn (j, i)
			ans += li(cnt[i]) * cnt[j];
	cout << ans << endl;
}
 
int main()
{
#ifdef _DEBUG
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif
 
	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;
 
	srand(int(time(NULL)));
 
	read();
	solve();
 
#ifdef _DEBUG
	cerr << "TIME: " << clock() << endl;
#endif
 
	return 0;
}

Measured memory_bytes: 764