akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename A, typename B>
inline bool chmax(A &a, const B &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template<typename A, typename B>
inline bool chmin(A &a, const B &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};

int h, w;
char c[25][25];
int sy, sx;
vector<int> gy, gx;
int dist[15][15];

int bfs(int fid, int gid) {
    int d[25][25];
    for(int i = 0; i < 25; ++i) {
        for(int j = 0; j < 25; ++j) {
            d[i][j] = INF;
        }
    }
    queue<pair<int, int>> que;
    que.push({gy[fid], gx[fid]});
    d[gy[fid]][gx[fid]] = 0;
    while(que.size()) {
        int py, px;
        tie(py, px) = que.front();
        que.pop();
        if(py == gy[gid] and px == gx[gid]) break;
        for(int i = 0; i < 4; ++i) {
            int ny = py + dy[i];
            int nx = px + dx[i];
            if(d[ny][nx] != INF) continue;
            if(c[ny][nx] == 'x') continue;
            if(ny < 0 or h <= ny) continue;
            if(nx < 0 or w <= nx) continue;
            d[ny][nx] = d[py][px] + 1;
            que.push({ny, nx});
        }
    }
    return d[gy[gid]][gx[gid]];
}

void solve() {
    int n = gy.size();
    for(int from = 0; from < n; ++from) {
        for(int to = from + 1; to < n; ++to) {
            dist[from][to] = dist[to][from] = bfs(from, to);
        }
    }
    n--;
    int dp[1<<n][n + 1];
    for(int i = 0; i < (1 << n); ++i) {
        for(int j = 0; j < n + 1; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][n] = 0;
    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int i = 0; i < n; ++i) {
            if((mask >> i) & 1) {
                for(int j = 0; j < n + 1; ++j) {
                    int pre = dp[mask - (1 << i)][j];
                    if(pre != INF and dist[i][j] != INF) {
                        chmin(dp[mask][i], pre + dist[i][j]);
                    }
                }
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < n + 1; ++i) {
        chmin(ans, dp[(1 << n) - 1][i]);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

int main() {
    while(cin >> w >> h and w > 0) {
        gy = gx = {};
        for(int y = 0; y < h; ++y) {
            for(int x = 0; x < w; ++x) {
                cin >> c[y][x];
                if(c[y][x] == 'o') {
                    c[y][x] = '.';
                    sy = y;
                    sx = x;
                }
                if(c[y][x] == '*') {
                    c[y][x] = '.';
                    gy.push_back(y);
                    gx.push_back(x);
                }
            }
        }
        gy.push_back(sy);
        gx.push_back(sx);
        solve();
    }
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int sum = 0;
    for (int i=0; i< M; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    int nokori = N - sum;
    if (nokori < 0) cout << -1 << endl;
    else cout << nokori << endl;
}


Measured memory_bytes: 3632
n = gets.chomp!.to_i
ls = gets.split(" ").map(&:to_i)

s1_list = Array.new
sum = ls.inject(:+)
for i in 1..n-1
  s1 = 0
  for j in 0..i
    s1 += ls[j]

  end
    s2 = sum - s1
    s1_list << (s1 - s2).abs

end

p s1_list.min

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

using namespace std;

using ll = long long;
int main(int argc, const char *argv[]) {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  ll dist = abs(a - b);
  ll sp = (v - w) * t;
  cout << (sp >= dist ? "YES" : "NO") << '\n';

  return 0;
}

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

int main() {
    int c4 = 0, c2 = 0, c0 = 0, n, a;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        if      (a%4==0) {c4++;}
        else if (a%2==0) {c2++;}
        else             {c0++;}
    }

    c2 = c2%2; // c2, c2, c2 -> c2となる

    string ret = "No";
    if (c2+c0==0 || c2+c0-1<=c4) {ret = "Yes";}

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3676
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNextInt()){
int count=0;
int n=sc.nextInt();
boolean[] prime=new boolean[n+1];
for(int i=2;i<=n;i++){
prime[i]=true;
}
for(int i=0;i<=n;i++){
if(prime[i]){
count++;
for(int j=i+i;j<=n;j+=i){
prime[j]=false;
}
}
}
System.out.println(count);
}
}
}

Measured memory_bytes: 35704
class Stack():
    def __init__(self, size):
        self.A = [None for i in range(size)]
        self.i = -1  #最後に追加された要素が入っているIndex。Aが空の場合、-1
        self.size = size
    
    def push(self, x):
        self.A[self.i+1] = x
        self.i += 1
    
    def pop(self):
        ret = self.A[self.i]
        self.A[self.i] = None
        self.i -= 1
        return ret
    
    def isEmpty(self):
        return self.i == -1
    
    def isFull(self):
        return self.i == size - 1

S = Stack(100)
for i in input().split():
    if i == '+':
        s1, s2= S.pop(), S.pop()
        S.push(s2 + s1)
    elif i == '-':
        s1, s2= S.pop(), S.pop()
        S.push(s2 - s1)
    elif i == '*':
        s1, s2= S.pop(), S.pop()
        S.push(s2 * s1)
    else:
        S.push(int(i))
print(S.pop())


Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<vector>
using namespace std;
int  i,j,k,n,h,w,a,b,c,d,x,y,z,t,ret;
int main(void){
  cin>>n;
  int l[n],sum=0;
  for(i=0;i<n;i++){cin>>l[i];sum+=l[i];}
  for(i=0;i<n;i++)if(l[i]>=sum-l[i]){cout<<"No";return 0;}
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	int A, B;
	cin >> A >> B;
	if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) Cout("Possible");
	else Cout("Impossible");
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=1e5+7;

int a[N],b[N],c[N];
int dp[N][3];

int main(){
	int n=input();
	for(int i=1;i<=n;i++){
		a[i]=input(),b[i]=input(),c[i]=input();
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}

	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Yagnik
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            int a = 0, b = 0;
            for (int i = 0; i < 3; i++) {
                if (c[i] == 'A') a = 1;
                else b = 1;
            }
            w.println((a ^ b) == 0 ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
'use strict'

function main(s) {
  s = s.split('\n')[0].split('');

  const str = new Set(s);
  const abc = [...Array(26)].map((c, i) => {
    return String.fromCharCode('a'.charCodeAt(0) + i);
  });
  
  let ans = '';
  for (const char of abc) {
    if (!(str.has(char))) {
      ans = char;
      break;
    }
  }

  console.log(ans ? ans : 'None');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	string s;
	cin >> s;

	int len = s.length();

	int np = 0;
	REP(i, len) {
		if (s[i] == 'p')np++;
	}



	cout << len/2-np << endl;
	return 0;
}

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

typedef long long ll;
const int MOD=1000000007;

int main(){
    int N;
    cin >> N;
    ll dp[105][5][5][5];
    
    dp[0][0][0][0]=1;
    for(int s=0;s<N;s++){
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                for(int k=0;k<5;k++){
                    for(int l=1;l<5;l++){
                        if(i==1&&j==2&&l==3) continue;
                        if(i==1&&k==2&&l==3) continue;
                        if(j==1&&k==2&&l==3) continue;
                        if(j==1&&k==3&&l==2) continue;
                        if(j==2&&k==1&&l==3) continue;
                        dp[s+1][j][k][l]+=dp[s][i][j][k];
                        dp[s+1][j][k][l]%=MOD;
                    }
                }
            }
        }
    }
    long long res=0;
    for(int i=1;i<5;i++){
        for(int j=1;j<5;j++){
            for(int k=1;k<5;k++){
                res+=dp[N][i][j][k];
                res%=MOD;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vector<pair<int,int>> conne[n];
    int c=0;
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        pii t=make_pair(b,i);
        conne[a].push_back(t);
        t.first=a;
        conne[b].push_back(t);
        chmax(c,(int)conne[a].size());
        chmax(c,(int)conne[b].size());
    }
    cout<<c<<endl;
    rep(i,0,n)sort(conne[i].begin(),conne[i].end());
    vi ans(n,0);
    queue<pii> q;
    q.emplace(0,0);
    while(!q.empty()){
        pii t=q.front();q.pop();
        int index=t.first;
        int pcolor=t.second;
        int wcolor=1;
        for(pii i:conne[index]){
            int ni=i.first;
            int ei=i.second;
            if(wcolor==pcolor)wcolor++;
            if(ans[ei]!=0)continue;
            else{
                ans[ei]=wcolor;
                q.emplace(ni,wcolor);
                wcolor++;
            }
        }
    }
    rep(i,0,n-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main(){int a,b,c;cin>>a>>b>>c;b--;c--;vector<int>A(a-1);for(int i=0;i<a;i++)for(int j=i+1;j<a;j++)A[min(min(abs(j-i)-1,abs(j-b)+abs(i-c)),abs(j-c)+abs(i-b))]++;for(int i=0;i<a-1;i++)cout<<A[i]<<endl;}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  string s;
  cin >>s;
  if(s=="SUN")
    cout<<7<<endl;
  if(s=="MON")
    cout<<6<<endl;
  if(s=="TUE")
    cout<<5<<endl;
  if(s=="WED")
    cout<<4<<endl;
  if(s=="THU")
    cout<<3<<endl;
  if(s=="FRI")
    cout<<2<<endl;
  if(s=="SAT")
    cout<<1<<endl;
}


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

int main(){
  int n;
  cin >> n;
  ll t=0;
  map<int,int> s;
  rep(i,n){
    int x;
    cin >> x;
    ++s[x];
    t+=x;
  }
  int q;
  cin >> q;
  rep(i,q){
    int b,c;
    cin >> b >> c;
    t += (c-b)*s[b];
    s[c] += s[b];
    s[b] = 0;
    cout << t << endl;
	}
  return 0;
}

Measured memory_bytes: 8036
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    ll k;
    if (d == 0) k = n;
    else k = 2 * (n - d);
    printf("%20.15f\n", (double(m - 1) / double(n)) * (double(k) / double(n)));
    //cout << (double(m - 1)/double(n)) * (double(k) / double(n)) << endl;
}

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

int n,a[100001],f=0;

void work(int num,int step)
{
	if(step==n+1)
	{
		f=1;
		return;
	}
	if(a[step]>=num) work(a[step],step+1);
	else if(a[step]+1>=num) work(a[step]+1,step+1);
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	work(a[1],2);
	if(f==1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int main() {
    double n;
    cin >> n;
    cout << fixed << n*(6.28318530717958623200) << endl;
    return 0;
}

Measured memory_bytes: 3792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	bitNum := 30
	bitCount := make([]int, bitNum)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		for j := uint(0); j < uint(bitNum); j++ {
			if ((a >> j) & 1) == 1 {
				bitCount[j]++
			}
		}
	}

	for i := 0; i < bitNum; i++ {
		if bitCount[i]%2 != 0 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n,k,q = map(int, input().split())
a = n*[k]
for i in range(q):
    num = int(input())
    a[num-1] += 1
a = [k-q for k in a]
for i in range(n):
    if a[i] > 0:
        print ("Yes")
    else:
        print ("No")

Measured memory_bytes: 9844
n = int(input())

ans = [0] * (n+1)
for x in range(1,110):
    for y in range(1,110):
        for z in range(1,110):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp <= n:
                ans[tmp] += 1

for i in ans[1:]:
    print(i)


Measured memory_bytes: 69536
#include <iostream>
#include <math.h>
using namespace std;

int N;

int main(){
  scanf("%d", &N);
  double a[N];
  double b[N];
  double total=0;
  for(int i=0; i<N; i++){
    scanf("%lf", &a[i]);
    b[i] = 1 / a[i];
    total += b[i];
  }
  double ans = 1 / total;
  printf("%lf", ans);
 
  return 0;
}

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

#define MAX 200002

int n;
int m;

vector<int> v[MAX];

int star[MAX];
int linkk[MAX];
int ord;
bool vis[MAX];
int cnt[MAX];


int belong[MAX];
inline int root(int b){
	if(belong[b]==-1)return b;
	return belong[b]=root(belong[b]);
}
inline void merge(int a,int b){
	a=root(a);
	b=root(b);
	if(a==b)return;
	cnt[b]+=cnt[a];
	belong[a]=b;
}

inline void dfs(int b,int pr=-1){
	vis[b]=true;
	linkk[b]=star[b]=ord;
	ord++;
	for(int go:v[b]){
		if(vis[go]){
			if(go==pr)continue;
			linkk[b]=min(linkk[b],star[go]);
			//cout<<"f "<<b<<" "<<go<<endl;
			merge(b,go);
			continue;
		}
		dfs(go,b);
		linkk[b]=min(linkk[b],linkk[go]);
		if(linkk[go]<=star[b]){
			merge(b,go);
		}
	}
}
vector<int> r;
vector<pair<int,int> > ed;

vector<int> g[MAX];

int dp[MAX][2];

inline void dfs2(int b,int pr=-1){
	vis[b]=true;
	dp[b][1]+=cnt[b];
	for(int go:g[b]){
		if(go==pr)continue;
		dfs2(go,b);
		dp[b][0]+=max(dp[go][1],dp[go][0]);
		dp[b][1]+=dp[go][0];
	}
}

int main(){
	memset(belong,-1,sizeof(belong));
	cin>>n>>m;
	for(int i=0;i<n;i++)cnt[i]=1;
	for(int j=0;j<m;j++){
		int s,t;
		scanf("%d%d",&s,&t);
		v[s].push_back(t);
		v[t].push_back(s);
		ed.push_back(make_pair(s,t));
	}
	for(int i=0;i<n;i++){
		if(vis[i]==false){
			dfs(i);
		}
	}
	for(int i=0;i<n;i++){
		r.push_back(root(i));
		//cout<<root(i)<<" ";
	}
//	cout<<endl;
	sort(r.begin(),r.end());
	r.erase(unique(r.begin(),r.end()),r.end());
	for(int i=0;i<ed.size();i++){
		int a=ed[i].first;
		int b=ed[i].second;
		a=root(a);
		b=root(b);
		if(a!=b){
			g[a].push_back(b);
			g[b].push_back(a);
		}
	}
	memset(vis,false,sizeof(vis));
	int ans=0;
	for(int i=0;i<r.size();i++){
		if(vis[r[i]]==false){
			dfs2(r[i]);
			ans+=max(dp[r[i]][0],dp[r[i]][1]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 22856
#include <cstdio>
#include <map>

int main()
{
  int n;
  scanf("%d", &n);
  std::map<long long, int> mp;
  for (int i = 0; i < n; ++i)
  {
    long long a;
    scanf("%lld", &a);
    mp[a]++;
  }
  long long e[2] = {0, 0};
  int i = 0;
  for (auto it = mp.rbegin(); it != mp.rend(); ++it)
  {
    if (it->second >= 2)
    {
      e[i++] = it->first;
      if (i == 2) break;
      if (it->second >= 4)
      {
        e[1] = it->first;
        break;
      }
    }    
  }
  printf("%lld\n", e[0] * e[1]);
  return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    string s; cin >> s;
    bool ok = false;
    if (s.size() % 2) {
        bool flag = true;
        for (int i = 0; i < s.size() / 2; i++) {
            if (s[i] != s[s.size() - i - 1] || s[i] != s[s.size() / 2 - i - 1]) flag = false;
        }
        if (flag) ok = true;
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll d=x/11LL;
    ll ans=2*d;
    x-=11*d;

    if(x==0);
    else if(x<=6) ans++;
    else if(x<=11) ans+=2;

    cout<<ans<<endl;
}


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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> count(3, 0);

    for (int i = 0; i < N; i++)
    {
        int p;
        cin >> p;

        if (p <= A)
        {
            count[0]++;
        }
        else if (A < p && p <= B)
        {
            count[1]++;
        }
        else
        {
            count[2]++;
        }
    }

    cout << *min_element(count.begin(), count.end()) << endl;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/


/+---test
5 2
8 7 6
rsrpr
---+/
/+---test
7 1
100 10 1
ssssppr
---+/
/+---test
30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);
  long R, S, P;
  readf(" %d %d %d ", &R, &S, &P);
  const T = readln.chomp;

  long ans;
  foreach (k; 0..K) {
    bool skip;
    for (long i = k; i < N; i+=K) {
      if (!skip && i >= K && T[i] == T[i-K]) {
        skip = true;
        continue;
      } else {
        skip = false;
      }
      ans +=
        T[i] == 'r'? P:
        T[i] == 's'? R:
        T[i] == 'p'? S: 0;
    }
  }
  ans.writeln;
}


Measured memory_bytes: 2556
s = input()

r = 0
l = 0
max_num = 0
min_num = 0
ans = 0

for i in range(len(s)):
  if s[i] == "<":
    r += 1
  if s[i] == ">":
    l += 1
  if i < (len(s)-1):
    if s[i] == ">" and s[i+1] == "<":
      max_num = max(r, l)
      min_num = min(r, l)
      ans += (max_num*(max_num+1))/2
      ans += ((min_num-1)*min_num)/2
      r = l = 0

max_num = max(r, l)
min_num = min(r, l)
ans += (max_num*(max_num+1))/2
ans += ((min_num-1)*min_num)/2

print(int(ans))

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 21

int N;
int a[MAX][MAX];

long long memo[1 << MAX];

long long dfs( int i, int bit )
{
	if( i == N ) {
		return 1;
	}
	if( memo[bit] >= 0 ) {
		return memo[bit];
	}
	long long res = 0;
	for( int j = 0; j < N; j++ ) {
		if( a[i][j] && ( bit & (1 << j)) == 0 ) {
			res = ( res + dfs( i + 1, bit | (1 << j) ) ) % MOD;
		}
	}
	return memo[bit] = res;
}

int main() {
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			cin >> a[i][j];
		}
	}

	memset( memo, -1, sizeof( memo ) );
	long long ans = dfs( 0, 0 );

	cout << ans << endl;

	return 0;
}


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

#define fi first
#define se second
#define all(A) A.begin(),A.end()

vector<int> B[100001];
int32_t main(){
	int n,m;
	scanf("%d %d",&n,&m);
	vector<pair<int,int>> A(n);
	map<int,int> Map;
	for(auto &a:A){
		scanf("%d %d",&a.fi,&a.se);
		if(a.fi<=m)
			B[a.fi].push_back(a.se);
	}
	priority_queue<int> pq;
	int ans = 0;
	for(int i=1;i<=m;i++){
		for(auto a:B[i])
			pq.push(a);
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << '\n';
	
}






Measured memory_bytes: 6400
import math

N, M = map(int, input().split())
if abs(N - M) == 1:
    print(math.factorial(N) * math.factorial(M) % (10**9 + 7))
elif N == M:
    print(math.factorial(N) * math.factorial(M) * 2 % (10**9 + 7))
else:
    print(0)


Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int N;
ll K;
vector<pair<ll, ll> > v;

int main(void) {
    scanf("%d %lld", &N, &K);
    rep(i, 0, N) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        v.pb(mp(a, b));
    }
    sort(v.bg, v.en);

    ll t = 0;
    rep (i, 0, N) {
        t += v[i].second;
        
        if (t >= K) {
            printf("%lld\n", v[i].first);
            return 0;
        }

    }

	return 0;
}


Measured memory_bytes: 2420
n=int(input())
a=list(map(int,input().split()))
q=[]
for i,j in enumerate(a):
  q.append(j-(i+1))
#print(q)
q.sort()
#print(q)
if n%2==1:
  b=q[n//2];#print(b)
else:
  b=(q[n//2]+q[n//2-1])/2;#print(b)
r=[]
for k in q:
  r.append(abs(k-b))
print(int(sum(r)))

#TLEの予感

Measured memory_bytes: 26836
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=4000;
const int mod=1e9+7;
int n,m,tot;
int l[maxn+8],r[maxn+8],fac[maxn+8],fact[maxn+8],sum[maxn+8];
int f[maxn+8][maxn+8];
char S[maxn+8];
 
int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
 
int power(int a,int k)
{
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
	if (k&1)
	    sum=1ll*sum*a%mod;
    return sum;
}
 
int C(int n,int m){if (n<m) return 0;return 1ll*fac[n]*fact[m]%mod*fact[n-m]%mod;}
 
int main()
{
    n=read(),m=read();
    scanf("%s",S+1);
    for (int i=1;i<=m;i++)
	{
	    int x=read(),y=read();
	    if (r[tot]>=y) continue;
	    if (l[tot]==x&&r[tot]<y) tot--;
	    l[++tot]=x,r[tot]=y;
	}
    l[++tot]=n,r[tot]=n;
    fac[0]=fact[0]=1;
    for (int i=1;i<=n;i++) sum[i]=sum[i-1]+(S[i]=='1');
    for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    fact[n]=power(fac[n],mod-2);
    for (int i=n-1;i;i--) fact[i]=1ll*fact[i+1]*(i+1)%mod;
    f[0][0]=1;
    for (int i=1;i<tot;i++)
	{
	    //printf("Time:%d\n",i);
	    if (l[i+1]>r[i])
		{
		    for (int j=0;j<=n;j++)
			f[i][0]=(f[i][0]+1ll*f[i-1][j]*C(r[i]-l[i]+1,j+sum[r[i]]-sum[max(l[i]-1,r[i-1])])%mod)%mod;
		    continue;
		}
	    for (int j=0;j<=r[i]-l[i+1]+1;j++)
		    for (int k=0;k<=l[i+1]-l[i]+j-sum[r[i]]+sum[max(l[i]-1,r[i-1])];k++)
			{
			    //printf("update:%d %d\n",j,k);
			    f[i][j]=(f[i][j]+1ll*f[i-1][k]*C(l[i+1]-l[i],k-j+sum[r[i]]-sum[max(l[i]-1,r[i-1])])%mod)%mod;
			}
	}
    //for (int i=1;i<tot;i++,puts(""))
    // 	for (int j=0;j<=n;j++)
    //	    	    printf("%d ",f[i][j]);
    int ans=0;
    for (int i=0;i<=n;i++) ans=(ans+f[tot-1][i])%mod;
       printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 19328
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

class Node
{
	public:
	vector<int> to,c;
};

class Trl
{
	public:
	int p,c,dc;

	Trl(int p, int c, int dc):p(p),c(c),dc(dc){}
	bool operator<(const Trl& t) const
	{
		return c>t.c;
	}
};


int main()
{
	int n,m;
	int a,b,c;
	while(cin >> n >> m , (n||m))
	{
		Node node[100];
		while(m--)
		{
			cin >> a >> b >> c;
			node[a].to.push_back(b);
			node[b].to.push_back(a);
			node[a].c.push_back(c);
			node[b].c.push_back(c);
		}
		
		int total = 0;
		bool visit[100] = {false};
		priority_queue<Trl> q;
		q.push(Trl(0,0,0));

		while(!q.empty())
		{
			Trl t=q.top(); q.pop();
			if(visit[t.p]) continue;

			visit[t.p] = true;
			total += t.dc;

			for(int i=0; i<node[t.p].to.size(); i++)
			{
				int next = node[t.p].to[i];
				int tc   = node[t.p].c[i];
				if(visit[next]) continue;
				
				q.push(Trl(next,tc,tc));
			}
		}

		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
using namespace std;
template <typename T> T Max(T x,T y){return x>y?x:y;}
template <typename T> T Min(T x,T y){return x<y?x:y;}
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}

int s,f[2005][2005];

int dfs(int p,int tot)
{
	if(tot==s) return 1;
	if(f[p][tot]!=-1) return f[p][tot];
	int sum=0;
	for(int i=3;tot+i<=s;i++)
	{
		sum+=dfs(p+1,tot+i);
		sum%=mod;
	}
	f[p][tot]=sum;
	return sum;
}

int main()
{
	memset(f,-1,sizeof(f));
	cin>>s;
	cout<<dfs(1,0)<<endl;
	return 0;
}

Measured memory_bytes: 19360
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int
#define N 200100
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=(n/(a+b))*a;
	if(n%(a+b)>=a)
		ans+=a;
	else
		ans+=(n%(a+b));
	cout<<ans<<endl;
}

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

int main()
{
	char ch;
	int re = 0, ro = 0;
	int a, b, c;
	while (cin >> a >> ch >> b >> ch >> c) {
		if (a * a + b * b == c * c) {
			re++;
		}
		if (a == b) {
			ro++;
		}
	}
	cout << re << endl;
	cout << ro << endl;
	return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;

vector<bool> isPr;

//0からnまでの数字が素数かどうかを表す配列isPr
void isPrime( ll n ){
  isPr.assign(n+1,true);
  isPr.at(0) = false;
  isPr.at(1) = false;
  isPr.at(2) = true;
  for(ll now=2;now<=n;++now){
    if( isPr.at(now) ){
      ll cnt = 2;
      while( now*cnt <= n ){
        isPr.at(now*cnt) = false;
        cnt++;
      }
    }
  }
}

int main(){
  ll q;
  cin >> q;
  isPrime(100000);
  vector<ll> sum(100001);
  ll now = 0;
  for(ll i=1;i<=100000;i+=2){
    if( isPr.at(i) && isPr.at((i+1)/2) ){
      ++now;
      sum.at(i) = now;
      sum.at(i+1) = now;
    }else{
      sum.at(i) = now;
      sum.at(i+1) = now;
    }
  }
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    ll ans;
    if( isPr.at(l) && isPr.at((l+1)/2) ){
      ans = sum.at(r)-sum.at(l)+1;
    }else{
      ans = sum.at(r)-sum.at(l);
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1408
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 A, B, n;
  cin >> A >> B >> n;
  int64 r = min(B - 1, n);
  int64 ret = A * r / B;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
void a(){
    ll n,m;
    cin >> n >> m;
    cout << n*(max((ll)0,n-1))/2+m*(max((ll)0,m-1))/2;
    
}

void b(){
    string s;cin >> s;
    string sf = s.substr(0,s.size()/2);
    string bsf = sf;
    reverse(bsf.begin(),bsf.end());
    string sb = s.substr((s.size()+1)/2);
    string bsb = sb;
    reverse(bsb.begin(),bsb.end());
    if(sf==bsf&&bsf==sb&&sb==bsb){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

void c(){
    double l;
    cin >> l;
    cout << fixed << setprecision(10)<<l/3*l/3*l/3;
}


void d(){
    ll n; cin >> n;
    auto a = v<>(n,0);
    auto m = map<int,ll>();
    

    rep(i,n) {
        cin >> a[i];
        m[a[i]]++;
    }
    ll kai =0;
    for(auto i:m){
        kai+= i.second*(i.second-1)/2;
    }
    rep(i,n){
        cout << kai -m[a[i]]*(m[a[i]]-1)/2 + (m[a[i]]-1)*max((ll)0,(m[a[i]]-2))/2 << endl; 
    }
}
int main(){
    a();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int x = sc.nextInt();

		for (int i = x - k + 1; i < x + k; i++) {
			System.out.print(i + " ");
		}

		sc.close();

	}
}

Measured memory_bytes: 38668
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3]={};
    int b[3]={};
    int c[3][3];
    int cnt=0;
    bool flg=false;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            
            if(c[i][j]==0){
                flg=true;
            }
            
            if(j==2&& flg==false){
                for(int k=0; k<3; k++){
                    c[i][k]--;
                }
                a[i]++;
                j=-1;
            }
        }
        
        flg = false;
    }
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            
            if(c[j][i]==0){
                flg=true;
            }
            
            if(j==2&& flg==false){
                for(int k=0; k<3; k++){
                    c[k][i]--;
                }
                b[i]++;
                j=-1;
            }
        }
        
        flg = false;
    }
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(c[i][j]!=0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int H=in.nextInt();
int W=in.nextInt();
String dum=in.nextLine();
String s[]=new String[H];
for (int i=0; i<H; i++)
s[i]=in.nextLine();
for(int i=0; i<W+2; i++)
System.out.print("#");
System.out.println("");
for (int i=0; i<H; i++)
System.out.println("#"+s[i]+"#");
for(int i=0; i<W+2; i++)
System.out.print("#");
}
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    cout << n*800-(n/15)*200 << endl;
     
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n[10],k[10],a,b;
	for(int i=0;i<10;i++)
	{
		cin>>n[i];
	}
	sort(n,n+10);
	a=n[9]+n[8]+n[7];
	for(int i=0;i<10;i++)
	{
		cin>>k[i];
	}
	sort(k,k+10);
	b=k[9]+k[8]+k[7];
	cout<<a<<" "<<b<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int X = N;

    int sum = 0;
    while(N > 0){
        sum += N % 10;
        N /= 10;
    }
    if(X % sum == 0){

        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=str(input())

letters=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
play=''
for j in range(len(S)):
    for i, let in enumerate(letters):
        if S[j]==let and i+N < len(letters):
            play+=letters[i+N]
        elif S[j]==let and i+N >= len(letters):
            play+=letters[N-len(letters)+i]
print(play)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int cnt[n+1]={0};
    for (int i=0; i<n-1; i++){
        int k;
        cin>>k;
        cnt[k]++;
    }
    for (int i=1; i<=n; i++) cout<<cnt[i]<<endl;
}

Measured memory_bytes: 4412
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Measured memory_bytes: 13968
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }

    let &max_num = a.iter().max().unwrap();
    let is_set_wise = a.iter().fold(0, |acc, ai| acc.gcd(ai)) == 1;

    let era = Eratosthenes::new(max_num);
    let mut divisor_counter = vec![0; max_num + 1];

    for ai in a {
        let hm = era.factorization(ai);

        for (k, _v) in hm {
            divisor_counter[k] += 1;
        }
    }

    let is_pair_wise = *divisor_counter.iter().max().unwrap() <= 1;

    let ans = if is_pair_wise {
        "pairwise coprime"
    } else if is_set_wise {
        "setwise coprime"
    } else {
        "not coprime"
    };

    println!("{}", ans);
}

use itertools::Itertools;
use std::collections::HashMap;
use num::Integer;

/// 二分累乗法
pub fn pow(x: isize, n: usize) -> isize {
    if n == 0 {
        1
    } else if n == 1 {
        x
    } else if n % 2 == 1 {
        x * pow(x, n - 1)
    } else {
        pow(x * x, n / 2)
    }
}

/// エラトステネスの篩
/// 構築 O(N log log N)
/// 素因数分解 O(log N)
/// 素数判定 O(log N)
pub struct Eratosthenes {
    smallest_prime_factors: Vec<usize>,
}

impl Eratosthenes {
    pub fn new(n: usize) -> Self {
        let mut smallest_prime_factors = (0..=n).collect_vec();

        for i in 2.. {
            if i * i > n {
                break;
            }

            if smallest_prime_factors[i] != i {
                continue;
            }

            let mut j = i * i;
            while j <= n {
                if smallest_prime_factors[j] == j {
                    smallest_prime_factors[j] = i;
                }

                j += i;
            }
        }

        Self {
            smallest_prime_factors,
        }
    }

    pub fn factorization(&self, mut i: usize) -> HashMap<usize, usize> {
        assert_ne!(i, 0);

        let mut factors = HashMap::new();

        while i != 1 {
            let divisor = self.smallest_prime_factors[i];
            *factors.entry(divisor).or_insert(0) += 1;

            i /= divisor;
        }

        factors
    }

    pub fn is_prime(&self, i: usize) -> bool {
        i >= 2 && self.smallest_prime_factors[i] == i
    }
}


Measured memory_bytes: 28412
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if p[i] == i+1:
        ans += 1
        now = i
        to = i
        if i == 0:
            to = i + 1
        elif i == n-1:
            to = i - 1
        else:
            if p[i-1] == i:
                to = i - 1
            else:
                to = i + 1
        tmp = p[now]
        p[now] = p[to]
        p[to] = tmp
        

print(ans)


Measured memory_bytes: 14008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 2000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
	ll x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }


/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/


int n;
int tot;
struct node {
	int x, y;
	int d;
	node(){}
	node(int x,int y,int d):x(x),y(y),d(d){}

}nd[maxn],nd2[maxn];

bool cmp(node a, node b) {
	return a.x < b.x;
}
bool cmp2(node a, node b) {
	return a.y < b.y;
}

bool cmp3(node a, node b) {
	return a.d < b.d;
}

int fa[maxn];
void init() {
	for (int i = 0; i <= n; i++)fa[i] = i;
}
int findfa(int x) {
	if (x == fa[x])return x;
	return fa[x] = findfa(fa[x]);
}

void merge(int u, int v) {
	int p = findfa(u);
	int q = findfa(v);
	if (p != q) {
		fa[p] = q;
	}
}

bool chk(int x, int y) {
	if (findfa(x) == findfa(y))return true;
	else return false;
}

int kruskal() {
	int sum = 0;
	init();
	for (int i = 0; i < tot; i++) {
		node tmp = nd2[i];
		if (tmp.d == 0)merge(tmp.x, tmp.y);
		if (!chk(tmp.x, tmp.y)) {
			merge(tmp.x, tmp.y); sum += tmp.d;
		}
	}
	return sum;
}

int main() {
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		rdint(nd[i].x); rdint(nd[i].y);
		nd[i].d = i;
	}
	tot = 0;
	sort(nd + 1, nd + 1 + n, cmp);
	for (int i = 2; i <= n; i++) {
		nd2[tot++] = node(nd[i].d, nd[i - 1].d, nd[i].x - nd[i - 1].x);
	}
	sort(nd+1, nd + n+1, cmp2);
	for (int i = 2; i <= n; i++) {
		nd2[tot++] = node(nd[i].d, nd[i - 1].d, nd[i].y - nd[i - 1].y);
	}
	sort(nd2, nd2 + tot, cmp3);
	int sum = kruskal();
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int R,B,G,N;
    cin >> R >> B >> G >> N;
    int r=N/R;
    int b=N/B;
    int g=N/G;
    int ans=0;
    rep(i,r+1){
        rep(j,(N-R*i)/B+1){
            if((N-i*R-j*B)%G==0) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256