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

const int MAXN = 200010;
int at[MAXN], A[MAXN], n;
bool chk(int a, int b, int c) {
	return (a < b) + (b < c) + (c < a) == 2;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i], at[A[i]] = i;
	int T = 0, f = -1;
	for (int i = n - 1; i; --i)
		if (!T) {
			if (at[i] > at[i + 1]) ++T, f = i + 1;
		} else if (!chk(at[f], at[i], at[i + 1])) ++T, f = i + 1;
	std::cout << T << std::endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
list = []
for i in range(n):
    keep = input()
    list.append(keep)
double = 0
b = 0
a = 0
include = 0
for j in range(n):
    if list[j][0] == "B" and list[j][-1:] == "A":
        double += 1
    elif list[j][0] == "B":
        b += 1
    elif list[j][-1:] == "A":
        a += 1

    keep_len = len(list[j])
    for k in range(keep_len-1):
        if list[j][k] == "A" and list[j][k+1] == "B":
            include += 1
if b == 0 and a == 0 and double == 0:
    print(include)
elif b == 0 and a == 0:
    print(double-1 + include)
elif b == 0 or a == 0:
    print(double-1 + include + 1)
else:
    print(double-1 + include + min(b, a) + 1)

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = -inf;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = max(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return -inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return max(lval, rval);
	}
	llint query(int a, int b)
	{
		if(a > b) return -inf;
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n, Q;
llint a[100005], b[100005], c[100005], d[100005];
llint x[100005], y[100005], z[100005], w[100005];
bool ans[100005];

vector<llint> xvec[100005], avec[100005];
vector<P> cvec;
SegTree seg(17);
llint cpos[100005];

void calc(llint l, llint r)
{
	if(r-l+1 <= 1) return;
	llint m = (l+r)/2;
	
	vector<E> vec;
	for(int i = l; i <= m; i++){
		for(int j = 0; j < xvec[i].size(); j++){
			int id = xvec[i][j];
			vec.push_back(E(P(y[id], 2), id));
		}
	}
	for(int i = m+1; i <= r; i++){
		for(int j = 0; j < avec[i].size(); j++){
			int id = avec[i][j];
			vec.push_back(E(P(a[id], 3), id));
			vec.push_back(E(P(b[id], 1), id));
		}
	}
	sort(vec.begin(), vec.end());
	
	for(int i = 0; i < vec.size(); i++){
		int type = vec[i].first.second, id = vec[i].second;
		if(type == 1) seg.update(cpos[id], -inf);
		if(type == 3) seg.update(cpos[id], d[id]);
		if(type == 2){
			llint lb = upper_bound(cvec.begin(), cvec.end(), P(z[id], inf)) - cvec.begin();
			llint ub = lower_bound(cvec.begin(), cvec.end(), P(w[id], 0)) - cvec.begin() - 1;
			if(seg.query(lb, ub) > w[id]) ans[id] = true;
		}
	}
	calc(l, m), calc(m+1, r);
}

int main(void)
{
	cin >> n >> Q;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	for(int i = 1; i <= Q; i++) cin >> x[i] >> y[i] >> z[i] >> w[i];
	
	for(int i = 1; i <= n; i++) avec[a[i]].push_back(i);
	for(int i = 1; i <= Q; i++) xvec[x[i]].push_back(i);
	
	for(int i = 1; i <= n; i++) cvec.push_back(P(c[i], i));
	sort(cvec.begin(), cvec.end());
	for(int i = 0; i < cvec.size(); i++) cpos[cvec[i].second] = i;
	
	seg.init();
	
	calc(1, 100000);
	for(int i = 1; i <= Q; i++){
		if(ans[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 69408
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} 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 min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

void res(int,int,int);

int main(void){
  int n,pm,pe,pj;

  for(;;){  
    cin >> n;
    if( n == 0 ) break;

    for( int i = 0 ; i < n ; i++ ){
      cin >> pm >> pe >> pj;
      res(pm,pe,pj);
    }
  }
  
  return 0;
}

void res(int pm,int pe,int pj){
  double ave,meave;

  ave = (double)(pm+pe+pj) / 3;
  meave = (double)(pm+pe) / 2;

  if( pm == 100 || pe == 100 || pj == 100 || meave >= 90 || ave >= 80 )
    cout << 'A' << endl;
  else if( ave >= 70 || ( ave >= 50 && ( pm >= 80 || pe >= 80 )))
    cout << 'B' << endl;
  else cout << 'C' << endl;

}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int n;
int p[50];

bool check() {
    for (int i = 0; i < n - 1; i++) {
        if (p[i] > p[i + 1]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    imfor(i, n) {
        cin >> p[i];
    }

    if (check()) {
        cout << "YES" << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                continue;
            }
            int tmp = p[i];
            p[i] = p[j];
            p[j] = tmp;
            if (check()) {
                cout << "YES" << endl;
                return 0;
            }
            tmp = p[i];
            p[i] = p[j];
            p[j] = tmp;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == 5 and b == 5 and c == 7)
    {
        printf("YES");
    }

    else if (a == 5 and b == 7 and c == 5)
    {
        printf("YES");
    }
    
    else if (a == 7 and b == 5 and c == 5)
    {
        printf("YES");
    }
    
    else
    {
        printf("NO");
    }
    
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    int n, m;
    cin >> n >> m;

    vector<PL> vv;
    ll price, num, num_total = 0, amount = 0;
    FOR(i, n){
        cin >> price >> num;
        vv.push_back(make_pair(price, num));
    }

    sort(ALL(vv));
    FOR(i, n){
        //cout << vv[i].first << " " << vv[i].second << endl;

        if((num_total+vv[i].second) > m){
            amount += (m - num_total)*vv[i].first;
            break;
        } else {
            amount += vv[i].second*vv[i].first;
        }

        //cout << amount << endl;
        num_total += vv[i].second;
    }

    cout << amount;
    
    return 0;
}


Measured memory_bytes: 2420
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#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;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int p,q,r;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        cin >> p >> q >> r;
        int ans = min( p+q,q+r );
        ans = min(ans, r+p);
        cout << ans << endl;

return 0;
}
///....


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

int main() {
    long long int n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    long long int m = min({a, b, c, d, e});
    cout << (n + (m - 1)) / m + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int x;
	cin >> x;
	if(x == 1)
	{
		cout << 0;
	}
	else
	{
		cout << 1;
	}
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}
int char_to_int(char val) {
    return val - '0';
}

int main() {
  int A, B, C; cin >> A >> B >> C;

  int max_num = max({A, B, C});
  int min_num = min({A, B, C});
  int mid_num = 0;
  int cnt = 0;

  string max_str = "";
  string min_str = "";
  string mid_str = "";
  if(max_num == A) {
    max_str = "A";
  } else if(max_num == B) {
    max_str = "B";
  } else {
    max_str = "C";
  }

  if(min_num == A) {
    min_str = "A";
  } else if(min_num == B) {
    min_str = "B";
  } else {
    min_str = "C";
  }

  if(max_str != "A" && min_str != "A") {
    mid_str = "A";
    mid_num = A;
  } else if(max_str != "B" && min_str != "B") {
    mid_str = "B";
    mid_num = B;
  } else {
    mid_str = "C";
    mid_num = C;
  }

  cnt = cnt + (max_num - mid_num);
  mid_num += cnt;
  min_num += cnt;

  int hantei = max_num - min_num;
  if(hantei == 2) {
    cnt++;
  } else {
    if(hantei % 2 == 0) {
      cnt += (max_num - min_num) / 2;
    } else {
      cnt += (max_num - min_num) / 2 + 1;
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a < b){
		if(b < c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
		
	return 0;
}

Measured memory_bytes: 580
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    C = [0 for _ in range(N - 1)]
    S = [0 for _ in range(N - 1)]
    F = [0 for _ in range(N - 1)]
    for i in range(N - 1):
        c, s, f = map(int, input().split())
        C[i] = c
        S[i] = s
        F[i] = f

    for i in range(N - 1):
        t = S[i]
        for j in range(i, N - 1):
            t += C[j]
            if j < N - 2:
                next_t = S[j + 1]
                if t > next_t:
                    next_t += math.ceil((t - next_t) / F[j + 1]) * F[j + 1]
                t = next_t
        print(t)
    print(0)


Measured memory_bytes: 45016
a, b, c = map(int, input().split())
t = 0
if a > b:
    t= a
    a = b
    b = t
if b > c:
    t = b
    b = c
    c = t
if a > b:
    t= a
    a = b
    b = t
print(a, b, c)


Measured memory_bytes: 5596
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    ll d = 0;
    if (A - B > 0)
    {
        d = A - B;
    }
    else
    {
        d = B - A;
    }

    ll v = V - W;
    ll d1 = v * T;
    if (d <= v * T)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, x;

vi v;

void read() {
  cin >> n >> x;
  for(int i = 0; i < n; ++i) {
    int nr;
    cin >> nr;
    v.pb(nr);
  }
}
void solve() {
  int sol = 1, sum = 0;
  for(int i = 0; i < n; ++i) {
    sum += v[i];
    if (sum <= x)
      ++sol;
    else break;
  }
  cout << sol;
}


int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  read();
  solve();
  return 0;
}


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

int main(int argc, char **argv)
{
  int a = 0;
  int p = 0;

  scanf("%d %d", &a, &p);

  printf("%d\n", ((a * 3 + p) / 2));

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    ans=n-2*m;
    if(ans<=0)
        cout<<0<<endl;
    else
        cout<<ans<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
heights = [0] + list(map(int, input().split()))
routes = [[] for _ in range(N+1)]
for __ in range(M):
  a, b = map(int, input().split())
  routes[a].append(b)
  routes[b].append(a)
answer = 0
for i, route in enumerate(routes):
  if i == 0:
    continue
  if len(route) == 0:
    answer += 1
    continue
  else:
    highest = True
    for dist in route:
      if heights[i] <= heights[dist]:
        highest = False
        break
    if highest:
      answer += 1
print(answer)
      

Measured memory_bytes: 95340
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }

    vector<int> pressNum(N, 0);  // index -> ボタン番号; value -> 押した回数

    int ans = 0;
    int current = 0;
    while (true) {
        if (current == 1) break;          // ボタン2の時に終了(0-index)
        int nextNum = a.at(current) - 1;  // 次のボタン位置(0-index)
        pressNum.at(current)++;           // 繰り返し防止
        if (pressNum.at(current) == 2) {
            ans = -1;
            break;
        }
        current = nextNum;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}


void init()
{
}

void solve()
{
	vector<int> x, y;
	rep(i, 3) {
		x.PB(GET<int>());
		y.PB(GET<int>());
	}
	int dx[4] = {0, 0, 0, 0};
	int dy[4] = {0, 0, 0, 0};
	int d[4];
	rep(i, 3) {
		dx[x[i]-1]++;
		dy[y[i]-1]++;
	}
	int cnt = 0;
	rep(i, 4) {
		d[i] = dx[i] + dy[i];
		if (d[i] == 0) {
			cout << "NO" << endl;
			return;
		}
		cnt += d[i] % 2;
	}
	PRINT(cnt == 0 || cnt == 2);
}



Measured memory_bytes: 256
N=int(input())
s=sorted([int(input())  for i in range(N)])
if sum(s)%10!=0:
    print(sum(s))
else:
    for j in range(N):
        if s[j]%10!=0:
            print(sum(s)-s[j])
            break
    else:
        print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int l,m,n,i,j,k,a,b,c,move,rem,cnt,x,y;
  cin >> n >>  m;
  vector< pair<int, int> > vc;
  vector<int> red_possibility;
  std::vector<int> numbers;

  for(i=0;i<m;i++){
    cin >> x >> y;
    //index -1 siteoku
    vc.push_back(pair<int, int>(x-1,y-1));
  }

  for(i=0;i<n;i++){
    numbers.push_back(1);
  }

  red_possibility.push_back(1);
  for(i=1;i<n;i++){
    red_possibility.push_back(0);
  }

  for(i=0;i<m;i++){
    pair<int, int> p = vc[i];
    x=p.first;
    y=p.second;
    //cout << x << y << endl;
    numbers[x] -= 1;
    numbers[y] += 1;
    if(red_possibility[x]==1){
      red_possibility[y]=1;
    }
    if(numbers[x]==0){
      red_possibility[x]=0;
    }
  }

  cnt=0;
  for(i=0;i<n;i++){
    if(red_possibility[i]==1){
      cnt ++;
    }
  }

  cout << cnt << endl;
  return 0;
}


  /*


  vector<int> vc;
  while(n--){
    int x;
    cin >> x;
    vc.push_back(x);
  }

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

  int x;
  cin >> x;
  if(binary_search(vc.begin(), vc.end(), x))
    cout << "I found " <<x<<"\n";
  vector<int>::iterator lit=lower_bound(vc.begin(), vc.end(), x);
  vector<int>::iterator uit=upper_bound(vc.begin(), vc.end(), x);

  if(lit != vc.end() && lit != uit){
    cout << uit-lit << "\n";
  }
}

string str;
str ="I like an apple";
str[3]='o';
str[4]='v';

if(str.length() >=5)
  cout << str <<"\n";

if(str.find("an") != string::npos)
  cout << str.find("an") <<"\n";

  map<char, int> mp;
  mp['a']=1;
  mp['b']=2;
  cout<<mp['a']<<" "<<mp['b']<<"\n";

  mp.insert(map<char, int>::value_type('c', 3));
  if(mp.find('c') != mp.end())
    cout<<mp['c']<<"\n";
}

  vector<int> vc;

  int x;
  cin >> x;

  while(x--){
    int y;
    cin >> y;
    vc.push_back(y);
  }

  x=vc.size()/2;

  if(vc[x]==vc.at(x))
    cout << x << "\n";
}
*/


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int p=0;
  int q=0;
  int r=0;
  int a[100010];
  for(int i=0;i<n;i++) a[i]=0;
  while(p<n){
    q=p;
    while(s.at(q)=='R') q++;
    r=q;
    while(r<n && s.at(r)=='L') r++;
    //printf("%d %d %d\n",p,q,r);
    a[q-1]=(q-p+1)/2+(r-q)/2;
    a[q]=(q-p)/2+(r-q+1)/2;
    p=r;
  }
  
  for(int i=0;i<n;i++) cout << a[i] << " ";
}

Measured memory_bytes: 1024
from collections import Counter
N=int(input())

st = []
for n in range(N):
    s = ''.join(sorted(input()))
    st.append(s)

a = 0
for k, f in dict(Counter(st)).items():
    if f == 1:
        continue
    else:
       a += f*(f-1)/2

print(int(a))

Measured memory_bytes: 22828
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n,x,t;
cin>>n>>x>>t;
if(n%x==0)cout<<t*(n/x)<<endl;
else cout<<((n/x)+1)*t<<endl;
return 0;
}

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

using namespace std;

int main()
{
  string C[2];
  cin>> C[0]>> C[1];

  string ret="NO";
  if(C[0][0]==C[1][2]&&C[0][1]==C[1][1]&&C[0][2]==C[1][0])ret="YES";
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	char a,b;
	while(cin>>a>>b){
		a=int(a);
		b=int(b);
		if(a>b){
			cout<<">"<<endl;
		}
		else if ( a == b){
			cout<<"="<<endl;
		}
		else{
			cout<<"<"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math

while True:
    n = int(input())
    if n == 0:
        break
    s = [int(x) for x in input().split()]
    m = sum(s) / n
    a = 0
    for i in range(n):
        a += (s[i] - m) ** 2
    a /= n
    a = math.sqrt(a)
    print(a)

Measured memory_bytes: 7792
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll M = 1000000000;
int digit(ll n){
  int res = 0;
  while(n){
    n /= 10;
    res++;
  }
  return res;
}
int top(ll n){
  int l = digit(n)-1;
  for(int i=0;i<l;i++){
    n /= 10;
  }
  return n;
}
ll power(int n){
  if(n==0) return 1;
  else return 10*power(n-1);
}

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

    int d = digit(N);
    if(d==1){
      cout << N <<endl;
      return 0;
    }

    int ans = 9*(d-1);
    if((N+1)%power(d-1)==0){
      ans += top(N);
    }else{
      ans += top(N) - 1;
    }

    cout << ans <<endl;

  	
    
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;   
    int count=0;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]!=i+1-count){
            count++;
        }
    }
    if(count<=n-1){
    cout<<count<<endl;
    }else{
        cout<<-1<<endl;
    }
}


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

using namespace std;

const int N = 1e5 + 5;

char a[N];

int main() {
  scanf("%s", a);
  int n = strlen(a);
  int ans = 0;
  for (int i = 0, j = n-1; i < j;) {
    if (a[i] != a[j]) {
      if (a[i] == 'x') i++, ans++;
      else if (a[j] == 'x') j--, ans++;
      else {
        puts("-1");
        return 0;
      }
    }
    else
      i++, j--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	sc.Scan()
	_, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	var AC, penalty int
	WA := make(map[int]int)
	var hasDone = make(map[int]bool)

	for i := 0; i < M; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		S := sc.Text()

		if hasDone[p] {
			continue
		}
		if S == "WA" {
			WA[p]++
		} else if S == "AC" {
			AC++
			penalty += WA[p]
			hasDone[p] = true
		}
	}
	fmt.Println(AC, penalty)
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int main()
{
	int cs; scanf("%d",&cs);
	while(cs--)
	{
		int a[9],b[9];
		rep(i,9)scanf("%d",a+i); rep(i,9)scanf("%d",b+i);
		sort(a,a+9);
		double ans=0;
		do
		{
			int sa=0,sb=0;
			rep(i,9)if(a[i]>b[i])sa+=a[i]+b[i]; else sb+=a[i]+b[i];
			ans+=sa>sb;
		}while(next_permutation(a,a+9));
		ans/=9*8*7*6*5*4*3*2;
		printf("%.9f %.9f\n",ans,1-ans);
	}
	return 0;
}

Measured memory_bytes: 904
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

vl dx = {-1,1,0,0};
vl dy = {0,0,-1,1};
ll H, W;
bool ok(ll h, ll w){
    return 0 <= h && h < H && 0 <= w && w < W;
}

int main(){
    cin >> H >> W;
    vvl a(H, vl(W, -LINF));
    PL fp = PL(LINF, LINF);
    queue<pair<ll, PL>> q;
    vvb used(H, vb(W, false));
    REP(i, H) REP(j, W){
        char c; cin >> c;
        if(c == '#'){
            a[i][j] = 0;
            q.push(make_pair(0, PL(i, j)));
            used[i][j] = true;
        }
        else a[i][j] = LINF;
    }
    while (q.size() > 0) {
        auto p = q.front(); q.pop();
        ll x = p.ss.ff, y = p.ss.ss;
        REP(i, 4){
            ll nx = x+dx[i], ny = y+dy[i];
            if(!ok(nx, ny)) continue;
            if(used[nx][ny]) continue;
            a[nx][ny] = p.ff + 1;
            used[nx][ny] = true;
            q.push(make_pair(a[nx][ny], PL(nx,ny)));
            
        }
    }
    
    ll ans = -LINF;
    REP(i, H) REP(j, W){
        ans = max(ans, a[i][j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 32436
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 100005
#define P 1000000007
int n, dp[N][13];
char a[N];
void add(int &x, int y){
	(x += y) >= P ? x -= P : 0;
}
int main(){
	scanf("%s", a + 1), n = strlen(a + 1);
	dp[0][0] = 1;
	for (register int i = 1; i <= n; ++i)
		if (a[i] == '?'){
			for (register int j = 0; j < 13; ++j)
				for (register int k = 0; k < 10; ++k)
					add(dp[i][(j * 10 + k) % 13], dp[i - 1][j]);
		}
		else{
			for (register int j = 0; j < 13; ++j)
				add(dp[i][(j * 10 + a[i] - '0') % 13], dp[i - 1][j]);
		}
	printf("%d\n", dp[n][5]);
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

struct button{
	string toName;
	int minx;
	int maxx;
	int miny;
	int maxy;
};

int page;
vector<string> history;
int n;
int h,w;
map<string,vector<button> > pageInfo;

int main(){

	while(cin>>n&&n!=0){
		history.clear();
		pageInfo.clear();
		page=0;
		history.clear();
		cin>>w>>h;
		for(int i = 0; i < n; i++){
			string str;
			int bn;
			cin>>str>>bn;
			if(i==0){
				history.push_back(str);
			}
			vector<button> vb;
			for(int j = 0; j < bn; j++){
				button b;
				cin>>b.minx>>b.miny>>b.maxx>>b.maxy>>b.toName;
				vb.push_back(b);
			}
			pageInfo[str]=vb;
		}
		int m;
		cin>>m;
		// operation start
		for(int i = 0; i < m; i++){
			string op;
			cin>>op;
			if(op=="click"){
				int x,y;
				cin>>x>>y;
				// buttonÌÊuðcheck
				for(int j = 0; j < pageInfo[history[page]].size(); j++){
					// Ú®Å«éÌÈçÎA»ÝÌêÌ¨É éhistoryðíµA»ÝÌêÌ¨ÉÚ®æy[WðÇÁµApageðCNg
					button &b = pageInfo[history[page]][j];
					if(b.minx<=x&&b.maxx>=x&&b.miny<=y&&b.maxy>=y){
						// »ÝÌêÌEÉ éhistoryðí
						int t=history.size();
						for(int k = page+1; k < t; k++){
							history.erase(history.begin()+history.size()-1);
						}
						// »ÝÌêÌEÉÚ®æy[WðÇÁ
						history.push_back(b.toName);
						page++;
						break;
					}
				}
			}
			else if(op=="show"){
				cout<<history[page]<<endl;
			}
			else if(op=="back"){
				page=max(0,page-1);
			}
			else if(op=="forward"){
				page=min((int)history.size()-1,page+1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string N;
  cin >> N;

  ll X = 0, sumX = 0, base = 1;
  rep_inv(i, N.size() - 1, -1){
    sumX += (ll)(N[i] - '0');
    X += base*(ll)(N[i] - '0');
    base *= 10;
  }

  if(X % sumX == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
      
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a0, a1, a2, b0, b1, b2 = 0, 0, 0, 0, 0, 0
    for i, a in enumerate(A):
        a0, a1, a2, b0, b1, b2 = (
                b0,
                max(b1, a0),
                max(b2, a1),
                a0 + a,
                a1 + a if i >= 1 else a1,
                a2 + a if i >= 2 else a2)

    if N & 1:
        return max(b2, a1)
    else:
        return max(b1, a0)


print(main())


Measured memory_bytes: 30876
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

struct edge{
	int from;
	int cost;
	int to;
};

map<string, int> mp;
int d[1000];
vector<edge> es;

int main(){
	int n;
	int a, b, size;
	string t1, t2, t3, t4;
	edge e1, e2;
	while(cin >> n && n){
		int count = 1;
		mp.clear();
		es.clear();
		for(int i = 0; i < n; i++){
			cin >> a >> t1 >> t2 >> t3 >> t4;
			string s(t3.begin() + 3, t3.end());
			stringstream ss;
			ss << s;
			ss >> b;
			if(mp[t1] == 0) mp[t1] = count++;
			if(mp[t4] == 0) mp[t4] = count++;
			e1.from = mp[t4];
			e1.cost = b;
			e1.to = mp[t1];
			es.push_back(e1);
			e2.from = mp[t1];
			e2.cost = -b;
			e2.to = mp[t4];
			es.push_back(e2);
		}
		size = es.size();
		fill(d, d + 1000, 0);
		bool update = true;
		for(int i = 0; i <= 2 * n; i++){
			update = false;
			for(int j = 0; j < size; j++){
				edge e = es[j];
				int s = e.from, t = e.to;
				if(d[t] > d[s] + e.cost){
					d[t] = d[s] + e.cost;
					update = true;
				}
			}
			if(!update) break;
		}
		if(update) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 976
#include<stdio.h>

int search(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while(A[i] != key)i++;
	return i != n;
}
int main(void){
	int i, n, A[10000+1], q, key, sum = 0;
	
	scanf("%d", &n);
	for(i=0;i<n;i++)scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i=0;i<q;i++){
		scanf("%d", &key);
		if( search(A, n, key))sum++;
	}
	printf("%d\n", sum);
return 0;
}


Measured memory_bytes: 2108
//Shik and Stone

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "

using p = pair<ll,string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int h,w;cin>>h>>w;
    vecrep(h,a,string);
    int c=0;
    rep(i,0,h){
        rep(j,0,w)if(a[i][j]=='#')c++;
    }
    if(h+w-1==c)cout<<"Possible"<<nnn;
    else cout<<"Impossible"<<nnn;
    return 0;
}

Measured memory_bytes: 256
import Foundation

extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
}

let input = readLine()!.split(by: " ").map{Int($0)!}
let N = input[0]
let Q = input[1]
let S = (readLine()!+"_").characters.map{$0}

var sum = [0]
for i in 1...N {
    sum.append(sum[i-1])
    if (S[i-1] == "A") && (S[i] == "C") {
        sum[i] += 1
    }
}

for _ in 0..<Q {
    let input = readLine()!.split(by: " ").map{Int($0)!}
    print(sum[input[1]-1] - sum[input[0]-1])
}

Measured memory_bytes: 4100
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        long[] n = SpRead(' ').Select(_ => long.Parse(_)).ToArray();
        long X = n[0], Y = n[1];
        long min = X;
        int count = 1;
        for (count = 1; min < Y;)
        {
            if (min * 2 <= Y)
            {
                min *= 2;
                //Console.WriteLine(min);
                count++;
            }
            else break;
        }
        Console.WriteLine(count);
    }
    //314159265 358979323846264338
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13396
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

const ll MOD = 1e9 + 7;
ll h, w, a, b, x, ans;
vll fac, inv_fac;

ll bin_exp(ll b, ll e, ll mod) {
    ll ret = 1;
    while (e > 0) {
        if (e & 1) {
            (ret *= b) %= mod;
        }
        (b *= b) %= mod;
        e >>= 1;
    }
    return ret;
}

void precompute_fac(ll n) {
    fac.resize(n); inv_fac.resize(n);
    fac[0] = 1;
    for (ll i = 1; i < n; i++) {
        fac[i] = i * fac[i - 1] % MOD;
    }
    inv_fac[n - 1] = bin_exp(fac[n - 1], MOD - 2, MOD);
    for (ll i = n - 1; i > 0; i--) {
        inv_fac[i - 1] = i * inv_fac[i] % MOD;
    }
}

int main() {
    fast_io; cout_precision;
    cin >> h >> w >> a >> b;
    precompute_fac(h + w);
    x = fac[h + w - 2 - b] * inv_fac[h - 1] % MOD * inv_fac[w - 1 - b] % MOD;
    for (ll i = 0; i < h - a; i++) {
        (ans += x) %= MOD;
        (x *= (b + i) * bin_exp(1 + i, MOD - 2, MOD) % MOD) %= MOD;
        (x *= (h - 1 - i) * bin_exp(h + w - 2 - b - i, MOD - 2, MOD) % MOD) %= MOD;
    }
    cout << (ans + MOD) % MOD << endl;
}

Measured memory_bytes: 3328
from math import sqrt
n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = list(map(float, input().split()))
    c = 2*((x2 - x1)*(y3 - y1) - (y2 - y1)*(x3 - x1))
    ox = ((y3 - y1)*(x2**2 - x1**2 + y2**2 - y1**2) + (y1 - y2)*(x3**2 - x1**2 + y3**2 - y1**2))/c
    oy = ((x1 - x3)*(x2**2 - x1**2 + y2**2 - y1**2) + (x2 - x1)*(x3**2 - x1**2 + y3**2 - y1**2))/c
    r = sqrt((x1-ox)**2+(y1-oy)**2)
    print("{0:.3f} {1:.3f} {2:.3f}".format(ox+0.0, oy+0.0, r+0.0))

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define m 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,W,i,j;
	cin>>n>>W;
	ll w[n],v[n];
	for(i=0;i<n;++i)
		cin>>w[i]>>v[i];
	ll dp[n+1][W+1];
	for(i=0;i<=n;++i)
		for(j=0;j<=W;++j)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(j>=w[i-1])
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
			else dp[i][j]=dp[i-1][j];
		}
	cout<<dp[n][W];
}

Measured memory_bytes: 79104
n,m,l=map(int,input().split())
matrix_a=[]
matrix_b=[]
matrix_c=[]
for i in range(n):
    matrix_a.append(list(map(int,input().split())))
for i in range(m):
    matrix_b.append(list(map(int,input().split())))
tmp_l=list()
for i in range(n):
    for j in range(l):
        tmp_n=0
        for k in range(m):
            tmp_n+=matrix_a[i][k]*matrix_b[k][j]
        tmp_l.append(tmp_n)
    matrix_c.append(tmp_l.copy())
    tmp_l.clear()
for i in matrix_c:
    tmp=0
    for j in i:
        tmp+=1
        if tmp==l:
            print(j,end="")
        else:
            print(j,"",end="")
    print()

Measured memory_bytes: 7132
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def gcd(a,b):
    while b:a,b=b,a%b
    return a

def lcm(a,b):return a*b//gcd(a,b)

def main():
    n=II()
    ta=LLI(n)
    x=y=-1
    for t,a in ta:
        if x==-1:
            x,y=t,a
            continue
        c=max((t+x-1)//t,(a+y-1)//a)
        x=c*t
        y=c*a
    print(x+y)

main()

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;


int main() {
  int N; cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    B[i] = A[i]-(i+1);
  }

  sort(B.begin(),B.end());
 
  int b = B[N/2];
  ll sum = 0;
  for ( int i = 0; i < N; i++ ) {
    sum += abs(B[i]-b);
  }
  cout << sum << endl;
  
  
  return 0;
}


Measured memory_bytes: 1792
#include <cstdint>
#include <vector>

using namespace std;

#define GRAPH_SIZE 101
#define START_INDEX 1

enum color_t {
  WHITE,
  GRAY,
  BLACK,
};

static uint32_t t = 0;
static color_t state[GRAPH_SIZE];
static vector<uint32_t> graph[GRAPH_SIZE];

void depth_first_search(void (*visited)(uint32_t), void (*invested)(uint32_t))
{
  for (uint32_t i = START_INDEX; i < GRAPH_SIZE; i++) {
    state[i] = WHITE;
  }

  static vector<pair<uint32_t, vector<uint32_t>>> stack;

  for (int32_t index = START_INDEX; index < GRAPH_SIZE; index++) {
    if (state[index] == WHITE) {
      stack.push_back(make_pair(index, graph[index]));
      state[index] = GRAY;
      t++;
      visited(index);

      while (!stack.empty()) {
        pair<uint32_t, vector<uint32_t>> top = stack.back();
        bool found = false;
        for (uint32_t i = 0; i < top.second.size(); i++) {
          uint32_t next = top.second[i];
          if (state[next] == WHITE) {
            found = true;
            state[next] = GRAY;
            t++;
            visited(next);
            stack.push_back(make_pair(next, graph[next]));
            break;
          }
        }

        if (!found) {
          stack.pop_back();
          t++;
          state[top.first] = BLACK;
          invested(top.first);
        }
      }
    }
  }
}

#include <iostream>

static uint32_t visited_time[GRAPH_SIZE];
static uint32_t invested_time[GRAPH_SIZE];

static void visited(uint32_t i)
{
  visited_time[i] = t;
}

static void invested(uint32_t i)
{
  invested_time[i] = t;
}

int32_t main(void)
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    uint32_t index, len;
    cin >> index >> len;
    for (uint32_t j = 0; j < len; j++) {
      uint32_t val;
      cin >> val;
      graph[index].push_back(val);
    }
  }

  depth_first_search(visited, invested);

  for (uint32_t i = START_INDEX; i < (START_INDEX + num); i++) {
    cout << i << " " << visited_time[i] << " " << invested_time[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3152
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)


N = I()
b = LI()

result = []
while True:
    #  print(b)
    for i in range(1, len(b)+1):
        #  print(i)
        if b[-i] == len(b)-i+1:
            #  print('break')
            result.append(b[-i])
            del b[-i]
            break
    else:
        if not b:
            break
        print(-1)
        exit()
for i in result[::-1]:
    print(i)


Measured memory_bytes: 65644
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    int a,b;
    cin >> a >> b;

    if( (((a+b)%3) == 0) || (a%3==0) || (b%3==0)) {
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }


}

Measured memory_bytes: 256
class Program
{
    static void Main(string[] args)
    {
        var line = System.Console.ReadLine().Trim();
        int N = int.Parse(line);

        ulong totalpower = 1L;

        for (int i = 0; i < N; i++)
        {
            totalpower = totalpower * (ulong)(i + 1);


            ulong a = totalpower % 107;


            if (totalpower >= System.Math.Pow(10, 9))
            {
                totalpower = totalpower % 1000000007;
            }

        }
        System.Console.WriteLine(totalpower);
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
#include<iostream>
#include<deque>
using namespace std;
char c;
int n=0;
int main()
{
	for(int i=1;i<=4;i++)
	{
		scanf("%c",&c);
		if(c=='+')n+=1;
		else n-=1;
	}
	printf("%d",n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
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; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
 
int main() {
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = INF;
    rep(p,101) {
        int hp = 0;
        rep(j,n) {
            hp += (x[j]-p)*(x[j]-p);
        }
        chmin(ans,hp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3488
import sys
def input():
	return sys.stdin.readline().strip()

S = input()

length_list = []
length = 1
now = S[0]
for i in range(1, len(S)):
	if now != S[i]:
		length_list.append(length)
		now = S[i]
		length = 1
	else:
		length += 1
length_list.append(length)

sum_list = []
x = 0
for i in range(len(length_list)):
	x += length_list[i]
	sum_list.append(x)

ans = 10000000000000
for i in range(len(length_list)):
	ans = min(ans, max(len(S) - sum_list[i], sum_list[i]))

print(ans)

Measured memory_bytes: 43120
x, y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
if x == 2 or y == 2:
    print("No")
elif (x in A and y in B) or (x in B and y in A):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll po(ll x,ll n){
    if(n==0) return 1;
    else if(n%2 == 0) return po((x*x)%MOD,n/2);
    else return (x*po((x*x)%MOD,(n-1)/2))%MOD;
}



void init(){
    
}

void solve( ll  tst ){
    ll n;
    cin>>n;
    ll freq[n+1] = {0};
    for( ll i=1;i<n;i++ ){
        ll tx;
        cin>>tx;
        freq[tx]++;
    }
    for( ll i=1;i<=n;i++ ){
        cout<<freq[i]<<"\n";
    }
    return;
}

int main(){
    FAST;
    init();
    //cout<<"init"<<endl;
    ll t = 1;
    //cin>>t;
    for (ll i=1;i<=t;i++ ) solve(i);
    return 0;
} 

Measured memory_bytes: 5184