akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static String a = "";
    public static String b = "";
    public static int[][] mm = new int[a.length()][b.length()];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[][] dataset = new String[n][2];
        for (int i = 0 ; i < n ; i++) {
            dataset[i][0] = scanner.next();
            dataset[i][1] = scanner.next();
        }

        for (int p = 0 ; p < n ; p++) {
            a = dataset[p][0];
            b = dataset[p][1];
            mm = new int[a.length()][b.length()];
            for (int i = 0 ; i < mm.length ; i++) {
                for (int j = 0 ; j < mm[i].length ; j++) {
                    mm[i][j] = -1;
                }
            }
            System.out.println(lcs(0, 0));
        }
        scanner.close();
    }

    public static int lcs(int i, int j) {
        if (i < a.length() && j < b.length() && mm[i][j] != -1) {
            return mm[i][j];
        }
        int s = 0;
        if (i == a.length() || j == b.length()) {
            return 0;
        } if (a.charAt(i) == b.charAt(j)) {
            s = lcs(i+1, j+1)+1;
        } else {
            s += Math.max(lcs(i+1,j), lcs(i,j+1));
        }
        mm[i][j] = s;
        return s;
    }

}



Measured memory_bytes: 72796
#include <algorithm>
#include <bitset>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n;
vector<int> a;
bitset<4004000> bs;

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int sum = 0;
  for (int i = 0; i < n; i++)
    sum += a[i];
  bs.set(0);
  for (int i = 0; i < n; i++) {
    bs |= bs << a[i];
  }
  for (int i = (sum + 1) / 2; i <= sum; i++) {
    if (bs[i]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string s;
    cin >> s;
    if (s.size() < 3) {
        cout << s << "\n";
    } else {
        cout << s[2] << s[1] << s[0] << "\n";
    }
}


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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    let mut h = 0;
    for x in v {
        if x >= h {
            h = x;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, K = map(int, input().split())
hs = list(map(int, input().split()))

dp = [0] * N
for i in range(1, N):
    hi = hs[i]
    dp2 = dp[max(0, i-K):i]
    costs = [abs(h - hi) for h in hs[max(0, i-K):i]]
    dp[i] = min([dpj + cost for dpj, cost in zip(dp2, costs)])

print(dp[N-1])


Measured memory_bytes: 53856
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            j = i + 1
        else:
            j = i
        if j == A[i]:
            continue
        else:
            print(0)
            exit()

else:
    for i in range(N):
        if i % 2 == 0:
            j = i
        else:
            j = i + 1
        if j == A[i]:
            continue
        else:
            print(0)
            exit()

print(2 ** (N // 2) % (10 ** 9 + 7))


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<int>vec[8];
bool visited[8];
int dfs(int now,bool){

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    string S=in<string>();
    string T=in<string>();
    if(gcd(N,M)==1){
        if(S[0]==T[0]){
            
        ll ans;
        ans=lcm(N,M);
        cout<<ans<<endl;
        }else{
            print("-1");
        }
        return 0;
    }else{
        int G;
        G=gcd(N,M);
        int n,m;
        n=N/G;m=M/G;
        REP(i,G){
            if(S[n*i]!=T[m*i]){
                print("-1");
                return 0;
            }
        }
        ll ans;
        ans=lcm(N,M);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		ArrayList<String> set = new ArrayList<>();
		for(int i = 0; i < S.length(); i++) {
			set.add(S.substring(i, i + 1));
		}

		String ans = "z";
		String check = "abcdefghijklmnopqrstuvwxyz";
		for(int i = 0; i < check.length(); i++) {
			String tmp = check.substring(i, i + 1);
			if(set.contains(tmp)) {
				if(i == check.length() - 1) {
					System.out.println("None");
					return;
				}
				continue;
			}else {
				ans = tmp;
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 31416
class UnionFind:
  def __init__(self, n):
    self.n = n
    self.g = [i for i in range(n)]
    self.nmembers = [1 for i in range(n)]
  def __len__(self):
    return self.n
  def __str__(self):
    return "group:{}\nnmembers:{}".format(self.g,self.nmembers)
  def __getitem__(self,x):
    return self.whichgroup(x)
  def merge(self, x, y):
    gx = self.whichgroup(x)
    gy = self.whichgroup(y)
    if gx != gy:
      nx = self.nmembers[gx]
      ny = self.nmembers[gy]
      ming = min(gx, gy)
      maxg = gx + gy - ming
      self.g[maxg] = ming
      self.nmembers[maxg] = 0
      self.nmembers[ming] = nx + ny
    
  def whichgroup(self, x):
    if x != self.g[x]:
      self.g[x] = self.whichgroup(self.g[x])
      self.nmembers[x] = 0
      return self.g[x]
    else:
      return x

N, M, K = map(int, input().split())
UF = UnionFind(N)
F = [0 for i in range(N)]
B = [0 for i in range(N)]
#print(UF)
for i in range(M):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  #print("x:{}, y:{}".format(x, y))
  UF.merge(x, y)
  F[x] += 1
  F[y] += 1
for i in range(K):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  
  gx = UF.whichgroup(x)
  gy = UF.whichgroup(y)
  if gx == gy:
    B[x] += 1
    B[y] += 1
#print(UF)
ans = []
for i in range(N):
  ans.append(UF.nmembers[UF[i]]-B[i]-F[i]-1)
print(*ans)
  

Measured memory_bytes: 17064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;

vector <int> v[N];
bool vis[N];
bool ok;
vector <int> f;
int clr[N];

void dfs(int s,int c)
{
    f.pb(s);
    vis[s]=true;
    clr[s]=c;
    for(auto x:v[s]){
        if(!vis[x]){
            dfs(x,(c+1)%2);
        }
        else{
            if(clr[x]==clr[s]) ok=false;
        }
    }
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int i;
    for(i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    } 
    for(i=1;i<=n;i++){
        vis[i]=false;
    }
    ll ans = 0;
    for(i=1;i<=n;i++){
        if(!vis[i]){
            f.clear();
            ok=true;
            dfs(i,0);
            ll lu = (ll)f.size();
            if(ok){
                ll c1=0,c2=0;
                for(int x:f){
                    if(clr[x]==1) c1++;
                    else c2++;
                }
                ans += c1*c2;
            }
            else{
                ans += (lu*(lu-1))/2;
            }
        }
    }

    cout << ans-m << endl;
 
    return 0;
}

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

int main(){

    ll n,m;
    cin>> n >> m;

    if(n*2<=m){
        n*=2;
        cout << (n+m)/4 <<endl;
    }else{
        cout << m/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int n,m; 
    cin >> n >> m; 
    cout << (m * (m - 1) + n * (n - 1))/2; 
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a) {
        cout << k << endl;
        return 0;
    }
    if(k>a&&k<=b+a) {
        cout<<a<<endl;
        return 0;
    }
    if(k>b+a&&k<=a+b+c) {
        cout<<2*a+b-k<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3624
function main(input) {
  const args = input.split(' ');
  const x = parseInt(args[0], 10);
  const a = parseInt(args[1], 10);
  if(x<a){
    console.log(0);
  }else{
    console.log(10);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
using System;
using System.Linq;


namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            int[] abcdek = new int [6];
            for(int i=0;i<6;i++)
            {
                abcdek[i] = int.Parse(Console.ReadLine());
            }
            
            Console.WriteLine(abcdek[4] - abcdek[0] <= abcdek[5] ? "Yay!" : ":(");

        }
    }
}


Measured memory_bytes: 11092
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


x = int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if i**5 - j**5 == x:
            print(i,j)
            sys.exit()

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

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= int(b); --i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m), check(n+1);
	REP(i, m) {
		cin >> a[i] >> b[i];
	}
	REP(i, m) {
		if (a[i] == 1)
			check[b[i]]++;
		if (b[i] == n)
			check[a[i]]++;
	}

	REP(i, n+1) {
		if (check[i] == 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    ll a,b;cin>>a>>b;
    cout<<a-b+1;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

static class ModeValue
{
    static void Main()
    {
        var q = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries )
            .Select( int.Parse )
            .GroupBy( x => x )
            .Select( x => new { k = x.Key, c = x.Count() } )
            .OrderByDescending( x => x.c )
            .ThenBy( x => x.k );
        var max = q.First().c;
        q
            .TakeWhile( x => x.c == max )
            .Select( x => x.k )
            .ToList()
            .ForEach( Console.WriteLine );
    }
}

Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

vector<vector<vector<pair<ll, ll>>>> G(1010, vector<vector<pair<ll, ll>>>(1010));
vector<vector<ll>> dp(1010, vector<ll>(1010, -1));
vector<vector<bool>> visited(1010, vector<bool>(1010, false));
ll dfs(ll v0, ll v1)
{
  if (v0 > v1)
    swap(v0, v1);

  if (dp.at(v0).at(v1) != -1)
    return dp.at(v0).at(v1);
  else if (visited.at(v0).at(v1))
    FINALANS(-1);

  visited.at(v0).at(v1) = true;

  //cerr << v0 << " " << v1 << " " << from.at(v0).at(v1) << endl;

  ll ret = 0;
  for (auto nv : G.at(v0).at(v1))
  {
    chmax(ret, dfs(nv.first, nv.second) + 1);
  }
  return dp.at(v0).at(v1) = ret;
}

int main()
{
  ll N;
  cin >> N;
  for (ll i = 0; i < N; i++)
  {
    vector<ll> A(N - 1);
    for (ll j = 0; j < N - 1; j++)
    {
      cin >> A.at(j);
      A.at(j)--;
      if (j == 0)
      {
        ll a = i;
        ll b = A.at(j);
        if (a > b)
          swap(a, b);
        G.at(0).at(0).push_back(make_pair(a, b));
      }
      else
      {
        ll a = i;
        ll b = A.at(j - 1);
        if (a > b)
          swap(a, b);
        ll c = i;
        ll d = A.at(j);
        if (c > d)
          swap(c, d);
        G.at(a).at(b).push_back(make_pair(c, d));
      }
    }
  }

  ll ans = dfs(0, 0);

  cout << ans << endl;
}

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

static const int MAX = 100;
int a[MAX];

void Trace(int a[], int len);

int main() {
	
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	Trace(a, n);
	
	for ( int i = 1; i < n; i++ ) {
		int key = a[i]; // ????????\?????°???
		int j = i - 1; // ????????????????°??????? 
		
		while ( j >= 0 && a[j] > key ) { // ??????a[j]>key,a[j]????§???????,j-- 
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		Trace(a, n);
	}
	
	return 0;
}

void Trace(int a[], int len) {
	for ( int i = 0; i < len; i++ ) {
		if ( i ) cout << " ";
		cout << a[i];
	}
	cout << endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a[105],b,c=1000000000;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b=max(b,a[i]);
		c=min(c,a[i]);
	}
	cout<<b-c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long long64;

template<class T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
#define INF (1000 * 1000 * 1000)
#define NINF (INF * (-1))
#define INF_LL ((long64)(INF) * (long64)(INF))
#define NINF_LL (INF_LL * (-1LL))

using namespace std;
#define MAX_N 100000

int N;
int *a, *b, *c;
vector< vector<int> > dp;

#define A 0
#define B 1
#define C 2

int max3(int i1, int i2, int i3){return max(max(i1, i2), i3);}

void Solve()
{
	for (int i = 1; i < N; ++i){
		dp[i][A] = max(dp[i - 1][B], dp[i - 1][C]) + a[i];
		dp[i][B] = max(dp[i - 1][C], dp[i - 1][A]) + b[i];
		dp[i][C] = max(dp[i - 1][A], dp[i - 1][B]) + c[i];
	}	
	cout << max3(dp[N - 1][A], dp[N - 1][B], dp[N - 1][C]) << endl;
}

void Init()
{
	cin >> N;
	a = new int[N]; b = new int[N]; c = new int[N];
	for (int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i];
	dp.resize(N);
	for (int i = 0; i < N; ++i){
		dp[i].resize(3);
		for (int j = 0; j < 3; ++j) dp[i][j] = 0;
	}
	dp[0][A] = a[0]; dp[0][B] = b[0]; dp[0][C] = c[0];
}

void Clean(){delete[] a; delete[] b; delete[] c;}

int main()
{
	Init();
	Solve();
	Clean();
	return 0;
}


Measured memory_bytes: 6912
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

ll tripleMax(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll tripleMin(ll a,ll b,ll c){
	return min(a,min(b,c));
}

int main()
{
	ll H,W;
	cin>>H>>W;
	ll minimumDifference = 1000000000000000;
	// cut horizontaly
	for(int h = 1; h < H; h++){
		ll A1,A2,A3;
		A1 = W*h;
		// pattern 1
		int width = W/2;
		A2 = (H-h)*width;
		A3 = (H-h)*(W-width);
		minimumDifference = min( minimumDifference, tripleMax(A1,A2,A3) - tripleMin(A1,A2,A3));

		// pattern 2;
		int height = (H-h)/2;
		A2 = W*height;
		A3 = W*(H-h-height);
		minimumDifference = min( minimumDifference, tripleMax(A1,A2,A3) - tripleMin(A1,A2,A3));
	}

	for(int w = 1; w < W; w++){
		ll A1,A2,A3;
		A1 = H*w;
		//pattern 1
		int height = H / 2;
		A2 = (W-w)*height;
		A3 = (W-w)*(H-height);
		minimumDifference = min( minimumDifference, tripleMax(A1,A2,A3) - tripleMin(A1,A2,A3));

		//pattern 2
		int width = (W-w)/2;
		A2 = H * width;
		A3 = H * (W-w-width);
		minimumDifference = min( minimumDifference, tripleMax(A1,A2,A3) - tripleMin(A1,A2,A3));
	}
	cout<<minimumDifference<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef pair<int, int> pii;
typedef pair<double, pii> pdpii;

const double INF = 1e10;

int main(){
	cout << setiosflags(ios::fixed) << setprecision(9);
	while(true){
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;
		if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0){ break; }
		--a; --b;
		vector<int> t(n);
		for(int i = 0; i < n; ++i){ cin >> t[i]; }
		vector< vector<pii> > roads(m);
		for(int i = 0; i < p; ++i){
			int x, y, z;
			cin >> x >> y >> z;
			--x; --y;
			roads[x].push_back(pii(y, z));
			roads[y].push_back(pii(x, z));
		}
		vector< vector<double> > table(m, vector<double>(1 << n, INF));
		priority_queue< pdpii, vector<pdpii>, greater<pdpii> > pq;
		pq.push(pdpii(0.0, pii(a, 0)));
		double answer = INF;
		while(!pq.empty()){
			pdpii e = pq.top();
			pq.pop();
			double cost = e.first;
			int city = e.second.first;
			int tickets = e.second.second;
			if(city == b){
				answer = cost;
				break;
			}
			if(cost >= table[city][tickets]){ continue; }
			table[city][tickets] = cost;
			for(int i = 0; i < roads[city].size(); ++i){
				for(int j = 0; j < n; ++j){
					if(tickets & (1 << j)){ continue; }
					double co = cost + (double)roads[city][i].second / t[j];
					int ci = roads[city][i].first;
					int ti = tickets | (1 << j);
					if(table[ci][ti] > co){
						pq.push(pdpii(co, pii(ci, ti)));
					}
				}
			}
		}
		if(answer >= INF){
			cout << "Impossible" << endl;
		}else{
			cout << answer << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9;
  
int n;
bool ok, bo[N];
vector<int> G[N];

void dfs(int x, int f) {
	if (G[x].size() == 1) bo[x] = 1;
	int tmp = 0;
	for (int i = 0; i < G[x].size(); i++) {
		int u = G[x][i];
		if (u == f) continue;
		dfs(u, x);
		if (bo[u]) tmp++;
	}
	if (tmp == 0) bo[x] = 1;
	if (tmp > 1) ok = 1;
}

int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
  	int x, y;
  	scanf("%d %d", &x, &y);
  	G[x].push_back(y);
  	G[y].push_back(x);
	}
	if (n & 1) ok = 1;
	dfs(1, 0);
	if (ok) puts("First");
	else puts("Second");
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int cnt = 0;

void dfs(string s, ll N, int b) {
	if (stol(s) > N) return;
	if (b & (1 << 0) && b & (1 << 1) && b & (1 << 2)) {
		cnt++;
	}
	dfs(s + "7" , N, (b | (1 << 0)));
	dfs(s + "5" , N, (b | (1 << 1)));
	dfs(s + "3" , N, (b | (1 << 2)));
}

void Main() {
	ll N; cin >> N;
	dfs("0", N, 0);
	cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    return fact[n]*inv[n-k]%mod;
}

int inv2=(mod+1)/2;

int N;
vint G[2222];

int dp[2222][2222][3];
int sz[2222];
int tmp[2222][3];

void dfs(int v){
    sz[v]=1;
    dp[v][1][0]=1;

    for(auto u:G[v]){
        dfs(u);

        rep(i,sz[v]+sz[u]+1)rep(j,3)tmp[i][j]=0;

        for(int i=1;i<=sz[v];i++){
            for(int j=1;j<=sz[u];j++){
                //0 0
                add(tmp[i+j][0],dp[v][i][0]*dp[u][j][0]%mod);
                add(tmp[i+j-1][1],dp[v][i][0]*dp[u][j][0]*2%mod);

                //0 1
                add(tmp[i+j][0],dp[v][i][0]*dp[u][j][1]%mod);
                add(tmp[i+j-1][1],dp[v][i][0]*dp[u][j][1]%mod);

                //0 2
                add(tmp[i+j][0],dp[v][i][0]*dp[u][j][2]%mod);

                //1 0
                add(tmp[i+j][1],dp[v][i][1]*dp[u][j][0]%mod);
                add(tmp[i+j-1][2],dp[v][i][1]*dp[u][j][0]%mod);

                //1 1
                add(tmp[i+j][1],dp[v][i][1]*dp[u][j][1]%mod);
                add(tmp[i+j-1][2],dp[v][i][1]*dp[u][j][1]%mod*inv2%mod);

                //1 2
                add(tmp[i+j][1],dp[v][i][1]*dp[u][j][2]%mod);

                //2 0
                add(tmp[i+j][2],dp[v][i][2]*dp[u][j][0]%mod);

                //2 1
                add(tmp[i+j][2],dp[v][i][2]*dp[u][j][1]%mod);

                //2 2
                add(tmp[i+j][2],dp[v][i][2]*dp[u][j][2]%mod);
            }
        }

        sz[v]+=sz[u];
        rep(i,sz[v]+1)rep(j,3)dp[v][i][j]=tmp[i][j];
    }
}

signed main(){
    cin>>N;
    for(int i=1;i<N;i++){
        int b;cin>>b;
        b--;
        G[b].pb(i);
    }

    dfs(0);
    int ans=0;
    for(int i=1;i<=N;i++){
        int ei=0;
        rep(j,3)add(ei,dp[0][i][j]);
        ei=ei*fact[i]%mod;

        if((N-i)&1){
            ans=(ans-ei+mod)%mod;
        }
        else{
            ans=(ans+ei)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    long long n,m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if(__gcd(n,m) == 1){
        if(s[0] == t[0]){
        cout << n * m << endl;
        return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    long long a = n / __gcd(n,m), b = m / __gcd(n,m);
    long long L = a * m;
    long long k = a * b;
    bool flag = true;
    long long i = 0;
    while(i * k < L){
            long long num = i * k;
            if(s[num / b] != t[num / a]){
                flag = false;
                break;
            }
            i++;
    }

    if(flag) cout << L << endl;
    else cout << -1 << endl;
    return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
string explanation1 = "これは幅優先探索の問題！";
string explanation2 = "参考URL:https://qiita.com/drken/items/996d80bcae64649a6580";

const int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;

  //グラフ入力受け取り
  Graph G(100005);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--; //distで０と１のズレを直しておくため
    G[a].push_back(b); //有向グラフ
    G[b].push_back(a); //無向グラフなのでこれも追加
  }

  //BFSのためのデータ構造
  vector<int> dist(n, INF); //全頂点を「未訪問」に初期化
  queue<int> que; //キュー
  vector<int> pre(n, -1);

  //初期条件（頂点1をノードとする）
  dist[0] = 0;
  que.push(0); //1を橙色頂点にする

  //BFS開始（キューが空になるまで探索を行う）
  while(!que.empty()) {
    int v = que.front(); //キューから先頭頂点を取り出す
    que.pop(); //先頭要素を削除

    // v から辿れる頂点をすべて調べる
    for(int u : G[v]) { //拡張for文 変数uにG[v]の値を入れてる
      if(dist[u] != INF) continue; //すでに発見済みの頂点は探索しない

      //新たな白色頂点uについて距離情報を更新してキューに追加する
      dist[u] = dist[v] + 1;
      pre[u] = v;
      que.push(u);
    }
  }

  for(int i = 1; i < n; i++) {
    if(pre[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i = 0; i < n; i++) {
    if(i == 0) continue;
    int ans = pre[i];
    ans++; //18,19行目で１減らしてたのを元に戻す
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10748
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		long B[] = new long[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		if (N%2==0) {
			System.out.println(B[N/2-1]+B[N/2]-(A[N/2-1]+A[N/2])+1);
		} else {
			System.out.println(B[N/2]-A[N/2]+1);
		}
	}
}


Measured memory_bytes: 62908
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<long long, long long> P;
typedef pair<P, P> L;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 998244353

int N;
int X[200], Y[200];
int p2[201];

long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b%a, a);
}

P reg(long long p, long long q) {
  if (q < 0) p = -p, q = -q;
  if (q == 0) return P(1, 0);
  long long g = gcd(abs(p), abs(q));
  p /= g, q /= g;
  return P(p, q);
}
P pls(P a, P b) {
  return reg(a._1*b._2 + a._2*b._1, a._2*b._2);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];
  p2[0] = 1;
  for (int i=1; i<=200; i++) p2[i] = (2LL*p2[i-1]) % MOD;
  vector<L> ls;
  rep(i, N) {
    rep(j, i) {
      int x1 = X[i], x2 = X[j], y1 = Y[i], y2 = Y[j];
      if (x1 == x2) {
        ls.pb(L(reg(1, 0), reg(x1, 1)));
      }
      else {
        P a = reg(y2-y1, x2-x1);
        P c = reg(y1*(x2-x1) - x1*(y2-y1), x2-x1);
        // cout<<"("<<a._1<<","<<a._2<<"), ("<<c._1<<","<<c._2<<")\n";
        ls.pb(L(a, c));
      }
    }
  }
  sort(all(ls)); uniq(ls);

  int s = 0;
  for (L l : ls) {
    P a = l._1, b = l._2;
    int n = 0;
    rep(i, N) {
      int x = X[i], y = Y[i];
      if (a == reg(1, 0)) {
        if (x == b._1) n++;
      }
      else {
        // y = ax + b
        if (reg(y, 1) == pls(reg(a._1*x, a._2), b)) n++;
      }
    }
    s += p2[n]-n-1;
    s %= MOD;
  }
  s += N+1;
  s %= MOD;
  cout << ((p2[N] - s + MOD) % MOD) << "\n";
  return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////
 
int N;
vi G[MAX_N];
int C[MAX_N];
 
int loop(int v, int p) {
	int res = 0;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n == p) continue;
		res += loop(n, v);
	}
	bool found = false;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n == p) continue;
		if(C[n] == 0) {
			found = true;
		}
	}
	if(found) {
		C[v] = 1; res++;
	}
	return res;
}
 
void solve() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	if(loop(0, -1) * 2 == N) cout << "Second\n";
	else cout << "First\n";
}
 
uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}
 
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}
 


Measured memory_bytes: 15616
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,m,x;sc(n);sc(m);sc(x);
 ll a,cnt[n+1]={0};
 rep(i,0,m){sc(a);cnt[a]=1;}
 ll ans1=0,ans2=0;
 rep(i,x,n+1){
  if(cnt[i]==1){
   ans1++;
  }
 }
 rrp(i,x,0){
  if(cnt[i]==1){
   ans2++;
  }
 }

 pr(min(ans1,ans2));
  
return 0;}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        double a = Double ();
        double b = Double ();
        double x = Double ();

        if (x > a * a * b / 2) {
            double remain = (a * a * b - x) / (a * a) * 2;
            Console.WriteLine (Math.Atan (remain / a) * 180 / Math.PI);
        } else {
            double remain = x / (a * b) * 2;
            Console.WriteLine (90 - Math.Atan (remain / b) * 180 / Math.PI);
        }
    }

    static int BinarySearch (int[] a, int b) {
        int index = Array.BinarySearch (a, b);
        if (index < 0) {
            return ~index;
        }
        int tmp = a[index];
        while (index - 1 >= 0 && tmp == a[index - 1]) {
            index--;
        }

        return index;
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;

const int MAX = 1e5+10;
const ll mod = 1e9+7;
vector<int> is_prime(1e5+100,1);

void Prime_init(){
  is_prime[0] = 0;
  is_prime[1] = 0;
  is_prime[2] = 1;
  for(int p=2;p*p<MAX;p++){
    if(!is_prime[p]) continue;//素数でないと判明していたら
    for(int i=p*2;i<=MAX;i+=p) is_prime[i] = 0;//pの倍数をすべてfalseに
  }
}

int c[100002];

int main(){
  int q;
  cin >> q;
  int cnt[q] = {0};
  vector<int> l(q,0),r(q,0);
  rep(i,q) cin >> l[i] >> r[i];
  Prime_init();
  //累積和
  for(int i=3;i<=100000;i+=2) if(is_prime[i] && is_prime[(i+1)/2])c[i]++;
  for(int i=3;i<=100000;i++) c[i]+=c[i-1];
  for(int i=0;i<q;i++) cout << c[r[i]] - c[l[i]-1] << endl;

}


Measured memory_bytes: 2560
a, b, c, x, y = [int(i) for i in input().split(" ")]

s = 0

if a + b > 2 * c:
    m = min(x, y)
    s += 2 * c * m
    x -= m
    y -= m
    if a > 2 * c:
        s += 2 * c * x
    else:
        s += a * x
    if b > 2 * c:
        s += 2 * c * y
    else:
        s += b* y
else:
    s += a * x + b * y

print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	vector<ll>v;
	v.push_back(a*c);
	v.push_back(a*d);
	v.push_back(b*c);
	v.push_back(b*d);
	cout<<*max_element(v.begin(),v.end());
  
}

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

int main(){
    string a, b ,c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int n, a[200];

int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    int res = 0;
    
    while (true) {
        bool frag = false;
        
        for (int i = 0; i < n; i++) 
            if (a[i] % 2 != 0) frag = true;
        if (frag) break;
        
        for (int i = 0; i < n; i++) a[i] /= 2;
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
n=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(n):
  s=input()
  if s=='AC':
    AC+=1
  if s=='WA':
    WA+=1
  if s=='TLE':
    TLE+=1
  if s=='RE':
    RE+=1
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

Measured memory_bytes: 9140
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  # Aiが奇数の場合
  if (a[i] % 2 == 1):
    ans = 'APPROVED'
  # Aiが偶数の場合
  else:
    # 3でも5でも割り切れない時
    if (a[i] % 3 != 0 and a[i] % 5 != 0):
      ans = 'DENIED'
      break
    else:
      ans = 'APPROVED'

print(ans)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
A = [list(map(int, input().split())) for i in range(3)]
B = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())

def isBingo(A):
  # 横
  for i in range(3):
    if sum(A[i])==3:
      return True
  # 縦
  for i in range(3):
    if A[0][i]+A[1][i]+A[2][i]==3:
      return True
  # 斜め
  if A[0][0]+A[1][1]+A[2][2]==3:
    return True
  if A[0][2]+A[1][1]+A[2][0]==3:
    return True
  
  return False

# 穴をあける
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b==A[j][k]:
        B[j][k] += 1

# 判定
if isBingo(B):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int A, B, X;
	cin >> A >> B >> X;
	if (X >= A && X <= A + B) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////

    char s;
    cin >> s;
    
    if(isupper(s)){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }

    return 0;
}


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

const size_t array[3] = {3,5,7};
bool checkVal(size_t val) {

    bool checkers[3] = {false, false, false};
    while (0 < val) {
        size_t temp = val % 10;
        if (temp == 3) checkers[0] = true;
        else if (temp == 5) checkers[1] = true;
        else checkers[2] = true;
        val /= 10;
    }
    return (checkers[0] && checkers[1] && checkers[2]);

}

size_t hoge(size_t max_val, size_t val = 0) {
    size_t ret = 0;
    size_t const start = val * 10;
    if (max_val < start) return ret;

    for (size_t i = 0; i < 3; i++) {
        size_t temp = start + array[i];
        if (checkVal(temp) && (temp <= max_val)) ret++;
        ret += hoge(max_val, temp); 
    }
    
    return ret;
}

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

    cout << hoge(N) << endl;

    return 0;
}



Measured memory_bytes: 256