akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <set>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n == 3) {
        cout << "2 5 63" << endl;
    } else if (n == 4) {
        cout << "2 5 20 63" << endl;
    } else if (n == 5) {
        cout << "2 5 20 30 63" << endl;
    } else {
        set<int> s;
        int sum = 0;
        REP(i, 2, 30001) {
            int m = i % 6;
            if (m == 0 || m == 2 || m == 3 || m == 4) {
                if (n == 0 && sum % 6 != 0) {
                    n--;
                    if (sum % 6 == 5) {
                        sum += i;
                        s.insert(i);
                        if (sum % 6 == 2) {
                            s.erase(8);
                            sum -= 8;
                        } else if (sum % 6 == 3) {
                            s.erase(9);
                            sum -= 9;
                        }
                    } else {
                        sum += 30000;
                        s.insert(30000);
                        if (sum % 6 == 2) {
                            s.erase(8);
                            sum -= 8;
                        } else if (sum % 6 == 3) {
                            s.erase(9);
                            sum -= 9;
                        }
                    }
                }
                if (n > 0) {
                    s.insert(i);
                    sum += i;
                    n--;
                }
            }
        }

        for (auto &it : s) {
            cout << it << " ";
        }
        cout << endl;
        dump(sum % 6, s.size());
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

using namespace std;

class StringChanger {

public:
   StringChanger(string setText) :
      text{setText}
   {}

   bool Read() {
      string command;
      int a, b;
      string stringA;
      
      if (!(cin >> command)) {return false;}
      if (command == "print") {
         cin >> a >> b;
         Print(a, b);
      } else if (command == "reverse") {
         cin >> a >> b;
         Reverse(a, b);
      } else if (command == "replace") {
         cin >> a >> b >> stringA;
         Replace(a, b, stringA);
      } else {
         return false;
      }
      return true;
   }

private:
   void Print(unsigned int begin, unsigned int end) {
      int count = end - begin + 1;
      for (int i = 0; i < count; ++i) {
         cout << text[begin + i];
      }
      cout << endl;
   }
   void Reverse(unsigned int begin, unsigned int end) {
      for (int i = 0; begin + i < end - i; ++i) {
         char tmpChar = text[begin + i];
         text[begin + i] = text[end - i];
         text[end - i] = tmpChar;
      }
   }
   void Replace(unsigned int begin, unsigned int end, string newString) {
      int count = end - begin + 1;
      for (int i = 0; i < count; ++i) {
         text[begin + i] = newString[i];
      }
   }

   string text;

};

int main() {

   string str;
   cin >> str;
   int n;
   cin >> n;

   StringChanger strcgr(str);
   while (strcgr.Read());

   return  0;

}

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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll H, W;
    string *map;
    bool *ignoredH, *ignoredW;
    cin >> H >> W;
    map = new string[H];
    ignoredW = new bool[W];
    ignoredH = new bool[H];
    for(ll h = 0;h < H;h++) {
        bool flag = true;
        cin >> map[h];
        for(ll w = 0;w < W;w++) {
            if(map[h][w] != '.') flag = false;
        }
        if(flag) ignoredH[h] = true;
    }
    for(ll w = 0;w < W;w++) {
        bool flag = true;
        for(ll h = 0;h < H;h++) {
            if(map[h][w] != '.') flag = false;
        }
        if(flag) ignoredW[w] = true;
    }
    for(ll h = 0;h < H;h++) {
        if(!ignoredH[h]) {
            for(ll w = 0;w < W;w++) {
                if(!ignoredW[w]) cout << map[h][w];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Abc
{
    static void Main()
    {
        string N = Console.ReadLine();
        int CC = 0;
        for (int i = 0; i < N.Length; i++)
        {
            if (char.IsUpper(N, i)) CC += 1;
        }
        if (N.Substring(N.Length-1) == "C" || N.Count(c => c == 'C') >= 2 ||  CC >= 3) Console.WriteLine("WA");
        else if (N.Substring(0, 1) == "A" && 2 <= N.IndexOf("C") && N.IndexOf("C") <= N.Length - 1) Console.WriteLine("AC");
        else Console.WriteLine("WA");
    }

}


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

int main(){
  string s,t;
  cin>>s>>t;
  int l = s.size();
  for(int i = 0; i<l; i++){
    if(s[i] != t[i]){
      cout<<"No"<<endl;
      exit(0);
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3568
import java.math.*

fun main(args: Array<String>) {
    val (Q, H, S, D) = readLine()!!.split(" ").map { it.toLong() }
    var N = readLine()!!.toLong() * 4L
    
    val qPrice = Q
    val hPrice = Math.min(qPrice * 2L, H)
    val sPrice = Math.min(hPrice * 2L, S)
    val dPrice = Math.min(sPrice * 2L, D)
    
    var ans = 0L
    
    ans += dPrice * (N / 8L)
    N %= 8L
    
    ans += sPrice * (N / 4L)
    N %= 4L
    
    ans += hPrice * (N / 2L)
    N %= 2L
    
    ans += qPrice * N

    println(ans)
}


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

const int N = 1e5;

int n;
int li[N+5];

int main(){
	scanf("%d",&n);
	int mini = N+5;
	int maksi = -1;
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
		mini = min(mini,li[i]);
		maksi = max(maksi,li[i]);
	}
	if(maksi - mini > 1){
		printf("No\n");
		return 0;
	}
	if(maksi != mini){
		int cnt = 0;
		for(int i=1;i<=n;i++){
			if(li[i] == mini) cnt++;
		}
		int sisa = n-cnt;
		int butuh = maksi - cnt;
		if(n-cnt >= 2*butuh && butuh > 0){
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	} else {
		if(maksi == n-1){
			printf("Yes\n");
		} else {
			if(n >= 2*maksi){
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    if((a[0]+a[2]-a[1])%2!=(a[2]%2)){
        cout << a[2]-a[1]+(a[1]-a[0]+1)/2+1 << endl;
    }
    else{
        cout << a[2]-a[1]+(a[1]-a[0])/2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
}

int main() {
    int n;
    cin>>n;
    map<string, int> a;
    int x = 0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        a[s]++;
        x=max(x, a[s]);
    }

    vector<string>ans;
    for(auto &p:a){
        if(p.second==x){
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout<<ans.at(i)<<endl;
    }







    return 0;
}


Measured memory_bytes: 26868
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)*}
    };
}

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, 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,
        a: [usize;n],
    }

    let mut order_stu: Vec<Vec<usize>> = Vec::new();
    for i in 0..n {
        let mut data: Vec<usize> = vec![i,a[i]]; 
        order_stu.push(data);
    }

    order_stu.sort_by(|x, y| x[1].cmp(&y[1]));

    for j in order_stu {
        print!("{} ", j[0]+1);
    }

}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
vector<pii> v(n);
rep(i,n){
    int a,b;
    cin >> a >> b;
    v[i] = {a,b};
}

sort(v.begin(), v.end(), [](pii a, pii b) {
    return a.second < b.second;
});

int sum = 0;
bool X = true;
rep(i,n){
    sum += v[i].first;
    if(sum > v[i].second) X = false;
}

if(X) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_V = 1000000;

struct edge {
    ll to, cost;
};
vector<edge> G[MAX_V];

ll d[MAX_V];  // 距離計算

void dfs(ll v, ll p, ll c) {
    d[v] = c;

    for (auto nv : G[v]) {
        if (nv.to == p) continue;  // nv が親 p だったらダメ
        dfs(nv.to, v, c + nv.cost);
    }
}

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

    for (ll i = 0; i < N - 1; i++) {
        ll s, t, c;
        cin >> s >> t >> c;
        s--;
        t--;
        edge et = {t, c};
        G[s].push_back(et);

        edge es = {s, c};
        G[t].push_back(es);
    }

    ll Q, K;
    cin >> Q >> K;
    K--;
    vector<ll> x(Q), y(Q);
    rep(i, Q) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    dfs(K, -1, 0LL);
    // dijkstra(K, N);
    // for (ll i = 0; i < N; i++) cout << i << ": " << d[i] << endl;

    rep(i, Q) { cout << d[x[i]] + d[y[i]] << endl; }

    return 0;
}

Measured memory_bytes: 38288
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    string s;
    cin >> a >> b >> s;
    string res = "Yes";
    for(int i=0; i<s.size(); i++){
        if(i==a){
            res = (s.at(i)=='-')?res:"No";
        }else{
            res = isdigit(s.at(i))?res:"No";
        }
    }
    cout << res << endl;
}


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

int64_t a, b, c, ans;
int main(int argc, char **argv) {

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

   	cin >> a >> b >> c;
    if (b <= c) {
        ans += 2 * b;
        c -= b;
        b = 0;
    } else {
        cout << b + c << endl;
        return 0;
    }

    while (c > 0 && a > 0) {
        c--;
        a--;
        ans++;
    }
    if (c > 0) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def solve():
    N = int(input())
    A = list(map(int,input().split()))
    gcd1 = [0] * N  # [0..a]
    gcd2 = [0] * N  # [a..N-1]
    gcd1[0] = A[0]
    for i in range(1,N):
        gcd1[i] = gcd(gcd1[i-1],A[i])
    gcd2[N-1] = A[N-1]
    for i in range(N-2,-1,-1):
        gcd2[i] = gcd(gcd2[i+1],A[i])

    ans = 0
    ans = max(ans, gcd2[1])
    ans = max(ans, gcd1[N-2])
    for i in range(1,N-1):
        ans = max(ans, gcd(gcd1[i-1], gcd2[i+1]))
    return ans

print(solve())


Measured memory_bytes: 63856
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
int main(){
  int n,m; cin>>n;

  int adj[100][100]={0};
  rep(i,n){
    int r,k,t; cin>>r>>k, r--;
    rep(j,k)cin>>t,adj[r][t-1]=1;
  }
  cin>>m;
  vi frontier,next; frontier.reserve(100),next.reserve(100);
  int cost[100];
  rep(i,m){
    int s,d,v; cin>>s>>d>>v,s--,d--;
    frontier.clear(); frontier.push_back(s);
    rep(j,n)cost[j]=9999; cost[s]=0;
    for(int step=0;step<v-1&&cost[d]==9999;step++){
      next.clear();
      rep(j,frontier.size())rep(h,n)if(adj[frontier[j]][h]&&cost[h]>step+1)
	cost[h]=step+1,next.push_back(h);
      frontier=next;
    }
    if(cost[d]!=9999)cout<<cost[d]+1<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int A[200000];
int main(void){
    int n,m; cin>>n>>m;
    if(n==0){
		if(m==0){
			cout<<0<<" "<<0<<endl;
			return 0;
		}else{
			cout<<-1<<endl;
			return 0;
		}
	}
	if(n==1){
		if(m==0){
			cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
			return 0;
		}else{
			cout<<-1<<endl;
			return 0;
		}
	}
    int x=1;
    for(int i=1;i<=n;i++){
		x=x*2;
	}
	int a=0;
	for(int i=1;i<x;i++){
		a=a^i;
	}
	if(m>=x){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<x;i++){
		if(a^i==m){
			//cout<<i<<endl;
			for(int j=0;j<2*x-1;j++){
				if(j<x-1){
					if(j<i){
						cout<<j<<" ";
						A[j]=j;
					}else{
						cout<<j+1<<" ";
						A[j]=j+1;
					}
				}else if(j==x-1){
					cout<<i<<" ";
				}else{
					cout<<A[x*2-2-j]<<" ";
				}
			}
			cout<<i<<endl;
			return 0;
		}
	}
    
}


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

struct pos {
  double x;
  double y;
};

double dist(struct pos a, struct pos b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

int main(int argc, char const *argv[]) {
  int A, B, H, M;
  scanf("%d %d %d %d", &A, &B, &H, &M);

  double ang_h, ang_m;
  ang_h = 2.0 * M_PI * ((H + M / 60.0) / 12.0);
  ang_m = 2.0 * M_PI * (M / 60.0);

  struct pos h, m;
  h.x = A * cos(ang_h);
  h.y = A * sin(ang_h);
  m.x = B * cos(ang_m);
  m.y = B * sin(ang_m);

  printf("%.16lf\n", dist(h, m));

  return 0;
}


Measured memory_bytes: 2520
from collections import*
input=open(0).readline
n=int(input())
e=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
f=[0]*n
v=[1]+[0]*~-n
q=deque([(0,0)])
while q:
    t,c=q.pop()
    v[t]=1
    f[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
s=[0]*n
v=[0]*~-n+[1]
q=deque([(n-1,0)])
while q:
    t,c=q.pop()
    v[t]=1
    s[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
a=b=0
for i,j in zip(f,s):
    if i<=j:
        a+=1
    else:
        b+=1
if a>b:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 30904
#133 11:06
L,R=map(int,input().split())
a=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        a.append((i*j)%2019)
        
        if (i*j)%2019==0:
            print(0)
            exit(0)
print(min(a))

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

#define int long long
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define printarr(arr, n) for(int i = 0; i < n; i++) cout << arr[i] << " "; cout << endl;
#define pii pair<int,int>
#define mp(x, y) make_pair(x, y)
#define debug(x) cout << "#debug " << x << endl;
#define print2D(arr, n) cout << "\n_____________________\n";  for(int i = 1; i  <= n; i++){	for(int j = 1; j <= n; j++){cout << arr[i][j] << " ";}cout << endl;}cout << "\n_____________________\n";
#define mii map<int,int>
#define printmap(mm) for(map<int,int>::iterator itr = mm.begin(); itr!=mm.end(); itr++) cout << itr->first << "->" << itr->second << " "; cout << endl;
#define iterm(mm) for(map<int,int>::iterator itr = mm.begin(); itr!=mm.end(); itr++)
#define NO cout << "NO"; return 0;
#define MO 1000000007
#define N 500100
#define MX 2000000000

void preprocess(){
	
}

signed main(){
	FAST_IO;
	#ifndef ONLINE_JUDGE
	//freopen("/home/divakar/programs/input.txt","r",stdin);
	//freopen("/home/divakar/programs/output.txt","w",stdout);
	#endif
	clock_t clk = clock();

	preprocess();
	int t=1;
	//cout << " dsf ";
	//cin >> t; 
	while(t--){

		int n;
		cin >> n;
		int arr[n][3];
		for (int i = 0; i < n; ++i)
		{
			cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
		}

		int dp[n][3][3];
		memset(dp,0,sizeof(dp));

		for (int i = 0; i < 3; ++i)
		{
			dp[0][i][0] = arr[0][i];
			dp[0][i][1] = arr[0][i];
			dp[0][i][2] = arr[0][i];
		}

		for (int i = 1; i < n; ++i)
		{
			for (int j = 0; j < 3; ++j)
			{
				for (int k = 0; k < 3; ++k)
				{
					if(j==k) continue;
					dp[i][j][k] = arr[i][j] + max(dp[i-1][k][0],max(dp[i-1][k][1],dp[i-1][k][2]));
				}
			}
		}
		int ans = INT_MIN;

		for (int k = 0; k < 3; ++k)
		{
			for (int l = 0; l < 3; ++l)
			{
				if(k==l) continue;
				ans = max(ans,dp[n-1][k][l]);
			}
		}
		cout << ans << endl;






        
		//cout << "ENDOFTEST "<< t << "\n";
	}









	// #ifndef ONLINE_JUDGE
	// clk = clock() - clk;
	// cout << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk)/CLOCKS_PER_SEC << "\n";
	// #endif
	return 0;
}






















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

int main() {
  using pii = pair<int, int>;
  // これ以降 pii という型名はpair<int, int> と同じ意味で使える
  using vi = vector<int>; // intの1次元の型に vi という別名をつける
  using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
//
//  pii p;
//  p = make_pair(1, 2);
//  int N = 10, M = 20;
//  vvi data(N, vi(M));  // N * M の2次元配列
//
  int a,b,c,k,ans,i;
  i = 0;
  cin >> a >>b >>c >>k;
  if(k <= a){
    ans = k;
  }
  else if(k <= a + b){
    ans = a;
  }
  else {
    ans = b -k;
    ans +=a;
    ans +=a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[300000];
long long A_bits[300000][60];
long long cum_sum_A[300000];
long long cum_sum_bits[300000][60];
const long long MOD = 1000000007;
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        for(int j = 0; j < 60; j++){
            if(((A[i] >> j) & 1) == 1){
                A_bits[i][j] = 1;
            }
        }
    }
    cum_sum_A[0] = A[0];
    for(int j = 0; j < 60; j++){
        cum_sum_bits[0][j] = A_bits[0][j];
    }
    for(int i = 1; i < N; i++){
        cum_sum_A[i] = (A[i] + cum_sum_A[i - 1]) % MOD;
        for(int j = 0; j < 60; j ++){
            cum_sum_bits[i][j] = A_bits[i][j] + cum_sum_bits[i - 1][j];
        }
    }
    
    long long ans = 0;
    for(long long i = 0; i < N; i++){
        long long tmp = cum_sum_A[N - 1] - cum_sum_A[i];
        for(long long j = 0; j < 60; j++){
            if(((A[i] >> j) & 1) == 1){
                //tmp = ((tmp - ((1 << j) * (N  - 1 - i - 
                //    (cum_sum_bits[N - 1][j] - cum_sum_bits[i][j]])) % MOD)) %MOD + MOD) % MOD;
                long long pl = ((((long long) 1 << j) % MOD) * (N - 1 - i - (cum_sum_bits[N - 1][j] - cum_sum_bits[i][j]))) % MOD;
                long long mi = ((((long long) 1 << j) % MOD) * ((cum_sum_bits[N - 1][j] - cum_sum_bits[i][j]))) % MOD;
                tmp = ((tmp - mi) % MOD + MOD) % MOD;
                tmp = (tmp + pl) % MOD;
            }
        }
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    int t = (n + m) * (n + m - 1) / 2;
    cout << t - n * m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int n;
int a[1000005],b[1000005],c[1000005];
int dp[1000005][4];

int rec_dp(int i, int prev){
    if(i == n) return 0;
    if(dp[i][prev] != -1) return dp[i][prev];
    
    int ans = INT_MIN;
    if(prev == 0){
        ans = max(ans, b[i]+rec_dp(i+1,1) );
        ans = max(ans, c[i]+rec_dp(i+1,2) );
    }
    else if(prev == 1){
        ans = max(ans, a[i]+rec_dp(i+1,0) );
        ans = max(ans, c[i]+rec_dp(i+1,2) );
    }
    else if(prev == 2){
        ans = max(ans, b[i]+rec_dp(i+1,1) );
        ans = max(ans, a[i]+rec_dp(i+1,0) );
    }
    else {
        ans = max(ans, a[i]+rec_dp(i+1,0) );
        ans = max(ans, b[i]+rec_dp(i+1,1) );
        ans = max(ans, c[i]+rec_dp(i+1,2) );
    }
    return dp[i][prev] = ans;
}

int solution(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i = 0;i < n;i++) cin>>a[i]>>b[i]>>c[i];
    
    cout<<rec_dp(0,4)<<"\n";
  
    return 0;
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 25104
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N,M = map(int,readline().split())
lines = readlines()
S = [list(map(int,line.split()))[1:] for line in lines[:-1]]
P = list(map(int,lines[-1].split()))

answer = 0
for switch in itertools.product([0,1],repeat=N):
    on = sum(sum(switch[x-1] for x in s) % 2 == p for s,p in zip(S,P))
    if on == M:
        answer += 1
print(answer)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
using namespace std;


int main() {

    using ll = unsigned long long;

    int n;
    ll number = 1;

    cin >> n;

    queue<ll> q;

    for(int i = 1; i <= 9; ++i)
        q.push(i);

    int count = 0;

    while(1) {

        number = q.front(); q.pop();
      //  cout << number << endl;

        count++;
        
        if(count == n)
            break;

        if(number % 10 != 0)
            q.push(number * 10 + number % 10 - 1);
        
        q.push(number * 10 + number % 10);

        if(number % 10 != 9)
            q.push(number * 10 + number % 10 + 1);



    }

   // cout << endl;

    cout << number << endl;

}



Measured memory_bytes: 5100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[][] x = new char[3][];

		x[0] = sc.next().toCharArray();
		x[1] = sc.next().toCharArray();
		x[2] = sc.next().toCharArray();

		int e = 0;
		int d = 0;
		int a = 0;
		int b = -1;
		int c = -1;

		for (int i = 0;; i++){
			if(d == 0 && a == x[0].length) break;
			if(d == 1 && b == x[1].length) break;
			if(d == 2 && c == x[2].length) break;

			if (x[d][e] == 'a') { d = 0; a++; e = a; continue;}
			if (x[d][e] == 'b') { d = 1; b++; e = b; continue;}
			if (x[d][e] == 'c') { d = 2; c++; e = c; continue;}
		}

		if (d == 0) System.out.println("A");
		if (d == 1) System.out.println("B");
		if (d == 2) System.out.println("C");


		sc.close();
	}

}


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

int main(){

    ll n; cin >> n;

    ll sum = 0;
    rep(i, n){
        if((i+1)%3==0) continue;
        if((i+1)%5==0) continue;
        sum += i+1;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>

const int m=998244353;
using namespace std;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}





int32_t main(){
	
	//FIO();
	
	int n,mx;cin>>n>>mx;
	int w[n],v[n],dp[mx+1];
	for(int i=0; i<n; i++){
		cin>>w[i]>>v[i];
	}
	for(int i=0; i<=mx; i++){
		dp[i]=-1;
	}
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int j=mx; j>=0; j--){
			if(dp[j]!=-1 && j+w[i]<=mx)
				dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	
	int ret=dp[0];
	for(int i=0; i<=mx; i++){
		ret=max(ret,dp[i]);
	}	
	
	cout<<ret<<"\n";
	

	return 0;
		
	
		
		
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
   int n,f = 0;
   char arare;
   cin >> n;
   for(int i = 0;i < n;i++){
      cin >> arare;
      if(arare == 'Y'){
         f++;
         break;
      }
   }
   if(f > 0)cout << "Four" << endl;
   else cout << "Three" << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n,m=map(int,input().split())
s=input()
spos=[0]*n
t=input()
tpos=[0]*m
l=n*m//gcd(n,m)
g=gcd(n,m)
ldic={}
flag=True
for i in range(n):
  ldic[1+i*m//g]=s[i]  
for i in range(m):
  if 1+i*n//g in ldic:
    if ldic[1+i*n//g]!=t[i]:
      flag=False
if flag:
  print(l)
else:
  print(-1)

Measured memory_bytes: 16632
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000007LL
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

int h,w,k;
char c[305][305];
int r[305][305];

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin >> h >> w >> k;
  int idx = 1;
  FOR(i,h) FOR(j,w) {
    cin >> c[i][j];
    if (c[i][j] == '#') {
      r[i][j] = idx;
      idx += 1;
    }
  }

  FOR(ii,h) FOR(jj,w) {
    if (c[ii][jj] == '#') {
      //cerr << ii << ' ' << jj << endl;
      int z = r[ii][jj];
      int x = ii;
      int yl = jj, yr = jj;

      //cerr << "A " << xl << ' ' << xr << endl;

      while (yl > 0) {
        bool bad = false;
          if (r[x][yl - 1] != 0) {
            bad = 1;
            break;
          }
        if (bad) break;
        yl--;
      }

      //cerr << "C " << xl << ' ' << xr << endl;

      while (yr < w-1) {
        bool bad = false;
          if (r[x][yr + 1] != 0) {
            bad = 1;
            break;
          }
        if (bad) break;
        yr++;
      }

      //cerr << "D " << yl << ' ' << yr << endl;


        for (int y = yl; y <= yr; y++) {
          r[x][y] = z;
        }
    }
  }

  FOR(ii,h) FOR(jj,w) {
    if (r[ii][jj] != 0) {
      int z = r[ii][jj];
      int i = ii - 1, j = jj;
      while(i >= 0 && r[i][j] == 0) {
        r[i][j] = z;
        i--;
      }
    }
  }

  FOR(j,w) {
    int last = r[0][j];
    FOR(i, h) {
      if (r[i][j] == 0) {
        r[i][j] = last;
      } else {
        last = r[i][j];
      }
    }
  }

  FOR(i,h) {
    FOR(j, w) {
      cout << r[i][j] << ' ';
    }
    cout << endl;
  }

  return 0;
}


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

int main()
{
	long long int n,x,y,i,j;
	cin>>n>>x>>y;
	long long int ans[n]={};
	long long int a;
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			ans[min(j-i,abs(i-x)+abs(j-y)+1)]++;
	for(i=1;i<n;i++)
		cout<<ans[i]<<endl;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const double EPS = 1e-8;

ll comb(ll n, ll k)
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    ll result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, A, B;
    cin >> N >> A >> B;
    vector<ll> V(N);
    rep(i, N) cin >> V[i];

    sort(V.begin(), V.end(), greater<ll>());

    ll last_v = INFLL;
    int must = 0;
    ll sum = 0;

    bool all_same = true;

    rep(i, A) {
        if (V[i] < last_v) {
            last_v = V[i];
            must = 1;
            if (i > 0) all_same = false;
        } else {
            must++;
        }

        sum += V[i];
    }

    int all = 0;
    rep(i, N) {
        if (V[i] == last_v) all++;
    }

    // DUMP2(must, all);
    ll cnt = 0LL;
    if (all_same) {
        for (int i=must; i<=B; i++) {
            // cnt += comb(must+free, i);
            cnt += comb(all, i);
        }
    } else {
        cnt = comb(all, must);
    }

    cout << fixed << setprecision(10) << (double)sum / A << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define PER(i, a, b) for(int i = a; i >= b; i--)
#define LL long long
#define lowbit(x) x &(-x)

inline int read() {
    int x = 0, flag = 1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') flag = - 1;
        ch = getchar();
    }
    while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * flag;
}

int main() {   
    int n = read();
    if(n % 2) cout << n / 2 << endl;
    else cout << (n - 2) / 2 << endl;
	return 0;
}


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

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << "0" << endl;
	}
	else if (a <= 12) {
		cout << b/2 << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int T = int.Parse(input[2]);

        int x = (T / A) * B;
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13140
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

dic = defaultdict(int)

for a in A:
    dic[a] += 1

d_k = len(dic)
to_decri = d_k - K 

d = sorted(dic.items(), key=lambda pair: pair[1], reverse=False)
# print(d)
ans = 0
# print(to_decri)
for i in range(to_decri):
    ans += d[i][1]
print(ans)

Measured memory_bytes: 39736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[100005][2][100];

int main() {
    string S;
    ll D;
    cin >> S >> D;
    ll N = S.size();

    dp[0][0][0] = 1;
    ll m = 0;
    rep(i, N) {
        ll s = S[i] - '0';
        rep(j, D) {
            rep(d, 10) {
                ll to = (j + d) % D;
                if (d < s) (dp[i + 1][1][to] += dp[i][0][j]) %= MOD;
                (dp[i + 1][1][to] += dp[i][1][j]) %= MOD;
            }
        }
        (m += s) %= D;
        dp[i + 1][0][m] = 1;
    }

    cout << (dp[N][0][0] + dp[N][1][0] + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 19256
import math
N = int(input())
M = math.floor(math.sqrt(N))

def F(a,b):
    return max(math.floor(math.log10(a)), math.floor(math.log10(b))) + 1

res = 0

for m in range(1, M+1):
    if N % m == 0:
        res = F(m, N//m)

print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,c[101010];
struct evol{int l,r,len;}a[303030];
bool cmp(evol u,evol v){ return u.len<v.len;}
void add(int x,int d)
{
	for(int i=x;i<=m;i+=(i&-i))
		c[i]+=d;
}
int query(int x)
{
	int res=0;
	for(int i=x;i;i-=(i&-i))
		res+=c[i];
	return res;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].l,&a[i].r),a[i].len=a[i].r-a[i].l+1;
	sort(a+1,a+n+1,cmp);
	int p=1;
	for(int i=1;i<=m;i++)
	{
		while(p<=n&&a[p].len<i)
		{
			add(a[p].l,1);
			add(a[p].r+1,-1);
			p++;
		}
		int sum=0;
		for(int j=0;j<=m;j+=i)
			sum+=query(j);
		printf("%d\n",n-p+1+sum);
	}
	return 0;
}

Measured memory_bytes: 4864
s = int(input())
A = [0 for _ in range(10**6)]
i = 1
a = s
A[a] = 1
while 1:
    i += 1
    if a%2==0:
        a = a//2
    else:
        a = 3*a+1
    if A[a]==1:break
    else:
        A[a] = 1
print(i)

Measured memory_bytes: 10904
implicit none
integer:: n,i,j,count, challenge_divide
integer,allocatable,dimension(:):: a

read(5,*) n
allocate(a(n))
read(5,*) (a(i),i=1,n)

count=0

do j=1,1000
    challenge_divide=0
    
    do i=1, n
        if (mod(a(i),2)==0) then
            challenge_divide=challenge_divide+1
        endif
    enddo
    
    if (challenge_divide==n) then
        count=count+1
        do i=1,n
            a(i)=a(i)/2
        enddo
        
    else
        exit
        
    endif
         
enddo

write(6,*) count

end


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    string s;
    cin >> s;
    int cou = 0;
    int f = 0;
    rep(i, 3){
        if(s.at(i) == s.at(i+1)){
            cou++;
        }else{
            cou = 0;
        }
        if(cou == 2) f = 1;
    }
    if(f == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

vector<ll> h;
ll n, a, b, c;

bool is_ok(ll cnt)
{
    ll base = cnt * b;
    for (auto hi: h)
    if (hi > base)
        cnt -= (hi - base + c - 1) / c;
    return cnt >= 0;
}


int main()
{
    cin >> n >> a >> b;
    c = a - b;
    h.assign(n, 0);
    rep(i, 0, n) cin >> h[i];

    ll left = 0;
    ll right = (1000000000LL + b - 1)/ b;

    while (left != right)
    {
        ll mid = (right + left) / 2LL;
        // cout << left << ' ' << right << ' ' << is_ok(mid) << endl;
        if (is_ok(mid))
            right = mid;
        else
            left = mid + 1LL;
    }
    printf("%lld", left);
    // cout << left << endl;s
    return 0;
}

Measured memory_bytes: 1024
"use strict";

function main(input) {
  input = input.trim().split("");
  if (input[input.length - 1] === "s") {
    input.push("e");
    input.push("s");
  } else {
    input.push("s");
  }
  console.log(input.join(""));
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29712
#include <iostream>
#include<math.h>
using namespace std;
int w,h,n,a,b,c,x1=0,x2,y=0,y2;
int main() {
	cin>>w>>h>>n;
	x2=w;y2=h;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		if(c==1)x1=max(a,x1);else
		if(c==2)x2=min(a,x2);else
		if(c==3)y=max(b,y);else
		y2=min(b,y2);
	}
	if(x2>x1&&y2>y){
	cout<<(x2-x1)*(y2-y)<<endl;
	}else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int x,tmp_500,tmp_5,sum;
        x=scan.nextInt();
        sum = 0;
        tmp_500= x/500;
        sum +=tmp_500*1000;
        tmp_5=(x-tmp_500*500)/5;
        tmp_5*=5;
        sum+=tmp_5;
        System.out.println(sum);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
    int N;
    cin >> N;
    vector<lint> x(N);
    REP(i, N) cin >> x[i];
    vector<lint> frac(N);
    frac[0] = 1;
    FOR(i, 1, N) {
        frac[i] = frac[i-1] * i % MOD;
    }
    lint ans = 0;
    lint last = 0;
    FOR(i, 1, N) {
        lint tmp = 0;
        tmp = (last + 1) * power((lint)i, MOD-2, MOD) % MOD;
        tmp = (tmp + last * power((lint)i, MOD-2, MOD) % MOD * ((lint)i-1) % MOD) % MOD;
        ans = (ans + tmp * frac[N-1] % MOD * (x[i] - x[i-1]) % MOD) % MOD;
        last = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scdl(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   INF 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a, b, c, d, e, f = 0, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
	ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
	ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
	string str, str1, str2;


scll(a);
cout<<a*a+a+a*a*a;
	   
return 0;
}

Measured memory_bytes: 3660
n, m = gets.split.map(&:to_i)
contests = {}

m.times do
  p, s = gets.split
  if contests[p].nil?
    contests[p] = [s]
  else
    contests[p] << s
  end
end

ac_count = 0
wa_count = 0

contests.each_value do |contest|
  if !(contest.include?('AC'))
    next
  else
    contest.each do |c|
      if c == 'AC'
        ac_count += 1
        break
      else
        wa_count += 1
      end
    end
  end
end

puts "#{ac_count} #{wa_count}"



Measured memory_bytes: 31740
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    string s;
    cin>>s;
    
    rep(i,s.size()) {
        if(s[i]=='1') {
            cout<<'9';
        } else{
            cout<<'1';
        }
    }
    cout<<endl;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] A = new int[M];
		int check = N;
		for(int i = 0; i < M; i++) {
			A[i] = Integer.parseInt(sc.next());
			check -= A[i];
		}
		sc.close();
		
		if(check > 0) {
			System.out.println(check);
		}else if(check == 0) {
			System.out.println(0);
		}else {
			System.out.println(-1);
		}
	}

}

Measured memory_bytes: 35128