akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n,k,ans=1;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		ans=min(2*ans,ans+k);
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main(){
	string str;
	while (cin >> str){
		for (int i = 0; i < str.size(); i++){
			if (str[i] == '@'){
				for (int j = str[i + 1]; j > '0'; j--){
					cout << str[i + 2];
				}
				i += 2;
			}
			else{
				cout << str[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
using namespace std;

int main(void){
  char a[128],b[128],c[128];
  scanf("%s%s%s",a,b,c);
  putchar(*a & ~32);
  putchar(*b & ~32);
  putchar(*c & ~32);
  puts("");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    string s; cin >> s;
    int q; cin >> q;
    bool flag = true;
    deque<char> lst;
    for (auto ch: s) {
        lst.push_back(ch);
    }
    rep(i, q) {
        int t; cin >> t;
        if (t == 1) {
            flag = (flag ? false : true);
        } else {
            int f; char c; cin >> f >> c;
            if (f == 1 && flag) {
                lst.push_front(c);
            } else if (f == 1 && !flag) {
                lst.push_back(c);
            } else if (f == 2 && flag) {
                lst.push_back(c);
            } else {
                lst.push_front(c);
            }
        }
    }
    if (flag) {
        for (auto ch: lst) {
            cout << ch;
        }
    } else {
        for (auto it = lst.rbegin(); it != lst.rend(); it++) {
            cout << *it;
        }
    }

    cout << endl;
}


Measured memory_bytes: 960
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;
    ll n;
    cin >> n;
    ll p[n];
    ll mx = 0;
    ll sum =0;
    F0R(i,n) {
        cin >> p[i];
        if(p[i] > mx) mx = p[i];
        sum += p[i];
    }
    cout << sum - (mx/2)<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
using AtCoderBeginnerContest130.Questions;
using AtCoderBeginnerContest130.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest130.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var whxy = inputStream.ReadIntArray();
            var w = whxy[0];
            var h = whxy[1];
            var x = whxy[2];
            var y = whxy[3];

            yield return $"{(double)w * h / 2} {(x * 2 == w && y * 2 == h ? 1 : 0)}";
        }
    }
}


namespace AtCoderBeginnerContest130
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest130.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest130.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  string s; cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<int,int>
template<class T> void chmax(T& a, T b){if(a < b) a = b;}
template<class T> void chmin(T& a, T b){if(a > b) a = b;}

bool prm[100010];

void prime(){
    for(int i = 2; i <= 1e5; i++){
        prm[i] = true;
    }
    for(int i = 2; i <= 1e5; i++){
        if(!prm[i]) continue;
        for(int j = i * 2; j <= 1e5; j += i){
            prm[j] = false;
        }
    }
}

int Q;
int sum[100010];

int main(){
    prime();
    cin >> Q;
    for(int i = 1; i <= 1e5; i += 2){
        if(prm[i] && prm[(i + 1) / 2]) sum[i]++;
        sum[i + 1] = sum[i];
        sum[i + 2] = sum[i];
    }
    for(int i = 1; i <= Q; i++){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <bits/stdc++.h>
using namespace std ;
#define printshosu(a) cout << fixed << setprecision(15) << a << endl;
int main(){
  int K;
  cin >>K;
  int ans = 0;
  for(int a = 1;a<=K;a++){
    for(int b = 1;b<=K;b++){
      for(int c = 1;c<=K;c++){
        ans += gcd(gcd(a,b),c);
      }
    }
  }
  cout<<ans<<endl;
}

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

x = [int(x) for x in input().split()]
y = [int(y) for y in input().split()]


for i in range(1, 4):
    d = 0
    for j in range(n):
        d += (abs(x[j] - y[j])) ** i
        
    print(d ** (1 / i))

d_max = 0

for j in range(n):
    d_max = max(abs(x[j] - y[j]), d_max)

print(d_max)


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

int main(){
    long long X,x=100;
    cin >> X;
    ll ans = 0;
    while(1){
        if(x>=X){
            cout << ans << endl;
            return 0;
        }
        ans++;
        x=(ll)(1.01*x);
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int N, K;
vector<int> A;
int main() {
  cin >> N >> K;
  A.resize(N);
  rep(i, N) cin >> A[i];

  sort(all(A));

  Combination<ModInt> comb(N);

  ModInt ans = 0;
  rep(i, N) {
    ans += comb.C(i, K - 1) * A[i];
    ans -= comb.C(N - 1 - i, K - 1) * A[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main()
{
  	char S[3];
  	int flag;

  	flag=3;

  	scanf("%s",S);
  
	if(S[0]==S[1] && S[1]==S[2]){
      printf("No\n");
    }
    else{
        printf("Yes\n");
    }
  
	return 0;  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> d(n), m(n);
  for (auto &e : d) {
    cin >> e;
    m[e]++;
  }

  if (d[0] != 0 || m[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll r = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m[i]; j++) {
      r *= m[i - 1];
      r %= MOD;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int a;
	char s[10];
	
	scanf("%d", &a);
	scanf("%s", s);
	
	if(a>=3200){ printf("%s", s); }
	else { printf("red"); }
	
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            cout << s[i];
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  string c = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(s.at(i)==c.at(j)){
        s.at(i)=c.at(j+n);
        cout<<s.at(i);
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace	std;
int main(){
  int n;
  vector <int> a;
  cin>>n;
  if(n==2){
    int n,m;
    cin>>n>>m;
    if(m>n) swap(n,m);
    cout<<n<<" "<<m<<endl;
    return 0;
  }
  for(int i=0,t;i<n&&cin>>t;i++) a.push_back(t);
  sort(a.begin(),a.end());
  int r0=a[n-1],r1,t0=*lower_bound(a.begin(),a.end(),r0/2),t1=(a[0]==t0?a[0]:*(lower_bound(a.begin(),a.end(),r0/2)-1));
  if(abs(t0-r0/2)>abs(t1-r0/2)) r1=t1;
  else r1=t0;
  cout<<r0<<" "<<r1<<endl;
  return 0;

}



Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1, 1, -1,-1,1};
int dy[] = {1, 0, -1, 0, 1, 1,-1,-1};
#define INF 1000000000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;
vector<int> d(100,0);
vector<int> f(100,0);

void dfs(int x,int y,Graph &G,Graph &visited){
    visited[y][x]=1;
    for(int A=0;A<8;A++){
        int n_x=x + dx[A];
        int n_y=y + dy[A];
        if(n_x<0 or 49<n_x or n_y<0 or 49<n_y) continue;
        if(G[n_y][n_x]==1&&visited[n_y][n_x]==0){
            dfs(n_x,n_y,G,visited);
        }
    }
}

int main(){
    vector<int> res;
    while(true){
        vector<vector<int>> visited(50,vector<int>(50,0));
        int w,h;cin>>w>>h;
        int ans=0;
        if(w==0&&h==0) break;
        vector<vector<int>> G(50,vector<int>(50,0));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++) cin>>G[i][j];
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(G[i][j]==1&&visited[i][j]==0){
                    dfs(j,i,G,visited);
                    ans++;
                }
            }
        }
        res.push_back(ans);
    }
    int s=res.size();
    for(int i=0;i<s;i++) cout<<res[i]<<endl;
}




Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int A,B;
  cin>>A>>B;
  if(A>=13){
    cout<<B<<endl;
  }
  else if(A>=6 && A<=12){
    cout<<(B/2);
  }
  else if(A>=0 && A<=5)
    cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	string s,t; cin >> s >> t;
	int ans = 0;
	rep(i,3) {
		if(s[i] == t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a1=Integer.parseInt(scan.next());
    		int a2=Integer.parseInt(scan.next());
    		int a3=Integer.parseInt(scan.next());
    		
    		int[] a= {a1,a2,a3};
    		Arrays.parallelSort(a);
    		
    		System.out.print(a[1]-a[0]+a[2]-a[1]);
     
    }
    }
// end 

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main(void)
{
  char a[101];
  char b[101];
  int i, n;
  int score_a = 0;
  int score_b = 0;
  int count = 0;

  scanf("%d", &n);

  for (i = 0 ; i < n; i++){
    scanf("%s %s", a, b);
    count = strcmp(a, b);
    if (count == 0){
      score_a++;
      score_b++;
    }
    else if(count > 0){
      score_a += 3;
    }
    else {
      score_b += 3;
    }
  }
  printf("%d %d\n", score_a, score_b);
  return (0);
}

Measured memory_bytes: 604
a, b, c, x, y = map(int, input().split())

p1 = a * x + b * y
# A>C
p = c * 2 * x

if x >= y:
  p = p

else:
  p = p + (y - x) * b
      
# B>C
p2 = c * 2 * y
if x >= y:
  p2 = p2 + (x - y) * a
else:
  p2 =p2
  
print(min(p, p1, p2))

Measured memory_bytes: 9184
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H, W, h, w;
        H = sc.nextInt();
        W = sc.nextInt();
        h = sc.nextInt();
        w = sc.nextInt();
        int ans;
        ans = H * W + h * w - (H * w + W * h);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    vector<int> a(3);
    for(int i=0; i<3; i++){
        cin >> a[i];
    }

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

    int ans = 0;
    for(int i=1; i<3; i++){
        ans += abs(a[i] - a[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
	int num, d, sum = 0, i = 0;

	scanf("%d %d", &num, &d);

	while (sum < num)
	{
		i++;
		sum += 1 + (2 * d);
	}

	printf("%d\n", i);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926

int main(){
	int x[200], y[200],n;
	double  D1 = 0.00000, D2 = 0.00000, D3 = 0.00000,D4=0.00000;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
	}

	for (int i = 1; i <= n; i++) {
		scanf("%d", &y[i]);
	}

	for (int i = 1; i <= n; i++) {
		D1 += abs(x[i] - y[i]);
		D2 += (x[i] - y[i])*(x[i] - y[i]);
		D3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		if (abs(x[i] - y[i]) > D4) {
			D4 = abs(x[i] - y[i]);
		}
	}
	printf("%f %f %f %f\n", D1, sqrt(D2), pow(D3, 1.0 / 3.0), D4);
	return 0;
}

Measured memory_bytes: 2884
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = 1e5;

int main() {

	int n;
	cin>>n;
	vl a(n);
	map<ll, ll> cnt;
	ll sum = 0;
	for (int i = 0;i < n;++i) {
		cin>>a[i];
		cnt[a[i]] += 1;
		sum += a[i];
	}

	//ll sum = accumulate(all(a), 0);
	int Q;
	cin>>Q;
	while (Q--) {
		ll b, c;
		cin>>b>>c;
		sum -= cnt[b] * b;
		sum -= cnt[c] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		sum += cnt[c] * c;
		cout<<sum<<endl;
	}

	return 0;
}


Measured memory_bytes: 9872
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
        int b = a;
        int c = 0;
        while(b>0){
            c+=b%10;
            b/=10;
        }
        if(a%c==0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[100000];
int main() {
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll>>key;
	ll ans=0;
	ll cnt=1;
	ll keta[12];
	for(ll i=0;i<12;i++){
		keta[i]=cnt;
		cnt*=2;
	}
	for(ll i=0;i<n;i++){
		ans+=keta[i];
		//cout <<ans<<endl;
	}
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		ll now=0;
		for(ll j=0;j<y;j++){
			ll z;
			cin>>z;
			z--;
			now+=keta[z];
		}
		//cout <<now<<endl;
		key.push_back(make_pair(x,now));
	}
	for(ll i=0;i<=ans;i++){
		ch[i]=INF;
	}
	ch[0]=0;
	for(ll i=0;i<=ans;i++){
		for(ll j=0;j<m;j++){
			ll co=key[j].first;
			ll op=key[j].second;
			ch[i|op]=min(ch[i|op],ch[i]+co);
		}
	}
	cout << (ch[ans]==INF?-1:ch[ans]);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int i = 0;
    int sm[k + 10], bg[k + 10];
    int cnt1 = 0, cnt2 = 0;
    int temp = b - a + 1;
    if(k > temp) {
        k = temp;
    }
    while(k--) {
        int d = a + i;
        int e = b - i;
        if(d == e){
            
            sm[cnt1++] = d;
            break; 
        }
        if(d > e) break;
        if(d <= b && d >= a) {
            sm[cnt1++] = d;
        } 
        if(e <= b && d >= a) {
            bg[cnt2++] = e;
        } 

        i++;
    }
    for(int i = 0; i < cnt1; i++) {
        printf("%d\n",sm[i] );
    }
    for(int i  = cnt2 - 1; i >= 0; i--) {
        printf("%d\n",bg[i] );
    } 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>

using namespace std;


int main() {
	int n;
	int u, v;
	int Adj[101][101];
	int deg;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			Adj[i][j] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		cin >> u;
		cin >> deg;
		for (int j = 1; j <= deg; j++) {
			cin >> v;
			Adj[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf("%d", Adj[i][j]);
			if (j != n) {
				printf(" ");
			}
		}
		printf("\n");
	}
}

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

using namespace std;

int N, X, Y, Z;
const int MOD = 1e9 + 7;

int main()
{
	cin >> N >> X >> Y >> Z;
    int masklim = 1 << (X + Y + Z);
    int haiku = (1 << (Z-1)) | (1 << (Y+Z-1)) | (1 << (X+Y+Z-1));
    vector< vector< vector<int> > > dp
    (N+1, vector< vector<int> >(masklim, vector<int>(2, 0)));
    dp[0][0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int mask = 0; mask < masklim; ++mask) {
//			cerr << i << ' ' << mask << ": " << dp[i][mask][0] << ' ' << dp[i][mask][1] << endl;
			for (int v = 1; v <= 10; ++v) {
				int nextmask = (mask << v) | (1 << (v-1));
				nextmask &= (masklim - 1);
				if ((nextmask & haiku) == haiku) {
//					cerr << nextmask << endl;
                    dp[i+1][nextmask][1] += dp[i][mask][0];
                    dp[i+1][nextmask][1] %= MOD;

                    dp[i+1][nextmask][1] += dp[i][mask][1];
                    dp[i+1][nextmask][1] %= MOD;
				} else {
					dp[i+1][nextmask][0] += dp[i][mask][0];
                    dp[i+1][nextmask][0] %= MOD;

					dp[i+1][nextmask][1] += dp[i][mask][1];
                    dp[i+1][nextmask][1] %= MOD;
				}
			}
        }
    }

    int res = 0;
    for (int mask = 0; mask < masklim; ++mask) {
//		cerr << N << ' ' << mask << ": " << dp[N][mask][0] << ' ' << dp[N][mask][1] << endl;
		res += dp[N][mask][1];
		res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 301440
while True:
    l = input().split()
    a,b = int(l[0]),int(l[2])
    if l[1]=='+' :
        print(a+b)
    elif l[1]=='-':
        print(a-b)
    elif l[1]=='*':
        print(a*b)
    elif l[1]=='/':
        print(int(a/b))
    elif l[1]=='?':
        break;


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#define NMAX 100000
struct node {
  int id;
  struct node *next;
};
struct node *list[NMAX];
void Insert(int a, int b);
int Dfs(int v, int c, int *color);
int main(void)
{
  int i, n, m, a, b, color[NMAX] = {0};
  long long int wb[2] = {0};
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    Insert(a - 1, b - 1);
  }
  if (!Dfs(0, 1, color)) {
    printf("%lld\n", (long long int)(n - 1) * n / 2 - m);
    return 0;
  }
  for (i = 0; i < n; i++) {
     wb[(color[i]+1)/2]++;
     free(list[i]);
  }
  printf("%lld\n", wb[0] * wb[1] - m);
}

void Insert(int a, int b)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->next = list[b];
  list[b] = p;
}

int Dfs(int v, int c, int *color)
{
  struct node *n;
  color[v] = c;
  for (n = list[v]; n != NULL; n = n->next) {
    if (color[n->id] == c) return 0;
    else if (color[n->id] == 0 && !Dfs(n->id, -c, color)) return 0;
  }
  return 1;
}

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

int main(){
  int n;
  cin >> n;
  int d[n+100];
  for (int i=0;i<n;i++) cin >> d[i];
  
  int num[110]={0};
  for (int i=0;i<n;i++) num[d[i]]++;
  
  int ans=0;
  for (int i=0;i<106;i++) {
    if(num[i]>0) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int64_t k) {
    int64_t ans = 0;
    REP3 (a, 1, k + 1) {
        REP3 (b, 1, k + 1) {
            REP3 (c, 1, k + 1) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    return ans;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t K;
    cin >> K;
    auto ans = solve(K);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.*;

class Main{
  static int n,x;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      n = sc.nextInt();
      int i = 3;
    while (i<=n) {
      x = i;
      if (i % 3 == 0) {
        System.out.printf(" %d",i);
      } else {
      while (x>=1) {
        if (x % 10 == 3) {
          System.out.printf(" %d",i);
          break;
        }
          x /= 10;
        }
      }
      i++;
    }
    System.out.println("");
  }
}


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

// 辺に重みをつける場合 
struct Edge{
  int to;
  int weight;
  Edge(int t,int w) : to(t), weight(w) { }
};

using Graph = vector<vector<Edge>>;
int A[100010];

//深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v){
  seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto nv : G[v]){
    if (seen[nv.to]) continue; // next_v が探索済みだったらスルー
    if(nv.weight % 2 == 0) A[nv.to] = A[v];
    else{
      if(A[v] == 0) A[nv.to] = 1;
      else A[nv.to] = 0;
    }
    dfs(G, nv.to); // 再帰的に探索
  } 
}

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

  int N; cin >> N;
  
  Graph G(N);
  for(int i=0;i<N-1;i++){
    int A, B, C;
    cin >> A >> B >> C;
    --A; --B;
    G[A].push_back(Edge(B, C));
    G[B].push_back(Edge(A, C));
  }

  seen.assign(N, false); // 全頂点を「未訪問」にして初期化
  A[0] = 0;
  dfs(G, 0);
  rep(i,N) cout << A[i] << endl;

}

Measured memory_bytes: 10112
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int m=in.nextInt();
			if(m==0)
				return;
			int tx[]=new int[m];
			int ty[]=new int[m];
			for(int i=0;i<m;i++)
			{
				tx[i]=in.nextInt();
				ty[i]=in.nextInt();
			}
			int n=in.nextInt();
			int skyx[]=new int[n];
			int skyy[]=new int[n];
			boolean judge[]=new boolean[m];
			boolean cmp=false;
			judge[0]=true;
			for(int i=0;i<n;i++)
			{
				skyx[i]=in.nextInt();
				skyy[i]=in.nextInt();
			}

			for(int i=0;i<n;i++)
			{
				int toX=skyx[i]-tx[0];
				int toY=skyy[i]-ty[0];
				Arrays.fill(judge, false);
				cmp=true;
				judge[0]=true;
				for(int j=1;j<m;j++)
				{
					int nx=tx[j]+toX;
					int ny=ty[j]+toY;
					for(int k=0;k<n;k++)
					{
						if(nx==skyx[k]&&ny==skyy[k])
						{
							judge[j]=true;
							break;
						}
					}	
				}
				for(int j=0;j<m;j++)
				{
					if(!judge[j])
						cmp=false;
				}
				if(cmp)
				{
					System.out.println(toX+" "+toY);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 29948
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n,a,b;cin>>n>>a>>b;
	int ans=0;
	if(b-a<=2 || n+1-2 <a)ans=n+1;
	else {
		int m=n-(a-1);
		ans=a+(b-a)*(m/2)+m%2;

	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

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

x = min(M//N, int(M**0.5))
ans_list = []

while x > 0:
    if M % x == 0:
        ans_list.append(x)
        if (M//x) * N <= M:
            ans_list.append(M//x)
    x -= 1
    
print(max(ans_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long double ans,a,b,h,m;
int main()
{
	cin>>a>>b>>h>>m;
	printf("%.10Lf",sqrt(a*a+b*b-2.0*a*b*cos((30.0*h-5.5*m)/180.0*M_PI)));
	return 0;
}

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

using namespace std;
int a[3];
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		for (int j = 1; j < (int)s.length(); ++j)
		{
			if (s[j - 1] == 'A' && s[j] == 'B')
			{
				ans++;
			}
		}
		if (s[0] == 'B' && s[s.length() - 1] == 'A')
			a[1]++;
		else if (s[0] == 'B')
		{
			a[0]++;
		}
		else if (s[s.length() - 1] == 'A')
		{
			a[2]++;
		}
	}
	if (a[1] == 0)
	{
		ans += min(a[0], a[2]);
	}
	else
	{
		ans += a[1] - 1;
		if (a[0] && a[2])
		{
			ans += 2 + min(a[0], a[2]) - 1;
		}
		else
		{
			ans += min(max(a[0], a[2]), 1);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import heapq
from typing import List, Tuple, Dict
from dataclasses import dataclass, field

import scipy
import numpy as np
from numba import njit

D = int(input())  # 日数 D = 365
C = np.array(list(map(int, input().split())), dtype='int32')  # 満足度の下がりやすさ 26個
S = np.array([list(map(int, input().split())) for _ in range(D)], dtype='int32')  # d日目にコンテストiを行ったときの満足度


@dataclass()
class Node:
    value: int
    plan: List[int]
    last: List[int]

    def __lt__(self, other) -> bool:
        return self.value > other.value  # PriorityQueueで最大値が欲しいので逆に


def calc_dissatisfaction(d: int, last: List[int]) -> int:
    return sum([C[i] * (d - last[i]) for i in range(26)])


CAPACITY = 15

queue: List[Node] = [Node(0, [], [0 for _ in range(26)])]
for d in range(D):
    next_queue: List[Node] = []

    heapq.heapify(queue)
    while queue:
        node = heapq.heappop(queue)
        dis = calc_dissatisfaction(d + 1, node.last)

        for i in range(26):
            s = S[d][i] + C[i] * (d + 1 - node.last[i]) - dis

            next_queue.append(
                Node(
                    node.value + s,
                    node.plan + [i + 1],
                    node.last[:i] + [d + 1] + node.last[i + 1:]
                ),
            )

    queue = sorted(next_queue)[:CAPACITY]

res_node = heapq.heappop(queue)
print(res_node, file=sys.stderr)
print('\n'.join(map(str, res_node.plan)))


Measured memory_bytes: 94792
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=2000000000;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX+1][MAX+1];
void dijkstra(){
    int minv;
    int d[MAX+1],color[MAX+1];
    for(int i=1;i<=n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    d[0]=0;
    while(1){
        minv=INFTY;
        int u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    for(int i=0;i<n;i++)
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<"\n";
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            M[i][j]=INFTY;
    }
    int k,c,u,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String b = scan.nextLine();
    switch (b) {
      case "A":
        System.out.println("T");
        return;
      case "T":
        System.out.println("A");
        return;
      case "C":
        System.out.println("G");
        return;
      case "G":
        System.out.println("C");
        return;
      default:
        return;
    }
  }
}

Measured memory_bytes: 23764
n=int(input())
lis=[]
for i in range(n):
    s,p=input().split()
    lis.append((i+1, str(s), int(p)))
ans=[]
lis=sorted(lis, key=lambda x:x[1])
tmp=[]
for l in lis:
    if tmp==[]:
        tmp.append(l)
    elif tmp[0][1]==l[1]:
        tmp.append(l)
    else:
        tmp=sorted(tmp,reverse=True,key=lambda x:x[2])
        for t in tmp:
            ans.append(t[0])
        tmp=[l]
tmp=sorted(tmp,reverse=True,key=lambda x:x[2])
for t in tmp:
    ans.append(t[0])

for i in ans:
    print(i)

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6 1");
            WillReturn.Add("3");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10 2");
            WillReturn.Add("4");
            WillReturn.Add("5");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("100 5");
            WillReturn.Add("1");
            WillReturn.Add("23");
            WillReturn.Add("45");
            WillReturn.Add("67");
            WillReturn.Add("89");
            //608200469
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        var ASet = new HashSet<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            ASet.Add(int.Parse(EachStr));
        }

        //場合の数[現在位置]なDP表
        int[] DPArr = new int[N + 1];
        DPArr[0] = 1;
        int UB = N;

        for (int I = 0; I <= UB; I++) {
            Action<int> wkAct = (pNextdan) =>
            {
                if (pNextdan <= UB && ASet.Contains(pNextdan) == false) {
                    DPArr[pNextdan] = DPArr[pNextdan] + DPArr[I];
                    DPArr[pNextdan] %= 1000000007;
                }
            };
            wkAct(I + 1);//1段あがる場合
            wkAct(I + 2);//2段あがる場合
        }
        Console.WriteLine(DPArr[UB]);
    }
}


Measured memory_bytes: 29024
N=int(input())
S=list(input())
a=[0]*N
for i in range(N):
    a[i]=ord(S[i])-96
from collections import Counter
b=Counter(a)
c=b.most_common()
ans=1
for i in range(len(c)):
    ans*=(c[i][1]+1)
print((ans-1)%(10**9+7))

Measured memory_bytes: 5032
#include <iostream>
#include <cstring>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int,int> P;

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

const int dy[4] = {-1, 1, 0, 0};
const int dx[4] = {0, 0, -1, 1};
const int MAX_W = 102, MAX_H = 102;
int maze[MAX_H][MAX_W];
int w, h, xs, ys, xg, yg, color;

void solve() {
  memset(maze, 0, sizeof maze);
  int n;
  cin>>xs>>ys>>xg>>yg>>n;
  rep(i,n) {
    int c, d, x, y;
    cin>>c>>d>>x>>y;
    //cout<<c<<d<<x<<y<<endl;
    if (d == 0) {
      REP(j,x,x+4) REP(k,y,y+2) maze[k][j] = c;
    } else {
      REP(j,x,x+2) REP(k,y,y+4) maze[k][j] = c;
    }
  }
  
  /*
  rep(i,h+1) {
    rep(j,w+1) cout<<maze[i][j];
    cout<<endl;
  }*/
  
  if (maze[ys][xs] == 0) {
    cout<<"NG"<<endl;
    return;
  } else {
    color = maze[ys][xs];
  }
  
  bool flag = false;
  queue<P> que;
  que.push(P(xs, ys));
  while (!que.empty() && !flag) {
    P p = que.front(); que.pop();
    int tx = p.first, ty = p.second;
    if (tx == xg && ty == yg) {
      flag = true; continue;
    }
    if (maze[ty][tx] == 0) continue;
    maze[ty][tx] = 0;
    
    rep(z,4) {
      int ttx = tx + dx[z], tty = ty + dy[z];
      if (ttx < 1 || tty < 1 || ttx > w || tty > h) continue;
      if (maze[tty][ttx] != color) continue;
      que.push(P(ttx, tty));
    }
  }
  
  if (flag) {
    cout<<"OK"<<endl;
  } else {
    cout<<"NG"<<endl;
  }
}

int main (int argc, char const* argv[]) {
  while (cin>>w>>h, w||h) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2) {
		cout<<"Borys"<<endl;
	} else {
		cout<<"Alice"<<endl;
	}
}


Measured memory_bytes: 764
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int>a(12);
	for(int i=0;i<12;i++){cin>>a[i];}
	SO(a);
	bool can=1;
	for(int i=0;i<11;i++){
		if(i%4==3){continue;}
		if(a[i]!=a[i+1]){can=0;}
	}
	cout<<(can?"yes":"no")<<endl;
	
	return 0;
}



Measured memory_bytes: 3232
#include<stdio.h>
int main() {
  int n[30];
  int i, j;
  for (i = 0; i < 30; i ++) n[i] = 0;
  for (i = 0; i < 28; i ++) {
    scanf("%d", &j);
    n[j - 1] = 1;
  }
  for (i = 0; i < 30; i ++) if (!n[i]) printf("%d\n", i + 1);
  return 0;
}

Measured memory_bytes: 596
n,p=map(int,input().split())
a=list(map(int,input().split()))

gu=0
ki=0

for aa in a:
    if aa%2==0:
        gu+=1
    else:
        ki+=1

gusu=2**gu
if ki>0:
    kisu=2**(ki-1)
else:
    kisu=1

if p==1 and ki==0:
    print(0)
    exit()

print(gusu*kisu)


#pが0だったら選ぶ袋の合計が偶数
#kisu の個数が偶数

#nが1だったら選ぶ袋の合計が奇数
#gusu の個数が奇数

#nは50、全探索はできんね





Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - y高橋君とホテルイージー / Tak and Hotels (ABC Edit)
            var line = ReadLines(4);
            int n = line[0];
            int k = line[1];
            int x = line[2];
            int y = line[3];

            if (n > k)
            {
                Console.WriteLine(k * x + (n - k) * y);
            }
            else
            {
                Console.WriteLine(n * x);
            }
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var lines = new List<int>();
            string s;

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                s = Console.ReadLine().TrimEnd();
                lines.Add(int.Parse(s));
            }

            return lines;
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll w[300000];
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k, sum = 0;
	cin>>n>>k;
	for(int i = 0; i < n; i++)
	{
		ll a;
		cin>>a;
		w[i] = a;
	}
	sort(w, w+n);
	for(int i = 0; i < n-k; i++) sum+=w[i];
	cout<<sum<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}



int main(){
  cout<<setprecision(1000);
  ll N,K;
  cin>>N>>K;
  vector<ll> snuke(N);
  REP(K){
    ll d;
    cin>>d;
    For(j,d){
      ll tmp;
      cin>>tmp;
      ++snuke[tmp-1];
    }
  }
  ll x=0;
  REP(N){
    if(snuke[i]==0){
      ++x;
    }
  }
  cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 3624
import numpy as np

N, T = map(int, input().split())
C = [tuple(map(int, input().split())) for _ in range(N)]
C.sort(key=lambda x: x[0])

dp = np.zeros(T, dtype=int)
ans = 0
for i, (a, b) in enumerate(C):
    ans = max(ans, dp[T - 1] + b)
    new_dp = dp.copy()
    new_dp[a:] = np.maximum(dp[a:], dp[:-a] + b)
    dp = new_dp
print(ans)


Measured memory_bytes: 12520
module Main where

import Data.List
import Data.Maybe
import Control.Monad
import Debug.Trace
import qualified Data.Map.Strict as Map


readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)

solve :: [Int] -> Int -> Int -> Int
solve hs n k = foldl' (\acc i -> min acc $ getHeightDiff i) maxHeight [0..(n-k)] where
    sortedMap = Map.fromAscList . zip [0..] . sort $ hs
    getHeightDiff i = fromMaybe maxHeight $ do
        high <- Map.lookup (i + k - 1) sortedMap
        low <- Map.lookup i sortedMap
        pure $ high - low
    maxHeight = 1000000000


main = do
    (n, k) <- readTuple
    hs <- replicateM n readLn
    print $ solve hs n k


Measured memory_bytes: 65916
#include<iostream>
#include<vector>
using namespace std;
#define MOD (long long)(1e9+7)
#define MAX_VAL (int)(1e5)

int u[200000], N;
vector<int> G[201010];

int foo(){
	for(int y : G[1]){
		for(int z : G[y]){
			if(z == N)return true;
		}
	}
	return false;
}

int main(){
	int M, flag =false, a , b;
	
	cin>>N>>M;
	
	for(int i = 1; i <= M; i++){
		cin>>a>>b;
		if(a==1||b==1||a==N||b==N){
		G[a].push_back(b);
		G[b].push_back(a);
		}
	}
	cout<<(foo()?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

Measured memory_bytes: 12016