akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
std::vector<int> v2(x-1);
std::vector<int> v(x);
rep(i,x-1){
  std::cin >> v2[i];
}
rep(i,x){
  v[i]=1000000;
}
rep(i,x-1){

    if(v2[i]<=v[i]){
      v[i]=v2[i];
    }
    v[i+1]=v2[i];

}
rep(i,x){
  z+=v[i];
}
std::cout << z << '\n';
}


Measured memory_bytes: 256
// Cursor jump numbers
// main @ 39
// global @ 35
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

bool checkpal(string &s, int start, int end) {
  for(int i=start; i < start + (end - start + 1)/2; i++) {
    if(s[i] != s[end - i + start])
      return false;
  }
  return true;
}

bool checkequal(string &s, int n) {
  int tmp = (n+1)/2;
  for(int i=1; i<=(n+1)/4; i++) {
    if(s[i] != s[tmp + i])  return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, inp;
  cin >> inp;
  s = " ";
  s.append(inp);
  int n = inp.size();
  if(checkpal(s, 1, (n-1)/2) && checkpal(s, (n+3)/2, n) && checkequal(s, n))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n;
    cin >> n;
    int l[n],r[n];
    for(int i = 0; i < n; i++){
        cin >> l[i] >> r[i];
    }
    for(int i = 0; i < n - 2; i++){
        if(l[i] == r[i] && l[i + 1] == r[i + 1] && l[i + 2] == r[i + 2]){
            output(true);return;
        }
    }
    output(false);
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int N; cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll sum=0;
  for(int i=1; i<N; i++) sum+=A[i/2];
  cout << sum;
  return 0;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

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

    int n;
    cin >> n;
    int a[n];
    unordered_map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        mp[a[i]]--;
        bool f = true;
        for(int j = 1; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                if((mp.count(j) > 0 && mp[j] > 0) || (mp.count(a[i] / j) > 0 && mp[a[i] / j] > 0)){
                    f = false;
                    break;
                }
            }
        }
        if(f){
            ans++;
        }
        mp[a[i]]++;
    }
    cout << ans;
}


Measured memory_bytes: 12192
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n, k;
    scan(n, k);
    auto s = readln.chomp;
    auto pf = new int[](n + 1);
    pf[1] = s[0] == '0';
    foreach (i ; 2 .. n + 1) {
        if (s[i - 1] == '0' && s[i - 2] == '1') {
            pf[i] = pf[i - 1] + 1;
        }
        else {
            pf[i] = pf[i - 1];
        }
    }

    debug {
        writeln(pf);
    }

    bool check(int x) {
        foreach (i ; 0 .. n - x + 1) {
            int d = pf[i + x] - pf[i];
            if (i > 0 && s[i] == '0' && s[i - 1] == '0') d++;
            if (d <= k) {
                return true;
            }
        }
        return false;
    }

    int ok = 0, ng = n + 1;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    writeln(ok);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0){
        cout << 1 << endl;
    }
    if(b==0){
        cout << 2 << endl;
    }
    if(c==0){
        cout << 3 << endl;
    }
    if(d==0){
        cout << 4 << endl;
    }
    if(e==0){
        cout << 5 << endl;
    }

    return 0;
}











Measured memory_bytes: 3588
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int N,M;
	cin >> N;
	cin >> M;

	while (N!=0||M!=0) {
		std::vector< std::vector<int> > all(11);
		int money = M;
		int ex_all = 0;
		int cost;
		int d,e;

		for (int i = 0; i < N; i++) {
			cin >> d;
			cin >> e;
			std::vector<int>::iterator itr = all[e].begin();
			itr = all[e].insert(itr, d);
		}

		for (int i = 10; i > 0 && money > 0; i--) {
			for (std::vector<int>::iterator itr = all[i].begin(); itr != all[i].end(); ++itr) {
				if (*itr < money) {
					money -= *itr;
					*itr = 0;
				}
				else {
					*itr -= money;
					money = 0;
				}
			}

		}
		for (int i = 1; i < 11; i++) {
			for (std::vector<int>::iterator itr = all[i].begin(); itr != all[i].end(); ++itr) {
				ex_all += i * (*itr);
			}
		}
		cout << ex_all << endl;
		cin >> N;
		cin >> M;
	}
	return 0;
}

Measured memory_bytes: 3160
using System;

namespace abc150B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            string temp;
            int Ans = 0;
            for(int i = 0; i <= N-3; i++)
            {
                temp = S.Substring(i, 3);
                if (temp == "ABC")
                    Ans = Ans + 1;
            }
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  int cnt = 0;
  int mx = 0;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    if(a == b){
      cnt++;
    }else{
      cnt = 0;
    }
    chmax(mx,cnt);
  }
  if(mx >= 3){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long dp[3333][3333],a[3333];
bool used[3333][3333];
long dfs(int l,int r)
{
	if(l>r)return 0;
	if(used[l][r])return dp[l][r];
	bool w=n+r-l&1;
	used[l][r]=1;
	long ret;
	if(w)
	{
		ret=max(a[l]+dfs(l+1,r),a[r]+dfs(l,r-1));
	}
	else
	{
		ret=min(-a[l]+dfs(l+1,r),-a[r]+dfs(l,r-1));
	}
	return dp[l][r]=ret;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cout<<dfs(0,n-1)<<endl;
}

Measured memory_bytes: 90496
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}

int main(){
    dcl(n,m);
    m/=2;
    cout<<min((n+m)/2,m)<<endl;
}


Measured memory_bytes: 256
object Main extends App {
  val S = io.StdIn.readLine()
  val map = scala.collection.mutable.Map.empty[String, Int]
  S.foreach { char =>
    val charStr = char.toString
    if (map.contains(charStr)) {
      val count = map(charStr)
      map.put(charStr, count + 1)
    } else {
      map.put(charStr, 1)
    }
  }

  val keysSize = map.keys.size

  if (keysSize == 2 && map.values.forall(_ == 2)) println("Yes")
  else println("No")
}

Measured memory_bytes: 27308
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x/gcd(x, y)*y; }
int mod_pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
int comb(int n, int k) { k = min(k, n - k); int nnn = 1; for (int i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } int kkk = 1; for (int i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
int to_int(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
int DisitSum(int x){ int ret=0; while(x){ ret++;x/=10;} return ret; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return n != 1; }
int extgcd(int a, int b, int& x, int& y) { // ax+by = gcd(a,b) >> gcd(a,b)
    int d = a;
    if(d != 0) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; }
    else { x = 1, y = 0; }
    return 0;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int x,y;
    cin>>x>>y;
    if(x%y==0||y==1){
        cout<<-1<<endl;
    }
    else{
        int a=gcd(x,y);
        if(a==1){
            cout<<x<<endl;
        }
        else{
            for(int i=2;i<10;i++){
                if(x*i%y!=0){
                    cout<<x*i<<endl;
                    return 0;
                }
            }
        }
    }

    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int c[1500][1500];
char x[1500], y[1500];

int lcs(int m, int n) {
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (x[i - 1] == y[j - 1])
	c[i][j] = c[i - 1][j - 1] + 1;
      else if (c[i - 1][j] >= c[i][j - 1])
	c[i][j] = c[i - 1][j];
      else
	c[i][j] = c[i][j - 1];
    }
  }
  return c[m][n];
}

int main(void) {
  int q, xlen, ylen;

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%s", x);
    scanf(" %s", y);
    xlen = strlen(x);
    ylen = strlen(y);
    printf("%d\n", lcs(xlen, ylen));
  }

  return 0;
}



Measured memory_bytes: 7596
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
    int l;
    cin>>n>>l;
    vector<int> ap(n);
    
    int ans1=0;
    for(int i=1;i<=n;i++)
    {
        ans1+=l+i-1;
        ap[i-1]=l+i-1;
    }
    
    int ans=INF;
    
    for(int i=0;i<n;i++)
    {
        if(abs(ap[i])<abs(ans))
        {
            ans=ap[i];
        }
    }
    cout<<ans1-ans<<endl;
}

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

#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	ll a,b; cin>>a>>b;
	if (a==b) {
		cout << 1 << endl;
		return 0;
	}
	int k = 60;
	while ((a>>k&1) == (b>>k&1)) k--;
	a%=1LL<<k; b%=1LL<<k;
	ll kk = k-1;
	while (kk>=0&&!(b>>kk&1)) kk--;
	ll y = (1LL<<(kk+1))-1;
	if (y>=a) cout << (1LL<<(k+1))-a << endl;	
	else cout << 2*((1LL<<k)-a) + y + 1 << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
n = 0


for i in range(N):
    if A[i]%2 ==0:
        n += 1
        if A[i]%3 ==0 or  A[i]%5 ==0:
            count += 1

if n == count:
    print("APPROVED")
else:
    print("DENIED")            





Measured memory_bytes: 3060
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 01/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  cout << (n/2)+(n%2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	vector<vector<ll>>a(n+1,vector<ll>(3)),dp(n+1,vector<ll>(3));
	for(i=1;i<=n;i++)
	    cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[1][0]=a[1][0];dp[1][1]=a[1][1];dp[1][2]=a[1][2];
	for(i=2;i<=n;i++)
	{
	    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
	    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
	    dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}ll ans=max(dp[n][0],dp[n][1]);
	ans=max(ans,dp[n][2]);
	cout<<ans;
	return 0;
}


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

ll mod = 998244353;
const int nax = 4e6+10;
ll fac[nax], inv[nax], ifac[nax];
ll ncr(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < nax; i++) {
    fac[i] = fac[i-1]*i%mod;
    inv[i] = i > 1 ? mod-(mod/i)*inv[mod%i]%mod : 1;
    ifac[i] = ifac[i-1]*inv[i]%mod;
    assert(fac[i]*ifac[i]%mod == 1);
  }
  ll ans = 0;
  for (int k = 0; k <= m && k <= n; k++) {
    if (k%2 != m%2) continue;
    int s = (3*m-k)/2+n;
    ll r = ncr(s-1,n-1);
    (r -= k*ncr(s-1-m,n-1)) %= mod;
    (r -= (n-k)*ncr(s-1-(m+1),n-1)) %= mod;
    (ans += ncr(n,k)*r) %= mod;
  }
  cout << (ans+mod)%mod << endl;
  return 0;

  set<vector<int>> seen;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      if (i == j) continue;
      for (int k = 0; k < 3; k++)
	for (int l = 0; l < 3; l++) {
	  if (k == l) continue;
	  vector<int> v(3,0);
	  v[i] += 2;
	  v[j] += 1;
	  v[k] += 2;
	  v[l] += 1;
	  seen.insert(v);
	}
    }
  for (auto v : seen) {
    if (v[0]%2 + v[1]%2 + v[2]%2 == 0) {
      for (int i : v) cout << i << ' '; cout << endl;
    }
  }
  cout << seen.size() << endl;
}


Measured memory_bytes: 93952
#include <stdio.h>
#include <math.h>

typedef struct {

    double x;
    double y;

} vect;

double dist(vect p1,vect p2) {

  return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));

}

int main(void) {

  vect pos[25];
  int n;

  double area;
  double z;
  double a,b,c;

  int i;

  n=0;

  while(scanf("%lf,%lf",&pos[n].x,&pos[n].y)!=EOF) {

    n++;
    //if(n==5) break;

  }

  area=0.0;

  for(i=1;i<=n-2;i++) {

    a=dist(pos[0],pos[i]);
    b=dist(pos[0],pos[i+1]);
    c=dist(pos[i],pos[i+1]);

    z=(a+b+c)/2.0;

    area+=sqrt(z*(z-a)*(z-b)*(z-c));

  }

  printf("%lf\n",area);

  return 0;

}

Measured memory_bytes: 0
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int dp[maxn][13], n;
string s;
int cal(int i, int r)
{
    if(i==n)
    {
        return r==5;
    }
    int &ret = dp[i][r];
    if(ret!=-1) return ret;
    ret = 0;

    if(s[i]!='?')
    {
        int d = s[i] - '0';
       // cout << i << " " << r << ": " << (r*10+d)%13 << "\n";
        ret=cal(i+1,(r*10+d)%13);
        return ret;
    }
    f0(d,10)
    {
        ret+=cal(i+1,(r*10+d)%13);
        ret%=mod;
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    cin>>s;
    n = s.size();
    mem(dp,-1);
    cout << cal(0,0) << endl;
    return 0;
}


Measured memory_bytes: 15440
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

     for(int i=1;i<10;i++){
       for(int j=1;j<10;j++){
        if(N==i*j){
          System.out.println("Yes");
          return;
        }
       }
     }
      System.out.println("No");
    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}

Measured memory_bytes: 22740
#include<iostream>
using namespace std;
int a[200005];
int cnt[200005];
int findroot(int v){
	return a[v]==v?v:a[v]=findroot(a[v]);
}
int main(){
	int n,m;
	cin>>n;
	cin>>m;
	for(int i=1;i<=n;i++){
		a[i]=i;
		cnt[i]=1;
	}
	int max=0;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		int findrootx=findroot(x);
		int findrooty=findroot(y);
		if(findrootx!=findrooty){
			a[findrooty]=findrootx;
			cnt[findrootx]+=cnt[findrooty];
		}
	}
	for(int i=1;i<=n;i++){
		if(findroot(i)==i){
			if(max<cnt[i]){
				max=cnt[i];
			}
		}
	}
	cout<<max;
	
}


Measured memory_bytes: 5444
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var r, g, b, n int

	fmt.Sscan(getNextLine(scanner), &r, &g, &b, &n)

	arr := make([]int, n+1)
	ans := 0
	for i := 0; i <= n; i += r {
		for j := 0; j <= n; j += g {
			t := i + j
			if t > n {
				break
			}
			arr[t]++
		}
	}
	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j += b {
			t := i + j
			if t > n {
				break
			}
			if t == n {
				ans += arr[i]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n[8],ans[8],p[8] = {1,4,1,4,1,2,1,2};
  int min,best,vmin,v,k;
  while(cin >> n[0]){
    for(i=1;i<8;i++) cin >> n[i];

    for(i=0;i<8;i++){
      ans[i] = 0;
      for(j=0;j<8;j++){
	if(n[j] - p[(j+i)%8] > 0) ans[i] += n[j] - p[(j+i)%8];
      }
    }

    min = ans[0];
    best = 0;
    vmin = 14141212;
    for(i=1;i<8;i++){
      if(min > ans[i]){
	min = ans[i];
	best = i;

	k = 10000000;
	v = 0;
	for(j=0;j<8;j++){
	  v += p[(j+i)%8] * k;
	  k /= 10;
	}
	vmin = v;

      }
    }

    for(i=0;i<8;i++){
     if(min == ans[i]){
	k = 10000000;
	v = 0;
	for(j=0;j<8;j++){
	  v += p[(j+i)%8] * k;
	  k /= 10;
	}
	if(vmin > v){
	  vmin = v;
	  best = i;
	}
      }
    }

    for(i=0;i<7;i++) cout << p[(best+i)%8] << " ";
    cout << p[(best+7)%8] << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#define MOD 10007LL
#define INF 10000000000000LL
#define MAX 100001
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
int main() {    
    int n,k;
    cin>>n>>k;
    int x,y;
    int a[5001][5001]={};
    for(int i=0;i<n;i++){
        char c;
        cin>>x>>y>>c;
        if(c=='W'){
            x+=k;
        }
        x%=2*k;
        y%=2*k;
        for(int j=0;j<4;j++){
            for(int kk=0;kk<4;kk++){
                int xx=x%k+j*k+1;
                int yy=y%k+kk*k+1;
                if((xx+yy)%(2*k)!=(x+y+2)%(2*k)){
                    continue;
                }
                if(xx+k<4*k&&yy+k<4*k){
                    a[xx][yy]++;
                    a[xx+k][yy]--;
                    a[xx][yy+k]--;
                    a[xx+k][yy+k]++;
                }
            }
        }
    }
    for(int i=0;i<4*k;i++){
        for(int j=1;j<4*k;j++){
            a[i][j]+=a[i][j-1];
        }
    }
    int ans=0;
    for(int i=1;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            a[i][j]+=a[i-1][j];
            ans=max(ans,a[i][j]);
        }
    }
    cout<<ans<<endl;
}

                           


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

int main() {
  int a,b;
  cin>>a;
  vector<int> vec(a);
  vector<int> vecT(a);
  for(int i=0;i<a;i++){
  	cin>>vec.at(i);    
  }
  for(int i=0;i<a;i++){
  	vecT.at(i) = i+1;
  }
 
  b=0;
  for(int i=0;i<a;i++){
  	if(vec.at(i)!=vecT.at(i))
      b++;
  }
  
  if(b==2||b==0)
  cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  
  
  return 0;
}
  

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

int main() {
	int n;
	cin >> n;
	int num[4]={};
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		num[a % 4]++;
	}
	string ans = "No";
	if (num[2] > 1) {
		int key = n - num[2] - num[0];
		if (key <= num[0])ans = "Yes";
	}
	else {
		if (n - num[0] - 1 <= num[0])ans = "Yes";
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] data = S.toCharArray();
        int len = data.length;
        long mod = 1000000007;
        long[][] dp = new long[len+1][4];
        dp[0][0] = 1;
        for (int i = 0; i < len; i++) {
            if (data[i] != '?') {
                dp[i + 1][0] += dp[i][0];
                dp[i + 1][0] %= mod;
                dp[i + 1][1] += dp[i][1];
                dp[i + 1][1] %= mod;
                dp[i + 1][2] += dp[i][2];
                dp[i + 1][2] %= mod;
                dp[i + 1][3] += dp[i][3];
                dp[i + 1][3] %= mod;
            } else {
                dp[i + 1][0] += dp[i][0] * 3;
                dp[i + 1][0] %= mod;
                dp[i + 1][1] += dp[i][1] * 3;
                dp[i + 1][1] %= mod;
                dp[i + 1][2] += dp[i][2] * 3;
                dp[i + 1][2] %= mod;
                dp[i + 1][3] += dp[i][3] * 3;
                dp[i + 1][3] %= mod;
            }
            if (data[i] == 'A' || data[i] == '?') {
                dp[i + 1][1] += dp[i][0];
                dp[i + 1][1] %= mod;
            }
            if (data[i] == 'B' || data[i] == '?') {
                dp[i + 1][2] += dp[i][1];
                dp[i + 1][2] %= mod;
            }
            if (data[i] == 'C' || data[i] == '?') {
                dp[i + 1][3] += dp[i][2];
                dp[i + 1][3] %= mod;
            }
        }
        System.out.println(dp[len][3]);
    }
}


Measured memory_bytes: 30672
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;

class Dice
{
public:
	Dice(int num[6]);
	int check_R(int t,int f);
	int T,F;
private:
	int _num[6];
	int _pattern[6][3];
};

//?????????????????????
Dice::Dice(int num[6])
{
	for (int i = 0; i < 6; i++){
		_num[i] = num[i];
	}

	T = _num[0];
	F = _num[1];

	int buf[6][3] = { { 1, 2, 3 }, { 2, 6, 3 }, { 3, 6, 5 }, { 4, 6, 2 }, { 5, 1, 3 }, { 6, 5, 3 } };
	for (int i = 0; i < 6; i++){
		for (int j = 0; j < 3; j++){
			_pattern[i][j] = buf[i][j];
		}
	}
}

int Dice::check_R(int t, int f){

	int ti, fi, ri;

	for (int i = 0; i < 6; i++){
		if (t == _num[i])ti = i;
		if (f == _num[i])fi = i;
	}

	if (fi == _pattern[ti][1] - 1) ri = _pattern[ti][2] - 1;
	if (fi == _pattern[ti][2] - 1 ) ri = 7 -_pattern[ti][1] - 1;
	if (fi == 7 - _pattern[ti][1] - 1) ri = 7 -_pattern[ti][2] -1;
	if (fi == 7 - _pattern[ti][2] - 1) ri = _pattern[ti][1] -1;

	return _num[ri];
}



int main(){

	int num[6], n, top, front,R;
	char c;

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

	Dice d1(num);

	cin >> n;

	while (n--){
		cin >> top >> front;

		R = d1.check_R(top,front);
		cout << R << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b;

	vector<int> sum = { 0, 0, 0, 0 };

	for (int i = 0; i < 3; i++) {
		cin >> a >> b;
		a--;
		b--;
		sum[a]++;
		sum[b]++;
	}

	if (*max_element(sum.begin(), sum.end()) < 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] a = new long[N];
		long[] ans = new long[N-1];
		long total = 0,dis = 0;
		for( int i=0; i<N; i++ ){
			a[i] = sc.nextLong();
			total += a[i];
		}
		for( int i=0; i<N-1; i++ ){
			dis += a[i];
			total -= a[i];          
			ans[i] = Math.abs(total-dis);        
		}
		Arrays.sort(ans);
		System.out.println(ans[0]);
	}
}


Measured memory_bytes: 83896
use std::io;


fn main() {
    let (x, y) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    /*
    let ans = ((y / x) as f32).log2();
    println!("{}", ans.floor() as usize + 1);
    */
    let mut ans = 0;
    let mut a = x;
    while a <= y {
        a *= 2;
        ans += 1;
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=2e5+6;
ll total;
void solve(){
		ll n,k;
		cin>>n>>k;
		total=0;
		for ( ll i=k;i<=n+1;i++){
			ll val=n-i;
			val=val*(val+1)/2;

			ll val2=(n*(n+1))/2;

			ll val3=i*(i-1)/2-1;
			val=val2-val-val3;

			total=(total+val)%mod;
		}
		cout<<total<<'\n';
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t=1;
//	cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





Measured memory_bytes: 3656
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
using namespace std;
using namespace std::chrono;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n;--i)
#define pb push_back
#define us unordered_set<lli>
#define um unordered_set<lli>
#define m_p make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define present(c,x)    ((c).find(x) != (c).end())
#define sz(p) p.size()
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define mem(p,v) memset(p,(lli)v,sizeof p);
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
void show(vector<lli> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(vector<int> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(int a[], int arraysize)
{
    for (int i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(lli a[], lli arraysize)
{
    for (lli i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(unordered_set<int> s)
{
    for (auto it = s.begin(); it != s.end(); it++)
    {
        cout << *it << " ";
    }
    cout<<endl;
}
void show(unordered_map<lli,lli> mp)
{
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        cout << it->first << " "<<it->second<<endl;
    }
    cout<<endl;
}

int main()
{
    run;
    lli n,m,ans,k,a,b;
    string s,p;
    cin>>n;
    cout<<n+pow(n,2)+pow(n,3)<<endl;
    return 0;
}



Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!\n";
    else
        cout << ":(\n";
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
V<int> d[5000];
int main(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<"Yes"<<endl;
        cout<<2<<endl;
        cout<<1<<" "<<1<<endl;
        cout<<1<<" "<<1<<endl;
        return 0;
    }
    if(n==3){
         cout<<"Yes"<<endl;
        cout<<3<<endl;
        cout<<2<<" "<<1<<" "<<2<<endl;
        cout<<2<<" "<<3<<" "<<1<<endl;
        cout<<2<<" "<<2<<" "<<3<<endl;
        return 0;
    }
   int now=6;
   int cnt=4;
   while(n>now)now+=cnt++;
   if(now!=n){
       cout<<"No"<<endl;
       return 0;
   }
   cnt--;
   d[0]={1,2};
   d[1]={2,3};
   d[2]={3,1};
   now=4;
   for(int i=3;i<10000;i++){
       for(int j=0;j<i;j++){
           d[i].push_back(now);
           now++;
       }
       if(now-1==n)break;
   }
   now=4;
   for(int i=3;i<10000;i++){
       for(int j=0;j<i;j++){
           d[j].push_back(now);
           now++;
       }
       if(now-1==n)break;
   }
   int t=0;
   while(1){
       if(d[t].size()==0)break;
       t++;
   }
   cout<<"Yes"<<endl;
   cout<<t<<endl;
   for(int i=0;i<10000;i++){
       if(d[i].size()==0)break;
       cout<<d[i].size()<<" ";
       for(int v :d[i])cout<<v<<" ";
       cout<<endl;
   }
}




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

#define int long long
#define ll long long
#define F first 
#define S second 
#define pb push_back
#define ld long double

using namespace std ; 

const int MAXN = 1001 * 1001 , MOD =  1e9 + 7 ;

int a[MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ;
	int n ; 
	cin >> n ; 
	n *= 3 ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] ; 
	sort(a,a+n) ; 
	int ans = 0 ; 
	int cnt = n / 3 ; 
	for(int i = n - 2 ; cnt ; i -= 2 , cnt -- )
		ans += a[i] ; 
	cout << ans << endl ; 
}


Measured memory_bytes: 4352
def linear_search(target, nums):
    for num in nums:
        if num == target:
            return True
    return False

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0
for t in T:
    if linear_search(t, S):
        count += 1
        
print(count)



Measured memory_bytes: 6552
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from random import randrange 
from itertools import accumulate
from bisect import bisect_left
import time
#%%code

def calc(LIST):
    ans=0
    last=[0]*26
    for i in range(len(LIST)):
        a=i+1 #day a0
        x=LIST[i]-1
        #increase
        ans+=S[i][x]
        #decrease
        last[x]=a#update
        temp=0
        for j in range(26):
            temp+=C[j]*(a-last[j])
        #print(ans,temp,"deb")
        ans-=temp
        #print(ans)

    return ans
    
def answerer(c):
    """
    #方針その１
    最初にですが乱択をします。ただし、Cの値に応じてあたりやすさをでかくします
    """    
    acc=list(accumulate(c))
    ret=[]
    for d in range(D):
        temp=randrange(acc[-1]) 
        s=bisect_left(acc,temp)
        ret.append(s+1)
        #print(s+1)
    return ret
    
def resolve():
    global D,C,S
    #input of prob.A
    D,=pin()
    C=[*pin()]#0-indexed
    S=[[*pin()]for i in range(D)]
    answerer(C)


    #print(acc)
    start=time.time()
    max_score=0-max(C)*365*26
    king=[1]*365
    while(time.time()-start<1.8):
        temp=answerer(C)
        challenge=calc(temp)
        if challenge>max_score:
            max_score=challenge
            king=temp[:]
    print(*king,sep="\n")
        
#%%submit!
resolve()

Measured memory_bytes: 86528
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int change(int bit, int digit) {
	int ans = 0;
	int nums[3] = { 3,5,7 };
	bool appear[3] = { false,false,false };
	for (int i = digit; i >= 0; i--) {
		int k = bit / pow(3, i);
		appear[k] = true;
		ans += nums[k] * pow(10, i);
		bit -= pow(3, i) * k;
	}
	return (appear[0] && appear[1] && appear[2] ? ans : -1);
}

int main() {
	int N;
	cin >> N;
	int digit = log10(N);
	int ans = 0;
	for (int i = 2; i < digit; i++) ans += pow(3, i+1) - 3 * pow(2, i+1) + 3;
	for (int i = 0; i < pow(3, digit + 1); i++) {
		int num = change(i, digit);
		if (num > N) break;
		if (num < 0) continue;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int D[1001][1001];

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


	int N = getint(), K = getint();

	int gyaku = 0;
	rep(i, N) {
		int x = getint(), y = getint();
		char c = getcha();
		getcha();
		int k = x / K ^ y / K;
		x = x % K;
		y = y % K;
		if (c == 'W' ^ (k & 1)) {
			gyaku++;
			D[x][y]--;
		}
		else D[x][y]++;
	}

	for (int i = K - 1; i >= 0; i--) {
		for (int j = K - 1; j >= 0; j--) {
			D[i][j] += D[i][j + 1] + D[i + 1][j] - D[i + 1][j + 1];
		}
	}
	int saidai = -1e9;
	rep(i, K) rep(j, K) {
		int kari = D[i][0] + D[0][j] - D[i][j] - D[i][j];
		saidai = max(saidai, kari);
		saidai = max(saidai, D[0][0] - kari);
	}
	printf("%d", gyaku + saidai);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>

#define MAX_M 100000
#define MAX_N 100000

long N, M;
long X[MAX_M];
long diff[MAX_M];

long solve() {
    if (N >= M) return 0;
    long res = X[M-1] - X[0];
    for (int i=0; i<M-1; ++i) diff[i] = X[i+1] - X[i];
    std::sort(diff, diff+M-1, std::greater<long>());
    for (int i=0; i<N-1; ++i) res -= diff[i];
    return res;
}


int main() {
    std::cin >> N >> M;
    for (long i=0; i<M; ++i) {
        std::cin >> X[i];
    }
    std::sort(X, X+M);
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int a,b,c;
  cin >> a >> b >> c;
  if(c%gcd(a,b)==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int n,a,b,c,x;
int y[100];
int rand(int x){
    return (a*x+b)%c;
}
int main(void){
    while(1){
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&x);
        if(n==0) break;
        rep(i,n) scanf("%d",&y[i]);
        int reel=0; int flag=0;
        int idx=0;
        for(int i=0;i<10001;i++){
            if(x==y[reel]) reel++;
            if(reel==n){
                idx=i;
                flag=1;
                break;
            }
            x=rand(x);
        }
        if(flag) printf("%d\n",idx);
        else printf("-1\n");
    }
}



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

int main()
{
    int a, b;
    cin >> a >> b;
    int times = max(a, b), c = min(a, b);
    rep(i, times) cout << c;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256