akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC103.D2
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var m = sc.Nextint();
            var demands = Enumerable.Range(0, m).Select(i => new { A = sc.Nextint(), B = sc.Nextint() }).ToArray();

            var maxRight = Enumerable.Repeat(n + 1, n).ToArray();
            foreach (var item in demands)
            {
                maxRight[item.A] = Math.Min(maxRight[item.A], item.B);
            }
            var cnt = 0;
            var r = n;
            for (int l = 0; l < n; l++)
            {
                r = Math.Min(maxRight[l], r);
                if (r <= l + 1)
                {
                    cnt++;
                    r = n + 1;
                }
            }
            Console.WriteLine(cnt);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 23496
s = input()

if len(s)%2 == 0:
    l = len(s) // 2
else:
    l = (len(s) // 2) + 1

ans = 0

for i in range(l):
    # print(s[i], s[-(i+1)])
    if s[i] != s[-(i+1)]:
        ans += 1

print(ans)

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

typedef struct{
    int i;
    int n;
}Mizu;

int main(void){
    int s1[20000];
    Mizu s2[20000];
    char s;
    int i,j,k,s1i,s2i,sum;
    s1i=0;s2i=0;sum=0;
    scanf("%c",&s);
    for(i=0;s!='\n';i++){
        if(s=='\\'){
            s1[s1i] = i;s1i++;
        }else if(s=='/' && s1i>0){
            j=s1[s1i-1];s1i--;
            k=i-j;
            sum+=k;
            while(s2i>0&&s2[s2i-1].i>j){
                k+=s2[s2i-1].n;s2i--;
            }
            s2[s2i].i=j; s2[s2i].n=k;
            s2i++;
        }
        scanf("%c",&s);
    }
    
    printf("%d\n",sum);
    printf("%d",s2i);
    for(i=0;i<s2i;i++){
        printf(" %d",s2[i].n);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2100
import sys,math
sys.setrecursionlimit(1000000)
INF = float("inf")

N = int(sys.stdin.readline())
c = tuple(tuple(map(int,sys.stdin.readline().rstrip().split()))[1:] for _ in range(N)) # multi line with multi param
Q = int(sys.stdin.readline())
uv = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
G = [list() for _ in range(N)]

for i,children in enumerate(c):
    G[i] = children

square = [i**2 for i in range(i,40)]
import bisect
#LN = bisect.bisect_left(square,N)+2
LN = math.ceil(math.log2(N))+1
depth = [0]*N
parents = [[0]*N for _ in range(LN)]

def dfs(v,p,l):
    parents[0][v] = p
    depth[v] = l
    for i in G[v]:
        if i != p:
            dfs(i,v,l+1)

dfs(0,-1,0)

for k in range(LN-1):#-1?
    for v in range(N):
        if parents[k][v] < 0:
            parents[k+1][v] = -1
        else:
            parents[k+1][v] = parents[k][parents[k][v]]

def query(u,v):
    if depth[u] > depth[v]:
        u,v = v,u
    while depth[v] != depth[u]:
        v = parents[int(math.log2(depth[v]-depth[u]))][v]
    # for k in range(LN)[::-1]:
    #     if ((depth[v]-depth[u])>>k & 1):
    #         v = parents[k][v]
    assert(depth[u]==depth[v])
    if u == v:
        return u
    for k in range(LN)[::-1]:
        if parents[k][v] != parents[k][u]:
            v = parents[k][v]
            u = parents[k][u]
    return parents[0][u]

ans = []
for u,v in uv:
    print(query(u,v))



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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> p(n);
  vector<int> h(n);
  for(int i = 0; i < n; i++) scanf("%d", &h[i]);
  for(int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    p[--a].push_back(--b);
    p[b].push_back(a);
  }
  int o = 0;
  for(int i = 0; i < n; i++) {
    int f = 1;
    for(auto x : p[i])
      if(h[i] <= h[x]) f = 0;
    if(f) o++;
  }
  printf("%d\n", o);
}

Measured memory_bytes: 8820
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
using std::swap;

vector <int> yp[100001];
int p[100000], y[100000];
int main() {
	int N, M;
	cin >> N >> M;
	rep(i, M)cin >> p[i] >> y[i], yp[p[i]].push_back(y[i]);
	rep(i, N) sort(yp[i + 1].begin(), yp[i + 1].end());
	rep(i, M)cout << setw(6) << setfill('0') << p[i] << setw(6) << setfill('0') << int(lower_bound(yp[p[i]].begin(), yp[p[i]].end(), y[i]) - yp[p[i]].begin()) + 1 << "\n";
	return 0;
}

Measured memory_bytes: 7808
import sys
import collections
input = sys.stdin.readline

def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    B = [0]
    for a in A:
        B.append((B[-1] + a) % M)

    c = collections.Counter(B)
    ans = 0
    for k in c.keys():
        if c[k] <= 1:
            continue
        ans += (c[k] * (c[k] - 1)) // 2

    print(ans)



if __name__ == '__main__':
    main()




Measured memory_bytes: 21936
function floor_sum(n, m, a, b)
  ans::BigInt = 0
  n,m,a,b=BigInt.([n,m,a,b])
  if a >= m
    ans += (n - 1) * n * (a ÷ m) / 2
    a %= m
  end
  if b >= m
    ans += n * (b ÷ m)
    b %= m
  end
  y_max = (a * n + b) ÷ m
  x_max = (y_max * m - b)
  if y_max == 0; return ans; end
  ans += (n - (x_max + a - 1) ÷ a) * y_max
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
  return ans
end
p()=parse.(Int,split(readline()))
n=parse(Int,readline())
function main()
  for i=1:n
    n,m,a,b=p()
    floor_sum(n,m,a,b) |> println
  end
end
main()

Measured memory_bytes: 288728
import sys
input = sys.stdin.buffer.readline
import copy

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
        
    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num
        
    for i in range(1,K+1):
        if i <= N-K+1:
            print((coef(N-K+1,i)*coef(K-1,i-1))%MOD)
        else:
            print(0)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 3992
import std.stdio, std.conv, std.string;

void main() {
	int N = to!(int)(readln().chomp());
	string [] S = readln().chomp().split();
	bool flg = false;
	foreach(i; S) {
		if(i=="Y")
			flg = true;
	}
	if(flg)
		writeln("Four");
	else
		writeln("Three");
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }

  map<ll, ll> mp;
  for (int i = 0; i < N; ++i)
  {
    for (ll j = 2; j * j <= A[i] + 10; ++j)
    {
      if (A[i] % j != 0)
        continue;
      while (A[i] % j == 0)
      {
        A[i] /= j;
      }
      mp[j]++;
    }
    if (A[i] > 1)
      mp[A[i]]++;
  }
  ll max_ = 0;
  for (auto &e : mp)
  {
    max_ = max(max_, e.second);
  }
  if (max_ <= 1)
    cout << "pairwise coprime" << endl;
  else if (max_ < N)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;

  return 0;
}


Measured memory_bytes: 15832
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<uint64_t> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  uint64_t div = 1000000000 + 7;

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

  vector<uint64_t> sig_(n);
  for (int i = 0; i < n; i++)
  {
    sig = sig - a[i];
    sig_[i] = sig % div;
    // cout << sig_[i] << endl;
  }

  uint64_t sum = 0;
  for (int i = 0; i < n - 1; i++)
  {
    uint64_t p = a[i] * sig_[i];

    sum += p % div;
    sum = sum % div;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6432
#include <iostream>


int main () { 
  int n, mod;
  int yen = 100000;
  std::cin >> n;
  for (int i = 0; i < n; i ++) {
    yen *= 1.05;
    mod = yen % 1000;
    if (mod > 0)
      yen += 1000 - mod;
  }
  std::cout << yen << std::endl;
  return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 101;

int n, W, w[N], v[N]; long long dp[100001], ans;

int main() {
	scanf("%d%d", &n, &W);
	rep(i, 1, n) {
		scanf("%d%d", &w[i], &v[i]);
	}
	rep(i, 1, n) {
		for (int j = W; j >= w[i]; j--) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
			ans = max(ans, dp[j]);
//			if (i == 3) cout << j << ' ' << dp[j - w[i]] << ' ' << v[i] << '\n';
		}	
//		rep(i, 1, 5) {
//			cout << dp[i] << '\n';
//		}cout << '\n';
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

// prime=>true, not prime=>false
// bool isPrime(int i){
//     for(int j=2; j<=i/2; j++){
//         if(i%j==0){
//             return false;
//         }
//     }
//     return true;
// }

bool isPrime(int n){
    if(n<2){
        return false;
    }else if(n==2){
        return true;
    }
    if(n%2==0){
        return false;
    }
    for(int i=3; i<=n/i; i+=2){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main(){

    int n;
    cin >> n;

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

    int prime_count = 0;
    for(int i=0; i<n; i++){
        if(isPrime(n_nums[i])){
            prime_count += 1;
        }
    }

    cout << prime_count << endl;
    return 0;
}



Measured memory_bytes: 3080
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m, k;
	cin >> n >> m >> k;

	vector<ll> a(n + 1, 0);
	vector<ll> b(m + 1, 0);

	REP(i, 1,  n) {
		ll x; cin >> x;
		a[i] = a[i - 1] + x;

	}
	REP(i, 1,  m) {
		ll x; cin >> x;
		b[i] = b[i - 1] + x;
	}

	int i = n;
	while (i > 0 && a[i] > k) {
		i--;
	}
	int ans = i;
	int j = 0;
	bool gone = false;
	while (i >= 0 && j <= m ) {
		if (a[i] + b[j] > k) {
			i--;
		} else {
			ans = max(ans, i + j);
			j++;

		}
	}
	if (i >= 0 && j <= m && a[i] + b[j] <= k) ans = max(ans, i + j);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int flg=1;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){flg=0;}
    }
    if(flg==1){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    return 0;
}

Measured memory_bytes: 1792
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n],val=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        val ^= a[i];
    }
    if(val == 0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int func(int h,int w,vector<string>&s,vector<vector<int>>&has,int c){
	int res=c;
	//clog<<h<<" "<<w<<endl;
	if(has[h][w]==0){
		has[h][w]=1;
		for(int nh=h-1;nh<=h+1;nh++){
			for(int nw=w-1;nw<=w+1;nw++){
				if(nh <0 or nw< 0 or nh >=s.size() or nw>=s[0].size() or not(nh==h xor nw==w)){
					continue;
				}
				if(s[nh][nw]=='#'){
				chmax(res,func(nh,nw,s,has,c+1));
				}
			}
		}
	}
//	clog<<h<<" "<<w<<" - "<<res<<endl;
	return res;
}
int main(){
	int h,w;
	bool ans=true;
	cin >>h>>w;
	vector<string>s(h);
	vector<vector<int>>has(h,vector<int>(w,0));
	rep(i,h){
		cin>>s[i];
	}
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#' and has[i][j]==0){
				if(func(i,j,s,has,0)==0){
					ans=false;
				}
			}else{
				has[i][j]=1;
			}
		}
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	
	int n;
	cin>>n;
	vector<vector<int>> a(n);
	rep(i,n){
		a[i].resize(n);
		rep(j,n){
			cin>>a[i][j];
			if(a[i][j]==-1)a[i][j]=INF;
		}
	}
	vector<int> t(n);
	rep(i,n){
		t[i]=0;
	}
	t[0]=1;
	int ans=0;
	rep(ii,n-1){
		int m=100000;
		int pm;
		rep(i,n){
			rep(j,n){
				if(t[i]==1 && t[j]==0 && m>a[i][j]){
					m=a[i][j];
					pm=j;
				}
			}
		}
		t[pm]=1;
		ans+=m;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3100
N = int(input())
Z=[]
for i in range(N):
	t, x, y = map(int, input().split())
	if t % 2 == 0:
		if x + y <= t and (x + y) % 2 == 0:
			Z.append(1)
		else:
			Z.append(0)
	else:
		if x + y <= t and (x + y) % 2 == 1:
			Z.append(1)
		else:
			Z.append(0)
	i += 1
if Z.count(0) >=1:
	print('No')
else:
	print('Yes')




Measured memory_bytes: 3872
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{


fastio();

ll a,b;
cin>>a>>b;

cout<<a*b;

return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  long long x, ans = 0; cin >> x;
  ans = (x / 11) * 2;
  if(x % 11 >= 1 && x % 11 <= 6) ans += 1;
  else if(x % 11 >= 7) ans += 2;
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))

Measured memory_bytes: 34616
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
using namespace std;

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

	string s;
	cin >> s;

	int x = (s[0] - '0') * 10 + s[1] - '0';
	int y = (s[2] - '0') * 10 + s[3] - '0';

	if (x <= 12 && x >= 1) {

		if (y <= 12 && y >= 1) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}

	}
	else {

		if (y <= 12 && y >= 1) {
			cout << "YYMM" << endl;
		}
		else cout << "NA" << endl;

	}


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct rect { ll hei; int pos; };
ll getmaxrect(int size, ll buffer[]) {
	stack<rect> s;
	ll res = 0;
	buffer[size] = 0;
	for (int i = 0; i <= size; i++) {
		rect rec;
		rec.hei = buffer[i];
		rec.pos = i;
		if (s.empty()) {
			s.push(rec);
		}
		else {
			if (s.top().hei < rec.hei) {
				s.push(rec);
			}
			else if (s.top().hei > rec.hei) {
				int tag = i;
				while (!s.empty() && s.top().hei >= rec.hei) {
					rect pre = s.top(); s.pop();
					ll area = (pre.hei+1)*(i - pre.pos+1);
					res = max(res, area);
					tag = pre.pos;
				}
				rec.pos = tag;
				s.push(rec);
			}
		}
	}
	return res;
}
int p[2000][2000];
char t[2000][2000];
ll hi[2000][2000];
int main() {
	ll buffer[2001];
	int h, w; cin >> h >> w;
	rep(i, h) {
		string s; cin >> s;
		rep(j, w) {
			t[i][j] = s[j];
		}
	}
	rep(i, h - 1) {
		rep(j, w - 1) {
			int cnt = 0;
			rep(k, 2) {
				rep(l, 2) {
					if (t[i + k][j + l] == '#')cnt++;
				}
			}
			if (cnt % 2)p[i][j] = 1;
		}
	}
	rep(j, w - 1) {
		hi[0][j] = 1;
		if (p[0][j])hi[0][j] = 0;
		rep1(i, h - 2) {
			if (p[i][j])hi[i][j] = 0;
			else hi[i][j] = hi[i - 1][j] + 1;
		}
	}
	ll out = max(h,w);
	rep(i, h - 1) {
		rep(j, w - 1) {
			buffer[j] = hi[i][j];
		}
		out = max(out, getmaxrect(w - 1, buffer));
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 51072
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int num[200005],num2[200005];
int main(){
	int i,j,l,n,k;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&num[i]);
	for(i=0;i<k;i++){
		for(j=0;j<n;j++)
			num2[j]=0;
		for(j=0;j<n;j++){
			num2[max(0,-num[j]+j)]++;
			num2[min(n,num[j]+j)+1]--;
		}
		for(j=1;j<n;j++){
			num2[j]+=num2[j-1];
		}
		bool right=1;
		for(j=0;j<n;j++){
			num[j]=num2[j];
			right&=(num[j]==n);
		}
		if(right)
			break;
	//	for(j=0;j<n;j++)
	//		printf("%d ",num[j]);
	//	putchar('\n');
	}
	for(i=0;i<n;i++)
		printf("%d ",num[i]);
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef pair<int,int> pii;

int n,m;
vector<pii> edge[200200];
vector<int> col[1001000];
vector<int> ned[500500];
int colour[200200],x[200200],l[200200];
int dist[500500];

int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		edge[p].pb(mp(c,q));
		edge[q].pb(mp(c,p));
		col[c].pb(q);
		col[c].pb(p);
	}
	for (int i=1;i<=n;i++){
		sort(edge[i].begin(),edge[i].end());
	}
	memset(colour,0,sizeof colour);
	memset(x,0,sizeof x);
	memset(l,0,sizeof l);
	int nw=n+1;
	for (int co=1;co<=1000000;co++){
		if (!col[co].size()) continue;
		for (int k=0;k<col[co].size();k++){
			int p=col[co][k];
			if (colour[p]==co) continue;;colour[p]=co;
			queue<int> q;
			q.push(p);
			while (!q.empty()){
				int b=q.front();
				q.pop();
				while (l[b]<edge[b].size()){
					int c=edge[b][l[b]].f;
					if (c!=co) break;
					int pp=edge[b][l[b]].s;
					if (colour[pp]!=co){
						colour[pp]=co;
						q.push(pp);
					}
					l[b]++;
				}
				ned[b].pb(nw);
				ned[nw].pb(b);
			}
			nw++;
		}
	}
	for (int i=1;i<=nw;i++) dist[i]=-2;
	queue<int> q;
	q.push(1);
	dist[1]=0;
	while (!q.empty()){
		int b=q.front();
		q.pop();
		for (int i=0;i<ned[b].size();i++){
			int p=ned[b][i];
			if (dist[p]==-2){
				dist[p]=dist[b]+1;
				q.push(p); 
			}
		}
	} 
	cout<<dist[n]/2<<endl;
	return 0;
}

Measured memory_bytes: 65280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    cin >> n;
    set <string> sET;
    for(i=0;i<n;i++)
    {
        string s;
        cin >> s;
        sET.insert(s);
    }
    cout << sET.size();
    return 0;
}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
 
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}
 
void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
   
      return (a * bc) % MOD;
  }
};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
int main(){
  lli k;
  cin >> k;
  lli ans=0;
  rep1(i,k)rep1(j,k)rep1(l,k)ans+=gcd(gcd(i,j),l);
  cout << ans;
}


Measured memory_bytes: 3640
#include <cstdio>

using namespace std;

int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int count = 0;
    for (int a = 0; a <= 9; a++)
      for (int b = 0; b <= 9; b++)
        for (int c = 0; c <= 9; c++)
          for (int d = 0; d <= 9; d++)
            if (a + b + c + d == n)
              count++;
    printf("%d\n", count);
  }
  return 0;
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N ;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  for(int a=0; a<N-1;a++){
    for(int b=a+1;b<N;b++){
      sum += vec.at(a)*vec.at(b);
    }
  }
  cout << sum << endl ; 
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int solve(){
  int a,b;
  cin >> a >> b;
  if(a == b)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,cnt2=0;
   cin>>n;
   string s;
    rep(i,0,n)
    {
       cin>>s;
       x=sz(s);
       if(s[0]=='B' && s[x-1]=='A')
          cnt2++;
       else if(s[0]=='B') cnt++;
       else if(s[x-1]=='A') cnt1++;
       rep(i,0,x-1)
       {
           if(s[i]=='A' && s[i+1]=='B')
            res++;
       }
    }
    //cout<<res<<" "<<cnt<<" "<<cnt1<"\n";
    if(cnt2>1)
        {res+=(cnt2-1);
         cnt2=1;}
    if(cnt2==1)
    {
        if(cnt1>0)
            {res+=1;cnt1--;}
        if(cnt>0)
        {
            res+=1;
            cnt--;
        }
    }
    res+=min(cnt1,cnt);
    cout<<res;
}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 384
/*
  This C++ Source Is
  Writen By syksykCCC
  (After July, 2019)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i < y; i++)
#define REP(i, x, y) for(int i = x; i <= y; i++)
#define per(i, x, y) for(int i = x; i > y; i--)
#define PER(i, x, y) for(int i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c))
	{
		if(c == '-') f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		val = (val << 3) + (val << 1) + (c ^ 48);
		c = getchar();
	}
	val *= f;
}
template<typename T> void write_(T val)
{
	if(!val) return;
	write_(val / 10);
	putchar(val % 10 + 48);
}
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0)
	{
		putchar('-');
		write_(-val);
	}
	else write_(val);
}

const int N = 105;
LL n, d[N], ans;

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, 1, n) cin >> d[i];
	REP(i, 1, n) REP(j, i + 1, n) ans += d[i] * d[j];
	cout << ans << endl; 
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S, T; cin >> S >> T;
    ll ans = 0;
    rep(i, S.size()){
        if (S[i] == T[i]){ans++;}
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		System.out.println(n*n);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
import sys
N = int(input())
As = list(map(int, input().split()))

for i in range(N):
    if As[i] % 2 == 0:
        if As[i] % 3 != 0 and As[i] % 5 != 0:
            print('DENIED')
            sys.exit(0)

print('APPROVED')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    REP(i,h) REP(j,w) if (s[i][j] == '.') s[i][j] = '0';
    REP(i,h) REP(j,w) {
        if (s[i][j] == '#') {
            FOR(a,i-1,i+2) FOR(b,j-1,j+2) {
                if (a >=0 &&
                    a < h &&
                    b >= 0 &&
                    b < w &&
                    s[a][b] != '#') s[a][b]++;
            }
        }
    }

    REP(i,h) cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


void solve(string s,int dice[6]){
    int ans[6]={};
    rep(i,6)ans[i]=dice[i];
    if(s=="North"){
        ans[0]=dice[1];
        ans[1]=dice[5];
        ans[4]=dice[0];
        ans[5]=dice[4];
    }
    if(s=="East"){
        ans[0]=dice[3];
        ans[2]=dice[0];
        ans[3]=dice[5];
        ans[5]=dice[2];
    }
    if(s=="West"){
        ans[0]=dice[2];
        ans[2]=dice[5];
        ans[3]=dice[0];
        ans[5]=dice[3];
    }
    if(s=="South"){
        ans[0]=dice[4];
        ans[1]=dice[0];
        ans[4]=dice[5];
        ans[5]=dice[1];
    }
    if(s=="Right"){
        ans[1]=dice[2];
        ans[2]=dice[4];
        ans[3]=dice[1];
        ans[4]=dice[3];
    }
    if(s=="Left"){
        ans[1]=dice[3];
        ans[2]=dice[1];
        ans[3]=dice[4];
        ans[4]=dice[2];
    }
    
    rep(i,6){
        dice[i]=ans[i];
    }
}

int main() {
    int n;
    
    while(cin>>n){
        if(n==0)break;
        
        rep(i,n){
            int a[5];
            int b[5];
            
            rep(i,4)cin>>a[i+1];
            rep(i,4)cin>>b[i+1];
            
            int x,y,z,w;
            x=a[1]*b[1] - a[2]*b[2] - a[3]*b[3] - a[4]*b[4];
            y=a[1]*b[2] + a[2]*b[1] + a[3]*b[4] - a[4]*b[3];
            z=a[1]*b[3] - a[2]*b[4] + a[3]*b[1] + a[4]*b[2];
            w=a[1]*b[4] + a[2]*b[3] - a[3]*b[2] + a[4]*b[1];
        
            cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main(){
    
    int n,x,min = 1000000,max = -1000000,i;
    long long sum = 0;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> x;
        if(x < min)
            min = x;
        if(x > max)
            max = x;
        sum += x;
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
    }

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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 5e4 + 233;
bitset<maxn> mp[maxn];
int n, m, T;
int x[maxn * 2], y[maxn * 2];
bool vis[maxn];
char s[maxn * 2];
int cnt[maxn], pos[maxn];

int main(){
    scanf("%d %d %d", &n, &m, &T);
    if(T == 1) {
        for (int i = 1; i <= n; i++) mp[i].set(i);
        for (int i = 1; i <= m; i++) {
            scanf("%d %d", &x[i], &y[i]);
            mp[x[i]] = mp[y[i]] = mp[x[i]] | mp[y[i]];
        }
        for (int i = 1; i <= n; i++) {
            if (mp[i].count() == n) {
                vis[i] = 1;
                for (int j = m; j; j--) {
                    if (vis[x[j]]) {
                        s[j] = '^';
                        vis[y[j]] = 1;
                    } else if (vis[y[j]]) {
                        vis[x[j]] = 1;
                        s[j] = 'v';
                    } else s[j] = 'v';
                }
                for (int j = 1; j <= m; j++) printf("%c", s[j]);
                puts("");
                return 0;
            }
        }
        puts("-1");
    }
    else{
        for(int i = 1; i <= m; i++) scanf("%d %d", &x[i], &y[i]);
        if(n == 2) puts("-1");
        else {
            for (int i = 1; i <= n; i++) cnt[i] = 1, pos[i] = i;
            for (int i = m; i; i--) {
                if (cnt[pos[x[i]]] >= 2) {
                    cnt[pos[x[i]]]--;
                    pos[x[i]] = pos[y[i]];
                    cnt[pos[y[i]]]++;
                    s[i] = 'v';
                } else {
                    cnt[pos[y[i]]]--;
                    pos[y[i]] = pos[x[i]];
                    cnt[pos[x[i]]]++;
                    s[i] = '^';
                }
            }
            s[m + 1] = '\0';
            puts(s + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 309248
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int c = sc.nextInt();
	    
	    if((a != b) && (b != c) && (c != a)) {
	    	System.out.println(3);
	    }else if((a==b) && (b==c) && (c==a)) {
	    	System.out.println(1);
	    }else {
	    	System.out.println(2);
	    }
	    
	}
	
}

Measured memory_bytes: 21460
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

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

Measured memory_bytes: 3652
n,p = map(int, input().split())
a = list(map(int, input().split()))

odd = 0
even = 0

for i in range(n):
  if a[i]%2 == 0:
    even += 1
  else:
    odd += 1

if odd == 0:
  if p == 1:
    print(0)
  else:
    print (2**n)
else:
  print (2**(n-1))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;map<int,int>m;for(int i=0;i<n;++i){int x;cin>>x;m[x-1]++;m[x]++;m[x+1]++;}int ans=0;for(auto p:m)ans=max(ans,p.second);
  cout<<ans;cout<<endl;
  return 0;}

Measured memory_bytes: 4736
#include<stdio.h>
int main(void)
{
    char c[13];
    int a, b;
    scanf("%d%d", &a, &b);
    if(a>b){
        for (int i = 1; i <= a;i++)
            c[i] = b;
    }else{
        for (int i = 1; i <= b;i++)
            c[i] = a;
    }

    int q = a > b ? a : b;
    for (int i = 1; i <= q;i++)
        printf("%d", c[i]);

    return 0;
}

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

using namespace std;
#define llu unsigned long long
#define ll long long
#define p pair<int,int>
#define M 1000000007
//sieve can be used here!
bool isPrime(int n){
	if(n==1)return false;//1 is not prime
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
bool myComp(p a,p b){
	if(a.first==b.first) return a.second<b.second;
	return a.first>b.first;
}
int row[]={-1,0,1,0};
int col[]={0,-1,0,1};
ll squareRoot(ll x){
	ll low=0;
	ll high=x;
	while(low<=high){
		ll mid= low+(high-low)/2;
		if((mid*mid)>x)high=mid-1;
		else if(mid*mid<x)low=mid+1;
		else return mid;
	}
	return low;
}
void dfs(char par,int r,int c,vector<vector<char>>& arr,vector<vector<bool>>& visited){
	int n=arr.size();
	int m=arr[0].size();
	visited[r][c]=true;
	arr[r][c]=par;
	for(int i=0;i<4;i++){
		int newRow=r+row[i];
		int newCol=c+col[i];
		if(newRow>=0&&newRow<n&&newCol>=0&&newCol<m&&!visited[newRow][newCol]&&arr[newRow][newCol]!='-'){
			if(par=='B') dfs('W',newRow,newCol,arr,visited);
			else dfs('B',newRow,newCol,arr,visited);
		}
	}
}
llu sumDigit(llu x){
	llu ans=0;
	while(x>0){
		ans+=x%10;
		x/=10;
	}
	return ans;
}
llu func(llu a,llu b){
	if(sumDigit(a)==b)return 0;
	llu ans=0;
	llu temp=1;
	while(sumDigit(a)>b){
		int currDigit=((a/temp)%10);
		llu curr=((10-(currDigit))%10)*temp;
		ans+=curr;
		a+=curr;
		temp*=10;
	}
	return ans;
}
ll func(vector<int>&arr){
	int n=arr.size();
	vector<ll> pref(n+1,0);
	for(int i=1;i<=n;i++){
		pref[i]=(pref[i-1]%M+arr[i-1]%M)%M;
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		ll temp=pref[n]-pref[i+1];
		if(temp<0)temp+=M;
		sum+=((temp)*arr[i]%M)%M;
		sum%=M;
	}
	return sum;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> arr(n,0);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	cout<<func(arr);
	return 0;
}



Measured memory_bytes: 5468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B; cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;


}


Measured memory_bytes: 256