akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    FOR(i, 1, N) {
        if(i%2==1) {
            vector<ll> divs = divisor(i);
            if(divs.size() == 8) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.14159265358979323846264338327950L
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;
using Graph = vector<vector<int>>;


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: 3584
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;


class Dice {
public:
  int f[6];
  int x, y, cost;
  Dice() {
    f[0] = 1;
    f[1] = 2;
    f[2] = 3;
    f[3] = 6;
    f[4] = 5;
    f[5] = 4;
  }
  bool operator <(const Dice &d) const {
    if(x != d.x) return x < d.x;
    if(y != d.y) return y < d.y;
    for(int i = 0; i < 3; ++i) {
      if(f[i] != d.f[i]) return f[i] < d.f[i];
    }
    return false;
  }

  void rotate(int dx, int dy) {
    int tmp;
    tmp = f[0];
    if(dx == -1) {
      f[0] = f[2];
      f[2] = f[3];
      f[3] = f[5];
      f[5] = tmp;
    } else if(dx == 1) {
      f[0] = f[5];
      f[5] = f[3];
      f[3] = f[2];
      f[2] = tmp;
    }
    x += dx;

    tmp = f[0];
    if(dy == -1) {
      f[0] = f[1];
      f[1] = f[3];
      f[3] = f[4];
      f[4] = tmp;
    } else if(dy == 1) {
      f[0] = f[4];
      f[4] = f[3];
      f[3] = f[1];
      f[1] = tmp;
    }
    y += dy;
  }
};

class Dice2 {
public:
  Dice d;
  int cost;
  Dice2(Dice d, int cost) : d(d), cost(cost) {}
  bool operator <(const Dice2 &d2) const {
    return cost > d2.cost;
  }
};

int h, w;
int M[10][10];
int sx, sy;
int gx, gy;

void solve() {
  const int dx[4] = {1,0,-1,0};
  const int dy[4] = {0,1,0,-1};
  Dice d;
  d.x = sx;
  d.y = sy;
  d.cost = 0;
  priority_queue<Dice2> que;
  que.push(Dice2(d,0));
  set<Dice> vis;
  vis.insert(d);
  while(!que.empty()) {
    const Dice2 d2 = que.top(); que.pop();
    if(d2.d.x == gx && d2.d.y == gy) {
      cout << d2.cost << endl;
      return;
    }

    for(int i = 0; i < 4; ++i) {
      d = d2.d;
      int nx = d.x + dx[i];
      int ny = d.y + dy[i];
      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      d.rotate(dx[i], dy[i]);
      if(vis.find(d) != vis.end()) continue;
      vis.insert(d);
      que.push(Dice2(d, d2.cost + d.f[3]*M[ny][nx]));
    }
  }
}

main() {
  while((cin >> h >> w) && (h || w)) {
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
	cin >> M[i][j];
      }
    }
    cin >> sy >> sx;
    cin >> gy >> gx;
    solve();
  }
}

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

int main() {
 vector<int> v(3);
  cin >> v.at(0) >>  v.at(1) >>  v.at(2);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  cout << 10*v.at(0)+v.at(1)+v.at(2);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int NG = INT_MIN;

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

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

    vector<vector<int> > dp(m+1, vector<int>(9, NG));
    dp[m][0] = 0;
    for(int i=0; i<n; ++i){
        vector<vector<int> > next(m+1, vector<int>(9, NG));
        for(int j=0; j<=m; ++j){     // まだ折っていないサイリウムの本数
            for(int k=0; k<=8; ++k){ // 前回折ったサイリウムの本数
                if(dp[j][k] == NG)
                    continue;

                for(int s=0; s<=min(j, 8); ++s){ // 今回折るサイリウムの本数
                    for(int t=0; t<=s; ++t){     // 今回使用するレベル2のサイリウムの本数
                        for(int u=0; u<=k; ++u){ // 今回使用するレベル1のサイリウムの本数
                            if(t + u > 8)
                                continue;

                            int satisfaction = dp[j][k];
                            if(t + u == 0)
                                satisfaction += c[i];
                            else
                                satisfaction += a[i] * t + b[i] * u;

                            next[j-s][s] = max(next[j-s][s], satisfaction);
                        }
                    }
                }
            }
        }
        dp.swap(next);
    }

    int ret = INT_MIN;
    for(int i=0; i<=m; ++i){
        for(int j=0; j<=8; ++j){
            ret = max(ret, dp[i][j]);
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

bool solve(long long A, long long B, long long C, long long D){

    if(A < B) return false;
    if(A <= C){
        if(B > D) return false;
        else if(A >= B) return true;
    }
    if(D < B) return false;
    if(C >= B) return true;

    if(D%B != 0 && D%B <= B-C-1) return false;

    long long fac = D%B;
    if(fac == 0){
        if(A % B > C) return false;
        else return true;
    }
    for(long long i=0; i<100000; i++){
        if(C-A > 0){
            A += (fac*((C-A)/fac))%B;
            A %= B;
        }
        A = (A + fac) % B;
        if(C < A) return false;
    }
    return true;
}

int main(){
    int T;
    cin >> T;
    vector<long long> A(T), B(T), C(T), D(T);
    for(int i=0; i<T; i++)
        cin >> A[i] >> B[i] >> C[i] >> D[i];

    for(int i=0; i<T; i++)
        cout << (solve(A[i], B[i], C[i], D[i]) ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 3e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
char val[3][60];

void solve()
{
	scanf("%d",&n);
	scanf("%s%s",val[1]+1,val[2]+1);
	ll res;
	int start;
	int pre;
	if(val[1][1]==val[2][1])
	{
		start=2;
		pre=1;
		res=3;
	}
	else
	{
		start=3;
		pre=2;
		res=6;
	}
	while(start<=n)
	{
		if(val[1][start]==val[2][start])
		{
			if(pre==1)
			{
				res*=2;
			}
			pre=1;
			start++;
		}
		else
		{
			if(pre==1)
			{
				res*=2;
			}
			else
			{
				res*=3;
			}
			pre=2;
			start+=2;
		}
		res%=mod;
	}
	printf("%lld\n", res);
}

int main()
{
	solve();
	// system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n, A[100];
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &A[i]);
	for(i=n-1; 0<i; i--) printf("%d ", A[i]);
	printf("%d\n", A[0]);
	return 0;
}


Measured memory_bytes: 2108
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lb(x) x&-x
#define il inline
#define ll long long
#define llu unsigned long long
#define mem(x) memset(x,0,sizeof(x))
#define mem3(x) memset(x,0x3f,sizeof(x))
#define ccA() puts("耐心冷静查代码")
#define cc() puts("谁知盘中餐，粒粒皆辛苦")
#define fo(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define fk(i,j) for(register int i=fir[j];i;i=nxt[i])
#define fv(i,q) for(int i=0;i<q.size();i++)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
    return x*f;
}
inline void write(ll a){
    if(a==0){putchar('0');return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    ll h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    fd(i,h,1)putchar(c1[i]);
    return;
}
inline void write_(ll a){write(a);putchar(' ');}
inline void writeln(ll a){write(a);putchar('\n');}
//-----------------------------------------------------------------
const ll mod=2019,N=1e2;
ll l,r,ans=2020,us;

int main(){
	l=read(),r=read();
	fo(i,l,l+2019){
		fd(j,r,r-2019){
			if(i<j)ans=min(ans,i%mod*j%mod);
		}
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    getline(cin, S);
    while(S.length() - 1){
        stack<char> st;
        bool flag = 0;
        for(char c:S){
            if(c == '[' || c == '(')st.push(c);
            if(c == ']' || c == ')'){
                if(st.size() == 0){
                    flag = 1;
                    break;

                }
                char t = st.top();
                st.pop();
                if(!(t == '[' && c == ']' || t == '(' && c == ')')){
                    flag = 1;
                    break;
                }
            }
        }
        if(!flag && st.size() == 0)cout << "yes" << endl;
        else    cout << "no" << endl;
        getline(cin, S);
    }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll h,w,n;cin>>h>>w>>n;
    ll x,y;cin>>x>>y;
    string s,t;cin>>s>>t;
    reverse(all(s));
    reverse(all(t));
    bool f=1;
    ll l=0,r=0;
    rep(i,n){
        if(r+l==w)f=0;
        if(t[i]=='L'){
            r=max(r-1,0LL);
        }
        if(t[i]=='R'){
            l=max(l-1,0LL);
        }
        if(s[i]=='L'){
            l++;
        }
        if(s[i]=='R'){
            r++;
        }
    }
    if(l>=y||y>=w+1-r)f=0;
    ll u=0,d=0;
    rep(i,n){
        if(u+d==h)f=0;
        if(t[i]=='U'){
            d=max(d-1,0LL);
        }
        if(t[i]=='D'){
            u=max(u-1,0LL);
        }
        if(s[i]=='U'){
            u++;
        }
        if(s[i]=='D'){
            d++;
        }
    }
    if(u>=x||x>=h+1-d)f=0;
    cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 776
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 405;
LL dp[N][N];
int a[N];
LL s[N];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	REP(i, n)s[i + 1] = s[i] + a[i];
	memset(dp, 0x7f, sizeof(dp));
	REP(i, n+1)dp[i][i] = dp[i][i + 1] = 0;
	FOR(w, 2, n + 1) {
		REP(i, n - w + 1) {
			REP(j, w - 1) {
				dp[i][i + w] = min(dp[i][i + w], dp[i][i + j + 1] + dp[i + j + 1][i + w] + s[i + w]- s[i]);
			}
		}
	}
	cout << dp[0][n] << endl;
	return 0;
}

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

int main(void)
{
	int n;
	scanf("%d",&n);
	int *p;
	int *q;
	p = (int *)malloc(sizeof(int)*(n));
	q = (int *)malloc(sizeof(int)*(n));
	int i = 0;
	while (i < n)
	{
		scanf("%d",&p[i]);
		q[i] = 1+i;
		i++;
	}
	int sig = 0;
	i = 0;
	while (i < n)
	{
		if (p[i] != i+1)
			sig++;
		i++;
	}
	if (sig == 2||sig == 0)
		printf("YES\n");
	else
		printf("NO\n");
	return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int a[10001];
int main()
{ 
	int n,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<k;i++)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = (int(i) for i in input().split())
e = 0
f = 0
g = 0
h = 0
j = 0
k = 0
l = 0
m = 0
n = 0
o = 0
count = 0

e = -(-a//c)
f = b // c 
g = f - e + 1 #cの倍数の個数

h = -(-a//d)
j = b // d 
k = j - h + 1 #dの倍数の個数

def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z
    
def lcm(m,n):
  return int(m*n / gcd(m,n))

o = lcm(c,d)
l = -(-a//o)
m = b // o 
n = m - l + 1 #c*dの倍数の個数 

print(b-a+1-g-k+n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/rope>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(int)((s).size())-1]
#define prelast(s) (s)[(int)((s).size())-2]
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
//#define time chas
#define y0 lolik
#define x1 ashkjl
#define y1 fakakaka
#define y2 ololol
#define x2 jejejejej
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("a.in", "r", stdin);freopen("a.out", "w", stdout);
#define ref svyazi
#define int long long
#define ii pair<int, int>
#define llong long long
#define ld long double
#define list spisok

const ld eps = 1e-12;
const ld Pi = acos(-1);
const int md = 1e9 + 7;

using namespace std;
//using namespace __gnu_cxx;


/*
*/


int n, k, v[1000100], a[10010];
int f = 40;
int it = 0;

bool cmp(int x, int y) {

    for(int i = f; i >= 0; i--) {
        if((x&(1ll<<i)) == (y&(1ll<<i)))continue;

        //cout << (x & (1ll << i)) << " " << (y & (1ll << i)) << endl;
        return ((x&(1ll<<i)) > (y&(1ll<<i)));
    }
    return false;
}

int32_t main() {
    //kchay;
    /*while(true) {
        int x, y;
        cin >> x >> y;
        cout << cmp(x, y) << endl;
    }*/
    cin >> n >> k;

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

    for(int i = 1; i <= n; i++) {
        int cnt = 0;
        for(int j = i; j <= n; j++) {
            cnt += a[j];
            //cout << cnt << endl;
            v[it++] = cnt;
        }
    }

    for(; f >= 0; f--) {
        sort(v, v + it, cmp);
        /*cout << "sorted" << endl;

        for(int i = 0; i < it; i++) {
            cout << v[i] << " ";
        }
        cout << endl;*/
        if(v[k - 1]&(1ll<<f)) {
            int l = k - 1, r = it - 1;
            while(r - l > 0) {
                int mid = (l + r + 1) / 2;
                if((v[mid]&(1ll<<f))) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            it = l + 1;
        }
    }
    int ans = v[0];
    //cout << "Added" << endl;
    //cout << v[0] << endl;
    for(int i = 1; i < min(it, k); i++) {
        //cout << v[i] << endl;
        ans &= v[i];
    }
    //cout << "ok?" << endl;

    cout << ans;




    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL n, x, y;
int main(){
    cin>>n>>x>>y;
    if(x > y)swap(x, y);
    if((x & 1) == (y & 1)){
        printf("%lld\n", (y - x) / 2); 
    }
    else{
        LL ans = min((y - x - 1) / 2 + x, (y - x - 1) / 2 + n - y + 1);
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

int n, m;

int main(void)
{
	scanf("%d %d", &n, &m);
	
	if(n < 10)
		printf("%d", (10 - n) * 100 + m);
	else
		printf("%d", m);
	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(m)]

dist = [0] * m

for a, b in ab:
    dist = [0] * m
    for j in range(m):
        dist[j] = abs(a-cd[j][0]) + abs(b-cd[j][1])
    ans = dist.index(min(dist)) + 1
    print(ans)

Measured memory_bytes: 39408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class Hello{
    public static void Main(){
        // Your code here!
        var n = int.Parse(Console.ReadLine());
        //var str = Console.ReadLine();
        //var t = Console.ReadLine();
        string ans = "No";
        if(n >= 30){
            ans = "Yes";
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// stoll(s);
int main()
{
    quick
	ll t;t=1;
    // cin >> t;
	while(t--){
        ll n,k; cin >>n>>k;
        ll a[n];
        rep(i,0,n)cin >>a[i];
        sort(a,a+n);
        ll sum = 0;
        rep(i,0,k)sum+=a[i];
    cout<<sum<<endl;
    }
}

Measured memory_bytes: 3648
import sys

import numpy as np

a = []
b = []

n = int(sys.stdin.readline().strip())

for i in range(n):
    ai, bi = map(int, sys.stdin.readline().strip().split())
    a.append(ai)
    b.append(bi)

l = np.argmax(a)
print(a[l]+b[l])


Measured memory_bytes: 21932
N=gets.to_i
array=gets.chomp.split(" ").map(&:to_i)

ret0=0
e=1
array.each do |a|
    ret0 = ret0 + a*e
    e*=-1
end
rets=[ret0]
(1..(N-1)).each do |n|
    rets[n] = 2*array[n-1] - rets[n-1]
end
puts rets.join(" ")


Measured memory_bytes: 24644
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    string str;
    int n, cnt=0;
    cin >> n;
    cin >> str;
    for(int i=0; i<n-2; i++){
        if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C'){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
#print(n,c,h)
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
    
print(dp[n-1])

Measured memory_bytes: 52208
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w,d;
  cin>>h>>w>>d;
  vector<pll> p(h*w);
  rep(i,h)rep(j,w) {
    ll a;
    cin>>a;
    a--;
    p[a]=mp(i+1,j+1);
  }
  vvll t(d,vll(1));
  vector<pll> f(d);
  rep(i,d){
    t[i][0]=p[i].F+p[i].S;
    f[i]=p[i];
  }
  rep(i,h*w){
    if(i<d) continue;
    t[i%d].pb(t[i%d][sz(t[i%d])-1]+(abs(f[i%d].F-p[i].F)+abs(f[i%d].S-p[i].S)));
    f[i%d]=p[i];
  }
  ll q;
  cin>>q;
  rep(i,q){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    ll a1=a/d;
    ll a2=a%d;
    ll b1=b/d;
    ll b2=b%d;
    COUT(t[b2][b1]-t[a2][a1]);
  }
}


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

using namespace std;

const int N = 1e5 + 5;

vector<int> g[N];
int cost[N][10];

int bfs(int st, int en) {
  queue<pair<int, int>> q;
  q.push({st, 0});
  int cnt = 0;
  while (!q.empty()) {
    int u = q.front().first;
    int c = q.front().second;
    q.pop();
    //cout << u << " " << c << endl;
    if (u == en && c % 3 == 0) {
      return cost[en][c % 3] / 3;
    }
    for (auto v : g[u]) {
      if (!cost[v][(c + 1) % 3]) {
        q.push({v, c + 1});
        cost[v][(c + 1) % 3] = cost[u][c % 3] + 1;
      } else if (cost[u][c % 3] + 1 < cost[v][(c + 1) % 3]) {
        q.push({v, c + 1});
        cost[v][(c + 1) % 3] = cost[u][c % 3] + 1;
      }
    }
//    cnt++;
//    if (cnt == 1e6) break;
  }
  return -1;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
  }
  int st, en;
  scanf("%d %d", &st, &en);
  cout << bfs(st, en);
  return 0;
}


Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
int A[100], B[100];
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	REP(i, 0, N) {
		cin >> B[i];
	}
	
	int sum = 0;
	REP(i, 0, N) {
		sum += A[i];
		A[i] = sum;
	}
	sum = 0;
	REM(i, 0, N) {
		sum += B[i];
		B[i] = sum;
	}

	int ans = 0;
	REP(i, 0, N) {
		ans = max(ans, A[i] + B[i]);
	}
	cout << ans << endl;
	return 0;
}

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

 int main (){
 	int hargaBarang,uangKu=0;
	scanf("%d",&hargaBarang);
// 	for (int i=1000;i<=hargaBarang;i+=1000){
//		uangKu=i;
//	}
	do{
		uangKu+=1000;
	}while(uangKu<hargaBarang);
	
	printf("%d",uangKu-hargaBarang);
}

Measured memory_bytes: 1688
#include<cstdio>
#include<algorithm>
#define MAX 100005
#define MAXV 1000000005
using namespace std;

int main(){
  int n, m, i, s, c = 1, d = 0;
  long long a[MAX], b[MAX], ans = 0;
  scanf("%d%d", &n, &m);
  a[0] = 0;
  for(i = 1; i <= n; i++){
    scanf("%d", &s);
    a[i] = (a[i-1] + s)  % m;
  }
  sort(a, a+n+1);
  a[n+1] = MAXV;
  for(i = 0; i <= n; i++){
    if(a[i] == a[i+1]) c++;
    else{ b[d] = c; c = 1; d++; }
  }
  for(i = 0; i < d; i++){
    ans += b[i] * (b[i]-1) / 2;
  }
  printf("%lld", ans);
}

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

int main() {
  char b;
  cin >> b;
  char result = 'G';
  if (b == 'A') {
    result = 'T';
  }
  if (b == 'T') {
    result = 'A';
  }
  if (b == 'G') {
    result = 'C';
  }
  cout << result << endl;
}


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

char str[MAX];

int main(void)
{
	int K;
	cin >> str >> K;
	long long ans = 0;
	int N = strlen(str);
	int idx = 0;
	while (str[0] == str[idx] && idx < N) idx++;
	if (idx == N)
	{
		long long NN = 1LL * N * K;
		cout << NN / 2 << endl;
		return 0;
	}
	int ridx = N - 1;
	while (str[0] == str[ridx]) ridx--;
	for (int i = idx; i <= ridx; i++)
	{
		if (str[i] == str[i - 1])
		{
			ans += K;
			str[i] = 0;
		}
	}
	ans += idx / 2;
	ans += (N - 1 - ridx) / 2;
	ans += (1LL * (N - 1 - ridx + idx) / 2) * (K - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut v: [i64; n]
    }
    v.sort();
    let mut pos: Vec<i64> = vec![];
    let mut neg: Vec<i64> = vec![];
    neg.push(v[0]);
    let mut i = 1;
    while i < n && v[i] < 0 {
        neg.push(v[i]);
        i += 1;
    }
    if i == n {
        pos.push(neg.pop().unwrap());
    }
    while i < n {
        pos.push(v[i]);
        i += 1;
    }
    println!("{}", pos.iter().cloned().sum::<i64>() - neg.iter().cloned().sum::<i64>());
    let pl = pos.len();
    let nl = neg.len();
    let mut t;
    if pl >= nl {
        t = neg[nl - 1];
        for i in nl..pl {
            println!("{} {}", t, pos[i]);
            t -= pos[i];
        }
        println!("{} {}", pos[nl - 1], t);
        t = pos[nl - 1] - t;
        for i in (0..nl - 1).rev() {
            println!("{} {}", neg[i], t);
            t = neg[i] - t;
            println!("{} {}", pos[i], t);
            t = pos[i] - t;
        }
    } else {
        t = pos[pl - 1];
        for i in pl - 1..nl {
            println!("{} {}", t, neg[i]);
            t -= neg[i];
        }
        for i in (0..pl - 1).rev() {
            println!("{} {}", neg[i], t);
            t = neg[i] - t;
            println!("{} {}", pos[i], t);
            t = pos[i] - t;
        }
    }
}


Measured memory_bytes: 8060
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const ll INF = (1LL << 60);
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/

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

    int n; cin >> n;
    string s; cin >> s;

    int l = -1;
    int r = n;

    rep(i,n){
        if(s[i]=='W'){
            l = i;
            break;
        }
    }

    for(int i=n-1; i>=0; i--){
        if(s[i]=='R'){
            r = i;
            break;
        }
    }

    if(l==-1 || r==n){
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    while(l<r){
        if(s[l]=='W' && s[r]=='R'){
            l++;
            r--;
            ans++;
        }

        if(s[l]=='R') l++;
        if(s[r]=='W') r--;

        //cout << l << " " << r << " " << ans << endl;
    }

    cout << ans << endl;


    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;

int main() {
	
	uint N;
	cin >> N;
	
	vector<uint> a(N);
	for(uint i=0; i<N; i++) cin >> a[i];	
	
	uint ta[2] = {0};
	uint tb[2] = {0};
	uint b0;
	vector<uint> x(N);
	vector<uint> b(N);
	
	for(uint i=0; i<N; i++) {
		cin >> b[i];
		
		if(i == 0) b0 = b[i];
		x[i] = a[i] ^ b0;
		
		bool c = i & 1; 
		ta[c] = a[i];
		tb[c] = b[i];
		
		a[i] ^= ta[!c];
		b[i] ^= tb[!c];
	}
	
	a[0] ^= ta[~N & 1];
	b[0] ^= tb[~N & 1];
	
	//for(uint i=0; i<N; i++) cout << a[i] << " "; cout << endl;
	//for(uint i=0; i<N; i++) cout << b[i] << " "; cout << endl;
	
	vector<int> T(N, 0);
	T[0] = -1;
	T[1] = 0;
	uint j = 0;
	
	for(uint i=2; i<N; i++) {
		if(b[i-1] == b[j]) {
			T[i] = ++j;
		} else if(j > 0) {
			j = T[j];
		}
	}
	
	//for(uint i=0; i<N; i++) cout << T[i] << endl;
	uint i = 0;
	uint k = 0;
	
	while(k < N) {
		if(b[i] == a[(k+i)%N]) { 
			if(i < N - 1) {
				i++;
			} else {
				cout << k << " " << x[k] << endl;
				k += i - T[i];
				i = max(0, T[i]);
			}
		} else {
			k += i - T[i];
			i = max(0, T[i]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();

        var ok = true;

        for (int i = 0; i < S.Length; i++)
        {
            if(i % 2 == 1)
            {
                if (S[i] == 'R')
                    ok = false;

            }
            else
            {
                if (S[i] == 'L')
                    ok = false;
            }
        }

        WriteLine(ok ? "Yes" : "No");
    }
}


Measured memory_bytes: 25880
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

vector<bool> visited;
bool can = false;
bool dfs(const vector<vector<ll>> &g, ll v, ll goal){
    visited[v] = true;
    
    for(auto next_v: g[v]){
        if(next_v == goal) can = true;
        if(visited[next_v]) continue;
        dfs(g, next_v, goal);
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n+1, vector<ll>());
    rep(i, m){
        ll aa, b;
        cin >> aa >> b;
        if(aa == 1) a[aa].push_back(b);
        else{
            if(b == n){
                a[aa].push_back(b);
                a[b].push_back(aa);
            }
        }
    }
    //visited.assign(n+1, false);
    //dfs(a, 1, n);
    rep(i, a[1].size()){
        rep(j, a[a[1][i]].size()){
            if(a[a[1][i]][j] == n){
                can = true;
                break;
            }
        }
    }
    if(can) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,k;
	int ans = 0;
	cin >> n >> k;
	int l[n];
	REP(i,n) cin >> l[i];
	SSORT(l,n);
	REP(i,k) ans+=l[i];
	cout << ans << endl;
}

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

int main(){
  long long a,b;
  cin >> a >> b;
  
  int k;
  cin >> k;
  
  int i=0;
  while (i<k){
    if(i%2 == 0){
      a = a/2;
      b = b + a;
    }else{
      b = b/2;
      a = a + b;
    }
    i++;
  }
  
  cout << a << " " << b << endl;    
}

Measured memory_bytes: 256
A, B, C = map(int, input().split(" "))
cnt = 0

if (A%2 == B%2) and (B%2 == C%2):
    pass
else:
    if A%2 == B%2:
        A += 1
        B += 1
        cnt += 1
    elif A%2 == C%2:
        A += 1
        C += 1
        cnt += 1
    else:
        B += 1
        C += 1
        cnt += 1

ABC = sorted([A, B, C])
cnt += (ABC[2] - ABC[1]) // 2
cnt += (ABC[2] - ABC[0]) // 2
print(cnt)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#define T double
typedef complex<T> pt;
#define x real()
#define y imag()
T dot(pt v, pt w) {return (conj(v)*w).x;}
T cross(pt v, pt w) {return (conj(v)*w).y;}
T orient(pt a, pt b, pt c) {return cross(b-a,c-a);}
T dist(pt a, pt b) {return abs(a-b);}

int main(){
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
	int b[n][3] = {};
	/*b[0][0] = max(a[0][1], a[0][2]);
	b[0][1] = max(a[0][0], a[0][2]);
	b[0][2] = max(a[0][1], a[0][0]);*/
	b[0][0] = a[0][0];
	b[0][1] = a[0][1];
	b[0][2] = a[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<=2;j++){
			b[i][j] = a[i][j] + max(b[i-1][(j+1)%3], b[i-1][(j+2)%3]);
		}
	}
	cout<<max({b[n-1][0], b[n-1][1], b[n-1][2]})<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int v[100005];
int f(int a,int b)
{
    if(b==0)
        return a;
    return f(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    int n,k,sol,ma,mi;
    cin>>n>>k;
    cin>>v[1];
    sol=ma=mi=v[1];
    for(int i=2;i<=n;i++)
    {
        cin>>v[i];
        sol=f(sol,v[i]);
        if(v[i]>ma)
            ma=v[i];
        if(v[i]<mi)
            mi=v[i];
    }
    if(k%sol or k>ma)
    {
        cout<<"IMPOSSIBLE\n";
        return 0;
    }
    cout<<"POSSIBLE\n";
    return 0;
}


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

int main(){
	int i,j;
	int c=0,buf;
	char* s;
	char str[1001];
	scanf("%d%*c",&i);
	for(j=0;j<i;j++){
		c=0;
		while(buf=getchar()){
			if(buf=='\n')
				break;
			str[c]=buf;
			c++;
		}
		str[c]='\0';
		while(s=strstr(str,"Hoshino")){
			*(s+6)='a';
		}
		puts(str);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		String[] line1b = line1.split(" ");
		int n = Integer.parseInt(line1b[0]);
		int m = Integer.parseInt(line1b[1]);
		int l = Integer.parseInt(line1b[2]);

		int[][] matA = new int[n][m];
		int[][] matB = new int[m][l];
		
		long[][] matC = new long[n][l];

		for (int i = 0; i < n; i++) {
			String kari = sc.nextLine();
			String[] strA = kari.split(" ");
			for (int j = 0; j < m; j++) {
				matA[i][j] = Integer.parseInt(strA[j]);
			}
		}

		for (int i = 0; i < m; i++) {
			String kari = sc.nextLine();
			String[] strB = kari.split(" ");
			for (int j = 0; j < l; j++) {
				matB[i][j] = Integer.parseInt(strB[j]);
			}
		}
		
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				for (int k = 0; k < l; k++) {
					matC[i][k] += matA[i][j]*matB[j][k];
				}
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				System.out.print(matC[i][j]);
				if (j != l-1) {
					System.out.print(" ");
				}
			}
			System.out.println("");
		}

	}

}

Measured memory_bytes: 37912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n, l;
  cin >> n >> l;
  arrst(s,n);

  sortall(s);

  rep(i,n){
    cout << s[i];
  }
  cout << "\n";
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

const ll mod = 1000000007;

int main() {
	ll n, m, q;
	cin >> n >> m >> q;
	vector <vector<ll>> grid(n + 1, vector<ll>(n + 1, 0));
	rep(i, m) {
		ll l, r;
		cin >> l >> r;
		grid[l][r]++;
	}
	vector <vector<ll>> sum(n + 2, vector<ll>(n + 2, 0));
	rep(i, n+1) {
		rep(j, n + 1) {
			sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + grid[i][j];
		}
	}
	vector<ll> ans;
	rep(i, q) {
		ll a, b;
		cin >> a >> b;
		auto v = sum[b+1][b+1] - sum[a][b+1] - sum[b+1][a] + sum[a][a];
		ans.push_back(v);
	}
	rep(i, q) {
		cout << ans[i] << endl;
	}
    return 0;
}



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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int N=in();
    ll x=in();
    vector<ll> a;
    ll temp;
    REP(i,N){
        cin>>temp;
        a.push_back(temp);
    }
    int ans;ans=0;
    sort(a.begin(),a.end());
    REP(i,N){
        //debug(a[i]);
        //debug(x);
        if(x-a[i]>=0){
            ans++;
            x-=a[i];
        }else{
            break;
        }
        if(i==N-1&&x>0)ans--;
    }
    print(ans);

}

Measured memory_bytes: 256
//THIS IS THE AATMANIRBHAR SOLUTION I FOUND..!!!!!

#include<bits/stdc++.h>
using namespace std ;
#define int double
// #define int long long
#define pb push_back
#define mp make_pair
#define F first 
#define S second 
#define P push
#define vvi vector<vector<int>>
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define pii vector<pair<int, int>> 
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define sort(v) sort(all(v))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(j,a,b) for(int j=a-1;j>=b;j--) 
#define binod ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e9 + 7 , N1 = 1e7 + 5 ;
int cnt=0,sum=0;

void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    int t1=d/s;
    if(t1<=t)
    cout<<"Yes";
    else cout<<"No";
}

signed main(){
    binod;
    int t1=1;  
    // cin>>t1;
    // cout<<fixed<<setprecision(6);
    while(t1--){ 
        solve();
        cout<<endl;
    }    
}
                                                                            
                                                                            //Don't judge me or anyone
                                                                            //this is life, 
                                                                            //not a reality show
                                                                            

Measured memory_bytes: 3736