akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;

ll modadd(ll a,ll b){
    return (a%MOD+b%MOD)%MOD;
}

ll modsub(ll a,ll b){
    a%=MOD;
    b%=MOD;
    if(a>=b) return a-b;
    else return MOD-b+a;
}

ll modmul(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll moddiv(ll a,ll b) {
    return modmul(a, modpow(b, MOD-2));
}

vll fac, finv, inv;

void COMinit(ll MAX) {
    if(MAX<1) return;
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k==0 || n==k) return 1;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    ll X,Y;
    cin>>X>>Y;
    //a,b
    //a+2b=X
    //2a+b=Y
    //a=(2Y-X)/3
    //b=(2X-Y)/3
    
    //ans=(a+b)!/a!/b!
    
    if((2*Y-X)%3!=0 || (2*X-Y)%3!=0) {
        cout<<0<<endl;
        return 0;
    }
    
    ll a=min((2*Y-X)/3,(2*X-Y)/3);
    ll b=max((2*Y-X)/3,(2*X-Y)/3);
    
    COMinit(a+b+1);
    
    cout<<COM(a+b,a);
    
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}
double pi = 3.1415926535897932384626;


int main(){
	double A, B, H, M; cin >> A >> B >> H >> M;
	double an = 30*H + M/2;
	double bn = 6*M;
	double c;
	if(an > bn) c = an - bn;
	else c = bn - an;
	deci;
	cout << sqrt(A*A+B*B-2*A*B*cos(c*pi/180)) << endl;
	return 0;
}


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

// helpers
const parseLines = (
  lines: string[]
): any => {
  let tmp = ``
  const N = +lines[0]
  const Bn = lines[1].split(` `).map(num => +num)
  const obj = { N, Bn }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, Bn } = parseLines(lines)

  let sum = Bn[0];
  let tmp = Bn[0];
  for(let i = 1; i < N - 1; i++) {
    sum += tmp < Bn[i] ? tmp : Bn[i]
    tmp = Bn[i]
  }
  sum += tmp
  return `${sum}`
}

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

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


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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
  ll n, m;
  cin >> n >> m;

  ll ans = 0;
  if(n * 2 <= m){
    ans = n + (m - n * 2) / 4;
  }else{
    ans = m / 2;
  }
  cout << ans << endl;
  return 0;
}


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

long long GCD(long long X, long long Y) {
	if (Y == 0) return X;
	else return GCD(Y, X % Y);
}

int main() {
	long long A, B, C, D, G, L;
	cin >> A >> B >> C >> D;
	G = GCD(C, D);
	L = C * D / G;
	cout << (B - A + 1) - (B / C + B / D - B / L - (A - 1) / C - (A - 1) / D + (A - 1) / L) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

ll __lcm(ll a, ll b) { return a / __gcd(a, b) * b; }

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a));
  unique(a);
  n = a.size();
  vector<int> cnt(n);
  REP(i, n) {
    a[i] >>= 1;
    int tmp = a[i];
    while (tmp % 2 == 0) {
      ++cnt[i];
      tmp >>= 1;
    }
  }
  sort(ALL(cnt));
  if (cnt.front() < cnt.back()) {
    cout << "0\n";
    return 0;
  }
  ll l = a[0];
  FOR(i, 1, n) {
    l = __lcm(l, a[i]);
    if (l > m) {
      cout << "0\n";
      return 0;
    }
  }
  m -= l;
  cout << m / (l * 2) + 1 << '\n';
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(void){
   string s;
   cin>>s;
   if(s=="A"){
       cout<<'T'<<endl;
   }
   else if(s=="T"){
       cout<<'A'<<endl;
   }
   else if(s=="C"){
       cout<<'G'<<endl;
   }
   else if(s=="G"){
       cout<<'C'<<endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

const int MAX = 2100;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    COMinit();
    int N,K;
    cin>>N>>K;
    REP(i,K){
        ll ans=(COM(N-K+1,i+1)*COM(K-1,i))%MOD;
        cout<<ans<<endl;
    }

}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
//#include<set>
//#include<iostream>
using namespace std;

int n;
#define maxn 111
#define LL long long
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
LL a[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	LL now=1;
	for (int i=1;i<=n;i++)
		now=now/gcd(now,a[i])*a[i];
	printf("%lld\n",now);
	return 0;
}

Measured memory_bytes: 128
/* ALDS1_4_C: Dictionary */

#include <iostream>

const int MAX_KEY_LENGTH = 12;
const int N_KEY_CHARS = 4;

class Dict {
    int *KEYS;
    int char_to_id(char);
    int to_hash(char*);
    public:
        Dict();
        void insert(char*);
        bool has(char*);
};

Dict::Dict() {
    int max_hash = 0, w = 1;
    for (int i = 0; i < MAX_KEY_LENGTH; i++, w *= N_KEY_CHARS) {
        max_hash += N_KEY_CHARS * w;
    }
    KEYS = new int[max_hash + 1];
    std::fill_n(KEYS, max_hash, 0);
}

void Dict::insert(char *key) {
    KEYS[ to_hash(key) ] = true;
}

bool Dict::has(char *key) {
    return KEYS[ to_hash(key) ];
}

int Dict::char_to_id(char c) {
    switch (c) {
        case 'A': return 1;
        case 'C': return 2;
        case 'G': return 3;
        case 'T': return 4;
    }
    return 0;
}

int Dict::to_hash(char *key) {
    int hash = 0;
    int w = 1;
    for (int i = 0; key[i]; i++, w *= N_KEY_CHARS) {
        hash += w * char_to_id(key[i]);
    }
    return hash;
}

int main() {
    int n_ops;
    std::cin >> n_ops;

    Dict dict;
    char op[10], key[MAX_KEY_LENGTH + 1];
    std::string ans;

    for (int i = 0; i < n_ops; i++) {
        std::cin >> op >> key;
        switch (op[0]) {
            case 'i': // insert
                dict.insert(key);
                break;
            case 'f': // find
                ans = dict.has(key) ? "yes" : "no";
                std::cout << ans << std::endl;
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 88580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,i;
    cin>>a;
    long long int ar[a];
    long long int sum=0;
    for(i=0;i<a;i++)
    {
        cin>>ar[i];
        sum+=ar[i];

    }
    c=0;
    d=0;
    for(i=0;i<a-1;i++)
    {
        c+=ar[i];
        d=sum-c;
        f=abs(c-d);
    e=min(e,f);

    }
    cout<<e<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n; cin >> n;
    int ans=0;
    for(int j=1; j<=n; j+=2){
        int cnt=0;
        for(int i=1; i<=j; i++){
            if(j%i==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout << ans  << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> co(3, 0);
  for(char c : s){
    co.at(c-'a')++;
  }
  sort(co.begin(), co.end());
  if(co.back() - co.front() > 1) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

int H,W;
char A[1002][1002];
int main(){
    scanf("%d %d",&H,&W);
    queue< pair<int,int> > q1;
    rep(i,H){
        rep(j,W){
            scanf("%c",&A[i][j]);
            if(A[i][j]!='#'&&A[i][j]!='.')scanf("%c",&A[i][j]);
            if(A[i][j]=='#')q1.push(mp(i,j));
        }
    }
    

    ll int ans=0;
    while(1){
        queue<pair<int,int> > q2;
        while(!q1.empty()){

            pair<int,int> p=q1.front();q1.pop();
            int i=p.first;int j= p.second;
            
            if(i>0&&A[i-1][j]!='#'){A[i-1][j]='#';q2.push(mp(i-1,j));}
            if(i<H-1&&A[i+1][j]!='#'){q2.push(mp(i+1,j));A[i+1][j]='#';}
            if(j>0&&A[i][j-1]!='#'){q2.push(mp(i,j-1));A[i][j-1]='#';}
            if(j<W-1&&A[i][j+1]!='#'){A[i][j+1]='#';q2.push(mp(i,j+1));}
        }

        if(q2.empty())break;
        swap( q1, q2);
        ans++;
    }
    printf("%lld\n",ans);
}


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

int main()
{
    int a,b,t, total_min = 0;
    cin >> a >> b >> t;
    float limit = t + 0.5;

    for(int min = 1; min <= limit; min++) {
        if(min % a == 0)
            total_min += b;
    }
    cout << total_min;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	if n%2==1
		println(0)
	else
		k = 0
		x = 10
		while x<=n
			k += div(n,x)
			x*=5
		end
		println(k)
	end
end

main()

Measured memory_bytes: 109704
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

        int n, a, b;
        cin >> n >> a >> b;
        int mx = (a + b) % n;
        if( a == n && b == n ) {
                cout << n << " " << n << endl;
                return 0;

        }
        if( a + b < n ) mx = 0;
        cout << min( a, b ) << " " << mx << endl;

    return 0;
}



Measured memory_bytes: 256
def checkWays(n,x)
  count = 0
  catch(:stop) do
    n.downto(1) do |n1|
      (n1-1).downto(1) do |n2|
        n3 = x - n1 - n2
        throw :stop if (n3 >= n1)
        break if (n3 >= n2)
        count += 1 if (n3 > 0)
      end
    end
  end
  puts count
end

while ((n,x = gets.split(" ").map(&:to_i)).inject(:+) != 0) do
  max = 3*(n-1)
  unless ((6..max).include?(x))
    puts 0
    next
  end
  checkWays(n,x)
end

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

int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    if(op=='+')cout << a+b << endl;
    else if(op=='-')cout << a-b << endl;
    else if(op=='*')cout << a*b << endl;
    else if(op=='/')cout << a/b << endl;
    cin >> a >> op >> b; 
  }
  return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	string a, b, c, d, e, f;
	cin >> a >> b >> c;
	transform(a.begin(), a.end(), a.begin(), ::toupper);
	transform(b.begin(), b.end(), b.begin(), ::toupper);
	transform(c.begin(), c.end(), c.begin(), ::toupper);
	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,c,i;
    long long b[200000],d=0;
    scanf("%d %d",&a,&c);
    for(i=0;i<a;i++)
    {
    scanf("%lld",&b[i]);
    }
    sort(b,b+a);
    for(i=0;i<a-c;i++)
    {
        d=d+b[i];
    }
    printf("%lld",d);
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int x,y;
  if(n%a!=0){
    x=((n/a+1)*b);
  }else
    x=n/a*b;
  if(n%c!=0){
    y=((n/c+1)*d);
  }else
    y=n/c*d;

  if(x>y)
    cout<<y<<endl;
  else
    cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 3096
// Addition and Multiplication

#include <iostream>

using namespace std;

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

	int res = 1;

	for (int i = 0; i < N; ++i){
		if (res <= K)
			res *= 2;
		else
			res += K;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
over = []
short = 0
cnt = 0
for i in range(n):
    c = A[i] - B[i]
    if c > 0:
        over.append(c)
    elif c < 0:
        short -= c
        cnt += 1
if sum(over) < short:
    print(-1)
else:
    over.sort(reverse=True)
    s = 0
    i = 0
    while s < short:
        s += over[i]
        i += 1
    cnt += i
    print(cnt)


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n,m;
	cin>>n>>m;

	vector<lli> a(m),b(m);

	REP(i,0,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	lli sum=0;

	REP(i,0,m){
		map<lli,vector<lli>> d;
		REP(j,0,m){
			if(i==j)continue;
			d[a[j]].push_back(b[j]);
			d[b[j]].push_back(a[j]);
		}

		vector<lli> flag(n,0);
		queue<lli> q;
		q.push(0);
		flag[0]=1;
		while(q.size()!=0){
			lli top = q.front();
			if(DEBUG)cout<<"top="<<top<<endl;
			q.pop();
			for(auto e:d[top]){
				if(flag[e]!=0)continue;
				if(DEBUG)cout<<"e="<<e<<endl;
				flag[e]=1;
				q.push(e);
			}
		}
		bool all=false;
		REP(i,0,n){
			if(flag[i]==0){
				all = true;
				break;
			}
		}
		if(all)sum++;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
n, a, b = gets.to_s.chomp.split.map{|t| t.to_i }

ans = 0
(1..n).each do |i|
  s = i.to_s.chars.map{|t| t.to_i }.reduce(0){|s,t|s+t}
  ans += i if s.between?(a, b)
end

puts ans

Measured memory_bytes: 3836
#include<stdio.h>
int main(void){
	char ch[1200];
	int i=0;

	while(1){
		scanf("%c",&ch[i]);
		if(ch[i]=='\n'){
			break;
		}
		if('a'<= ch[i] && ch[i] <= 'z'){
			ch[i]=ch[i]-32;
		}else if('A' <= ch[i] && ch[i] <= 'Z'){
			ch[i]=ch[i]+32;
		}
		i++;
	}
	i=0;
	while(1){
		if(ch[i]=='\n'){
			break;
		}
		printf("%c",ch[i]);
		i++;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2032
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int len = s.length();

		int[] A = new int[len];
		int[] B = new int[len];

		int i;
		for(i = 0; i < len; i++) {
			A[i] = i % 2;
			B[i] = (i + 1) % 2;
		}

		int tempA = 0;
		int tempB = 0;
		int intS;
		for(i = 0; i < len; i++) {
			intS = Integer.parseInt(s.substring(i, i + 1));

			if(intS != A[i])
				tempA++;

			if(intS != B[i])
				tempB++;
		}

		System.out.println(Math.min(tempA, tempB));
	}
}


Measured memory_bytes: 30040
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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;
}

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(data[y] < data[x]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x) { return data[x] < 0 ? x : (data[x] = root(data[x])); }

    int size(int x) { return -data[root(x)]; }
};

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

    ll N, M;
    cin >> N >> M;
    vector<ll> a(M), b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind UF(N);
    vector<ll> ans(M, 0);
    ans[M - 1] = N * (N - 1) / 2;

    for(int i = M - 1; i > 0; i--) {
        if(UF.root(a[i]) == UF.root(b[i])) {
            ans[i - 1] = ans[i];
            continue;
        }
        ans[i - 1] = ans[i] - 1ll * UF.size(a[i]) * UF.size(b[i]);
        UF.merge(a[i], b[i]);
    }
    rep(i, M) COUT(ans[i]);
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

#define endl '\n'
#define ll long long

using namespace std;

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

	int a[3] = { 0 };
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			a[0]++;
		else if (s[i] == 'G')
			a[1]++;
		else
			a[2]++;
	}
	ll s1 = 0;
	s1 = (ll)a[0] * a[1] * a[2];
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= min(i, n - i - 1); j++)
		{
			if (s[i] != s[i - j] && s[i] != s[i + j] && s[i - j] != s[i + j])
			{
				s1--;
			}
		}
	}
	cout << s1 << endl;

	return 0;
}

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


long long N;
long long W;
std::vector<long long> w;
std::vector<long long> v;
long long SUM_W;

long long dfs(long long n, long long used_w){
    if(n == N){
        return 0;
    }
    long long no_used = dfs(n + 1, used_w);
    if(used_w + w[n] <= W){
        long long used = dfs(n + 1, used_w + w[n]) + v[n];
        return max(used, no_used);  
    }else{
        return no_used;
    }  
}

long long dp(){
    auto table = vector<vector<long long>>(N + 1, vector<long long>(W+1));
    int i, i1;
    for(int i_=N - 1; i_ >= 0; i_--){
        i = i_%2;
        i1 = (i+1)%2;
        for(int j=0; j <= W+1; j++){
            if(j + w[i_] <= W){
                table[i][j] = max(table[i1][j + w[i_]] + v[i_], table[i1][j]);
            }else{
                table[i][j] = (table[i1][j]);
            }
        }
    }

    return *max_element(table[i].begin(), table[i].end());
}

void solve(long long N_, long long W_, std::vector<long long> w_, std::vector<long long> v_){
    N = N_;
    W = W_;
    w = w_;
    v = v_;
    SUM_W = accumulate(w.begin(), w.end(), 0);
    // long long res = dfs(0, 0);
    long long res = dp();
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#include <map>

// #pragma GCC optimize ("O3")

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m; long long k; cin >> n >> m >> k;
    vector<long long> a(n);
    vector<long long> b(m);
    // vector<long long> sum_a(n+1);
    // vector<long long> sum_b(m+1);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    // sum_a[0] = 0;
    // sum_b[0] = 0;
    // for (int i = 1; i < n+1; i++) sum_a[i] = sum_a[i-1] + a[i-1];
    // for (int i = 1; i < m+1; i++) sum_b[i] = sum_b[i-1] + b[i-1];

    // int lower_a = 0;
    // int lower_b = 0;
    // for (int i = 0; i < n; i++)
    //     if (sum_a[i] <= k)
    //         lower_a = i;
    // for (int i = 0; i < m; i++)
    //     if (sum_b[i] <= k)
    //         lower_b = i;
    // if (lower_a == 0 && lower_b == 0) {
    //     cout << 0;
    //     return 0;
    // }
    int out = 0;
    long long sum_sofar = 0;
    for (int i = 0; i < n; i++) {
        if (sum_sofar + a[i] <= k) {
            sum_sofar += a[i];
            out++;
        }
        else {
            break;
        }
    }
    int low = out - 1;
    // cout << low << " ";
    // sum = sum_a[out];
    int max_out = out;
    for (int j = 0; j < m; j++) {
        if (sum_sofar + b[j] <= k) {
            sum_sofar += b[j];
            out++;
            max_out = max(out, max_out);
            // cout << out << " ";
        }
        else {
            while (low >= 0 && sum_sofar + b[j] > k) {
                sum_sofar -= a[low];
                low--;
                out--;
                // cout << sum_sofar << " ";
            }
            if (sum_sofar + b[j] <= k) {
                sum_sofar += b[j];
                out++;
                max_out = max(out, max_out);
                // cout << sum_sofar << " ";
            } else {
                break;
            }
        }
    }
    cout << max_out;

    // int out1 = 0;
    // int remain = k - sum_a[lower_a];
    // int i = 0;
    // while (i < sum_b.size() && sum_b[i] <= remain) {
    //     i++;
    // }
    // out1 = lower_a + i +1;

    // int out2 = 0;
    // remain = k - sum_b[lower_b];
    // i = 0;
    // while (i < sum_a.size() && sum_a[i] <= remain) {
    //     i++;
    // }
    // out2 = lower_b + i +1;
    // cout << max(out2, out1);


}

Measured memory_bytes: 6360
#include <iostream>
using namespace std;
int main(void){
	int N, M;
	cin >> N >> M;

	const int nmmax = 50;
	char A[nmmax][nmmax], B[nmmax][nmmax];


 	for (int y = 0; y < N; ++y) {
 		for (int x = 0; x < N; ++x) {
 			cin >> A[y][x];
 		}
 	}

 	for (int y = 0; y < M; ++y) {
 		for (int x = 0; x < M; ++x) {
 			cin >> B[y][x];
    	}
 	}

	bool exist=false;

 	for (int ly = 0; ly < N; ++ly) {
 		for (int lx = 0; lx < N; ++lx) {
			if (ly+M-1>=N or lx+M-1>=N) 
              continue;

 			bool match=true;
 			for (int y = 0; y < M; ++y) {
  	 			for (int x = 0; x < M; ++x) {
 					if (A[ly+y][lx+x] != B[y][x]) 
                      match=false;
 				}
    		}
 			if(match) 
              exist=true;
 		}
 	}

 	if(exist)
 		cout << "Yes" << endl;
 	else
 		cout << "No" << endl;

 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;
  cout << "2018/01/" << s[8] << s[9] << endl;
  return 0;
}


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

const int maxn = 200005;
int a[maxn], b[maxn], x[maxn], y[maxn];
int n, ALL, ans, p, q, cnta, cntb;
long long res;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%d", &a[i]);
	rep (i, 1, n) scanf("%d", &b[i]);
	rep (i, 0, 28) {
		ALL = (1 << i) - 1;
		cnta = cntb = res = 0;
		rep (j, 1, n) {
			x[j] = a[j] & ALL;
			cnta += a[j] >> i & 1;
			y[j] = b[j] & ALL;
			cntb += b[j] >> i & 1;
		}
		sort(x+1, x+n+1); sort(y+1, y+n+1);
		p = 0; q = n + 1;
		while (++p <= n) {
			while (q >= 2 && y[q-1] + x[p] > ALL) q--;
			res += n - q + 1;
		}
		res += 1LL * cnta * (n - cntb);
		res += 1LL * cntb * (n - cnta);
		ans += (res&1) << i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3328
MAX_T = 2 * 10 ** 5


def main():
    n, c = map(int, input().split())

    ch = [[] for i in range(c)]
    for i in range(n):
        si, ti, ci = map(int, input().split())
        ch[ci-1].append([si, ti])

    for i in range(c):
        if len(ch[i]) != 0:
            ch[i].sort(key=lambda lst: lst[0])
            pro_lst = [ch[i][0]]
            for j in range(1, len(ch[i])):
                if ch[i][j][0] == pro_lst[-1][1]:
                    pro_lst[-1][1] = ch[i][j][1]
                else:
                    pro_lst.append(ch[i][j])
            ch[i] = pro_lst

    im = [0 for i in range(MAX_T+1)]
    for i in range(c):
        for j in range(len(ch[i])):
            im[2*ch[i][j][0]-1] += 1
            im[2*ch[i][j][1]] -= 1

    im_s = [0 for i in range(MAX_T+1)]
    for i in range(1, len(im)):
        im_s[i] = im_s[i-1] + im[i]

    print(max(im_s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23436
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s,t;
    while(cin>>s>>t){
        int dp[2][4001]={{0}};
        int Max=0;
        for(int i=0;i<t.length();i++){
      
            for(int j=0;j<s.length();j++){
                if(t[i]==s[j])dp[(i+1)&1][j+1]=dp[i&1][j]+1;
                else dp[(i+1)&1][j+1]=0;

                Max=max(dp[(i+1)&1][j+1],Max);
              
            }
    

        }
        cout<<Max<<endl;
    }
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

int main() {
    int N; // the number of given integers
    std::cin >> N;
    assert(2 <= N && N <= 100'000);
    assert(N % 2 == 0);

    std::vector<int> values; // the given integers

    for (int i=0; i<N; i++) {
        int v;
        std::cin >> v;
        assert(1 <= v && v <= 100'000);
        values.push_back(v);
    }

    std::sort(values.begin(), values.end());
    for (int i=0; i<N; i++) std::cerr << values.at(i) << " ";
    std::cerr << std::endl;
    int number_of_divisions = values.at(N/2) - values.at(N/2-1);

    std::cout << number_of_divisions << std::endl;

    return 0;
}


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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j,k;
        cin >> n >> k;
        ll arr[101];
        for(i=0;i<101;i++)
        {
            arr[i] = 0;
        }

        for(i=0;i<k;i++)
        {
            ll d;
            cin >> d;
            for(j=0;j<d;j++)
            {
                ll snuke;
                cin >> snuke;
                arr[snuke]++;
            }
        }

        ll ans = 0;
        for(i=1;i<=n;i++)
        {
            if(arr[i] == 0)
            {
                ans++;
            }
        }
        cout << ans << '\n';
    }

    
    
}

Measured memory_bytes: 3596
def main():
    from sys import stdin
    input = stdin.buffer.readline

    n, m = map(int, input().split())
    x, y, z = [0] * n, [0] * n, [0] * n
    for ind in range(n):
        i, j, k = map(int, input().split())
        x[ind] = i
        y[ind] = j
        z[ind] = k

    from itertools import product
    ans = 0
    for i, j, k in product([True, False], repeat=3):
        l = [0] * n
        if i:
            for ind in range(n):
                l[ind] += x[ind]
        else:
            for ind in range(n):
                l[ind] -= x[ind]
        if j:
            for ind in range(n):
                l[ind] += y[ind]
        else:
            for ind in range(n):
                l[ind] -= y[ind]
        if k:
            for ind in range(n):
                l[ind] += z[ind]
        else:
            for ind in range(n):
                l[ind] -= z[ind]

        l.sort(reverse=True)
        candidate = sum(l[:m])
        if ans < candidate:
            ans = candidate
    
    print(ans)

main()

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;
    
    ll ans = 0;
    for(ll i=1;i<=N;i++){
        if(i<=K){
            ans += X;
        }else{
            ans += Y;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    vector <ll> v(n);

    for(ll i=0; i<n; ++i) cin >> v[i];

    ll a, ans = 0;
    for(ll i=1; i<n; ++i)
    {
        if(v[i] < v[i-1]){
            a = v[i-1]-v[i];
            ans += a;
            v[i] += a;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4692
import java.util.*;
public class Main {
	static int N,u,v;
	static List<ArrayList<Integer>> ls = new ArrayList<ArrayList<Integer>>();
	static int t_dist[], a_dist[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt(); u = sc.nextInt()-1; v = sc.nextInt()-1;
		for(int i=0;i<N;i++) ls.add(new ArrayList<Integer>());
		for(int i=0;i<N-1;i++) {
			int A = sc.nextInt()-1, B = sc.nextInt()-1;
			ls.get(A).add(B);
			ls.get(B).add(A);
		}
		sc.close();
		t_dist = new int[N];
		a_dist = new int[N];
		int dif[] = new int[N];
		dfs(u, 0,-1);
		adfs(v, 0, -1);
		for(int i=0;i<N;i++) {
			dif[i] = Math.max(a_dist[i]-t_dist[i], 0);
		}

		int max = 0;
		for(int i=0;i<N;i++) {
			if(dif[i]>0&&max<a_dist[i]) {
				max = a_dist[i];
			}
		}
			
		long ans = max - 1;
		
		System.out.println(ans);
	}
	static void dfs(int now, int cnt, int parent) {
		t_dist[now]=cnt;
		for(int i=0;i<ls.get(now).size();i++) {
			int next = ls.get(now).get(i);
			if(next == parent)continue;
			dfs(next, cnt+1, now);
		}
	}
	static void adfs(int now, int cnt, int parent) {
		a_dist[now]=cnt;
		for(int i=0;i<ls.get(now).size();i++) {
			int next = ls.get(now).get(i);
			if(next == parent)continue;
			adfs(next, cnt+1, now);
		}
	}
}


Measured memory_bytes: 110796
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int X;

// 素因数分解
bool isPrime(int n)
{
    int a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            return false;
            n /= a;
        } else {
            a++;
        }
    }
    return true;
}

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

    int n;
    for (n = X; ; n++) {
        if (isPrime(n)) break;
    }

    output(n);

    return 0;
}

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

const int maxn = 2e5 + 3;

int n;
std::vector<int> E[maxn];

int c[maxn];
std::vector<int> cv[2];
std::queue<int> q;
bool vis[maxn];
std::deque<int> bf[3];
int res[maxn];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        E[u].push_back(v);
        E[v].push_back(u);
    }
    q.push(1);
    vis[1] = true;
    c[1] = 0;
    cv[c[1]].push_back(1);
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(auto &&v : E[u]) {
            if(vis[v])
                continue;
            q.push(v);
            vis[v] = true;
            c[v] = c[u] ^ 1;
            cv[c[v]].push_back(v);
        }
    }
    for(int i = 1; i <= n; ++i)
        bf[i % 3].push_back(i);
    if(cv[0].size() > cv[1].size())
        cv[0].swap(cv[1]);
    if(cv[0].size() <= bf[0].size()) {
        for(auto &&u : cv[0]) {
            res[u] = bf[0].back();
            bf[0].pop_back();
        }
        for(auto &&v : cv[1]) {
            for(int j = 0; j < 3; ++j)
            if(!bf[j].empty()) {
                res[v] = bf[j].back();
                bf[j].pop_back();
                break;
            }
        }
    } else {
        for(auto &&u : cv[0]) {
            if(!bf[2].empty()) {
                res[u] = bf[2].back();
                bf[2].pop_back();
            } else {
                res[u] = bf[0].back();
                bf[0].pop_back();
            }
        }
        for(auto &&v : cv[1]) {
            for(int j = 0; j < 3; ++j)
            if(!bf[j].empty()) {
                res[v] = bf[j].back();
                bf[j].pop_back();
                break;
            }
        }
    }
    for(int i = 1; i <= n; ++i) {
        printf("%d%c", res[i], " \n"[i == n]);
    }
    return 0;
}

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

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

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int i=X+1;i<=Y;i++){
       if(x[N-1]<i&&y[0]>=i){
           cout<<"No War"<<endl;
           return 0;
       }
    }
    cout<<"War"<<endl;
}

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
	int N, A[MAX_N + 2] = {};

	std::cin >> N;
	for(int i = 1; i <= N; ++i) {
		std::cin >> A[i];
	}

	ll cumsum[MAX_N + 2] = {};
	for(int i = 1; i <= N + 1; ++i) {
		cumsum[i] = cumsum[i - 1] + std::abs(A[i] - A[i - 1]);
	}

	for(int i = 1; i <= N; ++i) {
		ll ans = cumsum[N + 1] - std::abs(A[i] - A[i - 1]) - std::abs(A[i + 1] - A[i]) + std::abs(A[i + 1] - A[i - 1]);
		std::cout << ans << "\n";
	}

}


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

int main(){

  int n,y;
  cin>>n>>y;
  y/=1000;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=(n-i);j++){
      int t=y-10*i-5*j;
      if(i+j+t==n){
        cout<<i<<" "<<j<<" "<<t;
        return 0; 
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1;
  return 0;
}

Measured memory_bytes: 256
t = input()
q = [0]*(t + 1)
for i in range(t + 1):
	n,m = map(int,raw_input().split())
	vr = [map(float,raw_input().split()) for x in range(m)]
	q[i] = sum([v*r for v,r in vr])/sum([r for v,r in vr]) 
print "YES" if max(q[:-1]) - q[-1] > 0.0000001 else "NO"

Measured memory_bytes: 4252
import re
import sys
import math
import itertools
from sys import stdin

def main():
    """
     解答をこちらに
    """
    s = input()
    last_c = None
    for c in s:
        if c  == last_c:
            print("Bad")
            return
        last_c = c
    print("Good")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val S = rd.readString()
    val N = S.length

    var cnt = 0
    var i = 0; var j = N-1
    while (i < j) {
        if (S[i] == S[j]) {
            i++
            j--
        } else {
            if (S[i] == 'x') {
                i++
                cnt++
            } else if (S[j] == 'x') {
                j--
                cnt++
            } else {
                println(-1)
                return
            }
        }
    }

    val ans = cnt
    println(ans)
}


//val rd = debug.Reader("etc", "code-festival-2017-qualc", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 36360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int x;
    cin >> x;
    mp[x]++;
  }
  int ans = 0;
  for(auto p : mp){
    int key = p.first;
    int value = p.second;
    if(key > value) ans += value;
    if(key < value) ans += value-key;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
/* デバッグ */
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"

int main(){
  int A,B;
  cin>>A>>B;
  A--;B--;
  cout<<( (B+A-1)/A )<<endl;
}

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

int dp[100010][2];
bool flag[100010];
std::vector<int> sub_vertices[100010];
const int mod = 1e9+7;

void rec(int i){
    dp[i][0] = dp[i][1] = 1;
    for(int v : sub_vertices[i]){
        if(dp[v][0]) continue;
        rec(v);
        dp[i][0] = (dp[i][0] * long(dp[v][0]+dp[v][1])) % mod;
        dp[i][1] = (dp[i][1] * long(dp[v][0])) % mod;
    }
}

int main(){
    int n;
    std::cin >> n;
    for(int i = 0; i < n-1; i++){
        int x, y;
        std::cin >> x >> y;
        sub_vertices[x].push_back(y);
        sub_vertices[y].push_back(x);
    }
    rec(1);
    std::cout << (dp[1][0] + dp[1][1])%mod << std::endl;
}


Measured memory_bytes: 10624
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

main()
{
  unsigned short *A, *B;
  int C[VMAX+1]; //カウント用
  int i, j, n;

  scanf("%d", &n);
  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);

  for(i=0; i<=VMAX; i++) C[i]=0;

  /* Aの読込み & Cにそれぞれの数の出現数をカウント */
  for(i=0; i<n; i++)
    {
      scanf("%hu", &A[i+1]);
      C[A[i+1]]++;
    }

  /* C[i]にi以下の数の出現数を記録(handout 6th lecture p17) */
  for(i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

  /* partition */
  for(j=1; j<=n; j++)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  /* print */
  for(i=1; i<=n; i++)
    {
      printf("%d", B[i]);
      if(i != n)
	{
	  printf(" ");
	}
    }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $in = <>;
	chomp $in;
	my ($n, $k) = split(/ /, $in);

	my $cnt = 0;
	while ($n){
		$cnt++;
		if ($n > $k){
			$n = $n - ($k - 1);
		}else{
			last;
		}
	}

	print $cnt, "\n";

	return 0;
}

#----- 実行 -----#
exit( main() );




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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	A := nextInt()
	B := nextInt()

	fmt.Println(A * B)
}


Measured memory_bytes: 1760