akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

VEC<list<int>> G;
VEC<int> Cnt;
VEC<LL> Ans;
VEC<bool> visited;
void dfs(int node, int weight) {
  visited[node] = true;
  weight += Cnt[node];
  Ans[node] = weight;

  for (auto v : G[node]) {
    if (!visited[v]) dfs(v, weight);
  }
}
int main() {
  int N, Q;
  cin >> N >> Q;
  G = VEC<list<int>>(N, list<int>());
  REP(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  VEC<pair<int, int>> P(Q);
  Cnt = VEC<int>(N, 0);
  REP(i, 0, Q) {
    cin >> P[i].first >> P[i].second;
    P[i].first--;
    Cnt[P[i].first] += P[i].second;
  }
  // DUMP(Cnt);
  Ans = VEC<LL>(N, 0);
  visited = VEC<bool>(N, 0);
  dfs(0, 0);
  REP(i, 0, N) { cout << Ans[i] << " "; }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 31360
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[1000000];

const int MOD = 1000000007;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

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

  while (scanf("%*d%s", s) == 1) {
    vector<int> cnt(26);
    for (int i = 0; s[i]; i++) {
      cnt[s[i]-'a']++;
    }
    int ans = 1;
    for (int x : cnt) {
      ans = mul(ans, x + 1);
    }
    sub(ans, 1);
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int d[20][20];

void warshall_floyd(int V){
    rep(i, V)rep(j, V)rep(k, V)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    rep(i, 20)rep(j, 20) d[i][j] = INF;
    rep(i, 10)rep(j, 10) cin >> d[i][j];
    warshall_floyd(12);
    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            int a;
            cin >> a;
            if (a != -1 && a != 1)ans += d[a][1];
        }
    }
    cout << ans << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long x,y,ans=0;
    cin>>x>>y;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3644
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;
 
template<typename T> using V = vector<T>;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(all(v));
	double cur = v[0], nxt = 1;
	while (nxt < n) {
		cur = (cur + v[nxt]) / 2.0;
		++nxt;
	}
	cout << fixed << setprecision(10);
	cout << cur << '\n';
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, A);
    CIN(int, B);
    CIN(int, C);
    CINS(int, l, N);

    int ans = 1e9;
    for (int i = 0; i < pow(4, N); i++) {

        int index = i;
        int lA = 0, lB = 0, lC = 0;
        int mA = 0, mB = 0, mC = 0;

        for (int j = 0; j < N; j++) {

            if ( index % 4 == 1 ) {
                if ( lA > 0 ) mA += 10;
                lA += l[j];

            } else if ( index % 4 == 2 ) {
                if ( lB > 0 ) mB += 10;
                lB += l[j];

            } else if ( index % 4 == 3 ) {
                if ( lC > 0 ) mC += 10;
                lC += l[j];
            }

            index /= 4;
        }

        if ( lA * lB * lC > 0 ) {
            ans = min(ans, mA + mB + mC + abs(lA - A) + abs(lB - B) + abs(lC - C));
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
s = (gets.to_i).times.map{gets.to_s}
a = Array.new(5,0)
a[0] = s.count{|name|name.chr == "M"}
a[1] = s.count{|name|name.chr == "A"}
a[2] = s.count{|name|name.chr == "R"}
a[3] = s.count{|name|name.chr == "C"}
a[4] = s.count{|name|name.chr == "H"}
ans = 0
for i in 0..2
  for j in i+1..3
    for k in j+1..4
      ans += a[i]*a[j]*a[k]
    end
  end
end
puts ans

Measured memory_bytes: 9852
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    a += b;
    int n = 0;
    for (int i = 0; i < a.size(); ++i)
    {
        n *= 10;
        n += a[i] - '0';
    }
    for (int i = 1; i <= n; ++i)
        if (i * i == n)
            return cout << "Yes", 0;
    cout << "No";
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int r = 0;
    for (int i=0; i<2; i++) {
        if (a>b) {
            r += a;
            a--;
        } else {
            r += b;
            b--;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0)pr("Possible");
    else pr("Impossible");
}

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



fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val cout = PrintWriter(System.`out`)
    val n = cin.nextInt()

    cout.println(n*n*n)
    
    cout.flush()
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

Measured memory_bytes: 31124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);


int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	char s[5]; cin >> s;
	f(i, 0, 2)if (s[i] == '1') {
		s[i] = '9';
	}
	else s[i] = '1';
	cout << s;
}

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

typedef long long ll;

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

    string S;

    cin >> S;

    int l = S.length();

    for(int i = 0; i < l / 2; i++) {
        if(S[i] != S[l - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
        
    }

    for(int i = 0; i < l / 4; i++) {
        if(S[i] != S[(l - 1) / 2 - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = 0; i < l / 4; i++) {
        if(S[i + (l + 3) / 2 - 1] != S[l - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
a1 = int(input())
b1 = int(input())
c1 = int(input())
x1 = int(input())

co = 0
for a2 in range(0,a1+1):
    for b2 in range(0,b1+1):
        for c2 in range(0,c1+1):
            if a2*500 + b2*100 + 50 *c2 == x1:
                co += 1
print(co)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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 rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	int N, P; cin >> N >> P;
	string S; cin >> S; reverse(all(S));
	// dbl(S);
	int mod = 1;
	vi r(N + 1); // 右i桁をPで割った余り
	rep(i, N) {
		// db(i); db(r.at(i)); db(S.at(i) - '0'); db(mod); dbl(P);
		r.at(i + 1) = (r.at(i) + (S.at(i) - '0') * mod) % P; // dbl(r.at(i + 1));
		mod = mod * 10 % P;
	}
	map<int, ll> m; // 余り→個数
	rep2(i, 1, N + 1) {
		if (m.count(r.at(i))) m[r.at(i)]++;
		else m[r.at(i)] = 1;
	}
	ll ans = 0;
	// dbv(r);
	if (P != 2 && P != 5) {		
		for (pair<int, ll> p : m) {
			int rem; ll num; tie(rem, num) = p;
			// db(rem); dbl(num);
			if (rem == 0) ans += num;
			ans += num * (num - 1) / 2;		
		}
	} else {
		rep2(i, 1, N + 1) {
			int d = S.at(i - 1) - '0';
			if (d % P == 0) ans += N - i + 1;
		}
	}	
	cout << ans << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i, 3){
		if(s[i] == '7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int N = sc.nextInt();
		int[] dp = new int[N + 2];
		for (int i = 0; i < N; ++i) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			if (a < dp.length) {
				dp[a]++;
			}
			if (b + 1 < dp.length) {
				dp[b + 1]--;
			}
		}
		int ans = 0;
		for (int i = 1; i <= N+1; ++i) {
			dp[i] += dp[i - 1];
			if (dp[i] >= i - 1) ans = i - 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 13000
/*
   AOJ - ALDS1_1_B
Date: 20190309
Author: Mikoron * ♡mikoiwate_351♡
*/


#include<stdio.h>

int gcd(int a, int b);

int main(void) {
        int a, b;

        scanf("%d %d", &a, &b);
        printf("%d\n", gcd(a,b));
        return 0;
}

int gcd(int a, int b) {
        int buf, div_num;

        if(a == b) return a;
        else if(b > a) {
                b = b % a;
        } else if(a > b) {
                buf = a;
                a = b;
                b = buf % a;
        }

        div_num = 1;
        while(b >= div_num) {
                if(b % div_num == 0) {
                        if(a % (b / div_num) == 0) {
                                return b / div_num;
                        }
                }
                div_num++;
        }
        return 1;
}



Measured memory_bytes: 2092
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int w, h;
	while(scanf("%d%d", &w, &h), w){
		vvi field(h+1, vi(w, 0));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);
		
		vvi dp(h+1, vi(w, 0));
		rep(i, w)
			dp[0][i] = field[0][i] == 0;
		
		rep(i, h-1){
			rep(j, w){
				if(field[i][j] == 0){
					const int dx[] = {-1, 0, 1};
					rep(k, 3){
						int px = j + dx[k];
						if(px<0 || w<=px || field[i+1][px] == 1 || (dx[k]!=0 && field[i+1][px]==2))
							continue;
						dp[i+1][px] += dp[i][j];
					}
				}
				else if(field[i][j] == 2){
					if(i+1<h && field[i+2][j] != 1)
						dp[i+2][j] += dp[i][j];
				}
			}
		}
		
		int sum = 0;
		rep(i, 2) rep(j, w)
			sum += dp[h-i][j];
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if((j < A) == (i < B)) {
                cout << 0;
            } else {
                cout << 1;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

WeightedGraph G;

bool rec(int u, int p, int v, bitset<64> &path){
  if(u==v)return true;
  for(auto e : G[u]){
    if(e.first==p)continue;
    if(rec(e.first, u, v, path)){
      path.set(e.second);
      return true;
    }
  }
  return false;
}

int main(){
  int n; cin >> n;
  G.resize(n);
  for(int i = 0; i < n-1; ++i){
    int u,v;cin >> u >> v;
    --u; --v;
    G[u].push_back({v,i});
    G[v].push_back({u,i});
  }
  
  int m; cin >> m;
  vector<int> us(m), vs(m);
  for(int i = 0; i < m; ++i){
    cin >> us[i] >> vs[i];
    --us[i]; --vs[i];
  }
  
  vector<bitset<64>> paths(m);
  for(int i = 0; i < m; ++i){
    rec(us[i], -1, vs[i], paths[i]);
  }
  
  ll ans = 0;
  for(ll i = 0; i < (1LL<<m); ++i){
    bitset<64> val(0), bit(i);
    for(int j = 0; j < m; ++j){
      if(bit[j]) val |= paths[j];
    }
    ll rem = n-1 - val.count();
    ll tmp = (1LL<<rem);
    if(bit.count()%2==0)ans+=tmp;
    else ans -= tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vll a(m), c(m);
    REP(i, m) {
        ll b; cin >> a[i] >> b;
        REP(_, b) {
            ll _c; cin >> _c;
            c[i] += (1<<(_c-1));
        }
    }
    vll dp(1<<n, HIGHINF);
    dp[0] = 0;
    REP(s, 1<<n) {
        REP(i, m) {
            if ((s|c[i]) == s) continue;
            chmin(dp[s|c[i]], dp[s]+a[i]);
        }
    }
    if (dp[(1<<n)-1]==HIGHINF) cout << -1 << '\n';
    else cout << dp[(1<<n)-1] << '\n';
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, raw_input().split())
temp = 0

if c < a:
  temp = c
  c = a
  a = temp
if c < b:
  temp = b
  b = c
  c = temp
if b < a:
  temp = a
  a = b
  b = temp

print '{0} {1} {2}'.format(a, b, c)

Measured memory_bytes: 6436
#include<stdio.h>
int main()
{
int compare[3]={0,0,0},data[10],i,j;
for(i=0;i<10;i++)
{
    scanf("%d",&data[i]);
    if(data[i]>compare[0])
    {
        compare[2]=compare[1];
        compare[1]=compare[0];
        compare[0]=data[i];
    }
    else if(data[i]>compare[1])
    {
        compare[2]=compare[1];
        compare[1]=data[i];
    }
    else if(data[i]>compare[2])
    {
        compare[2]=data[i];
    }

}

for(i=0;i<3;i++)
{
    printf("%d\n",compare[i]);
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
bool m_ans(int x, int y, int *X, int n, int *Y, int m)
{
    int maxX = X[0], minY = Y[0];
    for (int i = 1; i < n; ++i)
    {
        if (X[i] > maxX)
            maxX = X[i];
    }
    maxX += 1;
    for (int i = 1; i < m; ++i)
    {
        if (Y[i] < minY)
        {
            minY = Y[i];
        }
    }
    if (maxX > minY)
        return true;
    else
    {
        for (int z = maxX; z <= minY; ++z)
        {
            if (z > x && z <= y)
                return false;
        }
        return true;
    }
}
int main()
{
    int n, m, x, y;
    bool ans;
    cin >> n >> m >> x >> y;
    int X[n], Y[m];
    for (int &i : X)
        cin >> i;
    for (int &i : Y)
        cin >> i;
    ans = m_ans(x, y, X, n, Y, m);
    if (ans)
        cout << "War" << endl;
    else
        cout << "No War" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	int K, S;
	cin >> K >> S;
	int count{};
	REP( i, K + 1 )
	{
		REP( j, K + 1 )
		{
			if( S - ( j + i ) <= K && S - ( i + j ) >= 0 )
			{
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <algorithm> // sort
#include <map> // pair
using namespace std;


int main(){
  int n;
  cin >> n;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  pair<long long,long long> pair[n*n];
  int x = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      pair[x] = make_pair(a[i]-a[j],b[i]-b[j]);
      x++;
    }
  }
  int maximum=1;
  // cout << endl;
  //  for(int i=0;i<n*(n-1)/2;i++){
  //    cout << pair[i].first << " " << pair[i].second << endl;
  //  }
  for(int i=0;i<n*(n-1)/2;i++){
    x=1;
    for(int j=i+1;j<n*(n-1)/2;j++){
      if((pair[i].first == pair[j].first && pair[i].second == pair[j].second)
      || (pair[i].first == -pair[j].first && pair[i].second == -pair[j].second)){
        x++;
        //cout << x << pair[i].first << pair[i].second << endl;
      }
    }
    maximum = max(maximum,x);
  }
  cout << max(n - maximum,1);
}


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

int main(){

    string S;
    int N=0;
    bool b=true;
    cin >> N;
    cin >> S;
    if(N%2==0){
        for(int i=0;i<N/2;i++){
            if(S.at(i)!=S.at(i+N/2)){
                b = false;
            }
        }
    }
    else{
        b=false;
    }
if(b==true){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[4];
        for (int i = 0 ; i < n ; i++) {
            String s = sc.next();
            if (s.equals("AC")) {
                a[0]++;
            }
            if (s.equals("WA")) {
                a[1]++;
            }
            if (s.equals("TLE")) {
                a[2]++;
            }
            if (s.equals("RE")) {
                a[3]++;
            }
        }
        System.out.println("AC x " + a[0]);
        System.out.println("WA x " + a[1]);
        System.out.println("TLE x " + a[2]);
        System.out.println("RE x " + a[3]);
    }
 
}

Measured memory_bytes: 58544
#include <stdio.h>
int main(void) {
	int i, n, flag, temp, A[10000], count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	flag = 1;
	while (flag) {
		flag = 0;
		for (i = n - 1; i > 0; i--) {
			if (A[i] < A[i - 1]) {
				temp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = temp;
				flag = 1;
				count++;
			}
		}
	}
	for (i = 0; i < n - 1; i++) {
		printf("%d ", A[i]);
	}
	printf("%d\n", A[n - 1]);
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 608
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long double N, K;
  cin >> N >> K;

  long double win = 0;
  long double a = 0;

  if (N >= K)
    win = (long double)1 - ((K - 1) / N);

  ll least = ceil(log2(K));
  FOR(i, 1, min(K, N + 1)) { a += DPOW(2, least - (ll)ceil(log2(K / i))); }
  cout << SP(20) << win + (a / (DPOW(2, least) * N)) << endl;

  return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<vector<long long>> a(N, vector<long long>(N));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> a[i][j];
    }
  }
  
  vector<long long> dp(1 << N, 0);
  
  for(int b = 0; b < (1 << N); b++){
    for(int i = 0; i < N; i++){
      for(int j = i; j < N; j++){
        if(((b >> i) & 1) && ((b >> j) & 1)){
          dp[b] += a[i][j];
        }
      }
    }
  }
  
  for(int b = 1; b < (1 << N); b++){
    for(int s = b; s; s = (s - 1) & b){
      dp[b] = max(dp[s] + dp[b ^ s], dp[b]);
    }
  }
  
  cout << dp.back() << endl;
  
  return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll mi = min(A,B),ma = max(A,B);
  if((ma - mi) % 2 == 0){
    cout << (ma - mi)/2 << endl;
    return 0;
  }else{
    ll tmp1,tmp2;
    tmp1 = mi + (ma - mi - 1)/2;
    tmp2 = N - ma + 1 + (ma - mi - 1)/2;
    // cout << tmp1 << tmp2 << endl;
    cout << min(tmp1,tmp2) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cctype>
#include<stdio.h>

int main() {
        char ch;
        while(1) {
                scanf("%c", &ch);
                if (islower(ch)) cout << (char)toupper(ch);
                else cout << (char)tolower(ch);
                if (ch =='\n') break;
        }
        return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    std::swap(X, Y);
    std::swap(X, Z);

    cout << X << ' ' << Y << ' ' << Z << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int h[] = new int[n];
    int answer = 0;
    for(int i=0;i<n;i++){
      if(sc.nextInt()>=k){
        answer = answer +1;
      }
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 51008
n,m=gets.split.map &:to_i
a=n.times.map{gets.chop}
b=m.times.map{gets.chop}
puts [*0..n-m].repeated_permutation(2).any?{|i,j|
	[*0...m].all?{|k|a[i+k].slice(j,m)==b[k]}
}? :Yes: :No

Measured memory_bytes: 2044
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    960 Hours of Solitude
    Quarantine_Day : 40
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x;
    cin>>n>>x;
    vi v(n);
    int ans = n;
    int mini = INT_MAX;
    int sum = 0;
    REP(i, n){
        int a; cin>>a;
        sum += a;
        mini = min(mini, a);
    }
    cout<<ans + (x - sum) / mini<<"\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using namespace __gnu_pbds;
using namespace std;

#define EPS 1e-9
#define INF LLONG_MAX/3LL
#define MOD 1e9+7
#define F first
#define S second
#define pf push_front
#define pb push_back
#define pof pop_front
#define pob pop_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define sz(a) ((int)(a).size())
#define all(a) begin(a), end(a)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define F0R(i, a) FOR(i, 0, a)
#define R0F(i, a) ROF(i, a, 0)
#define ITER(i, a) for(auto i : a)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef tree<pi, null_type, less<pi>,
             rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int ls(int x){ return (x)&(-x); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rngr(ll x, ll y) { return (rng()%(y-x+1))+x; }

ll n, t, c, a[100005];
int main(){
	FAST
	cin >> n;
	FOR(i, 1, n){
		cin >> a[i]; t += abs(a[i]-c); c = a[i];
	}
	t += abs(0-c);
	FOR(i, 1, n){
		if(a[i] >= a[i-1] && a[i] >= a[i+1]) cout << t-2*abs(a[i]-max(a[i-1], a[i+1]));
		else if(a[i] <= a[i-1] && a[i] <= a[i+1]) cout << t-2*abs(a[i]-min(a[i-1], a[i+1]));
		else cout << t;
		cout << "\n";
	}
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
using ll = long long;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ab = a + b;
  ll m = n/ab;
  ll ans = m*a;
  if(n%ab >= a){
    ans += a;
  }else {
    ans += n%ab;
  }
  cout << ans << endl;
}


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

int main() {
 int n,m,c,d=0,k=0;cin>>n>>m>>c;
  int b[m],a[n][m];for(int i=0;i<m;i++) cin>>b[i];
  
    
  for(int i=0;i<n;i++) {
    for(int j=0;j<m;j++)cin>>a[i][j];
 }
    
    
    for(int i=0;i<n;i++){
      
      for(int j=0 ;j<m;j++) {
        d += a[i][j]*b[j]; 
       //cout<<"d= "<<d<<endl;
      }
      
      d += c;
    //  cout<<"d= "<<d<<endl;
      if(d>0)k++;d=0;
    }
    cout<<k<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
map<int,int> p;
int main()
{
    int n,i,j,k,x,s,sum;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        p[x]++;
    }
    sum=0;
    for(i=0;i<=100000;i++)
    {
        s=p[i]+p[i+1]+p[i+2];
        sum=max(s,sum);
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 4864
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

q=int(input())
l=[]
r=[]
for i in range(q):
    ll,rr=map(int,input().split())
    l.append(ll)
    r.append(rr)

similar=[]
cnt=0
for i in range(10**5+2):
    if i<=2:
        similar.append(0)
    else:
        if is_prime(i)==True and (is_prime((i+1)/2))==True:
            cnt+=1
        similar.append(cnt)

for i in range(q):
    print(similar[r[i]]-similar[l[i]-1])


Measured memory_bytes: 12568
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(n):
    c += min(a[i], b[i])
    if b[i]-a[i] >= a[i+1]:
        c += a[i+1]
        a[i+1] = 0
    else:
        c += max(b[i]-a[i], 0)
        a[i+1] = max(a[i+1] - max(b[i]-a[i], 0), 0)
print(c)

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


int main() {
  int H, A;
  cin >> H >> A;
  if (H % A == 0) {
    cout << H / A << endl;
  } else {
    cout  << H / A + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      string s;
      cin >> s;
      if (s == "snuke") {
        cout << (char)('A' + j) << i + 1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <functional>

using namespace std::placeholders;
using namespace std;

void scanData(long int *t, long int *x, long int *y, long int size) {
    for (long int i = 0; i < size; ++i)
        scanf("%ld %ld %ld", &t[i], &x[i], &y[i]);
}

int traveling(const long int *t, const long int *x, const long int *y, long int size) {
    long int curX = 0;
    long int curY = 0;

    int i;
    for (i = 0; i < size; ++i) {
        long int difT = t[i] - (i == 0 ? 0 : t[i - 1]);
        long int remain = difT - (abs(x[i] - curX) + abs(y[i] - curY));

        curX = x[i];
        curY = y[i];
        if ((0 > remain || remain & 0x1)) break;
    }

    return i == size ? true : false;
}

int main() {
    long int N;
    long int *time;
    long int *x;
    long int *y;

    scanf("%ld", &N);
    time = (long int*)malloc(sizeof(long int) * (size_t)N);
    x = (long int*)malloc(sizeof(long int) * (size_t)N);
    y = (long int*)malloc(sizeof(long int) * (size_t)N);

    scanData(time, x, y, N);

    puts(traveling(time, x, y, N) ? "Yes" : "No");

    free(time);
    free(x);
    free(y);

    return 0;
}

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

int main(){
    vector<int> x(3);
    cin >> x[0] >> x[1] >> x[2];
    if (x[0] == x[1] && x[1] == x[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1e9+7;

int dp[80][80][10000];

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

  int h,w;
  cin >> h >> w;
  vvi a(h,vi(w)),b(h,vi(w));
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      cin >> b[i][j];
    }
  }
  vvi d(h,vi(w));
  rep(i,h){
    rep(j,w){
      d[i][j] = abs(a[i][j] - b[i][j]);
    }
  }
  dp[0][0][d[0][0]] = 1;
  rep(i,h){
    rep(j,w){
      if(i){
        rep(k,10000){
          if(dp[i-1][j][k] == 1){
            int tx = k + d[i][j],ty = k - d[i][j];
            if(tx < 10000)dp[i][j][tx] = 1;
            if(ty >= 0)dp[i][j][ty] = 1;
            else dp[i][j][-ty] = 1;
            //cout << i << " " << j << " " << k << endl;;
          }
        }
      }
      if(j){
        rep(k,10000){
          if(dp[i][j-1][k] == 1){
            int tx = k + d[i][j],ty = k - d[i][j];
            if(tx < 10000)dp[i][j][tx] = 1;
            if(ty >= 0)dp[i][j][ty] = 1;
            else dp[i][j][-ty] = 1;
            //cout << i << " " << j << " " << k << endl;;
          }
        }
      }
    }
  }
  rep(k,10000){
   if(dp[h-1][w-1][k] == 1){
     cout << k << endl;
    break;
   } 
  }
}


Measured memory_bytes: 248960
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        x: usize,
        ll: [usize; n]
    }
    let result = {
        let mut sum = 0;
        let mut cnt = 1;
        for l in ll {
            sum += l;
            if sum > x {
                break;
            }
            cnt += 1;
        }
        cnt
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B;
  cin >> A >> B;
  
  int Tap = 1;
  
  for(int i=0; i<B; i++){
    
    if(Tap>=B){
      cout << i << endl; 
      break;
    }
    
    Tap-=1;
    Tap+=A;

  }
  
  
}


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

const int MAXN = 1e5+5;

ll n, m, a[MAXN], ans;
bool vis[MAXN];

vector<int> g[MAXN];
vector<int> v;
vector<int> w;

void dfs(int u) {
	vis[u] = 1;
	v.push_back(a[u]);

	for (int t : g[u])
		if (!vis[t])
			dfs(t);
}

int main() {
	cin >> n >> m;
	if (2*n-2-2*m > n) {
		cout << "Impossible\n";
		return 0;
	}
	if (m == n-1) {
		cout << 0 << endl;
		return 0;
	}

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

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < n; ++i) {
		if (vis[i])
			continue;
		dfs(i);
		sort(v.begin(), v.end());
		ans += v[0];
		for (int j = 1; j < v.size(); ++j)
			w.push_back(v[j]);
		v.clear();
	}

	sort(w.begin(), w.end());
	for (int i = 0; i < n-m-2; ++i)
		ans += w[i];
	cout << ans << endl;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int h, w;

int main() {
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  range(i, 0, h) {
    range(j, 0, w) {
      cin >> a[i][j];
    }
  }
  vector<vector<int>> dp(h, vector<int>(w, INT_MAX));
  dp[0][0] = a[0][0] == '#';
  range(i, 0, h) {
    range(j, 0, w) {
      if(i > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i][j] != a[i - 1][j]));
      if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (a[i][j] != a[i][j - 1]));
    }
  }
  dp[h - 1][w - 1] += a[h - 1][w - 1] == '#';
  cout << dp[h - 1][w - 1] / 2;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int a[10];
int F()
{
#define C(a,b) if((a)!=(b))return 0
#define M(i,j,k) ((a[i]+a[j]+a[k])%a[9])
	int v=M(0,1,2);
	C(v,M(3,4,5));
	C(v,M(6,7,8));
	C(v,M(0,3,6));
	C(v,M(1,4,7));
	C(v,M(2,5,8));
	C(v,M(0,4,8));
	C(v,M(2,4,6));
	return 1;
}
int main()
{
	int i,r;
	for(;;)
	{
		vector<int>z(10,-1),v(10);	
		for(i=0;i<10;++i)scanf("%d",&a[i]),v[i]=i+1;;
		if(a[0]<0)return 0;
		for(r=i=0;i<10;++i)if(a[i])v.erase(find(v.begin(),v.end(),a[i]));
			else z[i]=r++;
		if(v.empty())printf("%d\n",F());
		else
		{
			r=0;
			do
			{
				for(i=0;i<10;++i)if(z[i]>=0)a[i]=v[z[i]];
				r+=F();
			}while(next_permutation(v.begin(),v.end()));
			printf("%d\n",r);
		}
	}
}

Measured memory_bytes: 816
using System;
using System.Text;

namespace AOJ.Volume0
{
    public class QuadrangularPyramid
    {
        public static int Main()
        {
            var output = new StringBuilder();
            while (true)
            {
                int x = int.Parse(Console.ReadLine());
                int h = int.Parse(Console.ReadLine());
                if (x == 0 && h == 0) { break; }

                // ????§?????????¨??¢????????´??¢???????§???¢??4??¨?????¢
                double s = (x * x) + Math.Sqrt(4 * h * h + x * x) * x;
                output.AppendLine(s.ToString());
            }

            Console.Write(output);
            return 0;
        }
    }
}

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  auto H=make_v(n,(ll)0);
  rep(i,n) cin>>H[i];
  auto dp=make_v(n,INF);
  dp[0]=0;
  rep(i,n){
    if(i+1<n) chmin(dp[i+1],dp[i]+abs(H[i+1]-H[i]));
    if(i+2<n) chmin(dp[i+2],dp[i]+abs(H[i+2]-H[i]));
  }
  cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

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

    vector<ll> a;
    bool isNF = true;
    ll cnt = 0;

    a.push_back(n);
    
    while (isNF) {
        ll nNum;
        cnt++;

        if (n % 2 == 0) {
            nNum = n / 2;
        } else {
            nNum = n * 3 + 1;
        }

        rep(i, cnt - 1) {
            if (nNum == a[i]) {
                isNF = false;
            }
        }

        n = nNum;
        a.push_back(nNum);
    }

    cout << cnt + 1 << endl;
}

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

int main() {
  string s;
  cin >> s;
  int l=s.length();
  for (int i=0;i<l/2;++i) {
    if (s[i]!=s[l-i-1]) {
      cout << "No";
      return 0;
    }
  }
  for (int i=0;i<l/4;++i) {
    if (s[i]!=s[l/2-1-i]) {
      cout << "No";
      return 0;
    }
  }
  for (int i=l/2;i<3*l/4;++i) {
    if (s[i]!=s[l-1-i]) {
      cout << "No";
      return 0;
    }
  }
  for (int i=(l+3)/2;i<(l-3)/2;++i) {
    if (s[i]!=s[l-1-i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256