akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    const ll inf = 1LL << 60;
    ll N,M;
    cin >> N >> M;
    map<ll,ll> cnt;
    vector<ll> num;

    for1(i,N) {
        ll a;
        cin >> a;
        if (cnt[a] == 0) {
            num.push_back(a);
        }
        cnt[a] += 1;
    }
    for1(i,M) {
        ll b,c;
        cin >> b >> c;
        if (cnt[c] == 0) {
            num.push_back(c);
        }
        cnt[c] += b;
    }
    ll ans = 0;

    sort(num.begin(),num.end(),greater<ll>());
    for (ll n : num) {
        if (cnt[n] >= N) {
            ans += n * N;
            break;
        }
        ans += n * cnt[n];
        N -= cnt[n];
    }

    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 14320
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>

#include<chrono>
#include<initializer_list>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

int main() {
	string str;
	cin>>str;
	int ans=0;

	for(int i=0;i<str.size();++i){
		if(i%2==0){
			if(str[i]=='p')--ans;
		}else{
			if(str[i]=='g')++ans;
		}
	}

	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
/*
* author: pavveu
*/

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

void go() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << std::max(std::max(a * c, b * d), std::max(a * d, c * b)) << endl;

}

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

	go();

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> V(n);
    REP (i, 0, n) {
        cin >> V[i];
    }
    ll ans = 0;
    REP (i, 0, k + 1) {
        REP (j, 0, i + 1) {
            int res = i - j;
            if (j + res > n) continue;
            vector<ll> val;
            REP (a, 0, j) {
                val.push_back(V[a]);
            }
            REP (a, max(n - res, 0), n) {
                val.push_back(V[a]);
            }
            sort(val.begin(), val.end());
            int out = k - i;
            ll sum = 0;
            REP (a, 0, val.size()) {
                if (val[a] < 0 && out) {
                    out--;
                } else {
                    sum += val[a];
                }
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N, cnt=0;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    int max=H[0];
    for(int i=0; i<N; i++){
        if(H[i]>=max){
            cnt++;
            max = H[i];
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll a,b,q;
    ll s[100005];
    ll t[100005];
    cin >> a >> b >> q;
    rep(i,a) cin >> s[i+1];
    rep(i,b) cin >> t[i+1];
    s[0] = -INF;
    t[0] = -INF;
    s[a+1] = INF;
    t[b+1] = INF;
    ll ls,rs,lt,rt,x;
    rep(i,q){
        cin >> x;
        if (binary_search(s,s+a+2,x)){
            ls = x;rs = x;
        }
        else{
            rs = s[lower_bound(s,s+a+2,x)-s];
            ls = s[lower_bound(s,s+a+2,x)-s-1];
        }
        if (binary_search(t,t+a+2,x)){
            lt = x;rt = x;
        }
        else{
            rt = t[lower_bound(t,t+b+2,x)-t];
            lt = t[lower_bound(t,t+b+2,x)-t-1];
        }
        //PRINT(ls << " " << rs << " " << lt << " " << rt);
        PRINT(min({max(rs-x,rt-x),max(x-ls,x-lt),rt-ls+min(rt-x,x-ls),rs-lt+min(rs-x,x-lt)}));
    }
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int money = x;
		money = money - a;
		money = money % b;
		System.out.println(money);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
    int n, m;
    cin >> n >> m;
    
    vector<vector<char> > grid(n, vector<char>(m));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> grid[i][j];
    
    vector<vector<int> > dp(n, vector<int>(m, 0));
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(grid[i][j] == '#'){
                dp[i][j] = 0;
                continue;
            }

            if(i == 0 and j == 0){
                dp[i][j] = 1;
            } else if(i == 0 or j ==0){
                if(i == 0)
                    dp[i][j] = dp[i][j-1];
                else
                    dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
            }
        }
    }
    
    cout << dp[n-1][m-1];
}

Measured memory_bytes: 8460
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int A[1<<20], N;
ll dp[1<<20];

// a b c d e f g h
//   1   1   1   1
//
// g h i

ll find_max(int i) {
  if(i == N-1) {
    return 0;
  }

  return max(dp[i+1], A[i] + find_max(i+2));
}

int main() {

//  freopen("input.in","r",stdin);
//  freopen("output.out","w",stdout);

  cin >>  N;
  rep(i, N) cin >> A[i];
  dp[N-1] = A[N-1];
  int i = N-3;
  while(i >= 0) {
    dp[i] = dp[i+2] + A[i];
    i -= 2;
  }

  i = N-2;
  while(i >= 0) {
    dp[i] = max(dp[i+1], A[i]+dp[i+2]);
    i-=2;
  }

  if(N%2==0) {
    cout << dp[0] << endl;
    return 0;
  }

  cout << find_max(0) << endl;


  return 0;
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
//#include <functional>
//#include <iostream>

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)



int main() {
  int a,b,h,m;
	cin >> a>>b>>h>>m;
  if(abs(12*m-60*h-m)==360){
    cout << a+b << endl;
    return 0;
  }
  else{
    long double c;
    if(abs(12*m-60*h-m)>360){
      c = cos((720-abs(12*m-60*h-m))*M_PI/360.0);
    }
    else{
      c = cos(abs(12*m-60*h-m)*M_PI/360.0);
    }

    long double ans = sqrt(a*a+b*b-2.0*a*b*c);
    cout << fixed << setprecision(20) << ans << endl;
  }

}


Measured memory_bytes: 4164
N, M, X = map(int, input().split())
C = [0] * N
for i in range(N):
  C[i] = list(map(int, input().split()))

ans = 10 ** 7
for i in range(2 ** N):
  abi = [0] * M
  money = 0
  for j in range(N):  # このループが一番のポイント
    #print(i, j)
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
        
        money += C[j][0]
        for k in range(M):
          abi[k] += C[j][k + 1]
          
  #print(abi, money)
  if min(abi) >= X:
    ans = min(ans, money)
  #print("A")
  
if ans == 10 ** 7:
  ans = -1
print(ans)

Measured memory_bytes: 9112
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    input!{ n: usize, a: [i32;n] }
    let mut b = vec![0;n];

    for i in (1..n+1).rev() {
        let mut j = 2*i;
        let mut sum = 0;
        while j <= n {
            sum += b[j-1];
            j += i;
        }
        if a[i-1] != sum%2 {
            b[i-1] = 1;
        }
    }

    let mut ans = Vec::new();
    for i in 0..n {
        if b[i] == 1 {
            ans.push(i+1);
        }
    }
    println!("{}", ans.len());
    for (i,v) in ans.iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", v);
    }
}

Measured memory_bytes: 9084
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

inline int ceiling(int n, int d) {
	return n % d == 0 ? n / d : n / d + 1;
}

int main() {
	int N; cin >> N;
	long long answer = 1;
	for (long long i = 1; i <= N; i++) {
		answer *= i;
		answer %= 1000000007;
	}
	cout << answer << endl;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define ll long long
#define MAX 101
using namespace std;

int main(){
    int n ;
    double a[MAX],ans=0;
    cin>>n;
    rep(n){
        int d;
        cin>>d;
        a[i]=1.0/d;
        ans+=a[i];
    }
    cout<<1/ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;(int)(n);i++)
int main() {
int x;
  cin>>x;
  int a=x/500;
    int b=x%500/5;
  cout<<a*1000+b*5<<endl;

  
  
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n-1; i++) {
			int k = sc.nextInt();
			a[k]++;
		}
		for(int i = 1; i < n; i++) {
			System.out.println(a[i]);
		}
		System.out.println(0);
		
	}
	
}


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

const int mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), cnt(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    int ans = 1;
    for (int i = N - 1; i > 0; i -= 2) {
        if (cnt[i] != 2) {
            cout << "0" << endl;
            return 0;
        }
        ans = (ans << 1) % mod;
    }
    if (cnt[0] != (N & 1)) {
        cout << "0" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> vec(n);
  rep(i,n) {
    int p;
    cin >> vec[i].first.first >> p;
    vec[i].first.second = -p;
    vec[i].second = i+1;
  }
  sort(vec.begin(),vec.end());
  rep(i,n) {
    cout << vec[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        List<String> list = new ArrayList<>();
        long[][] dp = new long[h][w];
        for(int i = 0; i < h; i++){
            list.add(scanner.next());
        }
        for(int i = 0; i < h; i++){
            if(list.get(i).charAt(0) == '#')
                break;
            dp[i][0] = 1;
        }
        for(int i = 0; i < w; i++){
            if(list.get(0).charAt(i) == '#')
                break;
            dp[0][i] = 1;
        }
        for(int i = 1; i < h; i++){
            for(int j = 1; j < w; j++){
                if(list.get(i).charAt(j) == '#'){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                    dp[i][j] %= 1000000007;
                }
            }
        }
        System.out.println(dp[h-1][w-1]);
    }
}


Measured memory_bytes: 39672
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll n, ans = 0; cin >> n;
	if(n % 2 == 0) for(n /= 2; n; n /= 5) ans += n / 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
char s[111];
char t[111];


int main() {
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	string S = string(s);
	string T = string(t);
	for(int start = 0; start <= n; start++) {
		string curr = S.substr(0, start);
		curr += T;
		bool ok = true;
		for(int i = 0; i < n; i++)
			if(curr[i] != S[i]) {
				ok = false;
				break;
			}
		if(ok) {
			printf("%d\n", (int)curr.size());
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int n,x,count;
    while(true){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0) break;
        count = 0;
        for(int min = 1; min < x/3 && min <= n-2;min++){
            for(int middle = min+1;middle < x - (min+middle) && middle <= n-1; middle++){
                if(x-(min+middle) <= n) count++;
            }
        }
        printf("%d\n",count);
    }
 
}



Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
double w, h, x, y;
ll n, m, s[2010], t[2010], dp[2010][2010], u[2010];

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> s[i];
	}
	for (int i = 1; i <= m; i++)
	{
		cin >> t[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		dp[i][0] = 1;
	}
	for (int i = 1; i <= m; i++)
	{
		dp[0][i] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			(dp[i][j] = (dp[i][j - 1] + u[j]) % mod) %= mod;
			if (s[i] == t[j])
			{
				(dp[i][j] += dp[i - 1][j - 1]) %= mod;
				(u[j] += dp[i - 1][j - 1]) %= mod;
			}
		}
	}
	cout << dp[n][m] << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 31744
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(double*)a - *(double*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

double v[50];

int main(void)
{
    int n;
    double ans;

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

    
    ans = 0;
    for(int i=0;i<n-1;i++) 
    {
        qsort(&(v[i]), n-i, sizeof(double), acs);
        v[i+1] = (v[i] + v[i+1])/ (double)2.0;
        // for(int i=0;i<n;i++) printf("%lf ",v[i]);
        // printf("\n");
    }
    
    printf("%g\n",v[n-1]);
    return 0;
}




Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] answer = new int[26];
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNextLine()) {
			String S = scanner.nextLine();
			S = S.toLowerCase();
			for(int i=0;i<S.length();i++) {
				if ('a'<=S.charAt(i)&&S.charAt(i)<='z') {
					answer[S.charAt(i)-'a']++;
				}
			}
			if (S.equals("")) {
				break;
			}
		}
		scanner.close();
		for(int i=0;i<26;i++) {
			System.out.println((char)(i+'a') + " : " + answer[i]);
		}
	}
}


Measured memory_bytes: 25976
#include <bits/stdc++.h>
#define DIV 998244353

using namespace std;

long a[301];
long dp1[301][90001];
long dp2[301][90001];

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

    dp1[0][0] = 1;
    dp2[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < sum; ++j) {
            if (dp1[i][j] != 0) {
                dp1[i + 1][j] = (dp1[i + 1][j] + dp1[i][j] * 2) % DIV;
                dp1[i + 1][j + a[i]] = (dp1[i + 1][j + a[i]] + dp1[i][j]) % DIV;
            }
            if (dp2[i][j] != 0) {
                dp2[i + 1][j] = (dp2[i + 1][j] + dp2[i][j]) % DIV;
                dp2[i + 1][j + a[i]] = (dp2[i + 1][j + a[i]] + dp2[i][j]) % DIV;
            }
        }
    }
    long answer = 1;
    for (int i = 0; i < n; ++i) {
        answer = answer * 3 % DIV;
    }
    for (int i = sum; i > (sum - 1) / 2; --i) {
        long sub = dp1[n][i];
        if (i * 2 == sum) {
            sub -= dp2[n][i];
        }
        answer = (answer - 3 * sub) % DIV;
    }
    if (answer < 0) answer += DIV;
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 421504
import itertools

N,D = map(int,input().split())

X = []
for i in range(N):
  X.append(list(map(int,input().split())))

cnt = 0
for v in itertools.combinations(X, 2):
  f = 0
  for w in range(D):
    f += (v[0][w]-v[1][w])**2
  f = f ** 0.5  
  if f.is_integer():
    cnt += 1
    
print(cnt)  

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

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

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

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

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

long int M = 1e+9+7;
int inf = 1e+9;

int n;
int solve(){
    int ans=0;
    return ans;
}

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

    while(cin >> n){
        vi a(n);
        int ans = 0;
        rep(i,n){
            cin >> a[i];
            ans ^= a[i];
        }
        rep(i,n){
            int t = ans ^ a[i];
            cout << t << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

#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 bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N;
int a[200005], b[200005];

int main(void) {
    scanf("%d", &N);
    rep(i, 1, N+1) scanf("%d", &a[i]);
    per(i, 1, N+1) {
    	int c = 0;
    	for (int j = i + i; j <= N; j += i) {
    		if (b[j]) c++;
    	}
    	if ((c%2) != a[i]) b[i] = 1;
    }

    vector<int> v;
    rep(i, 1, N+1) {
    	if (b[i]) v.pb(i);
    }
   

  
    printf("%d\n", (int)v.size());
    if (!v.empty()) {
    	rep(i, 0, v.size()) {
    		if (i > 0) printf(" ");
    		printf("%d", v[i]);
    	}
    	printf("\n");
    }

	return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
 
using namespace std;
 
const int maxn=500005;
typedef long long ll;
 
int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}
 
ll x,y;
ll a,b;
 
ll n,k;
ll vis[maxn],h[maxn];

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<=k;i++)
	{
		cin>>x>>y;
		if(h[x]>=h[y]) vis[y]=1;
		if(h[y]>=h[x]) vis[x]=1;
	}
	for(int i=1;i<=n;i++)
		if(vis[i]==0)
			a++;
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 5184
import java.util.Scanner;
import java.util.Arrays;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
long n=scan.nextLong();
long a=scan.nextLong();
long b=scan.nextLong();
  
if(n%(a+b)==0){
  System.out.println(n/(a+b)*a);
}else{
  long g=n/(a+b);
  long h=Math.min(n%(a+b),a);
System.out.println(g*a+h);
}

}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	string s;
	int ccount=0,ocount=0;
	cin>>s;
	
	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	
	for(int i=0;i<(int)s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			ocount++;
		}
	}
	
	for(int i=2;i<=(int)s.size()-2;i++){
		if(s[i]=='C'){
			ccount++;
		}
		
	}
	
	if(ccount==1 && ocount==(int)s.size()-2){
		cout<<"AC"<<endl;
	}
	else{
		cout<<"WA"<<endl;
	}

}

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

int main() {
  int n, a, count = 0;
  cin >> n;
  vector<int> vec(n);
  
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  int k = 1;
  for (int i=0; i<n; i++) {
    count++;
    k = vec.at(k-1);
    if (k == 2) break;
  }
  
  if (k != 2) count = -1;
  
  cout << count << endl;
}


Measured memory_bytes: 3728
<?php
//error_reporting(0);
$H = trim(fgets(STDIN));
$W = trim(fgets(STDIN));
$N = trim(fgets(STDIN));
//list($N,$W) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

printf("%d\n",ceil($N/max($H,$W)));


Measured memory_bytes: 4732
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

def check(m):
    sm = 0
    for i, a in enumerate(A):
        sm += abs(a - (m+i+1))
    return sm

# 三分探索
low = -INF
hi = INF
while low+2 < hi:
    m1 = (low*2+hi) // 3
    m2 = (low+hi*2) // 3
    res1 = check(m1)
    res2 = check(m2)
    # 今回は下に凸な関数なので値の小さい方に向かって狭めていく
    if res1 <= res2:
        hi = m2
    else:
        low = m1

ans = INF
for i in range(low, low+2):
    ans = min(ans, check(i))
print(ans)


Measured memory_bytes: 81648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll x; cin >> x;
    if(x >= 30){
    	print("Yes")
    }else{
    	print("No")
    }
    
    return 0;
}

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

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

    let mut lgcd = vec![0; n];
    let mut rgcd = vec![0; n];

    let mut g = aa[0];
    for i in 0..n {
        g = gcd(aa[i], g);
        lgcd[i] = g;
    }

    let mut g = aa[n-1];
    for i in (0..n).rev() {
        g = gcd(aa[i], g);
        rgcd[i] = g;
    }

    let mut ans = max(rgcd[1], lgcd[n-2]);
    for i in 1..n-1 {
        let l = lgcd[i-1];
        let r = rgcd[i+1];
        ans = max(ans, gcd(l, r));
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());
			long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			// 1 2 3 4 5 6 7 8 9
			Array.Sort(a);
			long ans = 0;
			for (int i = 0; i < n; i++) {
				ans += a[3 * n - 2 - (i * 2)];
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 45192
#include <iostream>
using namespace std;
int main(void){
    int N, A, B;
    cin >> N >> A >> B;
    
    if((B - A)%2 == 0){
        cout << "Alice" << endl;
        
    }else if((B - A)%2 == 1){
        cout << "Borys" << endl;
    }else{
        return 0;
    }
}


Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		private static long max = long.MaxValue - (long)1e12 * (16 + 1);

		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			var x = firstLine[0];
			var y = firstLine[1];

			var hashSet1 = new HashSet<int>() { 1, 3, 5, 7, 8, 10, 12 };
			var hashSet2 = new HashSet<int>() { 4, 6, 9, 11 };

			if((hashSet1.Contains(x) && hashSet1.Contains(y)) || (hashSet2.Contains(x) && hashSet2.Contains(y)) || (x == 2 && y == 2))
			{
				WriteLine("Yes");
			}
			else
			{
				WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 13408
#include<stdio.h>
#define MAX 100000
#define N -1
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n,D[MAX];

void print(int x){
  int i,c;
  printf("node %d: ",x);
  printf("parent = %d, ",T[x].p);
  printf("depth = %d, ",D[x]);
  if(T[x].p==N)
    printf("root, ");
  else if(T[x].l==N)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0,c=T[x].l;c!=N;i++,c=T[c].r){
    if(i)
      printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int x, int p){
  D[x]=p;
  if(T[x].r!=N)
    rec(T[x].r,p);
  if(T[x].l!=N)
    rec(T[x].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=N;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)
	T[v].l=c;
      else
	T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==N)
      r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<int> vint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;


lint gcd(lint x, lint y){
    if (x == 0) return y;
    return gcd(y % x, x);
};

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

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

lint powmod(lint x, lint y, lint m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

lint comb(lint n, lint r, lint m){
    if (n < r) return 0;

    if (n-r < r) r = n-r;
    int ret = 1; int d = 1;
    for (int i = n-r+1; i < n+1; i++) ret = (ret * i) % m;
    for (int i = 1; i < r+1; i++) d = (d * i) % m;
    ret *= powmod(d, m-2, m);
    return ret % m;
};

lint min_arr(vector<lint> x){
    lint y = x[0];
    rep(i, x.size()){
        y = min(y, x[i]);
    }
    return y;
};

int mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

int main() {
    int x, y, z; cin >> x >> y >>z;
    cout << z << " " << x << " " << y << endl;
}



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

const int INF = (int)1e9;

struct Edge {
  int to, cap, rev;
  Edge(int to_, int cap_, int rev_) :
    to(to_), cap(cap_), rev(rev_) { }
};

struct FordFulkerson {
  const int V;
  vector<vector<Edge> > G;
  vector<bool> used;
  FordFulkerson(int v) : V(v), G(v), used(v) { }
  void add_edge(int from, int to, int cap) {
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size() - 1);
  }
  int find_flow(int v, int t, int f) {
    if(v == t) return f;
    used[v] = true;
    for(Edge &e : G[v]) {
      if(used[e.to] == false && e.cap > 0) {
        int d = find_flow(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    while(true) {
      used.assign(V, false);
      int f = find_flow(s, t, INF);
      if(f == 0) return flow;
      flow += f;
    }
  }
};

int main() {
  int N; cin >> N;
  vector<int> W(N);
  vector<int> H(N);
  for(int i = 0; i < N; ++i) {
    cin >> W[i] >> H[i];
    if(H[i] > W[i]) swap(H[i], W[i]);
  }
  FordFulkerson flow(2*N+2);
  for(int i = 0; i < N; ++i) {
    flow.add_edge(2*N, i, 1);
    flow.add_edge(N + i, 2*N + 1, 1);
    for(int j = 0; j < N; ++j) {
      if(W[i] > W[j] && H[i] > H[j])
        flow.add_edge(i, N + j, 1);
    }
  }
  cout << (N - flow.max_flow(2*N, 2*N+1)) << endl;
}


Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void print(T x){cout << x << endl;}
template<class T>void printvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    ll n, k; cin >>n >>k;
    vector<ll> h(n); 
    rep(i, n) cin>>h[i];

    vector<ll> cost(n, INT64_MAX);
    cost[0]=0;
    rep(i, n){
        for(int j=1; j<=k; j++){
            if(i-j<0) break;
            chmin(cost[i], cost[i-j]+abs(h[i]-h[i-j]));
        }
    }
    print(cost[n-1]);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
   int N;
   cin>>N;
   while(N%111!=0){
       N++;
   }
   cout<<N<<endl;
}

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

using namespace std;
long long n,kq[100005],sl,x;
set<int> s;
pair<long long,int> a[100005];
int main()
{
  
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a+1,a+n+1);
    s.insert(a[n].second);
    sl=a[n].first;
    for (int i=n-1;i>=0;--i)
     if (a[i].first==sl) s.insert(a[i].second);
    else
    {
        x=s.size();
        kq[(*s.begin())]+=(x*(sl-a[i].first));
        sl=a[i].first;
        s.insert(a[i].second);

    }

    for (int i=1;i<=n;++i) cout<<kq[i]<<'\n';
    return 0;
}


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

using namespace std;

int main()
{
    int n,m;
    set <int> a,b;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a.insert(x);
    }
    cin>>m;
    while(m--)
    {
        int x;
        cin>>x;
        b.insert(x);
    }
    vector <int> c;
    set_symmetric_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    for(int i=0;i<c.size();i++)
    {
        cout<<c[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 23632
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

main(){
	fastio;
	int n;cin>>n;
	map<string,int> m;
	rep(i,0,n){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size()<<endl;
}


Measured memory_bytes: 19292
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N; cin>>N;

	bool flag=false;
	for(int i=1;i<=9;i++){
		if(N%i==0 && N/i<=9){
			flag = true;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define Mod 1000000007

using namespace std;

int main() {
  ll n;cin>>n;
  ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  cout<<a[n/2]-a[n/2-1];
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main
{
	public static void main(String[] args)throws Exception
	{
		Scanner scan=new Scanner(System.in);
		
		int a=scan.nextInt();
		int b=scan.nextInt();
		
		if(a<b)
		{
			System.out.println("a < b");
		}
		else if(a>b)
		{
			System.out.println("a > b");
		}
		else if(a==b)
		{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26184
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N, K; cin >> N >> K;
  vector<ll> NUM(K, 0);
  ll ans = 0;
  for (int i = 1; i <= N; i++) NUM[i % K]++;
  rep(a, K) {
    int b = (K-a) % K;
    int c = (K-a) % K;
    if ((b+c) % K != 0) continue;
    ans += NUM[a] * NUM[b] * NUM[c];
  }

  cout << ans << endl;
}


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

int main(){
    int r;
    cin >> r;
    float p = 3.1415;
    cout << 2*p*(float)r << endl;
    return 0;
}


Measured memory_bytes: 3788
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {

	int H, W;
	cin >> H >> W;

	string S[50];

	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}

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

	rep(i, H) {
		rep(j, W) {
			if (S[i][j] == '#') continue;

			int num = 0;
			for (int d = 0; d < 8; ++d) {
				const int ni = i + dy[d];
				const int nj = j + dx[d];

				if (ni < 0 || H <= ni) continue;
				if (nj < 0 || W	<= nj) continue;
				if (S[ni][nj] == '#') num++;
			}

			S[i][j] = char(num + '0');
		}	
	}

	rep(i, H) {
		cout << S[i] << endl;	
	}	

	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string N;
    cin >> N;

    ll temp = 0;
    REP(i, N.length()){
        temp += N[i] - '0';
    }
    if(temp%9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3704
package main

import "fmt"

func main() {
  var a, b int
  fmt.Scan(&a)
  fmt.Scan(&b)
  if a == 1 {
    if b == 2 {
      fmt.Println(3)
    }
    if b == 3 {
      fmt.Println(2)
    }
  }
  if a == 2 {
    if b == 1 {
      fmt.Println(3)
    }
    if b == 3 {
      fmt.Println(1)
    }
  }
  if a == 3 {
    if b == 1 {
      fmt.Println(2)
    }
    if b == 2 {
      fmt.Println(1)
    }
  }
}

Measured memory_bytes: 512
import sys
from fractions import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def lcm(x, y):
    return x * y // gcd(x, y)


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]
    B = A[::]

    while not any(b % 2 for b in B):
        B = [b // 2 for b in B]

    if not all(b % 2 for b in B):
        print(0)
        return

    semi_lcm = 1
    for a in A:
        semi_lcm = lcm(semi_lcm, a)

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 17716
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
int a[101][101],b[101],c[101];

int main()
{
     int n,m;
     std::cin>>n>>m;
     std::string s;
     for(int i=1;i<=n;i++)
     {
         std::cin>>s;
         for(int j=1;j<=m;j++)if(s[j-1]=='#')a[i][j]=1;
     }

     for(int i=1;i<=n;i++)
     {
         int p=0;
         for(int j=1;j<=m;j++)if(a[i][j])p=1;
         if(!p)b[i]=1;
     }

     for(int i=1;i<=m;i++)
     {
         int p=0;
         for(int j=1;j<=n;j++)if(a[j][i])p=1;
         if(!p)c[i]=1;
     }

     for(int i=1;i<=n;i++)
     {
         bool p=0;
         if(b[i])continue;
         for(int j=1;j<=m;j++)
         {
             if(c[j])continue;
             if(a[i][j])std::cout<<'#';
             else std::cout<<'.';
         }std::cout<<std::endl;
     }
}


Measured memory_bytes: 256