akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int N, A, B;
	cin >> N;
	if (N == 1)cout << "Hello World";
	else {
		cin >> A >> B;
		cout << A + B;
	}
}

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

using namespace std;

const int N = 105;
const int M = 5005;

int n, m, s;
int A[N], B[N], C[N], D[N];
long long f[N][M];
vector < pair <int, int> > g[N];

int main() {
    cin >> n >> m >> s;

    s = min(s, M - 1);

    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v >> A[i] >> B[i];
        g[u].emplace_back(v, i);
        g[v].emplace_back(u, i);
    }

    for (int i = 1; i <= n; i++) {
        cin >> C[i] >> D[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            f[i][j] = 1e18;
        }
    }

    f[1][s] = 0;
    set < pair <long long, pair <int, int> > > st;   
    st.insert({ f[1][s], {1, s} }); 

    while (!st.empty()) {
        int v = st.begin()->second.first, silver = st.begin()->second.second;
        st.erase(st.begin());
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i].first, id = g[v][i].second;
            if (silver - A[id] >= 0 && f[v][silver] + B[id] < f[to][silver - A[id]]) {
                st.erase({ f[to][silver - A[id]], {to, silver - A[id]} });
                f[to][silver - A[id]] = f[v][silver] + B[id];
                st.insert({ f[to][silver - A[id]], {to, silver - A[id]} });
            }
        }  
        int s = min(silver + C[v], M - 1);
        if (f[v][silver] + D[v] < f[v][s]) {
            st.erase({ f[v][s], {v, s} });
            f[v][s] = f[v][silver] + D[v];
            st.insert({ f[v][s], {v, s} });
        }
    }

    for (int i = 2; i <= n; i++) {
        long long ans = 1e18;
        for (int j = 0; j < M; j++) {
            ans = min(ans, f[i][j]);
        }
        cout << ans << endl;
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, x;cin >> n >> x;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	ll ans = 1;
	ll now = 0;

	REP(i, n){
		now += v[i];
		if(now <= x)ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace A___Round_Up_the_Mean
{
    class Program
    {
        static void Main(string[] args)
        {
            var a_b = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(Math.Ceiling(a_b.Average()));
        }
    }
}


Measured memory_bytes: 13396
#include <string>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <algorithm>
#include <map>
#include <iostream>
#include <sstream>
#include <queue>
#include <iomanip>

#include <string.h>

using namespace std;

void addDivisor(int *ar, int n)
{
	for(int i = 2; n > 1; i++)
	{
		while(n % i == 0)
		{
			ar[i]++;
			n /= i;
		}
	}
}

unsigned long long MOD = 1000000007;

int main()
{
	int n;

	int ar[1001] = {0};

	unsigned long long answer = 1;

	cin >> n;

	for(int i = 2; i <= n; i++)
	{
		addDivisor(ar, i);
	}

	for(int i = 2; i <= n; i++)
	{
		if(ar[i] > 0)
		{
			answer *= ar[i]+1;
			if(answer > MOD) answer %= MOD;
		}
	}

	cout << answer << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> onaji(n, 0);
  vector<int> onaji0(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (s.at(i) == s.at(j)) {
        onaji.at(i - j) += 1;
      } else {
        if (onaji.at(i - j) > onaji0.at(i - j)) {
          onaji0.at(i - j) = onaji.at(i - j);
        }
        onaji.at(i - j) = 0;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (onaji.at(i) > onaji0.at(i))
      onaji0.at(i) = onaji.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int tmp;
    if (i <= onaji0.at(i)) {
      tmp = i;
    } else {
      tmp = onaji0.at(i);
    }
    if (tmp > ans) ans = tmp;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) {
        cin >> x[i];
    }
    long count = 0;
    rep(i,n) {
        if (x[i] == 1) {
            break;
        }
        
        while(x[i] % 2 == 0){
            x[i] /= 2;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	ll li[n+1];
	li[0] = 2;
	li[1] = 1;
	for(int i = 2; i <= n; i++){
		li[i] = li[i-1] + li[i-2];
	}
	cout << li[n] << endl;
}

Measured memory_bytes: 256
n, m, x, y = [ int(v) for v in input().split() ]
xmax = max(sorted([ int(v) for v in input().split() ] + [x]))
ymin = min(sorted([ int(v) for v in input().split() ] + [y]))
ans = "War"
if xmax < ymin:
  ans = "No War"
print(ans)

Measured memory_bytes: 3060
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #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;

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;

ll dp[nax][3];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		for (int j=0; j<3; j++)
		{
			ll x;
			scanf("%lld", &x);
			for (int l=0; l<3; l++)
				if (j!=l)
					dp[i][j]=max(dp[i][j], dp[i-1][l]);
			dp[i][j]+=x;
		}
	}
	printf("%lld\n", max(max(dp[n][0], dp[n][1]), dp[n][2]));
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,K;
  cin >> N >> K;
  vi x(N);
  rep(i,N) {
    cin >> x[i];
  }
  int ans = INF;
  rep(i,N-K+1) {
    ans = min(ans,abs(x[i]) + abs(x[i] - x[i+K-1]));
    ans = min(ans,abs(x[i+K-1]) + abs(x[i] - x[i+K-1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;
int a,n,f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    f=1;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(a%2==0)
            if(a%3!=0 && a%5!=0) f=0;
    }
    if(f==1) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
string s;
bool flag;
int ans1, ans2;
int main(void){
    flag = true;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'A' && flag) {
            ans1 = i;
            flag = false;
        }
    }
    for (int i = s.size();; --i) {
        if (s[i] == 'Z') {
            ans2 = i;
            break;
        }
    }
    cout << ans2 - ans1 + 1 << endl;
    return 0;
}

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

const int N = 1e2 + 5;
const int M = N * 2;

int Max[N] , du[N] , dep[N] , n , m , x , y , fir[N] , ne[M] , to[M] , cnt;

void add(int x , int y) {
  ne[++ cnt] = fir[x];
  fir[x] = cnt;
  to[cnt] = y;
}

void link(int x , int y) {
  add(x , y);
  add(y , x);
}

#define Foreachson(i , x) for(int i = fir[x];i;i = ne[i])

int dis[N][N] , fa[N][N];

void get(int x , int f , int no) {
  fa[no][x] = f;
  Foreachson(i , x) {
    if(to[i] != f)
      dis[no][to[i]] = dis[no][x] + 1 ,
	get(to[i] , x , no);
  }
}

vector <int> Dia;

bool vis[N];

void dfs(int x , int f) {
  int now = 0;
  Foreachson(i , x) {
    int V = to[i];
    if(vis[V] || V == f) continue;
    ++ now;
    dep[V] = dep[x] + 1;
    dfs(V , x);
  }
  Max[dep[x]] = max(Max[dep[x]] , now);
}

void init(void) {
  for(int i = 0;i <= n;++ i) Max[i] = 0 , dep[i] = 0;
  memset(vis , 0 , sizeof(vis));
}

long long calc(int x , int y) {
  init();
  vis[x] = vis[y] = 1;
  dfs(x , 0);
  dfs(y , 0);
  long long ans = 1;
  for(int i = 0;i <= n;++ i) ans *= max(Max[i] , 1);
  return ans * 2;
}

long long findans1(void) {
  long long ans = 1e18;
  int now = Dia[Dia.size() / 2];
  init();
  dfs(now , 0);
  long long res = 1;
  for(int i = 0;i <= n;++ i) {
    res *= max(Max[i] , 1);
  }
  ans = min(ans , res);
  Foreachson(i , now) {
    int V = to[i];
    ans = min(ans , calc(V , now));
  }
  return ans;
}

void solve(int x , int y) {
  for(;y;y = fa[x][y]) Dia.push_back(y);
  if(Dia.size() & 1) {
    printf("%lld\n" , findans1());
  }
  else printf("%lld\n" , calc(Dia[Dia.size() / 2] , Dia[Dia.size() / 2 - 1]));
}

int main() {
  scanf("%d" , &n);
  for(int i = 1;i < n;++ i) {
    scanf("%d%d" , &x , &y);
    link(x , y);
  }
  for(int i = 1;i <= n;++ i) {
    get(i , 0 , i);
  }
  int res = 0;
  for(int i = 1;i <= n;++ i)
    for(int j = 1;j <= n;++ j)
      res = max(res , dis[i][j]);
  cout << res / 2 + 1 <<" ";
  for(int i = 1;i <= n;++ i)
    for(int j = 1;j <= n;++ j)
      if(dis[i][j] == res) {
	solve(i , j);
	return 0;
      }
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define maxn 100
using namespace std;
typedef long long ll;
int n,a,b;
ll v[maxn],sum,yh[maxn][maxn],s;
ll ans,tmp;
map<ll,int> m,c;
vector<ll> appear;
bool cmp(ll x,ll y) {
	return x>y;
}
int main() {
	scanf("%d %d %d",&n,&a,&b);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&v[i]);
		m[v[i]]++;
		bool t=true;
		for (int j=1;j<i;j++)
			if (v[j]==v[i]) {
				t=false;
				break;
			}
		if (t)
			appear.push_back(v[i]);
	}
	sort(v+1,v+(n+1),cmp);
	sum=0;
	for (int i=1;i<=a;i++) {
		sum+=v[i];
		c[v[i]]++;
	}
	
	printf("%.6f\n",1.0*sum/a);
	for (int i=1;i<=n;i++) {
		yh[i][0]=yh[i][i]=1;
		for (int j=1;j<i;j++)
			yh[i][j]=yh[i-1][j-1]+yh[i-1][j];
	}
	s=sum;
	ans=0;
	for (int cnt=a;cnt<=b;cnt++) {
		if (s*a==sum*cnt) {
			tmp=1;
			for (int i=0;i<appear.size();i++)
				tmp*=yh[m[appear[i]]][c[appear[i]]];
			ans+=tmp;
		}
		else break;
		s+=v[cnt+1];
		c[v[cnt+1]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

bool was[110];
int n, k;
int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	int ans = 0;
	for(int kk = 1; kk <= k; ++kk) {
        int x;
        cin >> x;
        for(int i = 1; i <= x; ++i) {
            int cc;
            cin >> cc;
            was[cc] = 1;
        }
	}
	for(int i = 1; i <= n; ++i) if(!was[i]) ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int r;cin>>r;
  if(r<1200)cout<<"ABC"<<endl;
  else if(r<2800)cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}

Measured memory_bytes: 256
s = list(map(int, input().split()))
n,x = s[0],s[1]
l = list(map(int, input().split()))
cnt = 0
for i in range(n+1):
    if i == 0:
        res = 0
        cnt+=1
    else:
        if res + l[i-1] > x:
            break
        res = res + l[i-1]
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
from collections import Counter
def mpow(a,b,mod):
  ret=1
  while b>0:
    if b&1:
      ret=(ret*a)%mod
    a=(a*a)%mod
    b>>=1
  return ret
n,p=map(int,input().split())
s=[int(i) for i in input()]
if p==2 or p==5:
  ans=0
  for i in range(n):
    if s[i]%p==0:
      ans+=i+1
  print(ans)
else:
  ans=0
  d=Counter()
  d[0]+=1
  num=0
  for i in range(n-1,-1,-1):
    num=(num+s[i]*mpow(10,n-1-i,p))%p
    ans+=d[num]
    d[num]+=1
  print(ans)






Measured memory_bytes: 5960
# -*- coding: utf-8 -*-
 
import sys
 
def amida(w, side_bar):
    result = []
    side_bar.reverse()
    for x in range(1, w+1):
        status = x
        for bar in side_bar:
            if status == bar[0]:
                status = bar[1]
            elif status == bar[1]:
                status = bar[0]
        result.append(status)
    return result
 
def main():
    W = int(input())
    N = int(input())
    side_bar = [tuple(map(int, input().split(','))) for line in range(N)]
    result = amida(W, side_bar)
    for r in result:
        print(r)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 7676
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
temp = []
for i in range(1, N):
    if A[i]-1 == A[i-1]:
        if not A[i]-2 < 0:
            ans += C[A[i]-2]
ans += sum(B)        
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] Ai = new int[N];
        int[] Bi = new int[N];
        int[] Ci = new int[N-1];

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

            Ai[i] = Integer.parseInt(sc.next());
        }

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

            Bi[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N-1; i++) {

            Ci[i] = Integer.parseInt(sc.next());
        }

        sc.close();

        int ans = 0;

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

            ans += Bi[Ai[i]-1];

            if (i != 0 && Ai[i] == Ai[i-1] + 1) {

                ans += Ci[Ai[i-1]-1];
            }
        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main () {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> dp(1000010, 0);
    vector<bool> seen(1000010, 0);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);

        if (seen[A[i]]) {
            dp[A[i]]++;
            continue;
        }
        seen[A[i]] = 1;
        int j = A[i];
        while (j <= 1000000) {
            dp[j]++;
            j += A[i];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (dp[A[i]] - 1 == 0) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7932
#include<iostream>
#include<vector>
using namespace std;
struct Point { long double px, py; };
Point Minus(Point a, Point b) { Point C; C.px = a.px - b.px; C.py = a.py - b.py; return C; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = Minus(v[i], p), b = Minus(v[(i + 1) % v.size()], p);
		if (a.py > b.py) swap(a, b);
		if (a.py <= 0 && 0 < b.py)
			if (crs(a, b) < 0) in = !in;
		if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
int main() {
	vector<Point>vec;
	Point P;
	int n, q; cin >> n;
	vec.clear();
	for (int j = 0; j < n; j++) { cin >> P.px >> P.py; vec.push_back(P); }
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> P.px >> P.py;
		int v = contain(vec, P); cout << v << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

class ab{
public:
  ll a, b, i;
  bool operator<(const ab &another) const{
    return b < another.b;
  }
};

void solve(){
  ll n, h, maxai = 0, maxaa, maxab, ans = 0; cin >> n >> h;
  vector<ab> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i].a >> v[i].b;
    v[i].i = i;
    if(v[maxai].a < v[i].a){
      maxai = i;
      maxaa = v[i].a;
      maxab = v[i].b;
    }
    else if(v[maxai].a == v[i].a && v[maxai].b <= v[i].b){
      maxai = i;
      maxaa = v[i].a;
      maxab = v[i].b;
    }
  }
  sort(v.begin(), v.end());
  bool flag = false;
  for(int i = n - 1; v[i].b > maxaa && h > 0 && i >= 0; i--){
    if(v[i].i == maxai) flag = true;
    if(flag == true){
      if(h - maxab <= 0){
        h -= maxab;
        ans++;
        continue;
      }
    }
    if(v[i].i == maxai) continue;
    h -= v[i].b;
    ans++;
    //cout << h << " " << v[i].a << " " << v[i].b << ans << endl;
  }
  if(h > 0){
    ans++;
    if(h - maxab > 0) ans += (h - maxab + maxaa - 1) / maxaa;
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 2688
#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++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> xs, ys, al;
    int now = 0;
    int N = s.size();
    while(now < N){
        int j = 0;
        while(now+j < N && s[now+j] == 'F') j++;
        al.pb(j);
        now += j+1;
    }
    rep(i, al.size()){
        if(i == 0 || al[i] == 0) continue;
        elif(i%2 == 0) xs.pb(al[i]);
        else ys.pb(al[i]); 
    }
    //for(auto &e: al) cout << e << endl;
    int a = xs.size(), b = ys.size();
    bool dpx[a+1][8001], dpy[b+1][8001];
    fill(dpx[0], dpx[a+1], false);
    fill(dpy[0], dpy[b+1], false);
    dpx[0][0] = true, dpy[0][0] = true;
    rep(i, a){
        rep(j, 8001){
            if(dpx[i][j]){
                dpx[i+1][j+xs[i]] = true;
                dpx[i+1][abs(j-xs[i])] = true;
            }
        }
    }
    rep(i, b){
        rep(j, 8001){
            if(dpy[i][j]){
                dpy[i+1][j+ys[i]] = true;
                dpy[i+1][abs(j-ys[i])] = true;
            }
        }
    }
  	if(abs(x-al[0]) > 8000) cout << "No" << endl; 
    elif(dpx[a][abs(x-al[0])] && dpy[b][abs(y)]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 31616
use std::collections::BinaryHeap;
use std::io::Read;

fn main() {
    let (n, m) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        let s: Vec<i32> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
        (s[0], s[1])
    };
    let a = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        let s: Vec<i64> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
        s
    };

    let mut heap = BinaryHeap::new();
    for t in a {
        heap.push(t);
    }
    for _i in 0..m {
        let next = heap.pop().unwrap() / 2;
        heap.push(next);
    }
    let sum: i64 = heap.iter().fold(0, |sum, a| sum + a);
    println!("{}", sum)
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, h[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(h[i]));
	
	const int sup = 1 << 30;
	int dp[100002];
	for (i = 2, dp[1] = 0; i <= N; i++) dp[i] = sup;
	for (i = 1; i < N; i++) {
		if (dp[i] + abs(h[i+1] - h[i]) < dp[i+1]) dp[i+1] = dp[i] + abs(h[i+1] - h[i]);
		if (dp[i] + abs(h[i+2] - h[i]) < dp[i+2]) dp[i+2] = dp[i] + abs(h[i+2] - h[i]);
	}
	printf("%d\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2504
#include <iostream>
#include <cstdio>
#include <cstring>
#define LEN 100005
using namespace std;

inline int min(int a, int b){return a < b ? a : b;}

typedef struct process{
  char name[100];
  int time;
}P;

P Q[LEN];
int head , tail ,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1)%LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1)%LEN;
  return x;
}
int main(){
  int n,q;
  int elaps = 0, c;
  cin >> n >> q;
  int i;
  P u;
  for(i=1;i <= n;i++){
    scanf("%s ",Q[i].name);
    scanf("%d ",&Q[i].time);
  }
  head = 1,tail = n + 1;
  while(head != tail){
    u = dequeue();
    c = min(q,u.time);
    u.time -= c;
    elaps += c;
    if(u.time > 0)enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }
}



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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#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)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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

vi dp(100000, -1);
int dfs(int x, const vector<vi>& edges){
  if(dp[x] != -1){
    //cout << "hit:" << x << endl;
    return dp[x];
  }
  //cout << "calc:" << x << endl;

  int ans = 0;
  for (auto i : edges[x]) ans = max(ans, 1 + dfs(i, edges));
  dp[x] = ans;
  return dp[x];
}

void solve(){
  int n, m;
  cin >> n >> m;
  vector<vi> edges(n);

  rep(i, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    edges[x].emplace_back(y);
  }

  int ans = 0;
  rep(i, n) ans = max(ans, dfs(i, edges));
  cout << ans << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){

  int n;cin>>n;
  ll ans=1;
  rep(i,n){
    ll t;cin>>t;
    ans = lcm(ans,t);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools

# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

S = input()
l = len(S)
#print('l={}'.format(l))
ans = 0
if l % 2 == 0:
    n = l // 2
    #print('n={}'.format(n))
    for i in range(n):
        #print('S[i]={}, S[-i-1]={}'.format(S[i], S[-i-1]))
        if S[i] != S[-i-1]:
            ans += 1
else:
    n = (l - 1) // 2
    for i in range(n):
        if S[i] != S[-i-1]:
            ans += 1

print(ans)

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

using namespace std;

typedef long long int lli;

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

    int n, k, a[100];
    vector<vector<bool>> dp(2, vector<bool>(100001, false));

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

    for (int i=a[0]; i<=k; i++) {
        for (int j=0; j<2; j++) {
            for (int l=0; l<n; l++) {
                if (a[l] > i) break;
                dp[j][i] = dp[j][i] || !dp[!j][i-a[l]];
            }
        }
    }

    cout << ((dp[0][k]) ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(all(a));
    rep(i,n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        if ((long double) ans > (long double) 1e18/a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui; int par[100000];
int rank1[100000];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank1[x] < rank1[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank1[x] == rank1[y])rank1[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int main(){
	int n, m; cin >> n >> m;
	int p; int inv[100000] = {};
	for (int i = 0; i < n; i++) {
		cin >> p; inv[p-1] = i;
	}
	init(n); int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y; unite(x-1, y-1);
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (same(i, inv[i]))count++;
	}
	cout << count << endl;
	char nyaa;
	std::cin >> nyaa;
	return 0;
}

Measured memory_bytes: 1408
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m>>v;
  cout<<m*int((v/n+0.5))<<endl;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cal(int num)
{
	int cnt = 0;
  	while(num!=0)
    {
      cnt++;
      num=num/10;
    }
  	return cnt;
}
int main()
{
  int n;
  cin>>n;
  int ans = 0;
  for(int i=1;i<=n;i++)
  {
    if(cal(i)&1)
      	ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  ll res = 0;
  for(int i = 0;i < m;i++){
    int a = 0;
    cin >> a;
    res += a;
  }
  if(res > n)res = -1;
  else res = n - res;
  cout << res << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	ll n,m;
	cin>>n>>m;
	vll a(n);
	ll total=0;
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
		total+=a[i];
	}

	ll cnt=0;
	for(ll i=0;i<n;++i)
	{
		ll val=total;
		if(a[i]>=((val+(4*m)-1)/(4*m)))
			++cnt;
	}

	if(cnt>=m)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}



Measured memory_bytes: 256
import heapq

n,m = map(int, input().split())
a = list(-int(i) for i in input().split()) 

heapq.heapify(a)

for i in range(m):
	n=heapq.heappop(a)//(-2)
	heapq.heappush(a, -n)

print(-sum(a))

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

int main()
{
  int H, W, B=0;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S.at(i);
  rep(i, H){
    rep(j, W){
      if(S.at(i).at(j)=='#'){
        if(i>0 && S.at(i-1).at(j)=='#') continue;
        if(i<H-1 && S.at(i+1).at(j)=='#') continue;
        if(j>0 && S.at(i).at(j-1)=='#') continue;
        if(j<H-1 && S.at(i).at(j+1)=='#') continue;
        B=1;
        break;
      }
    }
  }
  if(B==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.nextLine());
        List<String> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(s.nextLine());
        }
        Map<String, Long> map = list.stream().collect(groupingBy(identity(), counting()));
        long tmp = 0;
        for (Map.Entry<String, Long> e : map.entrySet()) {
            if (tmp < e.getValue()) {
                tmp = e.getValue();
            }
        }
        List<String> ret = new ArrayList<>();
        for (Map.Entry<String, Long> e : map.entrySet()) {
            if (tmp == e.getValue()) {
                ret.add(e.getKey());
            }
        }
        ret.stream().sorted(String::compareTo).peek(System.out::println).collect(Collectors.toList());
    }
}

Measured memory_bytes: 171680
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int A, int B) {
        return A * B % 2 != 0;
    }
}

Measured memory_bytes: 35628
from bisect import bisect_right
N = int(input())
A = [int(input()) for i in range(N)]
A.reverse()
X = [A[0]]

for i in range(1, N):
    if X[-1] <= A[i]:
        X.append(A[i])
    else:
        idx = bisect_right(X, A[i])
        X[idx] = A[i]

print(len(X))


Measured memory_bytes: 85556
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>

// 数値のハッシュ関数
#define HASHSIZ 5000011
int hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(int n)
{
	int *p;
	
	n++; p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(int n)
{
	int *p;
	
	n++; p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return;
		if (++p == hashend) p = hash;
	}
	*p = n;
}

char tr['T'+1];
char buf[20], *p;

int trans(char *p)
{
	int k, w;

	w = k = 0; while (*p >= ' ') {
		k = (k<<2) | tr[*p++], w++;
	}
	return w | (k<<4);
}

int main()
{
	int n;

	tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
	fgets(buf, 10, stdin), n = atoi(buf);
	while (n--) {
		fgets(p=buf, 20, stdin);
		if (*p == 'i') insert(trans(p+7));
		else puts(lookup(trans(p+5))? "yes": "no");
	}
	return 0;
}



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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL(x) memset(x,-1,sizeof(x))


using namespace std;

typedef long long ll;
typedef pair<int, bool> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<vector<P>> W;

vector<int> color;

bool visited[100010];

int N;

void dfs(int cur)
{
  visited[cur]=true;
  
  for(int i=0; i<W[cur].size(); i++)
    {
      if(!visited[W[cur][i].first])
	{
	  if(!W[cur][i].second)
	    {
	      
	      color[W[cur][i].first]=color[cur];
	      //	      cout << cur <<" to "<<W[cur][i].first<<" even"<< endl; 
	    }
	  else
	    {
	      color[W[cur][i].first]=color[cur]+1;
	      //cout << cur <<" to "<<W[cur][i].first<<" odd"<< endl;
	    }

	  color[W[cur][i].first]%=2;

	  
	  dfs(W[cur][i].first);
	}
    }
}


int main()
{
  
  cin >> N;
 

  for(int i=0; i<N; i++)
    visited[i]=false;

  color.resize(N);
  
  W.resize(N);

  color[0]=0; 

  ll u, v, w;
  for(int i=0; i<N-1; i++)
    {
      cin >> u >> v >> w;
      u--;
      v--;
      
      if(w%2==0)
	{
	  W[u].push_back(P(v,false));
	  W[v].push_back(P(u,false));
	}
      else
	{
	  W[u].push_back(P(v,true));
	  W[v].push_back(P(u,true));
	}
    }



  dfs(0);



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


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 7552
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int power(int a){
	if(a==0) return 1;
	else return power(a-1)*2;
}
int main(){
  	int D, G;
  	cin >> D >> G;
  	int p[D], c[D];

  	for(int i=0;i<D;i++){
  		cin >> p[i] >> c[i];
  	}

  	int M = power(D);
  	int ans = Max;
  	for(int x=0;x<M;x++){
  		int point = 0;
  		int cnt = 0;

  		for(int i=0;i<D;i++){
  			if(x&(1<<i)){
  				point += 100*(i+1)*p[i] + c[i];
  				cnt += p[i];
  			}
  		}

  		for(int i=D-1;i>=0;i--){
  			if(!(x&(1<<i))){
  				int j = 0;
  				while(j<p[i]-1 && point < G){
  					point += 100*(i+1);
  					cnt++;
  					j++;
  				}
  			}
  		}
  		if(point >= G) ans = min(ans, cnt);
  	}
  	cout << ans <<endl;


    
  	return 0;
}




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

int R, C, N;
vector< pair<int, int> > V;

int get(int x, int y) {
	if (x == 0) {
		return y;
	} else if (y == C) {
		return x + C;
	} else if (x == R) {
		return C + R + (C - y);
	} else if (y == 0) {
		return C + R + C + (R - x);
	} else return -1;
}

stack<int> S;

int main() {
	scanf("%d%d%d", &R, &C, &N);
	for (int i = 0; i < N; i++) {
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int p1 = get(a, b);
		int p2 = get(c, d);
		if (p1 == -1 || p2 == -1) continue;
		V.push_back(make_pair(p1, i));
		V.push_back(make_pair(p2, i));
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < V.size(); i++) {
		if (!S.empty() && S.top() == V[i].second) S.pop();
		else S.push(V[i].second);
	}
	if (!S.empty()) printf("NO\n");
	else printf("YES\n");
}


Measured memory_bytes: 2420
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    s = readline().strip()
    N = len(s)

    t = s[::-1]
    if s == t:
        u = s[:N//2]
        v = s[N//2+1:]
        if u == u[::-1] and v == v[::-1]:
            print("Yes")
            exit()
    
    print("No")
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
bool prime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main()
{
ll ans,n,temp;

cin >> n;
vector<int> v(101, 0); 
for(ll i = 2; i <= n; i++){
    if(prime(i)){v[i]++;}
    else{
        temp=i;
        for(ll j = 0; j <= temp; j++){
            if(prime(j)&&(temp%j==0)){
                temp=temp/j;v[j]++;j--;
            }
        if(temp==1)break;
        }
    }
}
ll up24=0,up14=0,up4=0,up2=0;
rep(i,50){
    if(v[i]>1){up2++;
    if(v[i]>3){up4++;
    if(v[i]>13){up14++;
    if(v[i]>23){up24++;
    }}}}
}
ans=(up4-1)*up4*(up2-2)/2+up24*(up2-1)+up14*(up4-1);
/* for (int i = 0; i <= n; ++i) {
    cout << v[i] << " ";
}cout  << endl; */
if(n>77)ans++;
cout << ans << endl;
return 0;
}





Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    h = sorted([int(i) for i in input().split()])
    for _ in range(k):
        h.pop()
        if h == []:
            print(0)
            return
    print(sum(h))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26180