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

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	int n;
	cin >> n;

	vector<int> a(n);

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

	ll ans = 0;

	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			ans += 1LL * a[i] * a[j];
		}
	}

	cout << ans << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var list = new List<int>();

            list.AddRange(Enumerable.Range(abk[0], abk[2]));
            list.AddRange(Enumerable.Range(abk[1] - abk[2] + 1, abk[2]));
            list = list.Distinct().Where(n => n >= abk[0] && n <= abk[1]).ToList();

            foreach (int i in list)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <stdint.h>

#define MAX_CITIES 50

using namespace std;

static uint32_t routes[MAX_CITIES][MAX_CITIES];

int32_t main()
{
  uint32_t N, M;
  cin >> N >> M;

  for (uint32_t i = 0; i < M; i++) {
    uint32_t a, b;
    cin >> a >> b;
    a--;
    b--;
    routes[a][b]++;
    routes[b][a]++;
  }

  for (uint32_t i = 0; i < N; i++) {
    uint32_t count = 0;
    for (uint32_t j = 0; j < N; j++) {
      count += routes[i][j];
    }
    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a < 3200){
    cout << "red\n";
  }
  else{
    cout << s << "\n";
  }
}

Measured memory_bytes: 3636
// #include <bits/stdc++.h>
// using namespace std;
// int a[10][10010];
// bool isRoll[10];
// int maxNum;
// void change(int row, int col, int nrow) {
//     if(nrow == row) {
//         return ;
//     }
//     if(!isRoll[nrow]) {
//         isRoll[nrow] = true;
//         for(int j = 0; j < col;j++) {
//             a[nrow][j] = 1 - a[nrow][j];
//         }
//         int total = 0;
//         for(int j = 0; j < col; j++) {
//             int num = 0;
//             for(int k = 0; k < row; k++) {
//                 if(a[k][j] == 0) {
//                     num++;
//                 }
//             }
//             total += max(num, row - num);
//         }
//         maxNum = max(maxNum, total);
//         change(row, col, nrow + 1);
//         isRoll[nrow] = false;
//         for(int j = 0; j < col;j++) {
//             a[nrow][j] = 1 - a[nrow][j];
//         }
//     }
// }

// void solve(int row, int col) {
//     maxNum = 0;
//     memset(isRoll, 0, sizeof(isRoll));
//     change(row, col, 0);
//     printf("%d\n", maxNum);
// }

// int main() {
//     int row, col;
//     scanf("%d%d", &row, &col);
//     while(row && col) {
//         for(int i = 0;i < row;i++) {
//             for(int j = 0; j < col; j++) {
//                 scanf("%d", &a[i][j]);
//             }
//         }
//         solve(row, col);
//         scanf("%d%d", &row, &col);
//     }
// }


#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
// bitset是一种类似数组的结构，它的每一个元素只能是0或1，每个元素仅用1bit空间
bitset<10000> cookie[10];
int main() {
    int r, c;
    while(cin >> r >> c && r) {
        int result = 0;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                bool what;
                cin >> what;
                cookie[i][j] = what;
            }
        }
        int permute = 1 << r;
        // 行的变换总共有2^r个，k取遍各种情况
        for(int k = 0; k < permute; k++) {
            // 每一种情况对应着r行的一次变化，每一行翻转或者不翻转
            for(int j = 0; j < r; j++) {
                // 对于每一个k，(1 << j)与i的二进制对应位上若都为1，这一行翻转
                if(k & (1 << j)) {
                    cookie[j].flip();
                }
            }
            int possible_num = 0;
            for(int j = 0;j < c; j++) {
                int up_number = 0;
                for(int i = 0; i < r; i++) {
                    if(cookie[i][j]) {
                        up_number++;
                    }
                }
                possible_num += max(up_number, r - up_number);
            }
            result = max(result, possible_num);
            for(int j = 0; j < r; j++) {
                if(k & (1 << j)) {
                    cookie[j].flip();
                }
            }
        }
        cout << result << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
// ABC-142 B:
// 2019.9.28 bal4u
// Template for Online Contest

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

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

int cmp_int(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int main()
{
	int i, N, K;
	int ans;
	
	N = in(), K = in();
	ans = 0; while (N--) if (in() >= K) ans++;
	printf("%d\n", ans);
	return 0;
}


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

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

    sort(p.begin(), p.end());
   
    int ans = 0;
    REP(i, N) {
        int v = p[i];
        if (i == N-1) v /= 2;
        ans += v;
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int q; cin >> q;
    set<ll> st;
    rep(i,q){
        ll com, x, y;
        cin >> com >> x;
        if(com == 0){
            st.insert(x);
            cout << st.size() << endl;
        }else if(com == 1)cout << st.count(x) << endl;
        else if(com == 2)st.erase(x);
        else{
            cin >> y;
            for(set<ll>::iterator it=st.lower_bound(x); it != st.upper_bound(y); it++)cout << *it << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12456
#include<bits/stdc++.h>
using namespace std;
int n,a[100100];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	int x=0,y=0;
    while (y+1<n&&x+1<a[y+2]&&x+1<a[y+1])
    {
    	x++;y++;
    }
    //走到边界处 
	int xx=(a[y+1]-x)%2,yy=1;
	//xx+1即为由上走出界的步数，yy同理 
	for (int i=x;i<=n;i++)
	{
		yy^=1;
		if (x>=a[i+1]) break;
	}
	if ((!xx)||(!yy)) cout<<"First\n";else cout<<"Second";
	return 0;
}

Measured memory_bytes: 640
def main():
    N, M = (int(i) for i in input().split())
    par = [i for i in range(N)]
    rank = [1]*N

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            x, y = y, x
        rank[x] += rank[y]
        par[y] = x

    def size(x):
        return rank[find_root(x)]

    ans = [N*(N-1)//2]
    AB = [[int(i)-1 for i in input().split()] for j in range(M)]
    for a, b in AB[::-1]:
        if is_same_group(a, b):
            ans.append(ans[-1])
        else:
            p = size(a)
            q = size(b)
            # print(a, b, p, q)
            unite(a, b)
            ans.append(ans[-1] - p * q)
    ans = ans[::-1]
    for a in ans[1:]:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 117536
#include "bits/stdc++.h"
using namespace std;
string s;
vector <int> g[2002];
int dp[2002];
int tot[2002];
int sum[2002];

void dfs(int x, int par) {
	sum[x] = 0;
	tot[x] = s[x] - '0';
	for(int i : g[x]) {
		if(i - par) {
			dfs(i, x);
			tot[x] += tot[i];
			sum[x] += tot[i] + sum[i];
		}
	}
}
bool matcher(int x, int par, int take) {
	if(take <= 0) return true;
	if(sum[x] - (sum[x] % 2) < take) return false;

	int big = -1;
	for(int i : g[x]) {
		if(i - par) {
			if(big == -1 || tot[big] + sum[big] < tot[i] + sum[i]) {
				big = i;
			}
		}
	}
	if(big == -1) return false;
	int w = tot[big] + sum[big];
	if(sum[x] - w < w) {
		int opt1 = 2*w - sum[x];
		int opt2 = take - 2 * (sum[x] - w);
		return matcher(big, x, min(opt1, opt2));
	} else {
		return true;
	}
}

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	cin >> s;
	s = "&" + s;
	for(int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = INT_MAX;
	for(int i = 1; i <= n; i++) {
		dfs(i, 0);
		if(sum[i] % 2 == 0) {
			if(matcher(i, 0, sum[i])) {
				ans = min(ans, sum[i] / 2);
			}
		}
	}
	if(ans == INT_MAX) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
class UnionFind():
    def __init__(self,size):
        self.table = [[-1,1] for _  in range(size)] # root, count
    def find(self,x):
        while self.table[x][0] >= 0:
            x = self.table[x][0]
        return x
    def union(self,x,y):
        szsz = 0
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            szsz = self.table[s1][1]*self.table[s2][1]
            if self.table[s1][0] != self.table[s2][0]:
                if self.table[s1][0] < self.table[s2][0]:
                    self.table[s2][0] = s1
                    self.table[s1][1] += self.table[s2][1]
                else:
                    self.table[s1][0] = s2
                    self.table[s2][1] += self.table[s1][1]
            else:
                self.table[s1][0] += -1
                self.table[s2][0] = s1
                self.table[s1][1] += self.table[s2][1]
        return szsz


N, M = map(long, raw_input().split())
uf = UnionFind(N)
V = [map(long, raw_input().split()) for _ in range(M)]

ans = N*(N-1)/2
answers = []
for v in reversed(V):
  answers.append(ans)
  szsz = uf.union(v[0]-1, v[1]-1)
  ans -= szsz
for a in reversed(answers):
  print a




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

int main()
{
    int n,cnt=0;
    long long d,x,y;
    cin >> n >>d;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        if(x*x+y*y <= d*d)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}





Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int               long long
// #define ld               long double
#define endl "\n";
#define lb lower_bound
#define ub upper_bound
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];

int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

// int t;
// cin >>t;
// while(t--){
int a,v,b,w,t;
cin >> a>>v>>b>>w>>t;
if((v*t) >=(w*t + abs(b-a))){
	cout << "YES" <<endl;
}
else{
	cout << "NO" <<endl;
}

return 0;
}

Measured memory_bytes: 3652
n,m,l = tuple(int(x) for x in input().split())
R = []
A = [[int(a) for a in input().split()] for i in range(n)]
B = [[] for j in range(l)]

for j in range(m):
    i = input().split()
    [B[k].append(int(i[k])) for k in range(l)]
    
for a in A:
    rs = []
    for j in range(l):
        rs.append(sum([a[r]*B[j][r] for r in range(m)]))
    R.append(rs)
    
for r in R:
    print(" ".join(map(str,r)))


Measured memory_bytes: 6624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s;
  cin >> s;
  ll n = s.size();

  ll ans = 0;
  ll cnt = 0;
  rep(i, n) {
    if (s[i] == 'A') {
      cnt++;
    } else if (i+1 < n and s.substr(i, 2) == "BC") {
      ans += cnt;
      i++;
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for (int i = 0; i < 1000; i++) {
      String key = String.format("%03d", i);
      if (can(key, s)) ans++;
    }
    System.out.println(ans);
  }

  public static boolean can(String key, String s) {
    int index = 0;
    for (int i = 0; i < 3; i++) {
      index = s.indexOf(key.charAt(i), index);
      if (index < 0) return false;
      index++;
    }
    return true;
  }
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X, D;
	cin >> N >> X >> D;
	if (D == 0) {
		if (X == 0) {
			cout << 1 << endl;
		} else {
			cout << 1 + N << endl;
		}
		return 0;
	}
	if (D < 0) {
		X = -X;
		D = -D;
	}
	map<int, int> R;
	int mn = 0;
	int mx = 0;
	int res = 0;
	vector<pair<int, pair<int, int> > > vp;
	vp.emplace_back(0, make_pair(0, 0));
	for (int i = 1; i <= N; i++) {
		int sum = X * i;
		mn += i - 1;
		mx += N - i;
		int ll = sum / D;
		if (D * ll > sum) {
			ll--;
		}
		int md = sum - D * ll;
		int l = ll + mn;
		int r = ll + mx;
		vp.emplace_back(md, make_pair(l, r));
	}
	sort(vp.begin(), vp.end());
	for (int i = 0; i < vp.size(); i++) {
		//cerr << i << " " << l << " " << r << endl;
		int md = vp[i].first;
		int l = vp[i].second.first;
		int r = vp[i].second.second;
		int t;
		if (R.count(md) == 0) {
			t = -((int)1 << 60);
		} else {
			t = R[md];
		}
		if (t >= l) {
			l = t + 1;
		}
		if (t < r) {
			res += r - l + 1;
			R[md] = r;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 18412
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#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 fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	int n, k, sum = 0;
	cin >> n >> k;
	int a[n];
	rep(i, 0, n)
	cin >> a[i];
	sort(a, a + n);
	rep(i, 0, k)
	sum += a[i];
	cout << sum << endl;
	return 0;
}

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

int main(){
    int h,n,p,m,t;
    cin >> h >> n >> p >> m >> t;
    vector<int> bar(h+1, -1);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        bar[a] = b-1;
    }

    int occupied = m;
    vector<vector<vector<double>>> dp(h+1, vector<vector<double>>(t+1, vector<double>(n, 0.0)));
    dp[h][0][p-1] = 1.0;
    for(int i=h; i>=1; i--){
        if(bar[i] == -1){
            for(int j=0; j<=t; j++){
                double p_chosen = (double)(t-j)/(i-occupied);
                for(int k=0; k<n; k++){
                    dp[i-1][j][k] += dp[i][j][k] *(1-p_chosen);
                }
                if(j == t) continue;
                for(int k=0; k<n; k++){
                    int straight = (k==0 or k==n-1)? n-2: n-3;
                    dp[i-1][j+1][k] += dp[i][j][k] *straight/(n-1) *p_chosen;
                }
                for(int k=0; k<n-1; k++){
                    dp[i-1][j+1][k+1] += dp[i][j][k] *1/(n-1) *p_chosen;
                    dp[i-1][j+1][k] += dp[i][j][k+1] *1/(n-1) *p_chosen;
                }
            }
        }else{
             occupied--;
            for(int j=0; j<=t; j++){
                for(int k=0; k<n; k++){
                    if(k == bar[i]){
                        dp[i-1][j][k+1] = dp[i][j][k];
                    }else if(k == bar[i]+1){
                        dp[i-1][j][k-1] = dp[i][j][k];
                    }else{
                        dp[i-1][j][k] = dp[i][j][k];
                    }
                }
            }
        }
    }
    cout << fixed << setprecision(10);
    cout << *max_element(dp[0][t].begin(), dp[0][t].end()) << endl;
    return 0;
}


Measured memory_bytes: 44700
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);
const lint MOD = 1000000007;

int main() {
    int A, P;
    cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	string s;
	cin >> s;
	rSORT(s);
	vector<string> a = {"dream", "dreamer", "erase", "eraser"};
	rep(i,4){
		string ch;
		ch = a[i];
		rSORT(ch);
		a[i] = ch;
	}
//	for(auto x: a){
//		cout << x << endl;
//	}
	int n = s.size();
	string forans ="";
	rep(i,n){
		if(s[i]=='r'){
			if(s[i+2]=='m'){
				forans += a[1];
				i += 6;
			}else{
				forans += a[3];
				i += 5;
			}
		}else{
			if(s[i]=='m'){
				forans+=a[0];
				i+=4;
			}else{
				forans+=a[2];
				i+=4;
			}
		}
	}
	if(s==forans){
		cout <<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 640
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

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

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

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

    int a[n];
    forn(i, n)
    {
        cin >> a[i];
    }

    int ans=0;
    for(int i=0; i<n-1; i++)
    {
        if(a[i]>a[i+1])
        {
            ans += a[i]-a[i+1];
        }
    }
    ans+=a[n-1];
    cout << ans << "\n";

    return 0;
}




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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  x = x - (x/b)*b;
  cout << x << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n,l,i;
	cin >> n >> l;
	vector<string> str(n);
	string uni;
	for(i=0; i<n; i++)
		cin >> str[i];

	sort(str.begin(), str.end());
	for(i=0; i<n; i++)
		uni += str[i];
	cout << uni << endl;


}


Measured memory_bytes: 256
/*
                                Shahriar Hasan
                          "University of Chittagong"
                                CSE 18 Batch
*/
#include <bits/stdc++.h>
using namespace std;

#define nln puts("")                    // newline
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))    //max/min from 3 input

#define even(x) x%2==0                  //even odd
#define odd(x) x%2!=0

#define PI acos(-1)                     // constant + math
#define lcm(a,b) (a*b/gcd(a,b))

#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)          // algorithm habijabi
#define srt(a,n) sort(a,a+n)
#define srtt sort(a.begin(),a.end())
#define cnt(x) count(a,a+n,x)
#define F first
#define S second
#define all(p) p.begin(),p.end()

#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(ull i=1;i<=n;i++)         //loop
#define forr(i,n) for(int i=n-1;i>=0;i--)
#define mem(a,b) memset(a, b, sizeof(a))
#define fill(a,b) fill(a.begin(),a.end(),b)
#define fill_n(a,n,b) fill_n(a.begin(),n,b)
                        //input
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print0(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define print1(a) for(int i=1;i<=a.size();i++)cout<<a[i]<<endl;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vl;
typedef pair<int,int> pii;           // datatype
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;



int gcd(int a, int b)               //gcd
{if(b==0)return a;return gcd(b,a%b);}

ull power(int a,int n)              // to the power
{ll multi=1;for(int i=1;i<=n;i++)multi=multi*a; return multi;}
bool isPrime(ull n)                 // prime number check
{if(n==2 | n==3)return true;else{ull m=power(2,n-1);if(m%n==1 && n%2==1)return true;else return false;}}
vi getdiv(ll n){vi div;int i;
    for(i=1;i*i<n;i++)
    {if(n%i==0){div.pb(i);div.pb(n/i);}}if(i*i==n)div.pb(i);            // divisor nirnoy kora
    //sort(div.begin(),div.end());
    return div;}
bool isPalindrome(int n){int num=n,sum=0,mod;
    while(n){mod=n%10;n=n/10;sum=sum*10+mod;}
    if(sum==num)return true;else return false;}


int main()
{
    int n;
    cin >> n;
    if(n<=81)
    {
        for1(i,9)
        {
            if(n%i==0 && n/i <=9)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;

    }
    else cout << "No" << endl;
    return 0;
}



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

using namespace std;

namespace {
	typedef long long ll;

	struct EndPoint
	{
		EndPoint(ll _x, pair<ll, ll> _y) : x(_x), y(_y) {}
		bool operator<(const EndPoint& rhs) const {	return x < rhs.x; }

		ll x;
		pair<ll,ll> y;
	};
}

static int countIntersection(const vector<EndPoint>& X)
{
	int num_int = 0;
	set<ll> Y;
	for (size_t i = 0; i < X.size(); i++) {
		if (X[i].y.first == X[i].y.second) {
			auto r = Y.insert(X[i].y.first);
			if (!r.second) {
				Y.erase(r.first);
			}
		}
		else {
			num_int += distance(Y.lower_bound(X[i].y.first), Y.lower_bound(X[i].y.second));
		}
	}

	return num_int;
}

int main()
{
	int n = 0;
	cin >> n;

	vector<EndPoint> X;
	for (int i = 0; i < n; i++) {
		ll x1, y1, x2, y2;
		scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
		if (y1 == y2) {
			X.push_back(EndPoint(min(x1, x2) * 4 - 1, make_pair(y1 * 4, y1 * 4)));
			X.push_back(EndPoint(max(x1, x2) * 4 + 1, make_pair(y1 * 4, y1 * 4)));
		}
		else {
			X.push_back(EndPoint(x1 * 4, make_pair(min(y1, y2) * 4 - 1, max(y1, y2) * 4 + 1)));
		}
	}

	sort(X.begin(), X.end());
	cout << countIntersection(X) << endl;
	return 0;
}


Measured memory_bytes: 10412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  long long int mod = 1000000007;
  int n, m;
  long long int a[100100];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
    //cout << a[1] << endl;;
  }

  long long int ans[100100];
  ans[0] = 1;
  int j = 1;
  if (a[j] == 1) {
    ans[1] = 0;
    j++;
  } else {
    ans[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (a[j] == i) {
      ans[i] = 0;
      j++;
    } else {
      ans[i] = (ans[i-2] + ans[i-1]) % mod;
    }
    //cout << ans[i] << endl;
  }
/*
  for (int i = 0; i <= n; i++) {
    cout << i << ans[n] << endl;
  }*/

  cout << ans[n] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

pair < pair <str,int> , int > res[300];
int n;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        str s;
        int x;
        cin>>s>>x;
        res[i]= mp ( mp(s,-1*x) , i);
    }
    sort(res+1,res+1+n);
    for(int i=1;i<=n;i++){
        cout<<res[i].se<<newl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
int64_t dp[3005][3005];
  dp[1][1]=1;
  int N; string s;
  cin>>N>>s;
  for(int i=2;i<=N;i++){
  if(s.at(i-2)=='>'){
  int64_t a=0;
    dp[i][i]=0;
    for(int j=i-1;1<=j;j--){
     a=(a+dp[i-1][j])%mod;
      dp[i][j]=a;
    }
  }else{
     int64_t a=0;
    dp[i][1]=0;
    for(int j=1;j<=i-1;j++){
     a=(a+dp[i-1][j])%mod;
      dp[i][j+1]=a;
  }
  }
  }int64_t ans=0;
    for(int i=1;i<=N;i++)
      ans=(ans+dp[N][i])%mod;
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 70528
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	ll n;
	cin >> n;

	ull res = n * (1 + n) / 2 - n;

	cout << res << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S;
	cin >> S;

	S[3] = '8';
	cout << S << endl;


	//end = clock();
	//printf("%d msec.\n", end - start);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll count = 0;
  ll ma = 1000000000;
  ll sum = 0;
  rep(i, n){
    cin >> a[i];
    if (a[i] < 0) count++;
    ma = min(ma, abs(a[i]));
    sum += abs(a[i]);
  }
  if (count % 2 == 0) cout << sum << endl;
  else cout << sum - ma*2 << endl;
  
  return 0;
}

Measured memory_bytes: 4032
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N,M,C;
    int A[21][21], B[21];
    cin >> N >> M >> C;
    for (int i = 0; i < M; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < M; ++j){
            cin >> A[i][j];
        }
    }
    int result[N];
    int count = 0;
    for (int i = 0; i < N; ++i){
        result[i] = 0;
        for (int j = 0; j < M; ++j){
            result[i] += A[i][j] * B[j];
        }
        result[i] += C;
        if (result[i] > 0){
            ++count;
        }
    }
    // 出力
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())

up = 1
for num in a:
    up *= num

down = 0
for i in range(n):
    cnt = 1
    for j in range(n):
        if j != i:
            cnt *= a[j]
    
    down += cnt
    
print(up / down)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N=405;
int ans,n,m,x[N*N],y[N*N],S[N][N],Del[N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)scanf("%d%d",&x[i],&y[i]);
	for (int i=1;i<=n;i++){
		S[i][i]=1;
		for (int j=m;j;j--){
			if (S[i][x[j]]&&S[i][y[j]]){
				Del[i]=1;
				break;
			}
			if (S[i][x[j]])S[i][y[j]]=1;
			if (S[i][y[j]])S[i][x[j]]=1;
		}
	}
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++)
			if (!Del[i]&&!Del[j]){
				int flag=1;
				for (int k=1;k<=n;k++)
					if (S[i][k]&&S[j][k])flag=0;
				ans+=flag;
			}
	printf("%d\n",ans);	
}

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

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

    int cnt = 0;
    int res = 0;
    while (cnt < 2)
    {
        if (A > B)
        {
            res += A;
            A--;
        }
        else
        {
            res += B;
            B--;
        }
        cnt++;
    }
    cout << res << endl;
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int allgcd = 0;
    rep(i,n) allgcd = gcd(a[i], allgcd);
    
    const int LIMIT = 1000000;
    vector<vector<int>> p(LIMIT + 1);
    reps(i,2,LIMIT){
        if(!p[i].empty()) continue;
        for(int j = i; j <= LIMIT; j += i){
            p[j].push_back(i);
        }
    }
    
    vector<bool> has_prime(LIMIT+1, false);
    bool is_pairwise = true;
    
    rep(i,n){
        for(int pr : p[a[i]]){
            if(has_prime[pr]){
                is_pairwise = false;
            }else{
                has_prime[pr] = true;
            }
        }
        if(!is_pairwise) break;
    }
    
    if(is_pairwise){
        cout << "pairwise coprime" << endl;
    }else if(allgcd == 1){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);

int n , a, b, c, d;
string s;
int mp[maxn],dpb[maxn],dpa[maxn];


int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> a >> b >> c >> d >> s;
    for(int i = 0 ; i < n ;i++){
        if(s[i] == '.')mp[i] = 1;
        else mp[i] = 0;
    }
    a--,b--,c--,d--;
    dpa[a] = dpb[b] = 1;
    // b
    for(int i = b + 1 ; i <= d ; i++){
        if(mp[i])dpb[i] = (dpb[i - 1] | dpb[i - 2]);
        else dpb[i] = 0;
    }
    mp[d] = 0;
    for(int i = a + 1 ; i <= c ; i++){
        if(mp[i])dpa[i] = (dpa[i - 1] | dpa[i - 2]);
        else dpa[i] = 0;
    }
/*
    for(int i = 0 ; i < n ;i++)
        cout << dpa[i];
        cout << endl;
    for(int i = 0 ; i < n ;i++)
        cout << dpb[i];
*/
    mp[d] = 1;
    int ans = dpa[c]&dpb[d];
    int flag = 0;
    for(int i = b ; i <= d; i++){
         if(mp[i-1] && mp[i] && mp[i+1]) flag = 1;
    }
    //if(dpa[b-1] && dpa[b + 1])flag = 1;
    if(flag){
        memset(dpa,0,sizeof(dpa));
        memset(dpb,0,sizeof(dpb));
         dpa[a] = dpb[b] = 1;
         for(int i = a + 1 ; i <= c ; i++){
            if(mp[i])dpa[i] = (dpa[i - 1] | dpa[i - 2]);
            else dpa[i] = 0;
        }
        mp[c] = 0;
        for(int i = b + 1 ; i <= d ; i++){
           if(mp[i])dpb[i] = (dpb[i - 1] | dpb[i - 2]);
           else dpb[i] = 0;
       }
        ans |= (dpa[c]&dpb[d]);
        //cout << ans << endl;
        mp[c] = 1;
    }
    if(c > d){
        memset(dpa,0,sizeof(dpa));
        memset(dpb,0,sizeof(dpb));
        for(int i = b + 1 ; i < n ; i++){
        if(mp[i])dpb[i] = (dpb[i - 1] | dpb[i - 2]);
        else dpb[i] = 0;
       }
        for(int i = a + 1 ; i <= b ; i++){
        if(mp[i])dpa[i] = (dpa[i - 1] | dpa[i - 2]);
        else dpa[i] = 0;
       }
       if(dpa[b]){
       for(int i = b + 1; i <= d - 1; i++){
           if(dpb[i - 1] && dpb[i + 1]){
               ans |= dpb[d];
               break;
           }
       }
       }
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}



Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,i,j;
	cin>>a>>b;
	c=a+b;
	if(a%3!=0&&b%3!=0&&(a+b)%3!=0){
		cout<<"Impossible"<<endl;
	}
	else{
		cout<<"Possible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;

  vector<vector<int> > t(N);

  int a,b;
  for(int i=0;i<N-1;i++){
    cin >> a >> b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }

  vector<int> P(N,-1);
  int f=0;
  P[0]=1;
  int cur=0;
  deque<int> s;
  s.push_back(0);
  while(!s.empty()){
    cur=s.back();
    s.pop_back();
    for(auto ti:t[cur]){
      if(P[ti]==-1){
	P[ti]=P[cur]+1;
	s.push_back(ti);
      }
    }
  }

  int n0=0,n1=0;
  for(auto pi:P){
    if(pi%2==0) n0++; else n1++;
  }

  int m0=0,m1=0,m2=0;
  if(n0<=N/3 || n1<=N/3){
    int r;
    if(n0<=N/3) r=0; else r=1;
    for(int i=0;i<N;i++){
      if(P[i]%2==r) {cout << 3*m0+3; m0++;}
      else{
	if(3*m1+1<=N) {cout << 3*m1+1; m1++;}
	else if(3*m2+2<=N) {cout << 3*m2+2; m2++;}
	else {cout << 3*m0+3; m0++;}
      }
      cout << " ";
    }
  }else{
    for(int i=0;i<N;i++){
      int r=P[i]%2;
      if(r==0){
	if(3*m1+1<=N) {cout << 3*m1+1; m1++;}
	else {cout << 3*m0+3; m0++;}
      }else{
	if(3*m2+2<=N) {cout << 3*m2+2; m2++;}
	else {cout << 3*m0+3; m0++;}
      }      
      cout << " ";
    }
  }
  cout << endl;    
  
  return 0;
}


Measured memory_bytes: 14452
N = int(input())
L = list(map(int,input().split()))

r = -1; s = 0
ans = 0
for i in range(N):
    while r < N - 1 and not (s & L[r+1]):
        s ^= L[r + 1]; r += 1
    ans += r - i + 1
    s ^= L[i]
print(ans)


Measured memory_bytes: 24424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main() {
  int N, T;
  cin >> N >> T;
  int c[1010], t[1010];
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
  }
  int minimum = 100000;
  int ans;

  for (int i= 0; i < N; i++) {
    if (t[i] <= T) {
      minimum = min(c[i], minimum);
      } 
    }
  if (minimum == 100000) cout << "TLE" << endl;
  else cout << minimum << endl;
}

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

int main()
{
	int N, res = 0, x = 0;
	string S;
	cin >> N >> S;
	for (char c : S) {
		if (c == 'I') {
			x++;
			res = max(res, x);
		}
		else {
			x--;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int cnt[3],a[100001];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		int tmp;
		scanf("%d",&tmp);
		if (tmp%4==0)
			++cnt[2];
		else if (tmp%2==0)
			++cnt[1];
		else
			++cnt[0];
	}
	for (int i=0;i<=2;++i)
		if (cnt[i])
		{
			a[1]=i;
			bool f=true;
			int tmp[3]={cnt[0],cnt[1],cnt[2]};
			--tmp[i];
			for (int j=1;f&&j<n;++j)
			{
				if (a[j]==0)
				{
					if (tmp[2]==0)
						f=false;
					else
					{
						a[j+1]=2;
						--tmp[2];
					}
				}
				else if (a[j]==1)
				{
					if (tmp[1])
					{
						a[j+1]=1;
						--tmp[1];
					}
					else if (tmp[2])
					{
						a[j+1]=2;
						--tmp[2];
					}
					else
						f=false;
				}
				else if (a[j]==2)
				{
					if (tmp[0])
					{
						--tmp[0];
						a[j+1]=0;
					}
					else if (tmp[1])
					{
						--tmp[1];
						a[j+1]=1;
					}
					else
					{
						--tmp[2];
						a[j+1]=2;
					}
				}
			}
			if (f)
			{
				printf("Yes");
				return 0;
			}
		}
	printf("No");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N  ;
    vector<ll> X;
    cin >> N ;
    rep(i, N){
        ll inp; cin >> inp;
        X.pb(inp);
    }
    
    ll ans = 1123456789 ;
    rep(x, 101){
        if(x == 0 ) continue;
        ll tmp = 0;
        rep(i, N){
            tmp += abs(x - X[i]) * abs(x - X[i]);
        }
        ans = min(tmp, ans) ;
    }

    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 888