akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct line{
    bool horizontal;
    int cost;
};
int W,H;
int p[110000],q[110000];
line lines[220000];

signed main() {
    cin>>W>>H;
    for(int i=0;i<W;i++){
        cin>>p[i];
        lines[i]={true,p[i]};
    }
    for(int i=0;i<H;i++){
        cin>>q[i];
        lines[i+W]={false,q[i]};
    }
    sort(lines,lines+W+H,[](const line& a, const line& b) { return a.cost < b.cost;});
    int w=0,h=0,ans=0;
    for(int i=0;i<W+H;i++){
        if(lines[i].horizontal){
            ans+=lines[i].cost*(H+1-h);
            w++;
        }else{
            ans+=lines[i].cost*(W+1-w);
            h++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <cmath>

int main()
{
  int n;
  int a[100];
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
    sum += a[i];
  }
  int m = std::round(sum / double(n));
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += (a[i] - m) * (a[i] - m);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
int main()
{
	priority_queue<P,vector<P>,greater<P> >que;
	long long n,m;
	long long a,b;
	P p;
	long long money_sum;
	money_sum=0;
	cin>>n>>m;
	rep(i,n)
	{
		cin>>a>>b;
		que.push(P(a,b));
	}
	while(!que.empty()&&m>0)
	{
		p=que.top();que.pop();
		
		money_sum+=min(p.second,m)*p.first;
		m-=min(p.second,m);
	}
	cout<<money_sum<<endl;
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}else if(a<b){
		cout<<"a < b"<<endl;
	}else{
		cout<<"a == b"<<endl;
	}
}


Measured memory_bytes: 3080
const Main = (input) => {
    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);

    var sum = a * b;

    if (sum % 2 == 0) {
        console.log("Even");
    } else {
        console.log("Odd");
    }
}

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


Measured memory_bytes: 7372
n = gets.to_i
a = gets.split.map &:to_i

max = -1000000
min = 1000000
sum = 0
n.times do |i|
    if a[i] < min
        min = a[i]
    end
    if a[i] > max
        max = a[i]
    end
    sum += a[i]
end

puts [min,max,sum].join(" ")


Measured memory_bytes: 7172
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
#define N 10010
int ans[N];
vector<pair<int,int>> dic[N];
long long int gcd(long long a, long long b) {
    return a%b==0?b:gcd(b,a%b);
}
void proc()
{
    for (int n=1;n<=10000;n++) {
        for (int i=1;i*i<=n;i++) {
            if (n%i==0)
                dic[n].push_back(pair<int,int>(i,n/i));
        }
        /*
        printf("size = %d:",dic[n].size());
        for (int i=0;i<dic[n].size();i++)
            printf("(%d,%d) ",dic[n][i].first,dic[n][i].second);
        printf("\n");
        */
    }
    for (int n=1;n<=10000;n++) {
        ans[n] = 0;
        for (int x=1;x*x+2*x+3<=n;x++)
        {

            for (int y=1;x*x+y*y+x*y+x+y<=n;y++)
            {
                //z*(z+x+y)=n-x*x-y*y-x*y
                int val = n-x*x-y*y-x*y;
                for (int i=0;i<dic[val].size();i++) {
                    int z = dic[val][i].first;
                    if (z+x+y==dic[val][i].second)
                    {
                        //printf("(%d,%d,%d)",x,y,z);
                        ans[n]++;
                    }
                }
            }
        }
        //printf("\n");
    }
}
int main(){
    int n,s;
    int t,l,r,d;
    proc();

    while (scanf("%d",&n)!=EOF) {
        for (int i=1;i<=n;i++)
            cout << ans[i] <<endl;
    }

    return 0;
}
/*
5
1 2 3 4 5
4
1 1 1 1
1 1 1 2
1 2 5 1
1 3 5 2
*/


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n), b(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	ll A = 0, B = 0;
	rep(i, n) {
		if (a[i] > b[i]) {
			A += a[i] - b[i];
		}
		else {
			B += (b[i] - a[i]) / 2;
		}
	}
	puts(A <= B ? "Yes" : "No");
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];

		map<int,int> f;
		for(int x:a){
			f[x-1]++;
			f[x]++;
			f[x+1]++;
		}
		int res=0;
		for(auto p:f)
			res=max(res,p.second);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = Integer.parseInt(sc.nextLine());

		long N = 7 % num;
		int ans = -1;

		for (int i = 0; i < num ; i++) {
			if (N == 0) {
				ans = i + 1;
				break;
			}
			N = (N * 10 + 7) % num;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 35380
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX = 1e5;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[26];
int arr[26][MAX];

int main() {
  // 入力
  string s;
  cin >> s;

  int l = 0, r = s.size() - 1;
  int ans = 0;
  while (l < r) {
    if (s[l] == s[r]) {
      l++; r--;
    } else {
      if (s[l] == 'x') l++;
      else if (s[r] == 'x') r--;
      else break;
      ans++;
    }
  }

  // 解答
  cout << (l < r ? -1 : ans) << endl;

  return 0;
}


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

using namespace std;

struct node {
	int a,b;
};

int b[101000]={0};
int n,m;

#define lowbit(x) (x&-x)

bool cmp(const node&x,const node&y) {
	return x.b<y.b;
}

void update(int i,int c) {
	for (int k=i;k<=n;k+=lowbit(k)) {
		b[k]+=c;
	}
}

int getsum(int k) {
	int ans=0;
	for (int i=k;i>0;i-=lowbit(i)) {
		ans+=b[i];
	}
	return ans;
}

int main() {
	node p[101000];
	cin>>n>>m;
	for (int i=1;i<=m;i++) {
		cin>>p[i].a>>p[i].b;
	}
	sort(p+1,p+m+1,cmp);
	int sum=0;
	for (int i=1;i<=m;i++) {
		if (getsum(p[i].b-1)-getsum(p[i].a-1)==0) {
			update(p[i].b-1,1);
			sum++;
		}
	}
	cout<<sum<<endl;
//	system("pause");
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
   // sort(ALL(a));
    int ans = INF;
    for (int i = -110; i <= 110; i++)
    {
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            cnt += (i - a[j]) * (i - a[j]);
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        long sum = a + b;
        if (sum % 2 == 0) {
            System.out.println(sum / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    int[] max = new int[N];
    max[N - 1] = a[N - 1];
    for (int i = N - 2; i >= 0; i--) max[i] = Math.max(a[i], max[i + 1]);

    int maxDiff = 0;
    for (int i = 0; i < N; i++) maxDiff = Math.max(maxDiff, max[i] - a[i]);

    int cnt = 0;
    for (int i = 0; i < N; i++) if (max[i] - a[i] == maxDiff) cnt++;
    System.out.println(cnt);
  }
}


Measured memory_bytes: 51632
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	int C[500];
	int S[500];
	int F[500];
	int ans[500] = { 0 };
	cin >> N;
	int i;
	FOR(i, 0, N-1)cin >> C[i] >> S[i] >> F[i];
	
	FOR(i, 0, N-1) {
		int t = 0;
		for (int j = i; j < N-1; j++) {
			if (t < S[j])t = S[j];

			if (t%F[j] != 0) {
				t += F[j] - t % F[j];
			}
			t += C[j];
		}
		ans[i] = t;

		

	}
	FOR(i, 0, N)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,q,m,k,l,ans;
vll a,b;
map<ll, vll> bits;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    
    string s;
    cin >> s;
    n = s.size();
    vi cumsum(n+1);
    cumsum[0] = 0;
    rep(i,n) cumsum[i+1] = (s[i]=='B')?cumsum[i]+1:cumsum[i];

    ans = 0;
    rep(i,n) if(s[i]=='W') ans += cumsum[i+1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 5001;
int n, a[N], b[N];

int main(){
    scanf("%d",&n);
    for(int i = 0; i<n-1; ++i)scanf("%d",b+i);
    ll an = 0;
    a[0] = b[0];
    b[n-1] = b[n-2];
    an = (ll) (an + a[0]);
    for(int i = 1; i<n; ++i){
        a[i] = min(b[i-1], max(b[i], b[i+1]));
        an = (ll)(an + a[i]);
    }
    for(int i = 0; i<n-1; ++i){
         if(max(a[i], a[i+1]) > b[i])an -= a[i], an += b[i];
    }
    printf("%lld\n",an);
}

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

int main() {
  string R;
  cin >> R;
  
  if (R[0]!='7' && R[1]!='7' && R[2]!='7') {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3592
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


// agc071
int main(){
	int N;cin>>N;
	vector<int> D(N);
	REP(i,N)cin>>D[i];

	sort(ALL(D));

	cout << (D[(int)N/2]-D[(int)N/2-1]) << endl;

	return 0;
}




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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, A;
  ll ans = 1;
  bool zero = false;
  cin >> N;
  REP(i,N) {
    cin >> A;
    ans *= A;
    if(A == 0) {
      zero = true;
      break;
    }
  }
  if(zero) cout << 0;
  else if(ans == 0 || ans > 1000000000000000000) cout << -1;
  else cout << ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    a,b,c,d = map(int, input().split())
    rooms[a-1][b-1][c-1] += d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(rooms[i][j][k]), end = "")
        print()
    if i != 3:
        print("####################")


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    string s;
    bool a=true;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]) a = false;
    }
    if(a) cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;
    return 0;
}

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

int main() {
    int N, C, ans = 0;

    cin >> N;

    vector<int> V(N);

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

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

        if (V[i] > C) {
            ans += (V[i] - C);
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a + (b / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    int n,m;
    char str[105][105];

    scanf("%d %d",&n,&m);

    for(int i=0; i<n; i++)
    {
        scanf("%s",str[i]);
    }

    for(int i=0; i<n; i++)
    {
        printf("%s\n",str[i]);
        printf("%s\n",str[i]);
    }


    return (0);
}


Measured memory_bytes: 256
x, y = map(int, input().split())


def g(i):
    if i in [1, 3, 5, 7, 8, 10, 12]:
        return 0
    elif i in [4, 6, 9, 11]:
        return 1
    else:
        return 2


if g(x) == g(y):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
from collections import Counter
n = int(input())
lista = list(map(int, input().split()))

count = Counter(lista)
lista.sort()

M = 1000001
P = [0] * (M+1)
ans = 0

for i in lista:
    if P[i] == 0:
        for j in range(M+1):
            x = i * j
            if x > M:
                break
            P[x] = 1
        if count[i] == 1:
            ans += 1

print(ans)

Measured memory_bytes: 38788
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    string S;
    cin >> S;
    if(S == "ABC"){cout << "ARC" << endl; return 0;}
    if(S == "ARC"){cout << "ABC" << endl; return 0;}


    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int n;
    char s[100001];
    int ans=1;

    cin>>n>>s;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
/*author : Yashvardhan
Saturday, May 02, 2020
6:24 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

int a,b,n;
int f(int x){
	int val1 = ((a * x) / b);
	int val2 = x / b;
	return val1 - a * val2;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	cin >> a >> b >> n;

	if(n >= b - 1){
		cout << f(b - 1) << endl;
	}
	else cout << f(n) << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
#define INF 10000000000
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
map<long long int,long long int> prime;
void prime_fact(long long int n){
    long long int nc=n;
    long long int i=2;
    while(nc!=1){
        if(i*i>nc) {
            if(prime.count(nc)) prime.at(nc)+=1;
            else {prime[nc]=1;}
            break;
        }
        if(nc%i==0){
            long long int count=0;
            while(nc%i==0){
                nc/=i;
                count++;
            }
            if(prime.count(i)) prime.at(i)+=count; 
            else{prime[i]=count;}
        }
        i++;
    }
};

int main(){
    lli n;
    lli ans=1;
    cin>>n;
    for(lli j=2;j<=n;j++){
        prime_fact(j);
    }
    for(auto v:prime){
        ans*=(v.second+1);
        ans%=1000000007;
    }
    out(ans);
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        a //= 2
        b += a
    else:
        if b%2 != 0:
            b -= 1
        b //= 2
        a += b
print(a,b)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <map>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define hash(a,b,c,d) ((((LL(a)*1000+b)*1000)+c)*1000+d)
using namespace std;

typedef long long LL;
int n,a[410][4];
LL ans,w[410];
map<LL,int> cnt,s;

void rotate(int *a)
{
    int t=a[0];
    a[0]=a[1],a[1]=a[2],a[2]=a[3],a[3]=t;
}

LL c(int n,int m)
{
    if (n<0)
        return 0;
    LL ret=1;
    repu(i,1,m)
        ret=LL(n-i+1)*ret;
    return ret;
}

LL get(int a,int b,int c,int d)
{
    return min(min(hash(a,b,c,d),hash(b,c,d,a)),min(hash(c,d,a,b),hash(d,a,b,c)));
}

int main()
{
    scanf("%d",&n);
    repu(i,1,n)
    {
        repu(j,0,3)
            scanf("%d",&a[i][j]);
        LL t[4];
        repu(j,1,i-1)
            repu(k,0,3)
            {
                t[0]=get(a[i][0],a[j][1],a[j][0],a[i][1]);
                t[1]=get(a[i][1],a[j][0],a[j][3],a[i][2]);
                t[2]=get(a[i][3],a[i][2],a[j][3],a[j][2]);
                t[3]=get(a[j][1],a[i][0],a[i][3],a[j][2]);
                sort(t,t+4);
                LL sum=1;
                repu(l,0,3)
                    sum*=s[t[l]];
                for (int ii=0,jj; ii<4; ii=jj)
                {
                    for (jj=ii; jj<4 && t[ii]==t[jj]; ++jj);
                    sum*=c(cnt[t[ii]]-(t[ii]==w[j]),jj-ii);
                }
                ans+=sum,rotate(a[j]);
            }
        repu(j,0,3)
            t[j]=hash(a[i][0],a[i][1],a[i][2],a[i][3]),rotate(a[i]);
        ++cnt[w[i]=min(min(t[0],t[1]),min(t[2],t[3]))];
        repu(j,0,3)
            s[t[j]]=(t[0]==t[j])+(t[1]==t[j])+(t[2]==t[j])+(t[3]==t[j]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 160000
n=int(input())
link=[[] for _ in range(n)]
for i in range(n):
    for j in range(int(input())):
        a,b=map(int,input().split())
        link[i].append([a-1,b])
def bitj(bit):
    for i in range(n):
        if not (bit>>i)&1:
            continue
        for x,y in link[i]:
          if y==1 and not (bit>>x)&1:
            return False
          elif y==0 and (bit>>x)&1:
            return False
    return True
ans=0
for i in range(1<<n):
    if not bitj(i):
        continue
    res=0
    for j in range(n):
        if (i>>j)&1:
            res+=1
    ans=max(ans,res)
print(ans)

Measured memory_bytes: 3064
import scala.io.StdIn._
object Main extends App {
  val Array(h, w) = readLine.split(" ").map(_.toInt)
  val grid = Array.fill(h)(readLine)

  val l, r, u, d = Array.ofDim[Int](h + 2, w + 2)

  for {
    x <- 1 to w
    y <- 1 to h
  } {
    if (grid(y - 1).charAt(x - 1) == '.') {
      l(y)(x) = l(y)(x - 1) + 1
      d(y)(x) = d(y - 1)(x) + 1
    } else {
      l(y)(x) = 0
      d(y)(x) = 0
    }
  }

  for {
    x <- w to 1 by -1
    y <- h to 1 by -1
  } {
    if (grid(y - 1).charAt(x - 1) == '.') {
      r(y)(x) = r(y)(x + 1) + 1
      u(y)(x) = u(y + 1)(x) + 1
    } else {
      r(y)(x) = 0
      u(y)(x) = 0
    }
  }

  var result = 0
  for {
    x <- 1 to w
    y <- 1 to h
  } result = Math.max(result, l(y)(x) + r(y)(x) + d(y)(x) + u(y)(x))

  println(result - 3)
}

Measured memory_bytes: 115164
ansList = [[0] * 3 for i in range(3)]
a_i = []
for x in range(3):
    a_i.append(list(map(int, input().split())))
n = int(input())
for x in range(n):
    val = int(input())
    for id in range(3):
        if(val in a_i[id]): 
            ansList[id][a_i[id].index(val)] = 1
            break
#横
if(ansList[0][0] == 1 and ansList[0][1] == 1 and ansList[0][2] == 1): print("Yes")
elif(ansList[1][0] == 1 and ansList[1][1] == 1 and ansList[1][2] == 1): print("Yes")
elif(ansList[2][0] == 1 and ansList[2][1] == 1 and ansList[2][2] == 1): print("Yes")
#縦
elif(ansList[0][0] == 1 and ansList[1][0] == 1 and ansList[2][0] == 1): print("Yes")
elif(ansList[0][1] == 1 and ansList[1][1] == 1 and ansList[2][1] == 1): print("Yes")
elif(ansList[0][2] == 1 and ansList[1][2] == 1 and ansList[2][2] == 1): print("Yes")
#ななめ
elif(ansList[0][0] == 1 and ansList[1][1] == 1 and ansList[2][2] == 1): print("Yes")
elif(ansList[0][2] == 1 and ansList[1][1] == 1 and ansList[2][0] == 1): print("Yes")
else: print("No")

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

d = {}

for _ in range(n):
    tmp = input()
    if tmp not in d.keys():
        d[tmp] = 1
    else:
        d[tmp] += 1

max_value = max(d.values())

ans = []

for k in d.keys():
    if d[k] == max_value:
        ans.append(k)

ans.sort()

for a in ans:
    print(a)

Measured memory_bytes: 32096
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);//abcabca
   #endif
   /********************* Code starts here ***********************/	
   int n,d,x;
   cin>>n>>d>>x;
   vector<int>a(n);
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }
   int ans=0;
   for(int i=0;i<n;i++)
   {
   	for(int j=1;j<=d;j+=a[i])
   	{
   		ans++;
   	}
   }
   ans=ans+x;
   cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++){
        cin >> A[i];
    }
    for(int i = 0; i < Y; i++){
        cin >> B[i];
    }
    for(int i = 0; i < Z; i++){
        cin >> C[i];
    }
    

    vector<long long> AB;
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<long long>());
    AB.resize(K);
    
    vector<long long> ABC;
    for(int i = 0; i < AB.size(); i++){
        for(int j = 0; j < Z; j++){
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<long long>());
    
    // 出力
    for(int k = 0; k < K; k++){
        cout << ABC[k] << endl;
    }


    return 0;
}

Measured memory_bytes: 43264
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

char buf[2001],work[2001];
int work_index;
bool check[1000][1000];


void func(){
	work_index = 0;

	for(int i = 0; buf[i] != '\0'; i++){
		if(buf[i] >= 'a' && buf[i] <= 'z'){
			work[work_index++] = buf[i]-32;
		}else if(buf[i] >= 'A' && buf[i] <= 'Z'){
			work[work_index++] = buf[i];
		}
	}
	if(work_index == 0){
		printf("\n");
		return;
	}

	for(int i = 0; i < work_index; i++){
		for(int k = 0; k < work_index; k++){
			check[i][k] = false;
		}
	}

	vector<string> V,REMOVE;
	bool FLG;

	for(int length = work_index; length >= 3; length--){
		for(int i = 0; i+length-1 < work_index; i++){
			if(check[i][i+length-1])continue;

			FLG = true;
			for(int k = 0; k < (length)/2; k++){
				if(work[i+k] != work[i+length-1-k]){
					FLG = false;
					break;
				}
			}

			if(!FLG)continue;

			string tmp;
			for(int k = i; k <= i+length-1; k++){
				tmp += work[k];
			}


			for(int k = 0; k < REMOVE.size(); k++){
				if(tmp == REMOVE[k]){
					FLG = false;
					break;
				}
			}
			if(!FLG)continue;

			V.push_back(tmp);

			for(int k = 0; k < length/2; k++){
				check[i+k][i+length-1-k] = true;
				string tmp2;
				for(int p = i+k; p <= i+length-1-k; p++){
					tmp2 += work[p];
				}
				REMOVE.push_back(tmp2);
			}
		}
	}

	if(V.size() == 0){
		printf("\n");
		return;
	}

	//sort(V.begin(),V.end());

	printf("%s",V[0].c_str());
	for(int i = 1; i < V.size(); i++){
		printf(" %s",V[i].c_str());
	}
	printf("\n");
}


int main(){

	while(fgets(buf,2000,stdin) != NULL){
		func();
	}

	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int n, int k, vi a) {
	int ma = -1;
	for (int i = 0; i < n; i++) {
		ma = max(ma, a[i]);
	}

	if (ma < k) {
		return false;
	}

	for (int i = 0; i < n - 1; i++) {
		a[i + 1] = gcd(a[i], a[i + 1]);
	}

	return (k % a[n-1] == 0);
}

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

	int n, k;
	cin >> n >> k;

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

	cout << (solve(n, k, a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int p=Integer.parseInt(sc.next())+Integer.parseInt(sc.next());
if(p>=10){
    out.println("error");
}else{
    out.println(p);
}
}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   
   priority_queue<ll> pq;
   for(ll i=0;i<n;i++)
        pq.push(arr[i]);
   
   for(ll i=0;i<m;i++)
   {
       ll temp = pq.top();
       temp/=2;
       pq.pop();
       pq.push(temp);
   }
   
   ll ans = 0;
   while(!pq.empty())
   {
       ans+=pq.top();
       pq.pop();
   }
   
   cout<<ans;
   
   return 0;
}

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

namespace ConsoleApp72
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] KS = Console.ReadLine().Split(' ');
            int K = int.Parse(KS[0]);
            int S = int.Parse(KS[1]);

            int i = 0;
            for(int X = 0; X <= K; X++)
            {
                for(int Y = 0; Y <= K; Y++)
                {
                    if (S - X - Y<=K && 0<=S-X-Y)
                    {
                        i++;
                    }
                }
            }
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		string t=" "+sc.S;
		int[] r=new int[s[0]+1];
		for(int i = 1;i<=s[0];i++) {
			if(t[i-1]=='A'&&t[i]=='C'){r[i]++;}
			r[i]+=r[i-1];
		}
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s[1];i++) {
			int[] q=sc.Ia;
			sb.Append((r[q[1]]-r[q[0]])+"\n");
		}
		Console.Write(sb);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 19008
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1e5+10;

struct edge{
	int to,dis,cost;
	edge(){}
	edge(int to,int dis,int cost) : to(to),dis(dis),cost(cost){}
	bool operator>(const edge& rhs) const{
		return dis != rhs.dis ? dis>rhs.dis : cost>rhs.cost;
	}
};

int V,M;
bool vis[maxn];

vector<edge> G[maxn];

int dijkstra(int s){
	int res = 0;
	priority_queue<edge,vector<edge>,greater<edge> > Q;

	Q.push(edge(0,0,0));

	while(!Q.empty()){
		edge p = Q.top(); Q.pop();
		int v = p.to;
		if(vis[v]) continue;
		vis[v] = true;
		res += p.cost;
		for(int i=0; i<G[v].size(); i++){
			Q.push(edge(G[v][i].to,p.dis+G[v][i].dis,G[v][i].cost));
		}
	}

	return res;
}


int main(){
	while(scanf("%d%d",&V,&M) && V){
		memset(vis,0,sizeof(vis));
		for(int i=0; i<=V; i++) G[i].clear();

		for(int i=0; i<M; i++){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			--u,--v;
			G[u].push_back(edge(v,d,c));
			G[v].push_back(edge(u,d,c));
		}

		printf("%d\n",dijkstra(0));

	}
}

Measured memory_bytes: 7684
N = int(input())
H = []
for _ in range(N):
    h = tuple(map(int, input().split()))
    H.append(h)

dp = H[0]
for i in range(1, N):
    a, b, c = H[i]
    dp_next = [
        max(dp[1] + a, dp[2] + a),
        max(dp[0] + b, dp[2] + b),
        max(dp[0] + c, dp[1] + c),
    ]
    dp = dp_next

print(max(dp))

Measured memory_bytes: 20552
#include <bits/stdc++.h>
#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 irep(i, a, n) for(int i=a;i<(int)(n);++i)
#define rrep(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for(int i=(int)(n);i>=1;--i)
#define allrep(V, v) for(auto&& V:v)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const int INF=1<<29;
const double EPS=1e-9;
using namespace std;


map<long long, long long> prime_factorization(long long n){
  map<long long, long long> factors;
  for(lint div=2; div*div <= n; ++div){
    if(n % div != 0) continue;
    int count = 0;
    while(n % div == 0){
      ++count;
      n /= div;
    }
    factors[div] = count;
  }
  if(n != 1) factors[n] = 1;
  return factors;
}

int main (void)
{
  lint n,p; cin>>n>>p;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  map<lint,lint> factors = prime_factorization(p);
  lint ans=1;
  allrep(f,factors){
    rep(i,f.second/n) ans*=f.first;
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
    int n, k, q;
    cin >> n >> k >> q;
    int temp;
    vector<int> p(n, k - q);
    for(int i=0; i<q; i++){
        cin >> temp;
        p.at(temp - 1)++;
    }

    for(int i=0; i<n; i++){
        if(p.at(i) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
l = list(map(int, input().split()))

N = l[0]
x = l[1]
y = l[2]

if N > x + y:
    b_min = 0
else:
    b_min = (x + y) - N

if x > y:
    b_max = y
else:
    b_max = x

if N == x and N == y:
    b_min = N
    b_max = N

print(b_max, b_min)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans,k;

//最大公約数
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
//最小公倍数
ll lcm(ll a,ll b){


    if(a==0 || b==0)return 0;

    return a/gcd(a,b)*b;

}
long long modpow(long long a, long long n, long long mod) {
    long long res=1;
    while (n>0) {
        if (n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){//N,MOD
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
unordered_map<int,int> maxcnt;
vector<int> prime;
void prfac(int n){
	unordered_map<int,int> prco;
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			prco[a]++;
			n/=a;
		}
		else{
			a++;
		}
	}
	prco[n]++;
	for(auto x:prco){
		maxcnt[x.first]=max(maxcnt[x.first],x.second);
	}
}
int a[11111],b[11111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		prfac(a[i]);
	}
	int allsum=1;
	rep(i,n){
		allsum*=a[i];
		allsum%=MOD;
	}
	
	//int GCDsum=modpow(GCD,n-1,MOD);
	int LCM=1;
	for(auto x:maxcnt){
		rep(i,x.second){
			LCM*=x.first;
			LCM%=MOD;
		}
	}
	rep(i,n){
		b[i]=LCM*mod_inverse(a[i],MOD);
		b[i]%=MOD;
	}
	rep(i,n){
		ans+=b[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define int ll
signed main(){
    int n,k;
    int left = 0, right = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i, right = max(right, i);
    
    // valid: right, invalid: left
    while(left + 1 < right){
        int mid = (left + right)/2;
        int cnt = 0;
        for (int i : a) cnt += (i - 1) / mid;
        if (cnt > k) left = mid;
        else
            right = mid;
    }
    cout << right;
}

Measured memory_bytes: 4824
# coding: utf-8

n = int(input())
G = [[0]*n for i in range(n)]

for i in range(n):
    Adj = list(map(int, input().split()))
    u = Adj[0]-1
    for j in Adj[2:]:
        G[u][j-1] = 1

# print()
for i in range(n):
    print(*G[i])


# 入力: 隣接リストを与える
# 出力: 隣接行列を出力する



Measured memory_bytes: 6388
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			int[]A = new int[N];
			Set<Integer>set = new TreeSet<Integer>();
			List<Integer>list = new ArrayList<Integer>();
			Map<Integer,Integer>map = new TreeMap<Integer,Integer>();
			
			

			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt();
				set.add(A[i]);
				list.add(A[i]);
				map.put(A[i], 1);
			}
			
			Collections.sort(list);
			
			
			for(int i = 0;i<list.size();i++) {
				int num = list.get(i);
				int max = list.get(list.size()-1);
				
				if(i>=1&&list.get(i-1)==num) {
					map.put(num, 0);
					continue;
				}
				
				if(map.get(num)==0)continue;
				
				for(int j =2*num;j<=max;j =j+num) {
					//System.out.println(j);
					if(set.contains(j)) {
						if(map.get(j)==1) {
							//System.out.println("    "+j);
							map.put(j,0);
						}
						
					}
				}
				
				
			}
			
			int count = 0;
			
			
			for(Integer key: map.keySet()) {
				if(map.get(key)==1)count++;
			}
			
			
			System.out.println(count);
			
			
			
			
			
			
			
					
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 88116
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if(abs(a - e) <= k){
		cout << "Yay!" << endl;
	}
	else{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		int index = 0;
		int[][] employee = new int[1000][4001];
		int[][] result = new int[1000][4001];
		int[][] ans = new int[1000][4001];
		
		while( n != 0 ){
			int count = 1;
			int[] check = new int[4001];
			for(int i = 0; i < n; i++){
				int id = stdIn.nextInt();
				long p = stdIn.nextLong();
				long q = stdIn.nextLong();
				if( check[id] == 0 ){
					check[id] = count;
					employee[index][count] = id;
					count++;
				} 
				result[index][check[id]] += p*q;
				if( p*q >= 1000000 || result[index][check[id]] >= 1000000 ){
					ans[index][check[id]] = 1;
				}
			}
			n = stdIn.nextInt();
			index++;
		}
		
		for(int i = 0; i < index; i++){
			boolean flag = false;
			for(int j = 1; j < 4001; j++){
				if( employee[i][j] == 0 ){
					if( !flag ){
						System.out.println("NA");
					}
					break;
				} else if( ans[i][j] == 1 ){
						System.out.println(employee[i][j]);
						flag = true;
				}
			}
		}
	}
}

Measured memory_bytes: 62000