akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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 comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

string S;
void solve(){
  ll N = S.size();
  S += '#';
  ll last = 0;
  vector<pair<ll, ll>> xs;
  rep(i, N){
    if(S[i] == 'L' && S[i] != S[i+1]){
      string X = S.substr(last, i - last + 1);
      last = i + 1;
      ll cntL = 0, cntR = 0;
      rep(j, X.size()){
        if(X[j] == 'L') cntL++;
        else cntR++;
      }
      ll l, r;
      l = (cntR + 1) / 2 + cntL / 2;
      r = (cntL + 1) / 2 + cntR / 2;
      xs.pb({l, r});
    }
  }
  ll at = 0;
  rep(i, N){
    if(S[i] == 'R' && S[i] != S[i+1]){
      cout << xs[at].f << " " << xs[at].s << " ";
      at++;
      i++;
    }else{
      cout << 0 << " ";
    }
  }
  cout << endl;
}


int main(){
  cin >> S;
  solve();
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<string> s(n);
  for (auto &x: s) cin >> x;

  vector<ll> count(5);
  for (int i = 0; i < n; i++) {
    if (s[i][0] == 'M') count[0]++;
    if (s[i][0] == 'A') count[1]++;
    if (s[i][0] == 'R') count[2]++;
    if (s[i][0] == 'C') count[3]++;
    if (s[i][0] == 'H') count[4]++;
  }

  ll ans = 0;
  ans += count[0] * count[1] * count[2];
  ans += count[0] * count[1] * count[3];
  ans += count[0] * count[1] * count[4];
  ans += count[0] * count[2] * count[3];
  ans += count[0] * count[2] * count[4];
  ans += count[0] * count[3] * count[4];
  ans += count[1] * count[2] * count[3];
  ans += count[1] * count[2] * count[4];
  ans += count[1] * count[3] * count[4];
  ans += count[2] * count[3] * count[4];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5760
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
/*int main(){
    ll c=0,d=0,k=0,n,m,h,w,p,q;
    const int max = 100000;
    string s,s1,s2;
    ll num[max+1];

    cin >> n >> k;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        num[a] += b;
    }

    for (int ans=1; ans<=max; ans++){
        if(k <= num[ans]){
            cout << ans << endl;
            break;
        }
        k -= num[ans];
    }

    return 0;
}*/
const int AMAX = 100000;
ll cnt[AMAX + 1];

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

rep(i,N){
 int A, B;
 cin >> A >> B;
 cnt[A] += B;
 }

for (int ans = 1; ans <= AMAX; ++ans){
 if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
}
 K -= cnt[ans];
 }

 return 0;
 }

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

int n;
int MAXIMUM=100005;
long INF = 1e15;
// W:未訪問
// G:訪問する候補
// B:訪問済み
int W=0,G=1,B=2;
vector<pair<int,int>> adj[100005];
long d[100005];
int dijkstra(int K){
  priority_queue<pair<int,int>> PQ;
  int u,minv;
  int color[MAXIMUM];
  // d[n]:Tに属する頂点と V - T に属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録

  //初期化
  for(int i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }

  d[K]=0;
  PQ.push(make_pair(0,K));
  color[K] = G;

  while (!PQ.empty()) {
    pair<int,int> f = PQ.top();
    PQ.pop();
    u = f.second;
    // 頂点を訪問済に
    color[u] = B;
    //最小値を取り出し、それが最短でなければ無視
    if( d[u]<f.first*(-1)) continue;

    //訪問済みでないかつ辺がつながっている頂点の中でコストが最小の辺を選択
    for(int j=0;j<adj[u].size();j++){
      int v = adj[u][j].first;
      if(color[v]== B) continue;
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
        color[v]=G;
      }
    }
  }


}

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

  int Q,K;
  cin>>Q>>K;
  dijkstra(K-1);
  for(int i=0;i<Q;i++){
      int x,y;
      cin>>x>>y;
      cout<<d[x-1]+d[y-1]<<endl;
  }

}


Measured memory_bytes: 9204
#include <stdio.h>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	double a, b, c, d, e, f;
	double b1, c1, e1, f1;
	double x, y;

	while (cin >> a >> b >> c >> d >> e >> f) {
		b1 = b * d;
		c1 = c * d;
		e1 = e * a;
		f1 = f * a;

		if (b1 == e1) continue;
		y = (c1 - f1) / (b1 - e1);
		x = (c - b * y) / a;
		printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
int main(){
  int x,y,i,j,s=0,sum=0;
  int n[100];
  while(scanf("%d",&x)!=EOF){
    for(i=0;i<x;i++){
      scanf("%d",&n[i]);
    }

    for(i=0;i<(x-1);i++){
      for(j=i;j<x;j++){
	if(n[i]>=n[j]){
	  y=n[i];
	  n[i]=n[j];
	  n[j]=y;
	}      
      }
    }

    s+=n[0];
    sum+=n[0];
    for(i=1;i<x;i++){
      sum+=n[i];
      s+=sum;
    } 
    printf("%d\n",s);
    s=0;
    sum=0;
  }  

  return 0;
}

Measured memory_bytes: 0
#ABC-086 (倍数判定)
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 倍数の生成
c = a*b
# 出力
if c % 2 == 0:
  print('Even')
else:
  print('Odd')

Measured memory_bytes: 2940
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto N = sread();
    writeln((N[0] == '7' || N[1] == '7' || N[2] == '7') ? "Yes" : "No");
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using lint = long long;
constexpr lint D = 1LL << 30;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> xs[i] >> ys[i];
        xs[i] += D, ys[i] += D;
    }

    int ans = n;
    for (int si = 0; si < n; ++si) {
        for (int sj = 0; sj < si; ++sj) {
            lint dx = xs[sj] - xs[si],
                 dy = ys[sj] - ys[si];

            if (dx < 0) {
                dx = -dx;
                dy = -dy;
            } else if (dx == 0 && dy < 0) {
                dy = -dy;
            }

            std::map<std::pair<lint, lint>, std::vector<lint>> pss;
            for (int i = 0; i < n; ++i) {
                lint x = xs[i], y = ys[i];

                lint k = (dx > 0 ? x / dx : y / dy);
                x -= dx * k;
                y -= dy * k;
                pss[std::make_pair(x, y)].push_back(k);
            }

            int cost = n;
            for (auto& ps : pss) {
                auto& vs = ps.second;
                std::sort(vs.begin(), vs.end());

                for (int i = 0; i + 1 < (int)vs.size(); ++i) {
                    if (vs[i + 1] - vs[i] == 1) --cost;
                }
            }

            ans = std::min(ans, cost);
        }
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


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

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int shift = Integer.parseInt(in.readLine());
        String string = in.readLine();
        for (int i = 0; i < string.length(); i++) {
            int val = string.charAt(i)-'A';
            val += shift;
            val %= 26;

            System.out.print(((char)(val + 'A')));
        }
        System.out.print('\n');
    }

}
/*


 */

Measured memory_bytes: 24148
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, X, T = readnums()
    print(N // X * T if not N % X else (N // X + 1) * T)


if __name__ == "__main__":
    main()


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


template<typename T, typename F>
class SegmentTree {
private:
	T e;
	F op;
	ll n;
	vector<T> dat;
public:
	SegmentTree(F f, T _e, vector<T> v) :op(f), e(_e) {
		int _n = v.size();
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, e);
		REP(i, _n)dat[n + i - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	SegmentTree(F f, T _e, int _n) :op(f), e(_e) {
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, e);
		for (int i = n - 2; i >= 0; i--)dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int i, T x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	T query(int l, int r) {
		//[l,r)でのクエリ処理
		T left = e, right = e;
		l += n - 1; r += n - 1;
		while (l < r) {
			if ((l & 1) == 0)left = op(left, dat[l]);
			if ((r & 1) == 0)right = op(dat[r - 1], right);
			l = l / 2;
			r = (r - 1) / 2;
		}
		return op(left, right);
	}
};



void solve(){
    ll n,x;
    cin>>n>>x;
    Array a(n,0);
    REP(i,n) cin>>a[i];
    auto op = [](ll a, ll b) {return min(a,b); };
    SegmentTree<ll, decltype(op)> seg(op,INF,a);

    auto check=[&](ll l,ll r)->ll{
        if(l<0){
            return min(seg.query(0,r+1),seg.query(n+l,n));
        }else{
            return seg.query(l,r+1);
        }
    };

    ll ans=INF;
    REP(i,n){
        //i回シフトを行う場合
        ll tmp=i*x;
        REP(j,n){
            tmp+=check(j-i,j);
        }
        chmin(ans,tmp);
    }
    cout<<ans<<en;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		System.out.println((s.charAt(0) != s.charAt(1) || s.charAt(1) != s.charAt(2)) ? "Yes" : "No");
		
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000010
using namespace std;

int dp[100010];
int n;
vector<int> a;

void solve() {
    fill(dp, dp+n, INF);
    for (int i=0; i<n; ++i) {
        *upper_bound(dp, dp+n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
}


int main() {
	cin >> n;

	for(int i = 0; i < n; i++){
		int v;
		cin >> v;
		a.push_back(v);
	}
	reverse(a.begin(), a.end());

	solve();
}


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

int main() {
    int A,B;
    cin >> A >> B;
    int cnt=0;
    for (int i = A;i<=B;i++){
        int A,B,C,D,E;
        A = i/10000;
        B = (i-A*10000)/1000;
        C = (i-A*10000-B*1000)/100;
        D = (i-A*10000-B*1000-C*100)/10;
        E = i-A*10000-B*1000-C*100-D*10;
        if(A==E&&B==D) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool cmp(int lhs,int rhs) {
	return abs(lhs)<abs(rhs);
}
int abs(int x) {
	if(x<0)return -x;
	return x;
}
int main(){
  int N,L;
  scanf("%d %d",&N,&L);
  int a[200+5];
  for(int i =1;i<=N;i++){
    a[i] = L+i-1;
  }
  sort(a+1,a+N+1,cmp);
  int sum=0;
  for(int i=2;i<=N;i++)
	sum+=a[i];
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 3768
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"


int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int value = 0;
	if (A <= K) {
		value = A;
		K -= A;
		
		K -= B;
		if (0 < K) {
			value += -1 * min(K, C);
		}
	}
	else {
		value = K;
	}
	cout << value << endl;
	return 0;
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      ll a,b;
      cin>>a>>b;
      ll x=a+b;
      ll y=a-b;
      ll z=a*b;
      cout<<max(x,max(y,z))<<endl;
    }
}
/* Be careful about integer ranges;
   Check the corner cases before submitting.
*/




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define bs binary_search
#define mp make_pair
#define F first
#define S second
#define It iterator
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rint register int
#define en "\n"
#define br break
#define con continue
#define fri(n) for( int i=0;i<n;i++)
#define frj(n) for( int j=0;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define fast ios_base::sync_with_stdio(0);cin.tie();cout.tie();
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi>vii;
typedef map<int,int> mi;
typedef set<int> S;
typedef list<int> L;
typedef stack<int> St;
typedef queue<int> Qu;
typedef deque<int> Dq;
typedef map<string,int> msi;
typedef map<pi,int> mpi;
typedef map<int,vii> mivi;
typedef map<pi,vi> mpivi;
int k;
int cost(int n,int a[],int res[])
{
    int ans=INT_MAX;
    for(int i=1;i<=k;i++){
        if(n-i>=1){
            if(res[n-i]==-1)res[n-i]=cost(n-i,a,res);
            ans=min(abs(a[n]-a[n-i])+res[n-i],ans);
        }
        else br;
    }
    return ans;
}
void solve()
{
    int n;cin>>n>>k;
    int a[n+1]={};fri(n)cin>>a[i+1];
    int res[n+1];fri(n+1)res[i]=-1;
    res[0]=0;
    res[1]=0;
    res[2]=abs(a[2]-a[1]);
    cout<<cost(n,a,res);
}
int main()
{
    fast;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //T(t)
    {
        solve();
    }
}


Measured memory_bytes: 12132
def main():
    x = input().split()

    W = int(x[0])
    a = int(x[1])
    b = int(x[2])

    if b > a+W:
        print(b - (a+W))
        return
    elif a > b+W:
        print(a - (b+W))
        return

    print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
typedef pair<ll, ll> P;
int main()
{
    int N;
    cin >> N;
    vector<int> G[N], cost[N];
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
        cost[u].push_back(w);
        cost[v].push_back(w);
    }

    vector<int> res(N, -1);
    res[0] = 0;
    stack<int> s;
    s.push(0);
    while (!s.empty()) {
        int v = s.top();
        s.pop();
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            int w = cost[v][i];

            if (res[u] != -1)
                continue;
            res[u] = (res[v] + w) % 2;
            s.push(u);
        }
    }

    for (int i = 0; i < N; i++)
        cout << res[i] << endl;
    return 0;
}


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

int main(){
  long long int N;
  string S;
  cin >> S;
  if(S == "Sunny") cout << "Cloudy" << endl;
  if(S == "Cloudy") cout << "Rainy" << endl;
  if(S == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include<string>
#include<vector>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli x,k,n,c,las;
	c=0;
	cin>>n>>k;
	if(k==n)cout<<"Yes";
	else cout<<"No";
	
	// cout<<0;
	// x='Z';
	// las=int('Z');
	// if('Z'-(s[0]+k)>=0)cout<<(char)(s[0]+2);
	// cout<<'Z'<<" "<<(s[0]+k);
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long long ull;
typedef long double ld;

int main(){

    ull a, b,c;
    cin >> a >> b >> c;
    ull d = c-a-b;
    if(d>0&&d*d>4*a*b)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}








Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn =  new Scanner(System.in);
		String str = scn.nextLine();
		String key = "keyence";
		String buf,buf2;
		boolean ans = false;
		for(int i = 0;i <= 7;i++) {
			buf = str.substring(0, i);
			buf2 = str.substring(str.length() - (7-i));
			ans |= key.equals(buf + buf2);
		}
		System.out.println(ans?"YES":"NO");
	}
}


Measured memory_bytes: 21716
import sys

if __name__ == "__main__":
	N = int(input())

	sum = 0

	for i in range(1, N+1):
		if (i % 15 == 0) or (i % 3 == 0) or (i % 5 == 0):
			continue
		else:
			sum += i

	print(sum)

Measured memory_bytes: 9172
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    char a;
    cin >> a;
    if(a>='a' && a<='z')cout << 'a';
    else cout << 'A';
    cout  << endl;
}

int main(){
    solve();
    return 0;
}




Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
	long long n,d,x,y;
	int i,c=0;
	scanf("%lld %lld",&n,&d);
	for(i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(d*d>=(x*x)+(y*y)){
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
ll dp[3001][6001];
ll n,s;


int main()
{
	cin >> n >> s;
	vector<ll> A(n);
	for(int i =0 ;i<n;i++)cin >> A[i];
	dp[0][0] = 1;
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<=3000;j++)
		{
			(dp[i+1][j+A[i]] += dp[i][j])%=MOD;
		}
		for(int j = 0;j<=3000;j++)
		{
			(dp[i+1][j] += dp[i][j]*2)%=MOD;
		}
	}
	//for(int i = 0;i<=n;i++){for(int j = 0 ;j<10;j++){cout<<dp[i][j]<<' ';}cout<<endl;}
	ll ans =0;
	cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 116428
def main():
    n, m = [int(x) for x in input().split()]

    liked_count = [0] * m
    for i in range(n):
        liked_list = [int(x) for x in input().split()[1:]]
        for liked_id in liked_list:
            liked_count[liked_id - 1] += 1

    print(liked_count.count(n))

if __name__ == "__main__":
    main()

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

int x[25][25];
int main()
{
    int n,d;
    cin>>n>>d;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<d; j++)
        {
            cin>>x[i][j];
        }
    }

    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            int sum=0;
            for(int k=0; k<d; k++)
            {
                sum+=((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
            }
            for(int k=1; k<=1000; k++)
            {
                if(k*k==sum)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;

int main()
{
	in >> S;
	if (S[0] != 'A') out << "WA" << std::endl;
	else
	{
		S.erase(S.begin());
		int cou = 0, pos;
		for (int i = 1; i < S.length() - 1; ++i)
		{
			if (S[i] == 'C')
			{
				++cou;
				pos = i;
			}
		}
		if (cou != 1) out << "WA" << std::endl;
		else
		{
			S.erase(S.begin() + pos);
			rep(i, S.length())
			{
				if ('A' <= S[i] && S[i] <= 'Z')
				{
					out << "WA" << std::endl;
					return 0;
				}
			}
			out << "AC" << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int a[200];
	int cnt,i,j,flg;
	cnt=0;
	flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	while(1){
		for(i=0;i<n;i++){
			if(a[i]%2!=0){
				flg=1;
				break;
			}
		}
		if(flg==1){
			break;
		}
		for(j=0;j<n;j++){
			a[j]/=2;
		}
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
#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(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k;
	cin >> n >> k;
	ll p[n];
	set<ll> s, t;
	zep(i, 0, n){
		cin >> p[i];
	}
	
	zep(i, 0, k){
		s.insert(p[i]);
		t.insert(-p[i]);
	}
	//print(*s.lower_bound(0))
	//print(-*t.lower_bound(-n))
	ll ans = 1;
	zep(i, k, n){
		s.erase(p[i-k]);
		t.erase(-p[i-k]);
		if(*s.lower_bound(0) < p[i-k] || p[i] < -*t.lower_bound(-n)){
			ans++;
		}
		s.insert(p[i]);
		t.insert(-p[i]);
	}
	
	ll noc = 0;
	ll cnt = 0;
	ll b = -1;
	zep(i, 0, n){
		cnt++;
		if(p[i] < b){
			if(cnt > k){
				noc++;
			}
			cnt = 1;	
		}
		b = p[i];
	}
	if(cnt >= k){
		noc++;
	}
	print(ans-max(noc-1, 0LL))
	return 0;
}

Measured memory_bytes: 20608
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int lmax=1999999999;
const long long lmx=1999999999999999999;
ll Nn,N,P;
ll ans=1LL;
ll lp[10000004];
int main(){std::ios::sync_with_stdio(false);
cin>>Nn>>P;
if(Nn==1LL){
	cout<<P<<endl;
	return 0;
}
N=P;
for (ll i=2; i*i<=N; ++i) {
    if (lp[i] == 0) {
        ll k=0;
		while(P%i==0){
			P/=i;
			k++;
		}
		while(k>=Nn){
			ans*=i;
			k-=Nn;
		}
    }
    for (ll j=i;j*j<=N;j+=i)
        lp[j] = 1;
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define rep2(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	i64 a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans;
	if (k % 2 == 0) ans = a - b;
	else ans = b - a;
	cout << ans << endl;
}

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

constexpr int inf = 1e9;

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(10);
    cout << (d == 0 ? 1 : 2) * (n - d) * (m - 1) / n / n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
int main() {

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


  ll n;
  cin>>n;
  ll ans=1;
  for(ll i=1;i<=n;i++)
  {
      ans=(ans%mod * i%mod)%mod;
  }
cout<<ans<<endl;
	return 0;
}


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

int h, w, n;
vector<string> grid;

class Data
{
public:
    vector<int> p;
    bitset<3> bs;
    Data(vector<int>& p0, bitset<3> bs0){
        p = p0;
        bs = bs0;
    }
    int toInt(){
        int ret = bs.to_ulong();
        for(int i=0; i<n; ++i){
            ret *= h * w;
            ret += p[i];
        }
        return ret;
    }
};

int solve()
{
    string gridLine = accumulate(grid.begin(), grid.end(), string());
    int diff[] = {1, -1, w, -w};

    vector<int> sp(n), gp(n);
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            int c = grid[i][j];
            if('a' <= c && c <= 'c'){
                sp[c-'a'] = i * w + j;
            }else if('A' <= c && c <= 'C'){
                gp[c-'A'] = i * w + j;
            }
        }
    }

    int size = 1 << n;
    for(int i=0; i<n; ++i)
        size *= h * w;

    vector<vector<bool> > check(2, vector<bool>(size, false));
    check[0][Data(sp, 0).toInt()] = true;
    check[1][Data(gp, 0).toInt()] = true;
    vector<deque<Data> > dq(2);
    dq[0].push_back(Data(sp, 0));
    dq[1].push_back(Data(gp, 0));

    int turn = 0;
    int m = 1;
    int ret = 1;
    for(;;){
        if(m == 0){
            ++ ret;
            turn ^= 1;
            m = dq[turn].size();
        }

        Data d = dq[turn].front();
        dq[turn].pop_front();
        -- m;

        for(int i=0; i<n; ++i){
            if(d.bs[i])
                continue;
            d.bs[i] = true;
            for(int j=0; j<4; ++j){
                d.p[i] += diff[j];

                bool ok = true;
                if(gridLine[d.p[i]] == '#')
                    ok = false;
                for(int k=0; k<n; ++k){
                    if(k != i && d.p[k] == d.p[i])
                        ok = false;
                }

                if(ok){
                    int a = d.toInt();
                    if(!check[turn][a]){
                        dq[turn].push_front(d);
                        ++ m;
                        check[turn][a] = true;
                    }
                }

                d.p[i] -= diff[j];
            }
            d.bs[i] = false;
        }

        d.bs = 0;
        int a = d.toInt();
        if(!check[turn][a]){
            if(check[turn^1][a])
                return ret;
            dq[turn].push_back(d);
            check[turn][a] = true;
        }
    }
}

int main()
{
    for(;;){
        cin >> w >> h >> n;
        if(w == 0)
            return 0;
        cin.ignore();

        grid.resize(h);
        for(int i=0; i<h; ++i)
            getline(cin, grid[i]);

        cout << solve() << endl;
    }
}

Measured memory_bytes: 50708
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <ctime>
#include <queue>
#include <set>
using namespace std;

#define N 10010
#define M 500010
	
typedef long long ll;
const int INF = 1 << 30;
const int mod = 1000000007;

bool dp[N];

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
 	
 	int n, x;
 	scanf("%d", &n);
 	dp[0] = 1;
 	while (n--)
 	{
 		scanf("%d", &x);	
 		for (int i = 10000; i >= x; --i) dp[i] |= dp[i - x];
	}
	for (int i = N - 1; i >= 0; --i)
	{
		if (dp[i] && i % 10)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>

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

using namespace std;

int gcd(int a,int b){
  if (a<b) return gcd(b,a);
  else {
  if (b==1) return 1;
  else if (b==0) return a;
  else return gcd(b,a%b);
  }
}

int main(){
 int n;cin >> n;
  int a[n+10]; 
  rep(i,n) cin>>a[i];
  int ans=a[0];
  rep(i,n) ans=gcd(ans,a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys


def input():
    return sys.stdin.readline().rstrip()

def main():

    mod =10**9+7
    N =int(input())
    A =list(map(int,input().split()))

    ss =sum(A) %mod
    sm =ss *ss % mod
    for i in A:
        sm -= i*i
        sm %=mod

    sm =sm*pow(2,mod-2,mod) %mod

    print(int(sm))










if __name__ == "__main__":
    main()


Measured memory_bytes: 94180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

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

    vector<ll> a(0);
    a.emplace_back(0);
    rep(i,1000){
        a.emplace_back(pow(i+1,5));
        a.emplace_back(-pow(i+1,5));
    }
    int ans_a, ans_b;
    for(int i=0; i<2001; i++){
        for(int j=0; j<2001; j++){
            if(a[i]-a[j]==x){
                if(i%2==0){
                    ans_a = (-i/2);
                }else{
                    ans_a = (i+1)/2;
                }
                if(j%2==0){
                    ans_b = (-j/2);
                }else{
                    ans_b = (j+1)/2;
                }
            }
        }
    }
    cout << ans_a << " " << ans_b << endl;
    return 0;
}

Measured memory_bytes: 4136
/* 方針
 * 1. ワーシャルフロイドで全最短経路長を求める O(N^3)
 * 2. 全経路列挙 O(8!) = 40320
 * 3. 足す
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

#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 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 ALL(a) (a).begin(), (a).end()

const int INF = 1e9;

using namespace std;

int main()
{
    int N, M, R; cin >> N >> M >> R;

    vector<int> goals(R);

    vector<vector<int>> distances(N, vector<int>(N, INF));

    REP(i, R)
    {
        cin >> goals[i];
        goals[i]--;
    }

    REP(i, M)
    {
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;

        distances[a][b] = c;
        distances[b][a] = c;
    }

    REP(k, N)
    {
        REP(i, N)
        {
            REP(j, N)
            {
                distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
            }
        }
    }

    sort(ALL(goals));
    long long distance = INF;
    do
    {
        long long current = 0;

        REP(i, R - 1)
            current += distances[goals[i]][goals[i+1]];

        distance = min(distance, current);

    } while(next_permutation(ALL(goals)));

    cout << distance << endl;

    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	if (n == 1)
	{
		println("Hello World");
	}
	else
	{
		ll a, b;
		cin >> a >> b;
		println(a + b);
	}
}


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

int main() {
  int n, x;
  cin >> n >> x;

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  sort(a.begin(), a.end());

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    x -= a[i];
    if (x >= 0)
      ++cnt;
    else
      break;
  }
  if (x > 0)
    --cnt;

  cout << cnt << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

const int MAX=100005;
char T[MAX];
char A[MAX],B[MAX],C[MAX],D[MAX];

int main(){
    
    int N;cin>>N;
    for(int i=0;i<N;i++){
        char a;cin>>a;
        T[i]=a;
    }
    A[0]='S';A[1]='S';
    B[0]='S';B[1]='W';
    C[0]='W';C[1]='S';
    D[0]='W';D[1]='W';
    for(int i=1;i<N;i++){
        if(T[i]=='o'){
            if(A[i]=='S') A[i+1]=A[i-1];
            else if(A[i-1]=='S') A[i+1]='W';
            else A[i+1]='S';
            if(B[i]=='S') B[i+1]=B[i-1];
            else if(B[i-1]=='S') B[i+1]='W';
            else B[i+1]='S';
            if(C[i]=='S') C[i+1]=C[i-1];
            else if(C[i-1]=='S') C[i+1]='W';
            else C[i+1]='S';
            if(D[i]=='S') D[i+1]=D[i-1];
            else if(D[i-1]=='S') D[i+1]='W';
            else D[i+1]='S';
        }else{
            if(A[i]=='W') A[i+1]=A[i-1];
            else if(A[i-1]=='S') A[i+1]='W';
            else A[i+1]='S';
            if(B[i]=='W') B[i+1]=B[i-1];
            else if(B[i-1]=='S') B[i+1]='W';
            else B[i+1]='S';
            if(C[i]=='W') C[i+1]=C[i-1];
            else if(C[i-1]=='S') C[i+1]='W';
            else C[i+1]='S';
            if(D[i]=='W') D[i+1]=D[i-1];
            else if(D[i-1]=='S') D[i+1]='W';
            else D[i+1]='S';
        }
    }
    if(T[0]=='o'){
        if(A[1]==A[N-1]&&A[0]==A[N]){
            for(int i=0;i<N;i++){
                cout<<A[i];
            }
        }else if(B[1]==B[N-1]&&B[0]==B[N]){
            for(int i=0;i<N;i++){
                cout<<B[i];
            }
        }else if(C[1]!=C[N-1]&&C[0]==C[N]){
            for(int i=0;i<N;i++){
                cout<<C[i];
            }
        }else if(D[1]!=D[N-1]&&D[0]==D[N]){
            for(int i=0;i<N;i++){
                cout<<D[i];
            }
        }else cout<<-1;
    }else{
        if(A[1]!=A[N-1]&&A[0]==A[N]){
            for(int i=0;i<N;i++){
                cout<<A[i];
            }
        }else if(B[1]!=B[N-1]&&B[0]==B[N]){
            for(int i=0;i<N;i++){
                cout<<B[i];
            }
        }else if(C[1]==C[N-1]&&C[0]==C[N]){
            for(int i=0;i<N;i++){
                cout<<C[i];
            }
        }else if(D[1]==D[N-1]&&D[0]==D[N]){
            for(int i=0;i<N;i++){
                cout<<D[i];
            }
        }else cout<<-1;
        
    }
    cout<<endl;
    
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

int main()
{
    long long a, b, c, x, y;

    cin >> a >> b >> c >> x >> y;

    long long sum = std::numeric_limits<long long>::max();

    for (long long i = 0; i < 10000000; i++)
    {
        long long cost = i * c;
        cost += a * max(0LL, x - i / 2LL);
        cost += b * max(0LL, y - i / 2LL);
        sum = min(sum, cost);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
H, W, D = map(int, input().split())

A = {0: (0, 0)}

for i in range(H):
    A_list = list(map(int, input().split()))

    for j in range(1, len(A_list) + 1):
        A[A_list[j - 1]] = (i, j)

serial = {}
for m in range(D):
    t_x = A[m][0]
    t_y = A[m][1]

    t = 0
    tmp_sum = 0
    serial[m] = []
    serial[m].append(tmp_sum)
    while(m + (t + 1) * D <= H * W):
        t += 1
        x = A[m + t * D][0]
        y = A[m + t * D][1]
        tmp_sum += abs(x - t_x) + abs(y - t_y)
        serial[m].append(tmp_sum)
        t_x = x
        t_y = y

Q = int(input())
ans = 0
# print(serial)
L = []
R = []
for i in range(Q):
    tL, tR = map(int, input().split())
    L.append(tL)
    R.append(tR)

for i in range(Q):
    tL = L[i]
    tR = R[i]
    print(serial[tL % D][tR // D] - serial[tL % D][tL // D])

Measured memory_bytes: 46468
def print_command(string, a, b):
    a, b = int(a), int(b)

    print(string[a:b + 1])

    return string


def reverse_command(string, a, b):
    a, b = int(a), int(b)

    return string[:a] + (string[a:b + 1])[::-1] + string[b + 1:]


def replace_command(string, a, b, replace):
    a, b = int(a), int(b)

    return string[:a] + replace + string[b + 1:]


if __name__ == "__main__":
    string = input()

    num_commands = int(input())

    commands = []

    for _ in range(num_commands):
        commands.append(input().split())

    command_function_table = {
        "print": print_command,
        "reverse": reverse_command,
        "replace": replace_command
    }

    for command in commands:
        string = command_function_table[command[0]](string, *(command[1:]))



Measured memory_bytes: 5620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Contest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var PQR = Console.ReadLine().Split().Select(int.Parse);
            Console.WriteLine(PQR.Sum() - PQR.Max());
        }
    }
}


Measured memory_bytes: 13268
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  m <- readLn
  ts <- replicateM m getLine
  print $ solve ss ts

solve :: [String] -> [String] -> Int
solve ss ts = let ds = ss \\ ts
              in f . map length . group . sort $ ds
  where
    f xs | null xs = 0
         | otherwise = maximum xs


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

using namespace std;

bool are_even(vector<int> vec);

int main()
{
    int n;
    vector<int> a(n);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        a.push_back(t);
    }

    int count = 0;
    for (;;) {
        if (are_even(a)) {
            for (int i = 0; i < n; ++i)
                a[i] = a[i] / 2;
            ++count;
        } else
            break;
    }
    cout << count << '\n';
}

bool are_even(vector<int> vec)
{
    for (auto v : vec) {
        if (v % 2 == 1)
            return false;
    }
    return true;
}


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

using namespace std;

template<typename T>
inline void remin(T& a, T b) { a = min(a, b); }

vector<long long> solve(int n, const vector<int>& x, const vector<int>& y, const vector<int>& p)
{
    long long inf = (1ll << 62);
    vector<long long> ans(n + 1, inf);
    vector< vector<int> > xsel(1 << n, vector<int>(n));
    vector< vector<int> > ysel(1 << n, vector<int>(n));
    
    for(int i = 0; i < 1 << n; ++i) {
        for(int j = 0; j < n; ++j) {
            xsel[i][j] = abs(x[j]);
            ysel[i][j] = abs(y[j]);
            for(int k = 0; k < n; ++k) {
                if((i >> k) & 1) {
                    remin(xsel[i][j], abs(x[j] - x[k]));
                    remin(ysel[i][j], abs(y[j] - y[k]));
                }
            }
        }
    }
    // Ate agora pagamos O(2^n * n^2), agora vem a parte tricky que domina a complexidade
    for(int i = 0; i < (1 << n); ++i) {
        int cnt = __builtin_popcount(i);
        for(int j = i; j >= 0; --j) {
            j &= i;
            long long cost = 0;
            for(int k = 0; k < n; ++k) {
                if(!((i >> k) & 1)) {
                    cost += 1LL * min(xsel[j][k], ysel[i - j][k]) * p[k];
                }
            }
            remin(ans[cnt], cost);
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> x(n), y(n), p(n);
    
    for(int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i] >> p[i];
    }
    
    auto ans = solve(n, x, y, p);
    for(int i = 0; i <= n; ++i) cout << ans[i] << '\n';
    return 0;

}


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

using std::pair;
using std::vector;
using std::string;
 
typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int T;
    ll a, b, c, d;

    read(T);
    while(T--) {
        read(a), read(b), read(c), read(d);

        if(a < b || d < b || a % b > c) { 
            puts("No"); 
        } else if(c >= b) {
            puts("Yes");
        } else {
            ll x = std::__gcd(b, d), y = a % b;
            ll t = (c - y + x) / x;
            if(y + t * x < b) puts("No"); else puts("Yes");
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main() {
  vector<int> nums(4, 0);
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    if (s == "AC") nums[0]++;
    if (s == "WA") nums[1]++;
    if (s == "TLE") nums[2]++;
    if (s == "RE") nums[3]++;
  }
  cout << "AC x " << nums[0] << endl;
  cout << "WA x " << nums[1] << endl;
  cout << "TLE x " << nums[2] << endl;
  cout << "RE x " << nums[3] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <complex>
#include <cmath>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;

    string str_a = to_string(a);
    string str_b = to_string(b);
    string str_ab = str_a + str_b;

    int ab = stoi(str_ab);
    int x = sqrt((double) ab);

    if (x * x == ab) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    string a;
    cin>>a;
    int ctr = 0;
    for(int i=0;i<a.length();i++)
    {
    	if(a[i]=='0')
    		ctr++;
    }
    int ctr2 =a.length()-ctr;
    cout<<min(ctr,ctr2)*2;
}

Measured memory_bytes: 512
//
// Created by haofeng on 5/29/20.
//
#include <iostream>
#include <stdio.h>
using namespace std;
int paiming[100010];
int N;
int tmp;
int main(){
    cin>>N;
    for (int i = 1; i <=N ; ++i) {
        cin>>tmp;
        paiming[tmp]=i;
    }
    for (int i = 1; i <=N ; ++i) {
        cout<<paiming[i]<<" ";
    }
}

Measured memory_bytes: 1152