akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var ABK = ReadInts ();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];
            var min = Math.Min (A, B);
            var divisor = Enumerable.Range (1, min).Reverse ().Where (x => A % x == 0 && B % x == 0);
            // PrintEnum (divisor);
            Console.WriteLine (divisor.ElementAt (K - 1));
        }
        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  auto v=divisor(m);
  
  ll ans=1;
  for(auto e: v){
    if(m-e*(n-1)>0 && (m-e*(n-1))%e==0) chmax(ans,e);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=100000;
int n,m;
vector<int> nei[N+1];
int dp[N+1];
bool vis[N+1];//是否访问过 
int ans;
void dfs(int x){//记忆花搜索 
	if(vis[x])return;
	vis[x]=true; 
	for(int i=0;i<nei[x].size();i++)dfs(nei[x][i]),dp[x]=max(dp[x],dp[nei[x][i]]+1);//转移 
	ans=max(ans,dp[x]);//目标 
}
int main(){
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);
	}
	for(int i=1;i<=n;i++)dfs(i);
	cout<<ans;
	return 0;
}
/*1
4 5
1 2
1 3
3 2
2 4
3 4
*/
/*2
6 3
2 3
4 5
5 6
*/
/*3
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/

Measured memory_bytes: 7552
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    ll N; cin >> N;
    vector<ll> A(N, 0), Cum(N,0);
    rep(i, N) cin >> A[i];

    Cum[0] = A[0];
    for (int i = 1; i < N; ++i) Cum[i] = (Cum[i - 1] + A[i]) % MOD;
    
    ll sum = 0;
    rep(i, N - 1) {
        ll thisSum = (Cum[N - 1] - Cum[i]) % MOD;
        if (thisSum < 0) thisSum += MOD;
        sum += (A[i] * thisSum);
        sum %= MOD;
    }
    cout << sum << endl;
}

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

    double tmp;
    cin >> tmp;

    return 0;
}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
int d[11],n,m,i,a,b,s,e;
int main(){
while(true) {
memset(d,0,sizeof(d));s=0;
std::cin>>n>>m;if(!n){break;}
for(i=0;i<n;i++){std::cin>>a>>b;d[b]+=a;}
for(i=10;i>=0;i--){e=std::min(d[i],m);m-=e;s+=i*(d[i]-e);}
printf("%d\n",s);}
}

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

int main(void){
  int i,n = 0;
  char w[11], t[1001];

  scanf("%s", w);

  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);

  printf("%d\n",n);

  return 0;
}


Measured memory_bytes: 1976
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
    int ans;
    if(x%y==0)ans=0;
    else ans =1;
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   vector<char> v;
   while(n>0)
   {
       v.pb(char((n%26 - 1 + 26)%26 + 'a'));
       n = (n-1)/26;
   }
   reverse(v.begin(),v.end());
   rep(v.size())
        cout<<v[i];
   
   
   return 0;        
}  
  
          
   


Measured memory_bytes: 3652
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

#include "atcoder/all"
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    // vector<int> as(n); cin >> as;
    segtree<int, op, e> seg(3e5 + 1);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        int maxi = seg.prod(max(0, a - k), min(int(3e5), a + k) + 1);
        seg.set(a, maxi + 1);
        // cerr << a - k << ' ' << a + k << '\n';
        // cerr << a << ' ' << maxi + 1 << ' ' << seg.all_prod() << '\n';
    }
    cout << seg.all_prod() << '\n';
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string s,t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    if(s<t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi pair < int, int>
#define ff first
#define ss second
#define int long long
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"


int32_t main(){
	boost;
	int n, t;
	cin >> n >> t;
	pi a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i].ff >> a[i].ss; 
	sort(a, a + n);
	vector < int > dp(t + 3001 , 0);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		vector < int > ndp = dp;
		for(int j = a[i].ff; j < t + 3001; j++) {
			if(j - a[i].ff < t)
				ndp[j] = max(ndp[j] , dp[j - a[i].ff] + a[i].ss);
			ans = max(ans , ndp[j]);
		}
		dp = ndp;
	} 
	cout << ans << endl;
}

Measured memory_bytes: 3708
use std::cmp::min;

fn read<T: std::str::FromStr>(stdin_lock: &mut std::io::StdinLock, buf: &mut Vec<u8>, delimiter: u8) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a = read(&mut stdin_lock, &mut buf, b' ');
    let b = read(&mut stdin_lock, &mut buf, b' ');
    let c = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(a, b, c));
}

fn solve(a: u8, b: u8, c: u8) -> u8 {
    min(c, b / a)
}

#[test]
fn example1() {
    assert_eq!(4, solve(2, 11, 4))
}

#[test]
fn example2() {
    assert_eq!(3, solve(3, 9, 5))
}

#[test]
fn example3() {
    assert_eq!(0, solve(100, 1, 10))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;

    ll ans = INT_MAX;
    for (ll i = 0; i < S.size() - 2; i++) {
        ans = min(ans, (ll)abs(stoll(S.substr(i, 3)) - 753));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np


if __name__ == '__main__':
  N = int(input())
  A = list(map(int, input().split()))

  num_of_minus = sum([a < 0 for a in A])
  abs_A = [abs(a) for a in A]
  ans = sum(abs_A)

  if (num_of_minus % 2 == 0) or (sum([a == 0 for a in A])>0):
      print(ans)
  else:
      print(ans - 2 * min(abs_A))

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

int main() {
int N;
cin >> N;
vector<int> A(N), B(N), C(N - 1);
for (int i = 0; i < N; i++) {
    cin >> A.at(i);
}
for (int i = 0; i < N; i++) {
    cin >> B.at(i);
}
for (int i = 0; i < N - 1; i++) {
    cin >> C.at(i);
}
int ans = 0;
for (int i = 0; i < N; i++) {
    ans += B.at(A.at(i) - 1);
    if (i != 0 && A.at(i) == A.at(i - 1) + 1) {
        ans += C.at(A.at(i - 1) - 1);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int a,b,c;
  cin >> a >> b >> c;

  ll ans = 0;
  ans = b;
  if (c > b) {
    ans += b;
    c -= b;
    if (c > a) {
      ans += a + 1;
    } else {
      ans += c;
    }
  } else {
    ans += c;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  rep(i,0,3){
    if(s[i]=='7'){
      cout<<"Yes"<<ENDL;
      return 0;
    }
  }
  cout<<"No"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int time[6];
	int ans[3];
	int i, j;
	int s[2];
	int a_s;
	int n;
	
	n = 3;
	while (n--){
		for (i = 0; i < 6; i++){
			scanf("%d", &time[i]);
		}
		
		
		for (i = 0; i < 2; i++){
			s[i] = time[i * 3] * 3600 + time[1 + i * 3] * 60 + time[2 + i * 3];
		}
		
		a_s = s[1] - s[0];
		
		ans[0] = a_s / 3600;
		a_s %= 3600;
		ans[1] = a_s / 60;
		a_s %= 60;
		ans[2] = a_s;
	
		printf("%d %d %d\n", ans[0], ans[1], ans[2]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll n,lar=0,cnt;
	cin >> n;
	ll ab[n][2];
	rep(i,n){
		rep(j,2) cin >> ab[i][j];
		if(lar<ab[i][0]){
			lar=ab[i][0];
			cnt=ab[i][1];
		}
	}
	cout << lar+cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n, a[123321], ans = 1;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) ans = 1ll * ans * __gcd(a[i], i - 1) % 998244353;
	printf("%d", ans);
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3632
import Data.List

main = do
    ss <- getContents
    let (dice1:dice2:_) = map genDice $ lines ss
    if isIdentical dice1 dice2
        then putStrLn "Yes"
        else putStrLn "No"
    

type Dice = (Int, Int, Int, Int, Int, Int)

genDice :: String -> Dice
genDice l = (n1,n2,n3,n4,n5,n6)
  where (n1:n2:n3:n4:n5:n6:_) = map (\x -> read x :: Int) $ words l

isIdentical :: Dice -> Dice -> Bool
isIdentical (d11,d12,d13,d14,d15,d16) (d21,d22,d23,d24,d25,d26) = isSameNums && match123 && match456 && match154
  where
    isSameNums = (sort [d11,d12,d13,d14,d15,d16]) == (sort [d21,d22,d23,d24,d25,d26])
    d2 = (d21,d22,d23,d24,d25,d26)
    match123 = getRight d2 d11 d12 == Just d13
    match456 = getRight d2 d16 d14 == Just d15
    match154 = getRight d2 d11 d15 == Just d14

sides :: Dice -> Int -> [Int]
sides (n1,n2,n3,n4,n5,n6) top
  | top == n1 = [n2,n3,n5,n4,n2]
  | top == n2 = [n1,n4,n6,n3,n1]
  | top == n3 = [n1,n2,n6,n5,n1]
  | top == n4 = [n1,n5,n6,n2,n1]
  | top == n5 = [n1,n3,n6,n4,n1]
  | top == n6 = [n2,n4,n5,n3,n2]
  | otherwise = sides (n1,n2,n3,n4,n5,n6) n1 -- NOT EXPECTED CASE

getRight :: Dice -> Int -> Int -> Maybe Int
getRight dice top front = next (sides dice top) front

next :: [Int] -> Int -> Maybe Int
next []  _ = Nothing
next [x] _ = Nothing
next (x:xs) y
  | x == y    = Just (head xs)
  | otherwise = next xs y


Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, a[111111], b[111111], np = 0, ip = -1;

std::vector<std::vector<int>> G;

class edge_t {
public:
  edge_t(int ii, int jj) {
    if (ii > jj)
      std::swap(ii, jj);

    i = ii;
    j = jj;
  };

public:
  inline bool operator<(const edge_t& e) const {
    if (i != e.i)
      return i < e.i;

    return j < e.j;
  };
  
public:
  int i;
  int j;
};

std::map<edge_t, int> map;


void dfs(int i, int j)
{
  int c = j == 0 ? 1 : 0;

  for (const auto& k : G[i]) {
    edge_t e(i, k);

    if (map.count(e))
      continue;
      
    map[e] = c;
    
    dfs(k, c);
    
    c ++;
    
    if (c == j)
      c ++;
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  G.resize(N);

  for (int i = 0; i < N - 1; i ++) {
    std::cin >> a[i] >> b[i];

    a[i] --;
    b[i] --;

    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  for (int i = 0; i < N; i ++) {
    int n = G[i].size();

    if (n > np) {
      np = n;
      ip = i;
    }
  }
    
  int c = 0;

  for (const auto& k : G[ip])
    map[edge_t(ip, k)] = c ++;

  for (const auto& k : G[ip])
    dfs(k, map[edge_t(ip, k)]);

  std::cout << np << std::endl;

  for (int i = 0; i < N - 1; i ++) {
    edge_t e(a[i], b[i]);

    assert(map.count(e));
    
    std::cout << map[e] + 1 << std::endl;
  }
  
  return 0;
}


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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; ~a; a = edge[a].nxt)
#define GREP(a, b) for (register int& a = cur[b]; ~a; a = edge[a].nxt)

char S[100005];

int sum[100005];

int f[100005], b[100005];

int main () {
    scanf ("%s", S + 1);

    int n = strlen(S + 1);
    b[n] = n;

    f[1] = 1;
    REP (i, 2, n) {
        f[i] = f[i - 1];
        if (S[i] == 'R')
            f[i] = i;
    }
    DREP (i, n - 1, 1) {
        b[i] = b[i + 1];
        if (S[i] == 'L')
            b[i] = i;
    }

    REP (i, 1, n) {
        if (S[i] == 'L') {
            if ((i - f[i]) & 1)
                ++sum[f[i] + 1];
            else
                ++sum[f[i]];
        } else {
            if ((b[i] - i) & 1)
                ++sum[b[i] - 1];
            else
                ++sum[b[i]];
        }
    }

    REP (i, 1, n) printf ("%d ", sum[i]);
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n;
int field[6][6];
char memo[1 << 24];

void printField() {
  REP(y, n) {
    REP(x, n) {
      cout << field[y][x] << " ";
    }
    cout << endl;
  }
}

int encode() {
  int ret = 0;
  REP(y, n) REP(x, n) {
    if (y == 0 && x == 0) { continue; }
    ret |= field[y][x] << ((y * n) + x - 1);
  }
  return ret;
}

int calc(int y, int x) {
  int state = encode();
  if (memo[state] != -1) { return memo[state]; }
  int ret = 100;
  if (x == n) { ret = calc(y + 1, 0); }
  else if (y == n) { ret = 0; }
  else if (field[y][x] == 0) { ret = calc(y, x + 1); }
  else {
    field[y][x] = 0;
    FOREQ(ny, y + 1, n) {
      FOREQ(nx, x + 1, n) {
        field[ny][x] ^=1;
        field[y][nx] ^=1;
        field[ny][nx] ^=1;
        ret = min(ret, calc(y, x + 1) + 1);
        field[ny][x] ^=1;
        field[y][nx] ^=1;
        field[ny][nx] ^=1;
      }
    }
    field[y][x] = 1;
  }
  if (y == 0 && x == 0) { return ret; }
  return memo[state] = ret;
}

int main() {
  while (scanf("%d", &n), n) {
    MEMSET(memo, -1);
    MEMSET(field, 0);
    REP(y, n) REP(x, n) {
      scanf("%d", &field[y][x]);
    }
    REP(y, n) REP(x, n) {
      if (field[y][x] == 1) {
        FOR(ny, y, n) FOR(nx, x, n) {
          field[ny][nx] ^= 1;
        }
        field[y][x] = 1;
      }
    }
    int ans = calc(0, 0);
    while (ans--) { printf("myon"); }
    puts("");
  }
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, d; cin >> n >> d;
    if(2 * d + 1 >= n){
        cout << 1 << endl;
        return 0;
    }else{
        n -= d * 2 + 1;
        int count = 1;
        while(n > 0){
            n -= (1 + 2 * d);
            count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int x;
	int s=0;
	
	for(int i=0;i<4;i++){
		cin>>x;
		s+=x;
	}
	cout<<s/60<<endl;
	cout<<s%60<<endl;

}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

string S;

const int maxn = 2e5 + 5;
int dp[maxn][3];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> S;
    memset(dp, -1, sizeof(dp));
    dp[1][1] = 1;
    int n = S.length();
    if(n > 1){
        dp[2][2] = 1;
        if(S[0] != S[1]){
            dp[2][1] = 2;
        }
    }
    for(int i = 3;i <= n;i++){
        for(int j = 1;j <= 2;j++){
            int k = i - j;
            string str1 = S.substr(i - j, j);
            for(int l = 1;l <= 2;l++){
                if(dp[k][l] == -1){
                    continue;
                }
                string str = S.substr(k - l, l);
                if(str != str1){
                    dp[i][j] = max(dp[i][j], dp[k][l] + 1);
                }
            }
        }
    }
    cout << max(dp[n][1], dp[n][2]) << endl;
    return 0;
}


Measured memory_bytes: 2964
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
long long gekoa[200000] = {};
long long gyaku(long long n){
	if(gekoa[n]) return gekoa[n];
	long long ans = 1;
	long long now = n;
	long long hoge = n;
	long long geko = MAX_MOD-2;
	while(geko != 0){
		if(geko % 2 == 1){
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		geko /= 2;
	}
	return gekoa[hoge] = ans;
}
int main(){
	int n;
	cin >> n;
	long long nya = 1;
	REP(i,n){
		nya *= (long long)(i+1);
		nya %= MAX_MOD;
	}
	REP(i,n){
		gyaku(i+1);
		gekoa[i+1] *= nya;
		gekoa[i+1] %= MAX_MOD;
		gekoa[i+1] += gekoa[i];
		gekoa[i+1] %= MAX_MOD;
	}
	long long ans = 0;
	REP(i,n){
		long long nya;
		cin >> nya;
		long long bobo = gekoa[n-i] + gekoa[i+1] - gekoa[1];
		bobo %= MAX_MOD;
		ans += nya * bobo;
		ans %= MAX_MOD;
		if(ans < 0){
			ans += -ans * MAX_MOD + MAX_MOD;
			ans %= MAX_MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, t;
    cin >> n >> t;
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v));
    vector<vector<ll>> dp(n + 1, vector<ll>(t + 3010, -LINF));
    dp[0][0] = 0;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        ll a = v[i].first, b = v[i].second;
        for (int j = 0; j < t + a; j++) {
            if (j >= a) {
                chmax(dp[i + 1][j], dp[i][j - a] + b);
            }
            chmax(dp[i + 1][j], dp[i][j]);
            chmax(res, dp[i + 1][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 141440
#include <stdio.h>

void swap(int a[],int i,int j){
    int tmp;
    tmp=a[i];
    a[i]=a[j];
    a[j]=tmp;
    
    return;
}

int main(void){
    int i,j;
    
    int n;
    scanf("%d\n",&n);
    
    int a[n];
    for(i=0;i<n;i++)scanf("%d \n",&a[i]);
    
    int q;
    scanf("%d\n",&q);
    
    int b,e;
    while(q--){
        scanf("%d %d\n",&b,&e);
        for(i=b,j=e-1;i<j;i++,j--)swap(a,i,j);
    }
    
    for(i=0;i<n;i++){
        if(i==0)printf("%d",a[i]);
        else printf(" %d",a[i]);
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2048
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int K;
    cin >> K;
    string S;
    cin >> S;

    string ret;
    if (S.size() <= K) {
        ret = S;
    }
    else {
        ret = S.substr(0, K) + "...";
    }
    cout << ret << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
    string s,ans="CODEFESTIVAL2016";
    int cnt=0;
    cin>>s;
    for(int i=0; i<16; i++){
        if(s[i]!=ans[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int n=s.size()-1;
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
        int k=0;
        for(int j=0;j<n;j++){
            if(i>>j&1){
                string t;
                for(int m=k;m<=j;m++){
                    t+=s[m];
                }
                ans+=(ll)atoll(t.c_str());
                k=j+1;
            }
        }
        string t;
        for(int j=k;j<=n;j++){
            t+=s[j];
        }
        ans+=(ll)atoll(t.c_str());
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

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

    string S, T;
    cin >> S >> T;

    vector<char> U(2 * N);
    for(int i = 0; i < N; i++)
    {
        U[2 * i] = S[i];
        U[2 * i + 1] = T[i];
    }
    string ans(U.begin(), U.end());
    cout << ans << endl;
}

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

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

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{

    string x;

    int n;
    cin >> n;
    cin >> x;
    if (n & 1)
    {
        cout << "No";
    }
    else
    {
        int flag = 1;
        for (int i = 0; i < x.size() / 2; i++)
        {
            if (x[i] != x[i + n/2])
            {
                flag = 0;
                break;
            }
        }
        if (!flag)
        {
            cout << "No";
        }
        else
            cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
n = 0
dat = []

swap = 0


def input_file():
    global n, A
    f = open('input', mode='r')
    n = int(f.readline())
    *A, = map(int, f.readline().split(' '))


def input_cmd():
    global n, A
    n = int(input())
    *A, = map(int, input().split(' '))


input_cmd()

# input_file()

ans = 0
for _ in range(n):
    for j in range(n - 1):
        if A[j + 1] < A[j]:
            A[j], A[j + 1] = A[j + 1], A[j]
            ans += 1

# ans = 0
# for _ in range(n):
#     for j in range(n - 1):
#         if A[j + 1] < A[j]:
#             A[j], A[j + 1] = A[j + 1], A[j]
#             ans += 1

print(*A)
print(ans)


Measured memory_bytes: 5612
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#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 repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

// index が条件を満たすかどうか
bool isOK(vector<ll> &v, ll index, ll key) {
    if (v[index] > key)
        return true;
    else
        return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(vector<ll> &v, ll key) {
    //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ng = -1LL;

    // 「index = a.size()-1」が条件を満たさないこともあるので、
    // 初期値は a.size()
    ll ok = (ll)v.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(v, mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    // repv(L) cout << *it << " ";
    // cout << endl;

    ll cnt = 0;

    for (ll i = N - 1; i >= 2; i--) {
        for (ll j = i - 1; j >= 1; j--) {
            ll rest = L[i] - L[j];
            // if (rest > L[j - 1]) continue;
            auto itr = upper_bound(L.begin(), L.end(), rest);
            ll ng = distance(L.begin(), itr);

            if (ng < j) cnt += (j - ng);

            // // ll idx = binary_search(L, rest);

            // cout << "i: " << L[i] << ", j: " << L[j] << ", rest: " << rest
            //      << ", j_idx: " << j << ", ng: " << ng << endl;
            // cnt += (j - idx);
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3548
i1 = input()
i2 = i1.split()

i2[0] = int(i2[0])
i2[1] = int(i2[1])

l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]

if (i2[0] in l1 and i2[1] in l1) or (i2[0] in l2 and i2[1] in l2) or (i2[0] in l3 and i2[1] in l3):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main(){
	int a[3];
	int i,j,t,sum=0;
	while(scanf("%d %d %d",&a[0],&a[1],&a[2])==3){
		sum=0;
		for(i=0;i<3;i++){
			for(j=0;j<2-i;j++){
				if(a[j]>a[j+1]){
					t=a[j];
					a[j]=a[j+1];
					a[j+1]=t;
				}
			}
		}
		for(i=0;i<2;i++){
			sum=sum+fabs(a[i+1]-a[i]);
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 26;
const int N = (int)1e5 + 5;
const int M = 123;

int a[N][3];
int dp[N][3];
int n;

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
            dp[i][j] = -inf;
        }
    }

    for(int i = 0; i < 3; i++)
        dp[0][i] = 0;

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if (k == j)
                    skip;
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
            }
        }
    }

    cout << *max_element(dp[n], dp[n] + 3) << endl;
}

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


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  char c; cin >>c;
  print(('A'<=c and c<='Z')?"A":"a");
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

    int ans = 0;
	for (int i = 0; i < n; ++i) {
	    for (int j = 0; j < m; ++j) {
		    if (a[i][j] == '#') continue;
			
			map<pair<int, int>, int> d;
			queue<pair<int, int>> q;
			q.push({i, j});
			d[{i, j}] = 0;
			while (!q.empty()) {
			    auto p = q.front();
				q.pop();
				ans = max(ans, d[p]);
				int x = p.first;
				int y = p.second;
				
				if (x > 0 && d.count({x - 1, y}) == 0 && a[x - 1][y] == '.') {
				    q.push({x - 1, y});
					d[{x - 1, y}] = d[{x, y}] + 1;
				}
				
				if (y > 0 && d.count({x, y - 1}) == 0 && a[x][y - 1] == '.') {
				    q.push({x, y - 1});
					d[{x, y - 1}] = d[{x, y}] + 1;
				}
				
				if (x + 1 < n && d.count({x + 1, y}) == 0 && a[x + 1][y] == '.') {
				    q.push({x + 1, y});
					d[{x + 1, y}] = d[{x, y}] + 1;
				}
				
				if (y + 1 < m && d.count({x, y + 1}) == 0 && a[x][y + 1] == '.') {
				    q.push({x, y + 1});
					d[{x, y + 1}] = d[{x, y}] + 1;
				}
				
				
			}
			
		}			
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; i * j <= n; j++) {
            sum += i * j;
        }
    }
    cout << sum << endl;
}

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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int m = -10000;
  
  m = max(m, a + b);
  m = max(m, a - b);
  m = max(m, a * b);
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int eval(int n){
  if(n == 3) return 100000;
  if(n == 2) return 200000;
  if(n == 1) return 300000;
  return 0;
}
int main(){
  int x, y; cin >> x >> y;
  int sum = (x == 1 && y == 1 ? 400000 : 0);
  sum += eval(x);
  sum += eval(y);
  cout << sum << endl;
}


Measured memory_bytes: 256
###==================================================
### import
#import bisect
from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
S = sInLV(N)

n_ac = 0
n_wa = 0
n_tle = 0
n_re = 0
for i in range(N):
    if S[i] == 'AC':
        n_ac += 1
    elif S[i] == 'WA':
        n_wa += 1
    elif S[i] == 'TLE':
        n_tle += 1
    else:
        n_re += 1

print('AC x', n_ac)
print('WA x', n_wa)
print('TLE x', n_tle)
print('RE x', n_re)

Measured memory_bytes: 16644
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define EPS (int)1e-9
typedef long long ll;
typedef vector<int> vi;
#define sz(v)		((int)((v).size()))
#define OO 0x3f3f3f3f
#define  ed  '\n'
#define watch(x) cerr << '>' << #x << ':' << x << '\n';
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline int two(int n) { return 1 << n; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
#define IOS std::ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
const ll mod=1e18+9;
const int N=200;
int arr[N];
int main(){
IOS;
int n;
cin>>n;


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

ll cost=1e16;
for (int i = -100; i < 101;++i)
{
	ll tmp=0;
	for (int j = 0; j < n; ++j)
	{
		ll t=(i-arr[j]);
		tmp+=(t*t);
	}
	cost=min(tmp,cost);
}
cout<<cost;
return 0;
}

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){
    
    string s,t;
    cin >> s >> t;
    string x = s;
    int n = s.size();
    for(int i = 0; i< n;i++){
        if(x == t){
            cout <<"Yes"<<endl;
            return 0;
        }
        for(int l =0;l<=i;l++){
            x[l] = s[n-1-i+l];
        }
        for(int l=0;l<=n-2-i;l++){
            x[i+1+l] = s[l];
        }
        //cout << x << endl; 
    }
    cout <<"No" <<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
    

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

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }
  int32_t main()
  {         
    
      IOS
       
        int x,y;
        cin>>x>>y;
        cout<<(x+y+1)/2;
        



      return 0;
  }           

Measured memory_bytes: 256