akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}



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

const int MAX = 1e5+100;
int N,M; // N P, M C. city i 在Y_i年建造在P_i
int P, Y;
int id[MAX];
char ans[MAX][15];
int a[10];

struct Node{
    int I, P, Y;
};

vector<Node> v;

bool cmp(Node a, Node b){
    return a.Y < b.Y;
}

void get(int P, int ID, int I){
    int cur = 0;
    while(P){
        a[cur++] = P % 10;
        P /= 10;
    }
    int i;
    for(i = 0; i < 6 - cur; ++i) ans[I][i] = '0';
    for(; i < 6; ++i) ans[I][i] = a[--cur] + '0';
    cur = 0;
    while(ID){
        a[cur++] = ID % 10;
        ID /= 10;
    }
    for(; i < 12 - cur; ++i) ans[I][i] = '0';
    for(; i < 12; ++i) ans[I][i] = a[--cur] + '0';
    ans[I][12] = '\0';
}

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    while(cin >> N >> M){
        v.clear();
        for(int i = 1; i <= M; ++i){
            cin >> P >> Y;
            v.push_back((Node){i, P, Y});
        }
        sort(v.begin(), v.end(), cmp);
        // 县编号出现年份编号
        memset(id, 0, sizeof id);
        for(auto &x:v){
            int I = x.I;
            P = x.P;
            ++id[P];
            get(P, id[P], I);
        }
        for(int i = 1; i <= M; ++i){
            cout << ans[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int H, W, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W >> A >> B;

    int a = H / A;
    int b = W / B;

    int ans = H * W - a * A * b * B;
    cout << ans << endl;
}


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

void Main(){
    int n;
    cin >> n;
    int a[n], idx[n];
    rep(i, n){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        idx[a[i-1]] = i;
    }
    for(int i = 1; i <= n; i++){
        cout << idx[i] << " ";
    }
    
    
    cout << endl;
}
    
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    Main();
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
seq = []
seq.append(str(input()))
count = 1
while count < n:
  seq.append(str(input()))
  if seq[-2][-1] != seq[-1][0]:
    print("No")
    break
  count += 1
else:
  if len(seq) != len(set(seq)):
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 3060
N = int(input())
resid = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(N) :
    b, f, r, v = map(int, input().split())
    resid[b - 1][f - 1][r - 1] += v

for k in range(4) :
    for j in range(3) :
        line = ""
        for i in range(10) :
            line += " " + str(resid[k][j][i])
        print(line)
    if k == 3 and j == 2 :
        break
    print("#" * 20)




Measured memory_bytes: 5604
# -*- coding:utf-8 -*-
def check(num):
    if num%2:
        return 0
    else:
        return 1

def process(num):
    count = 0
    while(num%2 == 0):
        num //= 2
        count += 1
    return count

if __name__ == "__main__":
    n = int(input())
    a = list(map(process, [ tmp for tmp in list(map(int, input().split())) if check(tmp) ]))
    ans = sum(a)
    print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int n, m;
int v[200];
vector<int> h;
int par[200];
int d[200][200];
vector<PIP> bridge;

int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
}

void unite(int a, int b) {
    int p = find(a), q = find(b);
    if(p == q) return;
    par[p] = q;
}

int main(){
    cin.sync_with_stdio(false);
    while(cin >> n >> m, n | m) {
        memset(d, 0, sizeof(d));
        h.clear(), bridge.clear();

        int k, maxi = 0;
        rep(i, n) {
            cin >> v[i], h.pb(v[i]);
            if (maxi < v[i]) maxi = v[i], k = i;
        }
        sort(all(h));
        uni(h);

        rep(i, m) {
            int a, b, c;
            cin >> a >> b >> c; a--, b--;
            d[a][b] = d[b][a] = c;
            bridge.pb(PIP(c, P(a, b)));
        }
        sort(all(bridge));

        iota(par, par + n, 0);

        int tmp = h.size() - 1;
        rep(i, h.size() - 1) {
            iota(par, par + n, 0);
            rep(j, m) {
                int p = bridge[j].se.fi, q = bridge[j].se.se;
                if (v[p] > h[i] && v[q] > h[i] && find(p) != find(q)) {
                    unite(p, q);
                }
            }

            bool ok = true;
            rep(j, n) if (v[j] > h[i] && find(j) != find(k)) ok = false;

            if (!ok) {
                tmp = i;
                break;
            }
        }

        int cost = 0;
        iota(par, par + n, 0);
        repr(i, tmp) {
            rep(j, m) {
                int p = bridge[j].se.fi, q = bridge[j].se.se;
                if (v[p] > h[i] && v[q] > h[i] && find(p) != find(q)) {
                    cost += bridge[j].fi;
                    unite(p, q);
                }
            }
        }

        rep(j, m) {
            int p = bridge[j].se.fi, q = bridge[j].se.se;
            if (find(p) != find(q)) {
                cost += bridge[j].fi;
                unite(p, q);
            }
        }

        rep(i, n) if (find(0) != find(i)) cost = 0;

        cout << cost << endl;
    }

    return 0;
}

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

int main() {

int W,H,x,y,r;

cin >> W >> H >> x >> y >> r;

if(x>=r && W-x>=r && y>=r && H-y>=r){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}

}


Measured memory_bytes: 3120
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)
 
var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}
 
func nextInt2() (int, int) {
	return nextInt(), nextInt()
}
 
func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}
 
func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}
 
func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}
 
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}
 
func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}
 
func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}
 
func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}
 
func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()
 
	x := nextInts(5)
	for i := range x {
		if x[i] == 0 {
			puts(i + 1)
		}
	}
}

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

/*                          
---------------------------------------------------------------
Aditya Kumar mishra
---------------------------------------------------------------
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    c_p_c();
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);

    if (x > 0 && (x / d) >= k)
    {

        x = x - (k)*d;
        cout << x << endl;
    }
    else
    {
        ll no = x / d;
        x = x - no * d; //spend k to reach as close as possible to 0
        k = k - no;     // remaining k
        if (k % 2 == 0) //even
        {
            cout << abs(x) << endl;
        }
        else // odd 
        {
            cout << min(abs(x - d), abs(x + d));
        }
    }

    return 0;
}

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

using namespace std;

int n, m;
vector<vector<int>> edges;
vector<int> dp;

int dfs(int u){
    if(dp[u] != -1) return dp[u];
    int res = 0;
    for(auto v : edges[u]){
        res = max(res,  1 + dfs(v));
    }
    return dp[u] = res;
}

int main(){
    cin>>n>>m;
    edges.resize(n + 2);
    dp.resize(n+1, -1);
    for(int i = 0; i < m; i++){
        int x, y;
        cin>>x>>y;
        edges[x-1].push_back(y-1);
    }
    for(int i = 0; i < n; i++){
        edges[n].push_back(i);
    }
    int res = dfs(n) - 1;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8696
#include <cstdio>
#include <algorithm>
#define rg register int
#define rep(a, b, c) for(rg a=b; a<=c; ++a)
 
int a[102];
 
inline int read() {
    int x=0; char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
 
int main() {
    int n; n=read();
    int ans=0;
    rep(i, 1, n+n) a[i]=read();
    std::sort(a+1, a+n+n+1);
    for(rg i=1; i<=2*n; i+=2) ans+=a[i];
    printf("%d", ans);
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007  PLEASE!! PLEASE!! HACK MY SOLUTION!!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long[] c = in.nextLongArray(4);
            for (int i = 0; i < 3; ++i) c[i + 1] = Math.min(c[i + 1], 2 * c[i]);
            long n = in.nextLong();
            out.println(c[3] * (n / 2) + c[2] * (n % 2));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
	string s;
	cin>>s;
	int ans=0,now=0;
	for(int i=0;i<3;++i) {
		if(s[i]=='R')
			++now;
		else {
			ans=max(ans,now);
			now=0;
		}
	}
	ans=max(ans,now);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define N 10001
using namespace std;
int n,m,cmp[N],used[N];
vector <int> G[N],rG[N],vs;

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int pos){
  used[pos]=1;
  for(int i=0;i<G[pos].size();i++)
    if(!used[G[pos][i]])dfs(G[pos][i]);
  vs.push_back(pos);
}


void rdfs(int pos,int k){
  used[pos]=1;
  cmp[pos]=k;
  for(int i=0;i<rG[pos].size();i++)
    if(!used[rG[pos][i]])rdfs(rG[pos][i],k);
}

int ssc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int i=0;i<n;i++) if(!used[i])dfs(i);

  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],k++);
  return k;
}


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

  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    add_edge(a,b);
  }
  ssc();
  int q;
  cin>>q;
  while(q--){
    int a,b;
    cin>>a>>b;
    cout<<(cmp[a]==cmp[b])<<endl;
  }

  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int x;
  cin >> x;
  int ret = 1;
  if(x < 1800) ret = 2;
  if(x < 1600) ret = 3;
  if(x < 1400) ret = 4;
  if(x < 1200) ret = 5;
  if(x < 1000) ret = 6;
  if(x < 800) ret = 7;
  if(x < 600) ret = 8;

  cout << ret << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>


using namespace std;
int main()
{/*二日目*/
	long long x,y,i;cin >> x;
	y = 100;
	i = 0;
	while(y<x) {
		y += y / 100;
		i++;
		
	}cout <<i;

	

	
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    int b,x=0,y=0,z=0,n,m,h,k,w,sum=0,ans=0;
    string s[50],t;
    bool f=true;
    cin >> h >> w;
    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1,};
    rep(i,h){
        cin >> s[i];
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;

            sum = 0;
            rep(k,8){
                x = j+dx[k];
                y = i+dy[k];
                if(y<0 || h <= y) continue;
                if(x<0 || w <= x) continue;
                if(s[y][x] == '#') sum++;
            }
            s[i][j] = (char)(sum + '0');
        }
    }
    rep(i,h){
        cout << s[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e5 + 5;
class node {
public:
    int u, v, w;
    node(int a, int b, int c) :u(a), v(b), w(c) {};
};
int fa[maxn];
int getf(int i) { return i == fa[i] ? i : fa[i] = getf(fa[i]); }
vector<node>edge;
bool cmp(const node&a, const node&b){return a.w < b.w;}
class T {
public:
    int value, id;
    bool operator<(const T &a){return value < a.value;}
};
T sx[maxn], sy[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i, j, k, m, n, ta, tb;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        fa[i] = i;
    for (int i = 1; i <= n; ++i)
    {
        cin >> sx[i].value >> sy[i].value;
        sx[i].id = sy[i].id = i;
    }
    sort(sx + 1, sx + n + 1);
    sort(sy + 1, sy + 1 + n);
    for (int i = 1; i < n; ++i)
    {
        edge.push_back(node(sx[i].id, sx[i + 1].id, sx[i+1].value - sx[i].value));
        edge.push_back(node(sy[i].id, sy[i + 1].id, sy[i+1].value - sy[i].value));
    }
    sort(all(edge), cmp);
    ll ans = 0;
    for (int i = 0; i <edge.size(); ++i)
    {
        if (getf(edge[i].u) != getf(edge[i].v))
        {
            ans += edge[i].w;
            fa[getf(edge[i].u)] = getf(edge[i].v);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N;
    cin>>N;
    int *T = new int[N];
    int M;
    unsigned long sum = 0;
    for(int i=0;i<N;i++)
    {
        cin>>T[i];
        sum+=T[i];
    }
    cin>>M;
    int *P = new int[M];
    int *X = new int[M];
    for(int i=0;i<M;i++)
    {
        cin>>P[i]>>X[i];
    }
    unsigned long tmpSum = sum;
    for(int i=0;i<M;i++)
    {
        tmpSum-=T[P[i]-1];
        tmpSum+=X[i];
        cout<<tmpSum<<endl;
        tmpSum = sum;
    }
    return 0;

}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = int(input())
c = [int(input()) for _ in range(n)]
d = [c[0]]
for i in range(1, n):
	if c[i] != d[-1]:
		d.append(c[i])
#print(d)
n = len(d)
rightmost = [-1] * 200001
seg = []
for i in range(n):
	if rightmost[d[i]] >= 0:
		seg.append([rightmost[d[i]], i])
	rightmost[d[i]] = i

#print(seg)
dp = [1 for _ in range(n)]
M = len(seg)
cnt = 0
for i in range(1, n):
	if cnt == M:
		dp[i] = dp[i-1]
	elif i == seg[cnt][1]:
		dp[i] = dp[i-1] + dp[seg[cnt][0]]
		cnt += 1
	else:
		dp[i] = dp[i-1]
	dp[i] %= MOD
print(dp[-1])

Measured memory_bytes: 47120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int start = 1;
  int finish = 2;
  bool finished = false;
  int N;
  cin >> N;
  vector<int> button(N);
  vector<bool> pushed(N);//default is false
  
  for(int i = 0; i < N; i++){
    cin >> button.at(i);
  }
  
  int n = start - 1;
  int count = 0;
  while(pushed.at(n) == false){
    count++;
    if(button.at(n) == finish){
      finished = true;
      break;
    }
    pushed.at(n) = true;
    n = button.at(n) - 1;
  }
  if(finished)
    cout << count << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3700
n = int(input())
cards = [[False]*13 for _ in range(4)]
suits = ["S", "H", "C", "D"]
for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    if suit == "S":
        suit_num = 0
    elif suit == "H":
        suit_num = 1
    elif suit == "C":
        suit_num = 2
    elif suit == "D":
        suit_num = 3
    cards[suit_num][rank-1] = True

for suit in range(4):
    for rank in range(13):
        if cards[suit][rank] is False:
            print("{} {}".format(suits[suit], rank + 1))


Measured memory_bytes: 5608
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local ior = io.input()
local n = ior:read("*n", "*n", "*l")
local mise = {}
for i = 1, n do
  local str = ior:read()
  local s, p = str:match("(%w+) (%d+)")
  p = tonumber(p)
  local tmp = {s, p, i}
  table.insert(mise, tmp)
end
for i = 1, n do
  -- print(unpack(mise[i]))
end
-- os.exit()
table.sort(mise, function(x, y)
  -- print("-")
  -- print(unpack(x))
  -- print(unpack(y))
  if(x[1] ~= y[1]) then
    return x[1] < y[1]
  else
    return x[2] > y[2]
  end
  -- if x[1] < y[1] then
  --   return true
  -- elseif y[1] < x[1] then
  --   return true
  -- else
  --   return x[2] < y[2]
  -- end
end)

for i = 1, n do
  print(mise[i][3])
end


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	int sum=0;
	cin>>a>>b;
	if(a<=0&&b>=0)
	{
		cout<<"Zero"<<endl;
	}
	else if(a>0&&b>0)
	{
		cout<<"Positive"<<endl;
	}
	else if(a<0&&b<0)
	{
		sum=b-a+1;
		if(sum%2==0) cout<<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


# 割り算をしない場合
ans1 = len(make_divisors(N-1)[1:])

# 割り算をする場合
ans2 = make_divisors(N)[1:]
ans3 = []
for i in ans2:
    Nt = N

    if Nt // i == 1:
        ans3.append(i)
        continue

    while True:
        if Nt % i == 0:
            Nt = Nt // i
        else:
            break

    if Nt % i == 1:
        ans3.append(i)

print(ans1 + len(ans3))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<vector<char>> maze(h, vector<char>(w));
    rep(y,h) {
        string s;
        cin >> s;
        rep(x,w) maze[y][x] = s[x];
    }
    vector<int> dx = {0,0,1,-1};
    vector<int> dy = {1,-1,0,0};
    int max_step = 0;
    rep(sx, w) rep(sy, h){
        if(maze[sy][sx] == '#') continue;
        queue<pair<pair<int,int>,int>> que;    
        vector<vector<bool>> seen(h,vector<bool>(w,false));
        seen[sy][sx] = true;
        que.push(make_pair(make_pair(sx,sy),0));
        while(que.size() != 0) {
            int x = que.front().first.first;
            int y = que.front().first.second;
            int step = que.front().second;
            que.pop();
            rep(i,4) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                if(maze[ny][nx] == '#') continue;
                if(seen[ny][nx] == true) continue;
                seen[ny][nx] = true;
                chmax(max_step, step+1);
                que.push(make_pair(make_pair(nx,ny),step+1));
            }
        }
    }
    cout << max_step << endl;
}

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

using namespace std;

int main()
{
  int n, ans = 0;
  scanf("%d", &n);
  bool tr = false;
  int a[n] = {0};

  for (int i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
  }

  while (true)
  {
    for (int i = 0; i < n; i++)
    {
      if (a[i] % 2 != 0)
      {
        tr = true;
        break;
      }
      else
      {
        a[i] /= 2;
      }
    }

    if (tr)
      break;

    ans++;
  }

  printf("%d", ans);
}

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

using namespace std;

int age, cost;

int main()
{
    while(cin >> age >> cost)
    {
        if(age >= 13)
            cout << cost << endl;
        else if(age >= 6)
            cout << cost / 2 << endl;
        else
            cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int main() {
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();
 
    vvl dp(n+1, vl(m+1));  // dp[i+1][j+1] : sのi文字目までとtのj文字目までのLCSの長さ 
    rep(i, n) {
        rep(j, m) {
            if(s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    /*cout << "\n";
    rep(i, n+1) {
        rep(j, m+1) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }*/
 
    string ans = "";
    ll i = n-1;
    ll j = m-1;
    while(i >= 0 && j >= 0) {
        if(dp[i+1][j+1] == dp[i][j+1]) {
            i--;
        }
        else if(dp[i+1][j+1] == dp[i+1][j]) {
             j--;
        }
        else {
            ans = s[i] + ans;
            i--;  j--;
        }
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 70784
loop do
  h, w = gets.split.map(&:to_i)
  break if h.zero? and w.zero?
  land = []
  h.times do
    land << gets.chomp.chars
  end
  r = 0
  h.times do |y|
    w.times do |x|
      if land[y][x]
        r += 1
        c, stack = land[y][x], [[x, y]]
        until stack.empty?
          p, q = stack.pop
          land[q][p] = nil
          [[1, 0], [-1, 0], [0, 1], [0, -1]].each do |i, j|
            a, b = p + i, q + j
            stack << [a, b] if 0 <= a && a < w && 0 <= b && b < h && land[b][a] == c
          end
        end
      end
    end
  end
  p r
end

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

#define NMAX 2010

const ll mod = 1000000000 + 7;
ll n, m;
ll dp[NMAX][NMAX];
ll s[NMAX], t[NMAX];

void init() {
    rep(i, 0, NMAX) {
        rep(j, 0, NMAX) dp[i][j] = 0;
    }
}

int main(){

    // input
    cin >> n >> m;
    rep(i, 0, n) cin >> s[i];
    rep(i, 0, m) cin >> t[i];

    // init dp table
    init();

    // lcs
    rep(i, 1, n+1) {
        rep(j, 1, m+1) {
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            dp[i][j] += (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod;
            dp[i][j] += mod;
            dp[i][j] %= mod;
        }
    }

    // debug
    /*
    rep(i, 0, n+1) rep(j, 0, m+1) {
        fprintf(stderr, "%3lld", dp[i][j]);
        fprintf(stderr, (j == n ? "\n" : " "));
    }
    */

   // print
    cout << (dp[n][m]+1) % mod << endl;

    return 0;
}

Measured memory_bytes: 35192
import sys
import numpy as np

def LI(): return [int(x) for x in sys.stdin.readline().split()]


if __name__ == "__main__":
    h, w = LI()
    a = []
    for _ in range(h):
        row = input()
        if row == '.'*w:
            continue
        else:
            a.append([e for e in row])

    b = []
    a_ = np.array(a).T
    for row in a_:
        if list(row) == ['.']*len(a):
            continue
        else:
            b.append(row)

    b = np.array(b).T
    for row in b:
        print(''.join(row))


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define N 50001
#define M 100011
#define f first
#define s second
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,T;
set<PP> G[M]; // to,cost,y,x
vector<int> g[M],c[M];
vector<P> D[M];
priority_queue<PP,vector<PP>,greater<PP> >Q;  
P dijkstra(int a,int b){
  vector<int>used(n,0);

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,cnt=t.f.s;
    int y=t.s.f, x=t.s.s;
    int pos=g[y][x];
    if(D[y][x]<t.f)continue;
    if(pos==b) return t.f;


    if(used[pos]++){
      if(x+1<g[y].size()){
	int ncost=cost+c[y][x],ncnt=cnt;
	int ny=y,nx=x+1;
	if(D[ny][nx]>P(ncost,ncnt)){
	  D[ny][nx]=P(ncost,ncnt);
	  Q.push(PP(D[ny][nx],P(ny,nx)));
	}
      }
      if(x-1>=0){
	int ncost=cost+c[y][x-1],ncnt=cnt;
	int ny=y,nx=x-1;
	if(D[ny][nx]>P(ncost,ncnt)){
	  D[ny][nx]=P(ncost,ncnt);
	  Q.push(PP(D[ny][nx],P(ny,nx)));
	}
      }
      continue;
    }
    
    for(set<PP>::iterator i=G[pos].begin();i!=G[pos].end();i++){
      int ncost=cost+i->f.s,ncnt=cnt;
      int ny=i->s.f,nx=i->s.s;
      if(pos!=a&&(ny!=y||abs(x-nx)!=1))ncost+=T,ncnt++;
      if(D[ny][nx]>P(ncost,ncnt)){
	D[ny][nx]=P(ncost,ncnt);
	Q.push(PP(D[ny][nx],P(ny,nx)));
      }
    }
    used[pos]++;
  }
  return P(-1,-1);
}

int main(){
  string s,t;
  cin>>m>>T>>s>>t;
  map<string,int> mp;
  mp[s]=n++;
  mp[t]=n++;

  for(int i=0,a;i<m;i++){
    cin>>a;
    D[i].resize(a,P(INF,INF));
    for(int j=0;j<a;j++){
      string str;
      cin>>str;
      if(!mp.count(str))mp[str]=n++;
      if(str==s)D[i][j]=P(0,0);
      if(str==s&&Q.empty())Q.push(PP(P(0,0),P(i,j)));
      g[i].push_back(mp[str]);
    }

    c[i].resize(a-1);
    for(int j=0,pre=g[i][0];j<a-1;j++){
      cin>>c[i][j];
      int pos=g[i][j+1];
      G[pre].insert(PP(P(pos,c[i][j]),P(i,j+1)));
      G[pos].insert(PP(P(pre,c[i][j]),P(i,j)));
      pre=pos;
    }
  }

  P ans=dijkstra(0,1);
  if(ans==P(-1,-1)) cout<<-1<<endl;
  else cout<<ans.f<<" "<<ans.s<<endl;
  return 0;
}

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

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0)break;

    int x[15][15]={};
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	cin >> x[i][j];
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	x[i][n] += x[i][j];
	x[n][j] += x[i][j];
	x[n][n] += x[i][j];
      }
    }
    
    for(int i = 0; i <= n; i++){
      for(int j = 0; j <= n; j++){
	if(j < n){
	  cout.width(5);
	  cout << x[i][j];
	}
	if(j==n){
	  cout.width(5);
	  cout << x[i][j] << "\n";
	}
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1172
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#define MOD 1000000007
using namespace std;
string str;
int d, f[10005][100], len, a[10005], b[10005];
long long ans;
int main() {
    cin >> str;
    cin >> d;
    len = str.size();
    a[0] = 1;
    b[0] = 0;
    for (int i = 0; i < len; i++) {
        for (int j = 0; j < d; j++)
            for (int l = 0; l < 10; l++)
                f[i + 1][(j + l) % d] = (f[i + 1][(j + l) % d] + f[i][j]) % MOD;
        for (int j = 0; j < str[i] - '0'; j++)
            f[i + 1][(b[i] + j) % d] = (a[i] + f[i + 1][(b[i] + j) % d]) % MOD;
        a[i + 1] = a[i];
        b[i + 1] = (b[i] + str[i] - '0') % d;
    }
    ans = f[len][0] - 1;
    if (!b[len]) ans++;
    ans = (ans + MOD) % MOD;
    cout << ans;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007


//逆元で二項係数を計算(MODは素数)　前処理O(n),本計算O(1)
#define MAXN 200000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}

//x^y%MOD
long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}


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

	init();
	int n, a, b, c;
	cin >> n >> a >> b >> c;

	int ab = a + b;

	long long ans = 0;
	long long wt = a * inv[ab] % MOD;
	long long wa = b * inv[ab] % MOD;

	// takahashi
	long long wint = pow_mod(wt, n);
	long long w_a = 1;
	rep(i, n) {
		ans += w_a * wint % MOD * C(n + i - 1, i) % MOD * (n + i) % MOD;

		w_a *= wa;
		w_a %= MOD;
	}

	//aoki
	long long wina = pow_mod(wa, n);
	long long w_t = 1;
	rep(i,n) {
		ans += w_t * wina % MOD * C(n + i - 1, i) % MOD * (n + i) % MOD;

		w_t *= wt;
		w_t %= MOD;
	}

	ans %= MOD;
	ans *= 100;
	ans %= MOD;
	ans *= inv[100 - c];

	ans %= MOD;

	cout << ans << endl;

	


	return 0;
}

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int main() {
	int A,B,C;
	cin>>A>>B>>C;

	int R=max(abs(A-B),(max(abs(B-C),abs(C-A))));
	cout<<abs(A-B)+abs(B-C)+abs(C-A)-R<<endl;


	return 0;
}


Measured memory_bytes: 256
/*
 *  Created on: 12-July-2020
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
#define INF 1000000005
#define PI acos(-1)
#define maxn 1000005

#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"

#define prAr(a, n) {for(int i = 0; i < n; i++) {cout<<a[i]<<" ";} cout<<"\n";}
#define inAr(a, n) for(int i = 0; i < n; i++) cin>>a[i];
#define prMat(a, n, m) {for(int i = 0; i < n; i++) {for(int j = 0; j < m; j++) {cout<<a[i][j]<<" ";} cout<<"\n";} }
#define inMat(a, n, m) {for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; }
#define nl cout<<"\n";

using namespace std;

void solve()
{
    int n; cin >> n;
    int a[n], b[n], c[n];
    fi(i,0,n) cin >> a[i] >> b[i] >> c[i];
    int dp[n+1][3];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    fi(i,1,n+1)
    {
        dp[i][0] = a[i-1] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i-1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i-1] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // freopen("/Users/administrator/Desktop/CODES/compile/testcase","r",stdin);
    // freopen("output.txt","w",stdout);
    // time_t start, end;
    int t = 1;
    // cin >> t;
    // time(&start);
    while(t--)
    {
        solve();
    }
    // time(&end);
    // double time_taken = double(end - start);
    // cerr << "Time taken by program is : " << fixed << time_taken << setprecision(5) << "seconds";
    return 0;
}


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

struct Stable {
	char Mark, Number;
};

void BubbleSort(Stable* Line, int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (Line[j].Number < Line[j - 1].Number) {
				char Case = Line[j].Number;
				Line[j].Number = Line[j - 1].Number;
				Line[j - 1].Number = Case;

				char C = Line[j].Mark;
				Line[j].Mark = Line[j - 1].Mark;
				Line[j - 1].Mark = C;
			}
		}
	}
}

void SelectionSort(Stable* Line, int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j) {
			if (Line[j].Number < Line[minj].Number) {
				minj = j;
			}


		}
		char Case = Line[i].Number;
		Line[i].Number = Line[minj].Number;
		Line[minj].Number = Case;

		char C = Line[i].Mark;
		Line[i].Mark = Line[minj].Mark;
		Line[minj].Mark = C;
	}
}

void Show(Stable* Line, int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) {
			cout << ' ';
		}
		cout << Line[i].Mark << Line[i].Number;
	}
	cout << endl;
}

bool Check(Stable* LineS, Stable* LineB, int N) {
	for (int i = 0; i < N; ++i) {
		if (LineS[i].Mark != LineB[i].Mark) { return false; }
	}
	return true;
}

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

	Stable* LineB = new Stable[N];
	Stable* LineS = new Stable[N];

	for (int i = 0; i < N; ++i) {
		cin >> LineB[i].Mark >> LineB[i].Number;


		LineS[i].Mark = LineB[i].Mark;
		LineS[i].Number = LineB[i].Number;
	}

	BubbleSort(LineB, N);
	SelectionSort(LineS, N);

	Show(LineB, N);
	cout << "Stable" << endl;



	Show(LineS, N);
	if (Check(LineS, LineB, N)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}


	delete[] LineB;
	delete[] LineS;
}


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

int main() {
    int n, h, w, a, b;
    cin >> n >> h >> w;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a >= h && b >= w)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int t[]=new int[n];
		int sum=0;
		for (int i = 0; i < n; i++) {
			t[i]=sc.nextInt();
			sum+=t[i];
}
		int m=sc.nextInt();
		int p[]=new int[m];
		int x[]=new int[m];
		for (int i = 0; i < m; i++) {
			p[i]=sc.nextInt()-1;
			x[i]=sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			System.out.println(sum-t[p[i]]+x[i]);
		}	
		
	}

}

Measured memory_bytes: 10196
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int i=0;
  while(s.at(i)==t.at(i)){
    i++;
    if(i==s.size()) break;
    }
  if(i==s.size()) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int n,m,a,b,ch[50],ok,ans,ch1[50];
vector<int> v[50];
vector<P> v1;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        v1.push_back({a,b});
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(auto y:v1){
        for(int j=0;j<n;j++)ch[j]=0;
        queue<int> que;
        que.push(0);
        ch[0]=1;
        while(!que.empty()){
            int q=que.front();
            que.pop();
            for(auto x:v[q]){
                if(q==y.first&&x==y.second)continue;
                if(x==y.first&&q==y.second)continue;
                if(ch[x]==0){
                    que.push(x);
                    ch[x]++;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(ch[i]==0){ans++;break;}
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;    
    int i = 1;
    int x = i;
    scanf("%d", &n);
    for( int mode = 0; mode < 3; ){
        switch( mode ){
        case 0:        
            x = i;
            if ( x % 3 == 0 ){
                printf(" %d", i);
                mode = 2;
                break;
            }
        case 1:     
            if ( x % 10 == 3 ){
                printf(" %d", i);
                mode = 2;
                break;
            }
            x = x / 10;
            if ( x ){
                mode = 1;
                break;
            }
        case 2:     
            if ( ++i <= n ){
                mode = 0;
                break;
            }
            
            printf("\n");
            mode = 3;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2112