akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int a,b,i;
    scanf("%d %d",&a,&b);
    for(i=1;i<=3;i++)
    {
        if(((a*b*i)%2)!=0) break;
    }
    if(i>3) printf("No\n");
    if(i<=3) printf("Yes\n");

}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans1 = min(a, b);
    int ans2 = max(0, a+b-n);
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define pb emplace_back
#define N 100123

using namespace std;

const double pi = acos(-1);
const double v1 = (pi * 6.0) / 180.0;
const double v2 = (0.5 * pi) / 180.0;

double a, b, h, m, angle;

int main() {
    ios_base::sync_with_stdio(0);
    
    cin >> a >> b >> h >> m;

    angle = (v2 *((h * 60.0) + m)) - (m * v1);
    //angle += pi;

    //angle = min(angle, (2.0 * pi) - angle);


    cout << fixed << setprecision(15) << endl;
    //cout << angle << endl;

    cout << sqrt((a * a) + (b * b) - (2 * a * b * cos(angle))) << endl;
    return 0;
}


Measured memory_bytes: 4156
#!python3

import sys
sys.setrecursionlimit(10 ** 6)

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
AB = [LI() for _ in range(M)]

# params
link = [[] for _ in range(N)]
for a, b in AB:
    link[a - 1].append(b - 1)
impossible = [False] * N


def joint(v, visit):
    if impossible[v]:
        return None
    visit = visit + [v]
    for u in link[v]:
        if u in visit:
            i = visit.index(u)
            return visit[i:]
        t = joint(u, visit)
        if t is not None:
            return t
    impossible[v] = True
    return None


def solve(l):
    n = len(l)
    d = {l[i]: i for i in range(n)}
    for i in range(n):
        x = l[i]
        for y in link[x]:
            if y in d:
                j = d[y]
                if (i + 1) % n == j:
                    continue
                if j < i:
                    l = l[j : i + 1]
                else:
                    l = l[: i + 1] + l[j:]
                return solve(l)
    return l
            

def main():
    t = None
    for i in range(N):
        t = joint(i, [])
        if t is not None:
            break
    if t is None:
        print(-1)
        return
    
    ans = solve(t)
    print(len(ans))
    for x in ans:
        print(x + 1)
        

if __name__ == "__main__":
    main()


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

int main() {
	char s[20] = {0};
	scanf ("%s", &s);
	int slong = strlen(s);
	int d[11] = {0};
	int B=0;
	
	// CHECKING IF THERE IS A B AND CHANGIN THE 'B' CHAR TO 1 in array
	for (int i = 0; i <= slong; i++) {
		if (s[i] == 'B') {
			B++;
			continue;
		}
		else if (s[i] != 'B') {
			int del = 0;
			del = B*2;
			for (int j = 1; j <= del; j++) {
				if (i - j >= 0) {
					d[i - j] = 1;
				}
				else {
					break;
				}
			}
			B = 0;
		}
	}
	// Just print 4head
	for (int k = 0; k < slong; k++) {
		if (d[k] == 0) {
			printf ("%c", s[k]);
		}
	}

	return 0;
}

Measured memory_bytes: 1608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

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

signed main(){
  ll n; cin>>n;
  if(n%2) return cout<<0<<endl,0;
  ll ans = 0;
  ll cnt = 10;
  while(n>=5){
    n /= cnt;
    ans += n;
    cnt = 5;
  }
  
  cout << ans << endl; 
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())

int main() {
  string s;
  cin >> s;
  if (s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3596
import math
from itertools import combinations_with_replacement

def calc(t):
    return t[0]*t[0] + t[1]*t[1] + t[2]*t[2] + t[0]*t[1] + t[1]*t[2] + t[2]*t[0]


n = int(input())
ans = [0]*n
n_root = math.floor(math.sqrt(n))+1

for pattern in combinations_with_replacement(range(1, n_root + 1), 3):
    pattern = list(pattern)
    buf = calc(pattern)
    #print(pattern)
    if buf <= n:
        if pattern[0] == pattern[1] == pattern[2]:
            ans[buf-1] += 1
        elif pattern[0] == pattern[1] or pattern[1] == pattern[2] or pattern[0] == pattern[2]:
            ans[buf-1] += 3
        else:
            ans[buf-1] += 6

[print(a) for a in ans]
#print(ans)

Measured memory_bytes: 9392
from copy import deepcopy

class Dice():

    def __init__(self):
        self.E = [4,2,1,6,5,3]
        self.N = [2,6,3,4,1,5]
        self.S = [5,1,3,4,6,2]
        self.W = [3,2,6,1,5,4]
        self.number = list(map(int,input().split()))
        self.order = "NNNNWNNNWNNNENNNENNNWNNN"

    def rotate(self,order):
        tmp = deepcopy(self.number)
        if order == "E":
            for i in range(6):
                self.number[i] = tmp[self.E[i]-1]
        elif order == "N":
            for i in range(6):
                self.number[i] = tmp[self.N[i]-1]
        elif order == "S":
            for i in range(6):
                self.number[i] = tmp[self.S[i]-1]
        elif order == "W":
            for i in range(6):
                self.number[i] = tmp[self.W[i]-1]
    
    def sidenum(self,x,y):
        for i in self.order:
            if self.number[1] == y and self.number[0] == x:
                print(self.number[2])
                break
            else:
                self.rotate(i)
    
    def check(self,other):
        flag = False
        for i in self.order:
            self.rotate(i)
            if self.number == other.number:
                flag = True
                break
        return flag

if __name__ == "__main__":
    n = int(input())
    dices = []
    for i in range(n):
        tmp = Dice()
        dices.append(tmp)
    flag = True
    for i in range(n-1):
        for j in range(i+1,n):
            if dices[i].check(dices[j]):
                flag = False
                break
    if flag:
        print("Yes")
    else:
        print("No")


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

namespace AtCoder.Abc
{
    class QuestionK
    {
        /// <summary>
        /// B - Count Balls
        /// https://atcoder.jp/contests/abc158/tasks/abc158_b
        /// </summary>
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var num_Array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var num_Unit = num_Array[1] + num_Array[2];

            var num_Set = num_Array[0] / num_Unit;
            var num_SP = num_Array[0] % num_Unit;

            long num_Blue = 0;

            if (num_SP >= num_Array[1])
            {
                num_Blue = num_Set * num_Array[1] + num_Array[1];
            }
            else if (num_SP < num_Array[1])
            {
                num_Blue = num_Set * num_Array[1] + num_SP;
            }

            Console.WriteLine(num_Blue);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int res,po,cnt[yuzu|10],n=read();
int main(){
re0 i,j;
for (i=1;i<=n;++i) cnt[read()]++;
for (i=1;i<=yuzu;++i){
  if (cnt[i]){  
    ++po;
    }
  }
write(po-!(po&1));
}

Measured memory_bytes: 640
import math
from collections import Counter

N = int(input())

s = []
for _ in range(N):
  s.append(''.join(sorted(str(input()))))
  
c = Counter(s) 

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

cnt = 0  
for i in c.values():
  if i >= 2:
    cnt += combinations_count(i, 2)

print(cnt)

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

namespace AtCoder3005
{
	class Program
	{
		static void Main(string[] args)
		{
			B();
		}

		static void B()
		{
			var str = Console.ReadLine();
			var newStr = str.Replace('?', 'D');
			Console.WriteLine(newStr);
		}

		static void A()
		{
			var ints = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
			var h1 = ints[0];
			var m1 = ints[1];
			var h2 = ints[2];
			var m2 = ints[3];
			var k = ints[4];

			var start = 60 * h1 + m1;
			var end = 60 * h2 + m2;
			if (end < start)
				end += 1440;

			var diff = end - start;
			Console.WriteLine(diff - k);
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, t;
  cin >> n >> t;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vector<vector<ll>> dp1(n+1, vector<ll>(t+1, 0)), dp2(n+1, vector<ll>(t+1, 0));

  rep(i, n) {
    for(int sum_t = 0; sum_t <= t; ++sum_t) {
      if(sum_t-a[i] >= 0) chmax(dp1[i+1][sum_t], dp1[i][sum_t-a[i]]+b[i]);
      chmax(dp1[i+1][sum_t], dp1[i][sum_t]);
    }
  }

  reverse(ALL(a));
  reverse(ALL(b));

  rep(i, n) {
    for(int sum_t = 0; sum_t <= t; ++sum_t) {
      if(sum_t-a[i] >= 0) chmax(dp2[i+1][sum_t], dp2[i][sum_t-a[i]]+b[i]);
      chmax(dp2[i+1][sum_t], dp2[i][sum_t]);
    }
  }

  
  reverse(ALL(a));
  reverse(ALL(b));

  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    for(int sum_t = 0; sum_t < t; ++sum_t) chmax(ans, dp1[i-1][sum_t]+dp2[n-i][(t-1)-sum_t]+b[i-1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 144240
#include <bits/stdc++.h>
using namespace std;
long long int n, k, ai;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    vector<bool>menang(k+1, false);
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin >> ai;
        arr[i]=ai;
    }
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=arr[j]&&!menang[i-arr[j]]){
                menang[i]=true;
                break;
            }
        }
    }
    (menang[k])?cout<<"First"<<endl:cout<<"Second"<<endl;
}

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

int main(){
  // input
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  // compute
  int ans = 0;
  for(int i = 0; i < N; i++){
    bool is_candidate = true;
    for(int j = 0; j < i; j++){
      if(H[j] > H[i]){
        is_candidate = false;
        break;
      }
    }
    if(is_candidate){
      ans++;
    }
  }
  
  // output
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    l = len(S)
    ws = bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    ans = min(wsc, bsc)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int r;
    cin >> r;

    cout << r * r << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"

const int N = 2e5;
const int INF = 2e9;

int n, v[N], w[N], W;
ll dp[N][200];

int main () {
	ios_base::sync_with_stdio(0);
	cin >> n >> W;
	for(int i = 1; i <= n; ++i) {
		cin >> w[i] >> v[i];
	}
	for(int k = 1; k <= n; ++k) {
		for(int s = 1; s <= W; ++s) {
		    //for(int k = 1; k <= n; ++k) {
			if(s >= w[k]) {
				dp[s][k] = max(dp[s][k - 1], dp[s - w[k]][k - 1] + v[k]);		
			}
			else {
				dp[s][k] = dp[s][k - 1];	
			}
			//show(s);
			//show(k);
			//show(dp[s][k]);			
		}
	}
	cout << dp[W][n];
	return 0;
}

Measured memory_bytes: 160000
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
#define mod 1000000007
 

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int> cnt(3,0);
    ll k = 1;
    for(int i=0;i<n;i++){
	ll c = 0;
	for(int j = 0;j<3;j++) if( a[i] == cnt[j] ) c++;
	k*=c;
	k%=mod;
	for(int j=0;j<3;j++)if(a[i]==cnt[j]){
	    cnt[j]++;
	    break;
	}
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Main().run();
	}
	
	void isort(int[] a) {
		for(int j = 1; j < a.length; j++) {
			pArray(a);
			int key = a[j];
			int i = j - 1;
			
			while(i >= 0 && a[i] > key) {
				a[i + 1] = a[i];
				i--;
			}
			a[i+1] = key;
		}
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] arr = new int[N];
		for(int i = 0; i < N; i++)
			arr[i] = sc.nextInt();
		
		isort(arr);
		
		pArray(arr);
	}
	
	boolean isOk(int[] arr) {
		boolean f = true;
		for (int i = 1; i < arr.length; i++) {
			int left = arr[i - 1];
			int right = arr[i];
			if(!(left <= right)) {
				f = false;
				break;
			}
		}
		return f;
	}
	
	void pArray(int[] a) {
		for (int i = 0; i < a.length - 1; i++) {
			int j = a[i];
			System.out.print(j + " ");
		}
		System.out.println(a[a.length - 1]);
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
#define MAX 1000000
struct pp{
    string name;
    int time;
};

pp Q[MAX];
int head, tail;

void enqueue(pp x){
    Q[tail].name = x.name;
    Q[tail].time = x.time;
    tail = (tail+1) % MAX;
}
pp dequeue(){
    head = (head+1) % MAX;
    return Q[head-1];
}

int main(){
    pp x;
    int count=0;
    int n, q;

    cin >> n >> q;
    for(int i=0;i<n;i++){
        cin >> x.name >> x.time;
        enqueue(x);
    }
    head = 0; tail = n;
    while(head != tail){
        x = dequeue();
        if(x.time <= q){
            count += x.time;
            cout << x.name << " " << count << endl;
        }
        else{
            count += q;
            x.time -= q;
            enqueue(x);
        }
    }
    
    return 0;
}


Measured memory_bytes: 21100
/*input
ggppgggpgggpg

*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define Error(x) cerr << #x << " = " << (x) <<endl;
#define Error2(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 1000010
#define lim2 3003
// inline lld sqr(lld x) { return x * x; }
// map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld B[lim],A[lim];
lld n,m,p,q;
string S[lim];

lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
bool bitSet(lld n,lld i){
    if((n&(1<<i))!=0) return true;
    else return false;
}

void mmod(long long int& cur) {
    while (cur >= mod) {
        cur -= mod;
    }
}


int main(){
    lld T,i,j,h,l,r,k,s,b,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    string S;
    cin>>S;
    n=S.size();
    lld score=0;
    a=b=0;
    rep(i,0,n-1){
        if(a<b){
            a++;
            t=1;
        }
        else{
            b++;
            t=0;
        }
        if(S[i]=='p'){
            if(t==0) score--;
        }
        else{
            if(t==1) score++;
        }
    }
    prL(score);
    return 0;
}


Measured memory_bytes: 8320
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

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

    ll a;
    ll ans = 1;
    ll MAX = 1e18;
    bool flag = 0;
    bool zero = 0;

    rep(i, n) {
        cin >> a;
        if (a==0) zero = 1;
        // else if (ans > MAX/a) flag = 1;
        if (ans != 0) if (a > MAX/ans) flag = 1;
        ans *= a;
        // cout << ans << endl;
    }

    if (zero) cout << 0 << endl;
    else if (flag) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

struct triangle {
  int a, b, c;
};

int main(void) 
{
  int i, N;
  struct triangle T;

  scanf("%d", &N);

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

    scanf("%d %d %d", &T.a, &T.b, &T.c);

    if (T.a * T.a + T.b * T.b == T.c * T.c || T.b * T.b + T.c * T.c == T.a * T.a || T.c * T.c + T.a * T.a == T.b * T.b) 
      printf("YES\n");
    else 
      printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  string x,y;
  cin >> x >> y;
  int a = stoi(x, nullptr, 16);
  int b = stoi(y, nullptr, 16);
  if(a<b) cout << "<" << "\n";
  else if(a>b) cout << ">" << "\n";
  else cout << "=" << "\n";
}

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

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

  vector<int> A(N); 

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int count = 0;
  
  while ( true ){
    bool exist_odd = false;
    for ( int i =  0; i < N; i++){
      if ( A.at(i) % 2 != 0 ){
        exist_odd = true;
      }
    }
    
    if ( exist_odd ){
      break;
    }
    
    for ( int i = 0; i < N; i++){
      A.at(i) /= 2;
    }
    
    count ++;
    
  }
  
  cout << count << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 200000+9;
int n,m;
struct E{
	int next,to;
}edge[MAXN<<1];
int head[MAXN],edge_num;
bool pd;
int col[MAXN];

void addedge(int x,int y){
	edge[++edge_num].next=head[x];
	edge[edge_num].to=y;
	head[x]=edge_num;
}

void DFS(int x,int c){
	int i;
	col[x]=c;
	for(i=head[x];i;i=edge[i].next){
		if(col[edge[i].to]==-1)
			DFS(edge[i].to,c^1);
		else if(col[edge[i].to]==col[x])pd=true;
	}
}

int main(){
	memset(col,-1,sizeof(col));
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,b);addedge(b,a);
	}
	//col[1]=1;
	DFS(1,0);
	long long ans;
	if(pd)
		ans=1LL*n*(n-1)/2-m;
	else{
		long long tmp=0;
		for(i=1;i<=n;i++){
			if(col[i]==1)
				tmp++;
		}
		ans=tmp*(n-tmp)-m;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }
    
    ll result = 0;
    ll count = 0;
    
    rep(i, n-1){
        if(h[i+1] <= h[i]){
            count ++;
        } else{
            if(result < count){
                result = count;
            }
            count = 0;
        }
    }
    if(result < count){
        result = count;
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 1024
use std::io::*;

const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let mut len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        if len > 0 {
            len -= 1;
        }

        &self.bytes_buffer[0..len]
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn get_pattern_count(stair_no: usize, table: &mut Vec<Option<u32>>) -> u32 {
    table[stair_no].unwrap_or_else(|| match stair_no {
        0 => 1,
        1 => {
            table[1] = Some(1);
            1
        }
        _ => {
            let pattern_count =
                (get_pattern_count(stair_no - 2, table) + get_pattern_count(stair_no - 1, table)) % 1000000007;
            table[stair_no] = Some(pattern_count);
            pattern_count
        }
    })
}

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 32);

    let n = cin.scan_u(SP) as usize;
    let m = cin.scan_u(LF) as usize;

    let mut table = vec![None as Option<u32>; n + 1];
    table[0] = Some(1);

    for _ in 0..m {
        table[cin.scan_u(LF) as usize] = Some(0);
    }

    println(get_pattern_count(n, &mut table));
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n;
int a[200005];
ll sum;
ll cur;
ll min_diff;

int main()
{
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &a[i]);
		sum+=a[i];
	}
	min_diff=1LL<<60;
	for(int i=0; i<n-1; i++) {
		cur+=a[i];
		if(abs(cur-(sum-cur))<min_diff) {
			min_diff=abs(cur-(sum-cur));
		}
	}
	printf("%lld\n", min_diff);

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

// const long long INF = 1LL << 60;

template <typename T>
struct Edge {
  int to;
  T cost;
};

// Dijkstra
template <typename T>
class Dijkstra {
 private:
  vector<vector<Edge<T>>> G;
  int num_v;

 public:
  Dijkstra(int num_v) : G(num_v), num_v(num_v) {
  }

  void add_edge(int from, int to, T cost) {
    G[from].push_back((Edge<T>){to, cost});
  }

  // start: Start point
  // result: result
  void solve(int start, vector<T>& result) {
    vector<int> tmp;
    solve(start, result, tmp);
  }

  void solve(int start, vector<T>& result, vector<int>& prev) {
    result.resize(num_v, INF);
    prev.resize(num_v, -1);

    // get<0>(T): cost
    // get<1>(T): index
    // get<2>(T): ... ( for extent)
    using Tup = tuple<T, int>;
    priority_queue<Tup, vector<Tup>, greater<Tup>> que;

    que.emplace(0, start);

    while (!que.empty()) {
      Tup p = que.top();
      que.pop();

      T t = get<0>(p);
      int v = get<1>(p);

      // 対象以下のコストの経路が既に見つかっている場合
      if (result[v] <= t) {
        continue;
      }

      result[v] = t;

      // vの各辺に対しよりコストの低い経路があるかを確認
      for (auto& e : G[v]) {
        // prevを見ないときはこの条件式はなくても良い
        if (result[e.to] > result[v] + e.cost) {
          prev[e.to] = v;
          que.emplace(result[v] + e.cost, e.to);
        }
      }
    }
  }

  // t: 目的地
  vector<int> get_path(const vector<int>& prev, int t) {
    vector<int> path;

    for (int v = t; v != -1; v = prev[v]) {
      path.push_back(v);
    }

    reverse(path.begin(), path.end());
    return path;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  const ll step = 100000;

  Dijkstra<ll> G(300010);
  rep(i, m) {
    ll u, v;
    cin >> u >> v;
    G.add_edge(u, v + step, 1);
    G.add_edge(u + step, v + 2 * step, 1);
    G.add_edge(u + 2 * step, v, 1);
  }

  ll s, t;
  cin >> s >> t;
  vll result;
  G.solve(s, result);

  ll ans = result[t];
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans / 3 << endl;
  }

  return 0;
}


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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long A, long long B){
    if (A >= 13) {
        cout << B << endl;
    } else if (A <= 5) {
        cout << 0 << endl;
    } else {
        cout << B/2 << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n, m, k, x, y, z;
	scanf("%d %d %d", &n, &m, &k);
	int a[n], b[m];
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < m; i++) scanf("%d", &b[i]);
	int ans = *min_element(a, a + n) + *min_element(b, b + n);
	for (int i = 0; i < k; i++){
		scanf("%d %d %d", &x, &y, &z);
		ans = min(ans, a[x - 1] + b[y - 1] - z);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 896
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 2010
ll dp[N][N];

int main(){
	int n, k;
	cin>>n>>k;
	dp[0][0] = 1;
	rep(i, n-k-1) (dp[0][0]*=2)%=mod;
	dp[0][1] = mod-dp[0][0];
	rep(i, k+1){
		for(int j = i; j < n; j++){
			(dp[i+1][max(i+1, j)]+=dp[i][j])%=mod;
			(dp[i][j+1]+=dp[i][j])%=mod;
		}
	}
	cout<<(dp[k][n]%mod+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 31104
N = int(input())
a = [i**5 for i in range(120)]
for i in range(120):
  for j in range(i + 1, 120):
    if a[j] - a[i] == N:
      print(j, i)
      break
    if a[j] + a[i] == N:
      print(j, -i)
      break
    else:
      continue
    break


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    long long n;
    cin >> n;
    cout << (n - 1) * n / 2;
//    int ans = 0;
//    for(int i = 1; i < n; i++){
//        ans += i % (i + 1);
//    }
//    cout << ans;
}


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

using ll = long long;
ll mod(const ll a, const ll b) { return a%b >= 0 ? a%b : a%b + b; }

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

    auto a = vector<int>(N), b = vector<int>(N);
    for (auto i = 0; i < N; i++)
        cin >> a[i] >> b[i];

    auto answer = 0LL;
    for (auto i = N-1; i >= 0; i--)
    {
        const auto presses = mod(-(answer + a[i]), b[i]);
        answer += presses;
    }
    cout << answer << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    if(A>=1 && A<=B && B<=100){
        for(int i = 0;i<=10000000;i++){
            int valora = i*0.08;
            int valorb = i*0.1;
            if(valora==A&&valorb==B){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

X,A = rl()
print(0 if X<A else 10)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ers erase
#define ins insert
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cout << #x << "= " << x << '\n';
#define kill(x) return cout << x, 0;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 1e3 + 10;
const ll INF = 1e18;
const ll LOG = 25;

ll fac[N], im[N], dp[N][N], n, A, B, C, D;

ll POW(ll x, ll t){
	if (t == 0) return 1;
	if (t % 2 == 0) return POW(x * x % MOD, t / 2);
	return x * POW(x, t - 1) % MOD;
}

ll choose(ll x, ll y){
	if (y > x || x < 0 || y < 0) return 0;
	ll res = fac[x];
	res *= im[y];
	res %= MOD;
	res *= im[x - y];
	res %= MOD;
	return res;;
}


int main(){
	fac[0] = 1, im[0] = 1;
	for (int i = 1; i < N; i++){
		fac[i] = fac[i - 1] * i % MOD;
		im[i] = POW(fac[i], MOD - 2);
	}
	cin >> n >> A >> B >> C >> D;
	dp[0][0] = 1;
	//cout << choose(5, 3);
	for (int i = 1; i <= B; i++){
		for (int j = 0; j <= n; j++){
			ll cnt = 1;
			for (int ted = 0; j + ted * i <= n; ted ++){
				if (ted != 0){
						cnt *= choose(n - j - (i * (ted - 1)), i);
						cnt %= MOD;
				}
					
				if ((ted == 0) || ((ted >= C && ted <= D) && (i >= A && i <= B))){
					ll ted2 = cnt * im[ted] % MOD;
					dp[i][ted * i + j] += dp[i - 1][j] * ted2 % MOD;
					dp[i][ted * i + j] %= MOD; 
				}
			}
			
		}
	}
	cout << dp[B][n];

	
	return 0;

}


Measured memory_bytes: 8192
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    vector<string> v;
    string ab(b, (char)('0' + a)), ba(a, (char)('0' + b));
    v.push_back(ab);
    v.push_back(ba);
    sort(ALL(v));
    cout << v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S, T;
  cin >> S >> T;

  int ret = S.size();

  rep(i,S.size()-T.size()+1){
    int sum = 0;
    rep(j,T.size()){
      if(S[i+j] != T[j]) sum++;
    }
    ret = min(ret, sum);
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 3628
import math,fractions
a=list(map(int,input().split()))
A=a[1]-a[0]+1 #もともとのAとBの間の数
B=(a[1]//a[2])-((a[0]-1)//a[2]) #Bの中のCの倍数-Aの中のCの倍数
C=(a[1]//a[3])-((a[0]-1)//a[3]) #Bの中のDの倍数-Aの中のDの倍数
d=a[2]*a[3]//fractions.gcd(a[2],a[3]) #CとDの最小公倍数
D=(a[1]//d)-((a[0]-1)//d) #Bの中の最小公倍数の倍数-Aの中の最小公倍数の倍数
print(A-B-C+D)


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e5
#define f1 first
#define s2 second
#define INF INT_MAX
#define pb push_back
#define ll long long
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

ll dizi[N][3],dp[N][3],n;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> dizi[i][0] >> dizi[i][1] >> dizi[i][2];
	}
	dp[0][0] = dizi[0][0];
	dp[0][1] = dizi[0][1];
	dp[0][2] = dizi[0][2];
	for(int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + dizi[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + dizi[i][1];
		dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + dizi[i][2];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
return 0;
}

Measured memory_bytes: 4992
# coding: utf-8
# Your code here!
H,N=map(int,input().split())
L=[[0,0]]#なんで最初に[0,0]を入れておくのか
for i in range(N):
    a,b=map(int,input().split())
    L.append([a,b])
INF=10**9

#dp[i][j]:iまでの魔法を使ってjダメージ与える場合の最小コスト
dp=[[INF for i in range(H+1)] for j in range(N+1)]
#print(dp)

#0ダメージ与えるのにコストはかからない
for i in range(N+1):
    dp[i][0]=0
    
for i in range(1,N+1):
    for j in range(1,H+1):
        dp[i][j]=min(dp[i-1][j],dp[i][max(j-L[i][0],0)] + L[i][1])
print(dp[N][H])

Measured memory_bytes: 126040
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#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 foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    //even->0 odd->1
    vector<int> continuous;
    continuous.push_back(0);
    int num = 0;
    bool now = 1;
    rep(i,s.length()){
        if(s[i]==now+'0'){
            num++;
        }else{
            continuous.push_back(continuous.back()+num);
            num = 1;
            now = !now;
        }
    }
//    rep(i,continuous.size()) cout << continuous[i] << ",";
    continuous.push_back(continuous.back()+num);
    int mx = 1;
    for(int l=0;l<continuous.size();l+=2){
        int r = l + k*2+1;
        if(r >= continuous.size()) r = (int)continuous.size() - 1;
        mx = max(mx, continuous[r]-continuous[l]);
    }
    cout << mx << endl;
    return 0;
}

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

using namespace std;

int main()
{
    map<string, int> ans;
    string s;
    cin >> s;
    ans["SUN"] = 7;
    ans["MON"] = 6;
    ans["TUE"] = 5;
    ans["WED"] = 4;
    ans["THU"] = 3;
    ans["FRI"] = 2;
    ans["SAT"] = 1;
    cout << ans[s] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template <typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int x = 0) : n(x), d(x + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
};

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<int, int>> p(n);

  long long x_max = 0;
  for (auto& pi : p) {
    cin >> pi.first >> pi.second;
    x_max = max(x_max, (long long)pi.first);
  }
  sort(p.begin(), p.end());
  BIT<long long> bit(n + 1);

  long long ret = 0;
  for (int i = 0; i < n; ++i) {
    long long x = p[i].first;
    long long h = p[i].second;
    h -= bit.sum(i);
    if (h <= 0) continue;
    long long num = (h + a - 1) / a;
    ret += num;
    long long damage = num * a;
    bit.add(i, damage);
    int rx = min(x + 2 * d, x_max);
    int j = upper_bound(p.begin(), p.end(), make_pair(rx + 1, -1)) - p.begin();
    bit.add(j, -damage);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 6356
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)

int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 2); // 前番兵、後番兵
  rep(i, 1, n + 1) cin >> a[i];
  // 蟻本 p298
  // 最大長方形、iを固定したときに
  // L[i] := a[j] < a[i]となるjのうち最も右のもの
  // R[i] := a[i] > a[j]となるjのうち最も左のもの
  // が入るようにする。これはstackでできる
  vector<ll> L(n + 2), R(n + 2);
  vector<ll> st;
  rep(i, 0, n + 1) {
    while (st.size() > 0 && a[st.back()] >= a[i]) st.pop_back();
    L[i] = st.size() > 0 ? st.back() + 1 : 0;
    st.push_back(i);
  }
  st.clear();
  rrep(i, 1, n + 2) {
    while (st.size() > 0 && a[st.back()] >= a[i]) st.pop_back();
    R[i] = st.size() > 0 ? st.back() : n + 1;
    st.push_back(i);
  }

  ll ans = 0;
  rep(i, 1, n + 1) ans += a[i] * (R[i] - i) * (i - L[i] + 1);

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


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

vector<ll> factorize(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(res.begin(),res.end());
    return res;  
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x;
cin >> x;
vector<ll> v = factorize(x);

ll a, b;
bool ok=false;

for (auto factor : v)
{
    reps(tmp_a,200,-200){
        ll tmp_b = tmp_a-factor;
        ll val = pow(tmp_a, 5) - pow(tmp_b, 5);
        if (val == x)
        {
            ok = true;
            a = tmp_a;
            b = tmp_b;
        }
        if(ok){
            break;
        }
    }
    if(ok){
            break;
    }
}
cout << a << " " << b << endl;
return 0;
}

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

int gcd(int x, int y)
{
    int r;
    while((r = x % y) != 0) 
    {
        x = y;
        y = r;
    }
    return y;
}

int main(){
    int n;
    cin>>n;
    int a[n],s[n],t[n];
    for(int i=0;i<n;i++) cin>>a[i];
    s[0]=a[0];
    for(int i=1;i<n;i++){
        s[i]=gcd(s[i-1],a[i]);
    }
    t[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        t[i]=gcd(t[i+1],a[i]);
    }
    int ans=t[1];
    for(int i=1;i<n-1;i++){
        ans=max(ans,gcd(s[i-1],t[i+1]));
    }
    ans=max(ans,s[n-2]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
N, M = map(int, input().split())
buffer = []
count = 0
money = 0

for i in range(N):
    buffer.append(list(map(int, input().split())))
buffer.sort()
for i in range(N):
    if(count + buffer[i][1] < M):
        count += buffer[i][1]
        money += buffer[i][0] * buffer[i][1]
    else:
        money += buffer[i][0] * (M - count)
        break

print(money) 

Measured memory_bytes: 60760