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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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 T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    scc_graph gr(n);
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        gr.add_edge(a, b);
    }
    auto scc = gr.scc();
    printf("%d\n", scc.size());
    for (auto &c : scc) {
        printf("%d ", c.size());
        for (auto v : c) printf("%d ", v);
        printf("\n");
    }
}

Measured memory_bytes: 40580
<?php
while(true){
    list($n,$x) = explode(" ",trim(fgets(STDIN)));
    if($n == 0 && $x == 0) break;
    echo cnt($n,$x)."\n";
}
function cnt($n,$x){
    $cnt = 0;
    for($i = 1; $i <= $n-2; $i++){
        for($j = $i+1; $j <= $n-1; $j++){
            for($k = $j+1; $k <= $n; $k++){
                if(($i + $j + $k) == $x) $cnt++; 
            }
        }
    }
    return $cnt;
}

Measured memory_bytes: 15344
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		try(BufferedReader bf = new BufferedReader(new InputStreamReader(System.in))){
			int max = 100010;
			//探索用配列
			boolean[] target = new boolean[max];
			Arrays.fill(target, true);
			target[0] = false;
			target[1] = false;

			int sqrt = (int)Math.sqrt(target.length);
			for(int i=2; i<=sqrt; i++) {
				int firstNum = i;
				if (target[i]) {
					for (int j=i*firstNum; j<target.length; j+=firstNum) {
						target[j] = false;
					}
				}
			}
			int[] a = new int[max];
			for (int i=2; i<target.length; i++) {
				if(i%2==0) continue;
				if (target[i] && target[(i+1)/2]) {
					a[i] = 1;
				}
			}
			//累積和
			int[] sum = new int[max+1];
			for(int i = 0;i < max;i++) {
				sum[i+1] = sum[i] + a[i];
			}
			//Query処理
			int Q = Integer.parseInt(bf.readLine());
			for(int q = 0;q < Q;q++) {
				String[] s = bf.readLine().split(" ");
				int l = Integer.parseInt(s[0]);
				int r = Integer.parseInt(s[1])+1;
				System.out.println(sum[r] - sum[l]);
			}
		}catch(IOException ioe) {
			ioe.getMessage();
		}
	}
}

Measured memory_bytes: 58560
#include <bits/stdc++.h> // only for GCC
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

int main() {
  int x, y;

  while(cin >> x >> y) {
    if(x < y) swap(x, y);
    int ans = gcd(x, y);
    cout<< ans << endl;
  }
}

Measured memory_bytes: 1160
use proconio::input;

fn main() {
    input! {
        a:f64,
        b:f64,
        h:f64,
        m:f64,
    }
    let mut aa = h * 30f64 + m * 0.5; 
    let mut bb = m * 6f64;
    
    let mut cc = (aa - bb).abs();
    if cc > 180f64 {
        cc = 360f64 - cc;
    }
    println!("{}",(a * a + b * b - 2f64 * a * b * cc.to_radians().cos()).sqrt());
}


Measured memory_bytes: 2960
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n,S;
int r[10004];
void solve() {
    int ans=0;
    rep(i,n) cin>>r[i];
    sort(r,r+n);

    rep(i,n) {
        int pos=upper_bound(r+i+1,r+n,S-r[i])-r;
        // cout<<r[i]<<","<<pos<<endl;
        ans+=n-pos;
    }

    cout<<ans<<endl;

}

int main() {
    while(cin>>n>>S) {
        if(n+S==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<string.h>

int main(){

  int i;
  char str1[1000],str2[1000];

  scanf("%s %s",str1,str2);
  
  for(i=0;i<strlen(str1);i++){
    if(strncmp(str1+i,str2,strlen(str2))==0) printf("%d\n",i);
  }

  return 0;
}

Measured memory_bytes: 1796
#include<iostream>
#include<stack>
#include<algorithm>
#define MAX 100000005
#define MAX_N 100005
using namespace std;

struct point { int x; int y; };

struct points { point first; point second; };
points a[MAX_N];


bool on_edge(point a,int r,int c) {
	return !(0 < a.x&& a.x < r &&a.y < c && 0 < a.y);
}

int dist(point a) {
	if (a.y == 0) {
		return a.x;
	}
	else if (a.x == 0) {
		return 4 * MAX - a.y;
	}
	else { return 2 * MAX + a.y - a.x; }
}

bool order(points a, points b) {
	return dist(a.first) < dist(b.first);
}

stack<int> box;

int main() {
	int cnt = 0;
	point t1,t2;
	int r, c,n;
	cin >> r >> c >> n;
	for (int i = 0; i < n; i++) {
		cin >> t1.x >> t1.y >> t2.x >> t2.y;
		if (on_edge(t1, r, c) && on_edge(t2, r, c)) {
			if (dist(t1) > dist(t2)) {
				swap(t1, t2);
			}
			a[cnt].first = t1;
			a[cnt].second = t2;
			cnt++;
		}
	}
	n = cnt;
	sort(a, a + n, order);
	box.push(MAX * 4 + 1);
	for (int i = 0; i < n; i++) {
		while (dist(a[i].first) > box.top()) {
			box.pop();
		}
		if (dist(a[i].second) > box.top()) {
			std::cout << "NO" << endl;
			return 0;
		}
		else {
			box.push(dist(a[i].second));
		}
	}
	std::cout << "YES" << endl;
}

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


int main(){
    string s,t;

    cin >> s >> t;
  int i;
  for(i=0;s[i]!=0;i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include <math.h>
using namespace std;
int main(){
	long yen,div,rem,hap;
	cin>>yen;
	if(yen<5)
	{
		cout<<"0";
		return 0;
	}
	div=yen/500;
	rem=yen%500;
	hap=div*1000;
	if (rem>=5)
	{
		div=rem/5;
		hap+=div*5;
	}
	cout<<hap;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	int sum = arr[n - 1];
	int tmp = n - 2, i = n - 2;
	while (tmp > 0)
	{
		tmp -= 2;
		if (tmp >= 0)
			sum += 2 * (arr[i]);
		else
			sum += arr[i];
		i--;
	}



	cout << sum;
	//cout << "\n\n" << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;

}

Measured memory_bytes: 5204
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N;

	scanf("%d", &N);

	int C = 0;

	rep(i, N+1) {
		if (!(i % 2)) continue;
		map<int,int> p;
		int n = i;
		for (int t = 3; n > 1; ++t) {
			if (!(n % t)) {
				p[t]++;
				n /= t;
				t = 2;
			}
		}
		int count = 1;
		for (auto pp : p) {
			count *= pp.second + 1;
		}
		if (count == 8) C++;
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int t0 = 0, t1 = 0, t2 = 0;
	int n; cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		string s; cin >> s;
		int len = s.size();
		for(int j = 0; j < len - 1; j++) ans += s[j] == 'A' && s[j+1] == 'B';
		if(s[0] == 'B' && s.back() == 'A') t2++;
		else if(s[0] == 'B') t0++;
		else if(s.back() == 'A') t1++;	
	}
  	if(t0 && t1 && t2){
    	ans += t2 + 1;
      	t1--;
      	t0--;
      t2 = 0;
    }
	int g = min({t0, t1, t2});
 	ans += 2 * g;
  	t0 -= g; t1 -= g; t2 -= g;
  	int g2 = min(t0, t1);
  	ans += g2;
  	t0 -= g2; t1 -= g2;
  	ans += max(t2 - 1, 0);
  	t2 = min(t2, 1);
  	if(t2 && (t0 || t1))ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,x,mi,ma,l;
    cin >>k>>x;
    l=2*k-1;
    mi=max(-1000000,x-k+1);
    ma=min(1000000,x+k-1);
    for(int i=mi;i<ma+1;i++){
        cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

ll lcm(ll a, ll b){
    if(a == 0 || b == 0) return 0;
    ll num = 1;
    ll c = min(a,b);
    _rep(i,2,c + 1){
        while(a % i == 0 && b % i == 0){
            if(a % i == 0 && b % i == 0){
                num *= i;
                a /= i;
                b /= i;
            }
        }
    }
    return num * a * b;
}

int main(){
    ll a,b; cin >> a >> b;
    print(lcm(a,b));
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];

    sort(p.begin(), p.end(), greater<int>());
    ll ans = 0;
    REP(i, N){
        if(i==0)p[i] = (int)(p[i]/2);
        ans += p[i];
    }

    cout << ans << endl;

}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
double A[100010],B[100010],C[100010],nw;
int n,tree[300010],nd[100010],rk[100010];
inline void Add(int x)
{
	for(;x<=n;x+=x&-x)
		tree[x]++;
}
inline int Ask(int x)
{
	int ret=0; for(;x;x-=x&-x)
		ret+=tree[x]; return ret;
}
inline bool cmp(const int a,const int b)
{
	return (C[a]-A[a]*nw)/B[a]<(C[b]-A[b]*nw)/B[b];
}
inline double work()
{
	for(int i=1;i<=n;i++) rk[i]=i;
	nw=-1000000000; sort(rk+1,rk+1+n,cmp);
	for(int i=1;i<=n;i++) nd[rk[i]]=i;
	//for(int i=1;i<=n;i++) cout << nd[i] << " " ; cout << endl;
	double L=-1000000000,R=10000000000;
	for(int i=1;i<=100;i++)
	{
		nw=(L+R)/2;
		sort(rk+1,rk+1+n,cmp);
		ll tp=0;		
		memset(tree,0,sizeof tree);
		for(int i=1;i<=n;i++)
		{
			tp+=Ask(n)-Ask(nd[rk[i]]);
			Add(nd[rk[i]]);
		}
	//	cout << tp << endl;
		if(n*(n-1)%4)
		{
			if(tp>1ll*(n-1)*n/2/2) R=nw;
			else L=nw;
		}
		else 
		{
			if(tp>=1ll*(n-1)*n/2/2) R=nw;
			else L=nw;

		}
	}
	return L;
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<=n;i++)
	A[i]=read(), B[i]=read(), C[i]=read();
	double X=work(); 
	for(int i=1;i<=n;i++) swap(A[i],B[i]);
	double Y=work();
	printf("%.9lf %.9lf\n",X,Y);
	return 0;
}

Measured memory_bytes: 3968
input = gets(nil).chomp

o = {}

input.split("\n").each do |line|
  n = line.to_i
  o[n] = 0 unless o[n]
  o[n] += 1
end

m = 0
o.each do |k,v|
  m = v if v > m
end

o.select{|k,v| v == m}.keys.sort.each {|i| puts i}

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    ll ans=0;
    priority_queue<pair<int,int>>q;
    rep(i,n){
        int a; cin>>a;
        q.push(make_pair(a,1));
    }
    rep(i,m){
        int b,c;
        cin>>b>>c;
        q.push(make_pair(c,b));
    }
    while(n>0){
        int qf=q.top().first;
        int qs=q.top().second;
        ans+=(ll)qf*qs;
        n-=qs;
        if(n<0)ans+=(ll)qf*n;
        q.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  long h,n;
  cin >> h >> n;
  int a;
  int i;
  long summ = 0;
  for(i=0;i<n;i++){
    cin >> a;
    summ += a;
  }
  if(summ >= h)cout << "Yes" << endl;
  else cout << "No"<<endl;

}


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

using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 1;
  for (int i = 0; i < n; i++) {
    ans = min(2 * ans, ans + k);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, Q;
	bool F = true;
	cin >> N;
	VI sor(N),A(N);
	REP(i, N) {
		cin >> A[i];
		sor[i] = A[i];
	}
	SORT(sor);
	int cnt = 0;
	REP(i, N) {
		if (sor[i] == A[i]) {
			cnt++;
		}
	}
	if (cnt == N) {
		cout << 0 << endl;
		F = false;
	}

	cin >> Q;
	REP(i, Q) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (A[a] == sor[b])cnt++;
		if (sor[a] == A[b])cnt++;
		if (A[a] == sor[a])cnt--;
		if (A[b] == sor[b])cnt--;
		swap(A[a], A[b]);

		if (cnt == N && F) {
			cout << i + 1 << endl;
			F = false;
		}

	}
	if (F) {
		cout << -1 << endl;
	}
	return 0;
}




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

using namespace std;

typedef long long ll;

vector<string> vp[10]; //Vector Prev
vector<string> vn[10]; //Vector next
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int k;
	cin >> k;
	vector<string> ans;
	for(int i=0; i<10; i++){
		vp[i].push_back(to_string(i));
		ans.push_back(to_string(i));
	}
	while((int)ans.size() <= k){
		for(int i=0; i<10; i++){
			vn[i].clear();
			for(int j=max(0, i-1); j<=min(i+1, 9); j++){
				for(string s: vp[j]){
					string aux = to_string(i) + s;
					vn[i].push_back(aux);
					if(i > 0)
						ans.push_back(aux);
				}
			}			
		}		
		for(int i=0; i<10; i++)
			swap(vn[i], vp[i]);		
	}
	cout << ans[k] << endl;
	return 0;
}


Measured memory_bytes: 13040
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,ac,wa,tle,re;
  ac=0;
  wa=0;
  tle=0;
  re=0;
  cin>>N;
  for(int i=0;i<N;i++){
    string a;
    cin>>a;
    if(a=="AC"){
    ac++;
    }
    if(a=="WA"){
    wa++;
    }
    if(a=="TLE"){
    tle++;
    }
    if(a=="RE"){
    re++;
    }
  }
  cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
  int n,f[100][10],cnt[100]={},i,j,k,a[10];
  long p[100][11],max=-100000000000,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      scanf("%d",&f[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<11;j++){
      scanf("%ld",&p[i][j]);
    }
  }
  for(a[0]=0;a[0]<2;a[0]++){
    for(a[1]=0;a[1]<2;a[1]++){
      for(a[2]=0;a[2]<2;a[2]++){
        for(a[3]=0;a[3]<2;a[3]++){
          for(a[4]=0;a[4]<2;a[4]++){
            for(a[5]=0;a[5]<2;a[5]++){
              for(a[6]=0;a[6]<2;a[6]++){
                for(a[7]=0;a[7]<2;a[7]++){
                  for(a[8]=0;a[8]<2;a[8]++){
                    for(a[9]=0;a[9]<2;a[9]++){
                      sum=0;
                      if(a[0]||a[1]||a[2]||a[3]||a[4]||a[5]||a[6]||a[7]||a[8]||a[9]){
                        for(i=0;i<n;i++){                        
                          cnt[i]=0;
                          for(j=0;j<10;j++){
                            if(a[j]&&f[i][j])
                              cnt[i]++;
                          }
                          sum+=p[i][cnt[i]];
                        }
                        if(max<sum)
                          max=sum;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  printf("%ld\n",max);
}

Measured memory_bytes: 128
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main = do
    n<-readLn :: IO Int
    ms <- replicateM n $ unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    --
    putStrLn $ if all fst $ scanl' chkmv (True,(0,0)) ms then "Yes" else "No"

chkmv (_, (x,y)) [t,xi,yi] =
    if and [t>=dx+dy, even $ t-dx+dy] then (True,(x,y)) else (False, (x,y))
    where
        dx = abs $ xi-x
        dy = abs $ yi-y

Measured memory_bytes: 28028
#include <bits/stdc++.h>
using namespace std;
int n,s,dp[3300],mod=998244353,ans;
int main()
{
    cin>>n>>s;
    for(int i=1;i<=n;i++) //枚举前n个物品的方案数. i表示从1到第i个物品 
    {
        int x; cin>>x;
        dp[0]=i;//01背包的变形。 这里dp[0]=i是因为 以前的背包问题只算了1--i的方案数,缺少2--i,3--i,4--i,以及i--i等i-1种情况.每情况对dp[0]要使用一次 
        for(int j=s;j>=x;j--) dp[j]=(dp[j]+dp[j-x])%mod;
        ans=(ans+dp[s])%mod;
    }
    cout<<ans<<endl;
}

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

int main() {
  int64_t N, K; cin >> N >> K;
  
  int64_t A = N % K;
  int64_t B = K - A;
  if (B < 0) B *= -1;
  cout << min(A, B) << endl;
}

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

int main(void) {
    char b; cin >> b;
    if (b == 'A') {
        cout << 'T' << endl;
    }else if(b == 'T') {
        cout << 'A' << endl;
    }else if(b == 'C') {
        cout << 'G' << endl;
    }else {
        cout << 'C' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define int long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int n,i,j,k;
    cin>>n;
    vector<vector<int>> v(n+5,vector<int>(3)), dp(n+5,vector<int>(3,0));
    for(i=1;i<=n;i++)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    for(i=1;i<=n;i++)
    {
        dp[i][0] = v[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = v[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;           
}

Measured memory_bytes: 14140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  int x,y;
  cin >> x >> y;
  cout << fixed << setprecision(16);
  double H,M;
  cin >> H >> M;
  double a=30*H+M/2;
  double b=6*M;
  double c=b-a;
  
  double ans = pow(x*x+y*y-2*x*y*cos(c*M_PI/180),0.5);
  cout << ans << endl;
}

Measured memory_bytes: 4356
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PI;
using namespace std;
#define MAX  999999
int main(){
    int n;
    while(cin>> n,n){
        vi array(1000,0); bool check = false; int ans = 0; int hoge = -INF;;
        vi num(1000,0); vi size(1000,0);
        vi z;
        vvi v(1000,vi(1000,0));
        rep(i,n){cin >> size[i]; rep(j,size[i])cin >> v[i][j];}
        int temp; cin>>temp; vi u(temp+1,0);
        rep(i,temp) cin >> u[i];
        rep(i,n){
            rep(j,v[i].size()){
                rep(k,temp){
                    if(v[i][j] == u[k]){array[i]++; num[u[k]]+=1;}
                }
            }
            if(hoge < array[i]){hoge = array[i];ans = i;}
        }
    
        /*judgement all element*/
        rep(i,size[ans]){
            if(v[ans][i]!= 0){
                //cout << v[ans][i]; cout << endl;
                //cout << num[v[ans][i]]; cout << endl;
                if(num[v[ans][i]] == 1){check = true;}
            }
        }
        if(hoge != temp) check = false;
        if(check == true) cout << ans+1 << endl;
        else  cout << -1 << endl;
    }
}

Measured memory_bytes: 6836
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


const int INF = 1e9;
int V, E, r;
int d[100010];

struct edge{
    int to, cost;
    edge(int to, int cost): to(to), cost(cost){}
};
vector<edge> G[100010];


// void dijkstra(int s){
//     // memset(d, INF, sizeof(d));
//     rep(i, 0, V) d[i] = INF;
//     d[s] = 0;
//     priority_queue<P, vector<P>, greater<P> > q;
//     q.push(P(0, s));
//     while(!q.empty()){
//         P p = q.top(); q.pop();
//         int from = p.second;
//         int cost = p.first;
//         if(d[from] < cost) continue;
//         rep(i, 0, G[from].size()){
//             edge e = G[from][i];
//             int next = e.to;
//             int newCost = e.cost + cost;
//             // cout << i << " " << next << " " << newCost << endl;
            
//             if(d[next] > newCost){
//                 d[next] = newCost;
//                 q.push(P(newCost, next));
//             }
//         }
//     }
// }

void dijkstra(int s){
    fill(d, d + V, INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(d[s], s));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int cost = p.first;
        if(d[from] < cost) continue;
        rep(i, 0, G[from].size()){
            edge e = G[from][i];
            int next = e.to;
            int newCost = e.cost + cost;
            if(d[next] > newCost){
                d[next] = newCost;
                q.push(P(newCost, next));
            }
        }
    }
}

// void dijkstra(int s){
//     priority_queue<P, vector<P>, greater<P> > q;//P
//     fill(d, d + V, INF);//INF
//     d[s] = 0;
//     q.push(P(0, s));

//     while(!q.empty()){
//         P p = q.top(); q.pop();
//         int v = p.second;
//         if(d[v] < p.first) continue;
//         rep(i, 0, G[v].size()){
//             edge e = G[v][i];
//             if(d[e.to] > d[v] + e.cost){
//                 d[e.to] = d[v] + e.cost;
//                 q.push(make_pair(d[e.to], e.to));
//             }
//         }
//     }
// }

signed main(){
    cin >> V >> E >> r;
    int s, t, a;
    rep(i, 0, E){
        cin >> s >> t >> a;
        G[s].push_back(edge(t, a));
    }
    dijkstra(r);
    rep(i, 0, V){
        if(d[i] == INF) cout << "INF"  << endl;
        else cout << d[i] << endl;
    }
}

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

int main () {
  int N, sum=0, ave, ans=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
//    printf("%d,%d\n", a.at(i), sum);
  }
  ave=2*sum;
  ave/=N;
  ave+=1;
  ave/=2;
//  printf("%d\n", ave);
  for(int i=0;i<N;i++){
    int sq=a.at(i)-ave;
    sq*=sq;
    ans+=sq;
//    printf("%d\n", ans);    
  }
  cout<<ans<<endl;
}

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

int func(int N){
    if(N < 10)  return N;
    return func(N/10) + N%10;
}

int main(){
    int N;
    cin >> N;
    int S = func(N);
    if(N%S == 0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=1e9+7;
ll dp[17][1<<16];
ll quick(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
ll inv(ll a){return quick(a,mod-2);}
const int maxn=1<<17;
ll fac[maxn];
ll facinv[maxn];
void init()
{
    fac[0]=facinv[0]=1;
    for(int i=1;i<maxn;i++) 
    {
        fac[i]=fac[i-1]*i%mod;
        facinv[i]=inv(fac[i]);
    }
}
inline ll C(int n,int m)
{
    if(n<m) return 0;
    return fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main()
{
    init();
    int n,m;
    cin>>n>>m;
    vi a(m);
    for(int i=0;i<m;i++) cin>>a[i];
    dp[m][0]=1;
    for(int i=m-1;i>=0;i--)
    {
        for(int S=0;S<(1<<n);S++)
        {
            if(!dp[i+1][S]) continue;
            dp[i][S]=(dp[i][S]+dp[i+1][S])%mod;
            for(int j=0;j<n;j++)
            {
                if(S&(1<<j)) continue;
                int tot=(1<<n)-a[i]-S;
                dp[i][S|(1<<j)]=(dp[i][S|(1<<j)]+C(tot,(1<<j)-1)*dp[i+1][S]%mod*fac[1<<j]%mod)%mod;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<(1<<n);i++)
    {
        int cc=__builtin_popcount(i);
        if(cc&1) ans=(ans-dp[0][i]*fac[(1<<n)-1-i]%mod+mod)%mod;
        else ans=(ans+dp[0][i]*fac[(1<<n)-1-i]%mod)%mod;
    }
    ans=ans*(1<<n)%mod;
    print(ans);
}

Measured memory_bytes: 10496
# include <iostream>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a, b;

int main()
{
	cin >> a >> b;
	if( a > 12 )
		cout << b;
	else if( a > 5 )
		cout << b / 2;
	else
		cout << 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];

    sort(d.begin(), d.end());
    int L = d[N / 2 - 1] + 1;
    int R = d[N / 2];

    cout << R - L + 1 << endl;
}

Measured memory_bytes: 640
s = raw_input()
length = len(s)
if length == 1:
    print 1
    exit()
T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
if len(T) == 0:
    print length
else:
    print min(T)

Measured memory_bytes: 7684
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        string N;
        cin >> N;
        N[3] = '8';

        cout << N<< endl;

        return 0;
}


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

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int N[5], k;
  rep(i, 5){
    cin >> N[i];
  }
  cin >> k;

  vector<int> check(5, 0);
  int flag = 1;
  rep(i, 5){
    for(int j = i+1; j < 5; j++){
      if (abs(N[i] - N[j]) > k) {
        flag = 0;
      }
    }
  }

  if(flag) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N, X, Y;
	cin >> N >> X >> Y;

	X--;
	Y--;
	
	vint ans(N);
	for (int i = 0; i < N; i++)
	{
		ans[i] = 0;
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			if (i == 0 && j == 4)
			{
				int saf = 0;
			}
			if (j <= X || i >= Y)
			{
				// 普通に数える
				ans[j - i]++;
			}
			else if (X <= i && j <= Y)
			{
				int dis = j - i;
				dis = min(dis, i - X + 1 + Y - j);
				ans[dis]++;

			}
			else if (j <= Y)
			{
				// i , X, j , Y
				int dis = j-i;
				dis = min(dis, X - i + Y - j + 1);
				ans[dis]++;
			}
			else if (i >= X)
			{
				// X,  i Y j 
				int dis = j - i;
				dis = min(dis, i - X + 1 + j - Y);
				ans[dis]++;
			}
			else if(i<= X && Y <= j)
			{
				int dis = j - Y + 1 + X - i;
				ans[dis]++;
			}


		}
	}


	for (int i = 1; i < N; i++)
	{
		cout << ans[i] << endl;
	}

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b;

int main(){
	cin >> a >> b;
	double ret = 0;
	for (int i = 1; i <= a; i++){
		double tmp = 1.0 / a;
		int now = i;
		while (now < b){
			now *= 2;
			tmp /= 2;
		}
		ret += tmp;
	}

	printf("%.10f\n", ret);

	return 0;
}

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

int main(){
    int ans = 0;
    int cnt = 0;
    int i,j,n;
    
    scanf("%d",&n);
    
    for(i = 1; i <= n; i+=2){
        cnt = 0;
        for(j = 1; j <= i; j++){
            if(i%j == 0)
                cnt++;
        }
        if(cnt == 8)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000
using namespace std;



int main(){
  long long d, n; cin >> d >> n;
  long long ans = 0;
  REP(i, n){
    ans += pow(100, d);
  }
  if(n==100){
    ans += pow(100, d);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll k;
vvin edge(100020);

ll dfs(int from,int now){
    ll can;
    if(from==-1)can=k-(ll)1;
    else can=k-(ll)2;
    if(k<=edge[now].size())return 0;
    ll res=(ll)1;
    for(auto e:edge[now]){
        if(e==from)continue;
        res*=can;
        res%=inf;
        can--;
    }
    for(auto e:edge[now]){
        if(e==from)continue;
        res*=dfs(now,e);
        res%=inf;
    }
    return res;
}

int main(){
    int n;cin>>n>>k;
    int a,b;
    rep(i,n-1){
        cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll ans=k*dfs(-1,1);
    cout<<ans%inf<<endl;
}

Measured memory_bytes: 13416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    auto g = make_vec<int>(n, 0);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    auto dist = make_vec<int>(n, 3);
    fill_v<int>(dist, -1);
    dist[s][0] = 0;
    queue<pair<int, int>> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        auto p = q.front();
        int v = p.first, r = p.second;
        q.pop();
        int nr = (r+1) % 3;
        for (int u : g[v]) {
            if (dist[u][nr] != -1) continue;
            dist[u][nr] = dist[v][r] + 1;
            q.emplace(u, nr);
        }
    }
    int ans = dist[t][0];
    cout << (ans == -1 ? ans : ans / 3) << endl;
}


Measured memory_bytes: 14248
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if((y-2*x)%2==0&&y-2*x>=0&&(4*x-y)%2==0&&4*x-y>=0)
        printf("Yes\n");
    else
        printf("No\n");
	return 0;
}


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

int main(){
  int N; int K;
  std::string str;
  std::cin>>N;
  std::cin>>str;
  std::cin>>K;
  char a = str[K-1];
  char ast = '*';
  std::string output("");
  //std::cout<<a<<std::endl;
  for(auto &&r : str){
    if(r==a){
      output += a;
    }else{
      output += ast;
    }
  }
  std::cout<<output<<std::endl;
  return 0;
}


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

// DP実装の順序
// 1. DP配列全体を「DPの種類に応じた初期値」で初期化
// 2. 初期条件を入力
// 3. ループを回す
// 4. テーブルから解を得て出力

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

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

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100010];

int main() {
    // 入力受け取り
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    // dpテーブル初期化
    for (int i = 1; i <= N; i++) {
        dp[i] = INF;
    }

    // 初期条件
    dp[1] = 0;

    for (int i = 2; i <= N; i++) {
        if (2 < i) {
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    }
    cout << dp[N] << endl;
    return 0;
}

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

int N;
vector<long long int> a;

int main(void) {

	cin >> N;
	long long int tmp;
	for (int i = 1; i <= N*3; i++) {
		cin >> tmp; a.push_back(tmp);
	}

	sort(a.rbegin(),a.rend());

/*	for (int i = 0; i < N*3; i++) {
		cout << a[i] << " " << endl;
	}*/

	long long int ans = 0;

	int count = 0;
	for (int i = 1;; i += 2) {
		ans += a[i];
		count++;
		if (count >= N) { break; }
	}

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

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

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        long ans = 0;

        for (var i = 1; i < input + 1; i++) 
        {
            for(var j = 1; j < input + 1; j++)
            {
                var mid = EuclideanAlgorithm(i, j);
                for(var k = 1; k < input + 1; k++)
                {
                    ans += EuclideanAlgorithm(mid, k);
                }
            }
        }

        Console.WriteLine(ans);
        
        Console.ReadLine();

    }

    public static long EuclideanAlgorithm(long a, long b)
    {
        if (a < b)
        {
            var temp = a;
            a = b;
            b = temp;
        }

        long result = 0;
        while (true)
        {
            var remainder = a % b;
            if (remainder == 0)
            {
                result = b;
                break;
            }
            else
            {
                a = b;
                b = remainder;
            }
        }

        return result;
    }
}



Measured memory_bytes: 17648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string S;
  cin>>S;
  int N=S.size();

  vector<ll> rig(N+1,0);
  for(int i=N-1;i>=0;i--){
    if(S[i]=='>') rig[i]=rig[i+1]+1;
    else rig[i]=0;
  }

  ll now=0;
  ll ans=0;
  S+="<";
  for(int i=0;i<N+1;i++){
    if(S[i]=='<'){
      if(i-1>=0&&S[i-1]=='>'){
        now=1;
      }else{
        ans+=now;
        now++;
      }
    }else{
      if((i-1>=0&&S[i-1]=='<')||(i==0&&S[i]=='>')){
        ll x=max(now,rig[i]);
        ans+=x;
        now=x-1;
      }else{
        ll x=min(now,rig[i]);
        ans+=x;
        now=x-1;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
//A-BがMの倍数->A mod M == B mod M
int main(){
  ll N,M;
  cin >> N >> M;
  map<ll,ll> nums;
  ll sum = 0;
  nums[0]++;
  rep(i,N) {
    int a;
    cin >> a; 
    sum += a;
    nums[sum % M]++;
  }
  ll res = 0;
  for (auto itr = nums.begin(); itr != nums.end(); itr++) {
    res += itr->second * (itr->second - 1) / 2;
  }
  cout << res << endl;  
  return 0;
}

Measured memory_bytes: 4224
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  cin>>n;
  vector<int>a;
  for(int i=2;i*(ll)i<=n;i++){
    int c = 0;
    while(n%i==0){
      c++;
      n/=i;
    }
    if(c)a.push_back(c);
  }
  if(n>1)a.push_back(1);
  int ret = 0;
  for(auto x : a){
    int cur = 1;
    while(x>=cur){
      ret++;
      x-=cur;
      cur++;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int H, W, K; cin >> H >>W >> K;

    vector<string> vs(H);
    for(int i=0; i<H; i++) cin >> vs[i];

    int ans = 0;
    for(int bit=0; bit<(1<<(H+W)); bit++) {
        vector<string> tmp = vs;
        for(int i=0; i<H; i++) {
            if(!(bit >> i & 1)) continue;
            for(int j=0; j<W; j++) {
                tmp[i][j] = '.';
            }
        }
        for(int j=0; j<W; j++) {
            if(!(bit >> (H+j) & 1)) continue;
            for(int i=0; i<H; i++) {
                tmp[i][j] = '.';
            }
        }

        int cnt = 0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(tmp[i][j] == '#') cnt++;
            }
        }

        if(cnt == K) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    cout << s[0];
    rep(i, 1 << 3){
        bitset<3> a(i);
        int sum = s[0] - '0'; //charからintへ 数字 - '0'
        rep(i, 3){
            if(a.test(i)){
                sum += s[i+1] - '0';
            } else {
                sum -= s[i+1] - '0';
            }
        }
        if(sum == 7){
            rep(i, 3){
                if(a.test(i)){
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << s[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256