akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct Compress {
  vector<T> xs;

  Compress() = default;

  Compress(const vector<T> &vs) {
    add(vs);
  }

  Compress(const initializer_list<vector<T>> &vs) {
    for(auto &p : vs) add(p);
  }

  void add(const vector<T> &vs) {
    copy(begin(vs), end(vs), back_inserter(xs));
  }

  void add(const T &x) {
    xs.emplace_back(x);
  }

  void build() {
    sort(begin(xs), end(xs));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
  }

  vector<int> get(const vector<T> &vs) const {
    vector<int> ret;
    transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
      return lower_bound(begin(xs), end(xs), x) - begin(xs);
    });
    return ret;
  }

  int get(const T &x) const {
    return lower_bound(begin(xs), end(xs), x) - begin(xs);
  }

  const T &operator[](int k) const {
    return xs[k];
  }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> x1(N),x2(N),y1(N),y2(N);
    rep(i,N) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];

    Compress<ll> Comx(x1),Comy(y1);
    Comx.add(x2);
    Comx.add(-1e9-1);
    Comy.add(y2);
    Comy.add(-1e9-1);
    Comx.build();
    Comy.build();

    int H = Comx.xs.size();
    int W = Comy.xs.size();
    vector<vector<int>> S(H, vector<int>(W));
    rep(i,N) {
        S[Comx.get(x2[i])][Comy.get(y2[i])]++;
        S[Comx.get(x1[i])][Comy.get(y2[i])]--;
        S[Comx.get(x2[i])][Comy.get(y1[i])]--;
        S[Comx.get(x1[i])][Comy.get(y1[i])]++;
    }
    for (int i = H-1; i >= 0; --i) {
        for (int j = W-1; j > 0; --j) {
            S[i][j-1] += S[i][j];
        }
    }
    for (int j = W-1; j >= 0; --j) {
        for (int i = H-1; i > 0; --i) {
            S[i-1][j] += S[i][j];
        }
    }
    ll ans = 0;
    rep(i,H) {
        rep(j,W) {
            if (S[i][j]) ans += (Comx[i] - Comx[i-1])*(Comy[j]-Comy[j-1]);
        }
    }

    cout << ans << ln;
}


Measured memory_bytes: 65716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N, M, l_max = Integer.MIN_VALUE, r_min = Integer.MAX_VALUE;
    	
        void solve(InputReader in, PrintWriter out) {
            // write your code here
        	N = in.nextInt();
        	M = in.nextInt();
        	
        	for (int i = 0; i < M; ++i) {
        		int l = in.nextInt(), r = in.nextInt();
        		l_max = Math.max(l_max, l);
        		r_min = Math.min(r_min, r);
        	}
        	
        	out.println(r_min >= l_max ? r_min - l_max + 1 : 0);
        }
        
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 40068
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

void solve()
{
	int x,val;
	for(int i=0;i<5;i++)
	{
		cin>>x;
		if(x==0)
		val = i+1;
	}
	cout<<val;
}
int32_t main()
{
	IOS;
	//int t;
	//cin>>t;
	//for(int i=0;i<t;i++)
	{
		solve();
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
using namespace std;

double degreeToRad(double degree){
	double rad =M_PI*degree / 180.0;
	return rad;
}

int main()
{
	double a,b,C,c;
	double S,L,h;
	cin>>a>>b>>C;
	C = degreeToRad(C);
	S = 0.5*a*b*sin(C);
	h = b*sin(C);
	c = sqrt(a*a + b*b - 2.0*a*b*cos(C));
	L = a + b + c;

	printf("%0.5lf\n%0.5lf\n%0.5lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 3384
import Data.List as L

main=do
  (k:_)<-L.map read . words<$>getLine::IO[Int]
  (a:b:_)<-L.map read . words<$>getLine::IO[Int]
  putStrLn $ if (k-a`mod`k) `mod` k <= b - a then "OK" else "NG"

Measured memory_bytes: 3884
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
        int r,c;
    
    cin>>r>>c;
    
    int A[r+1][c+1];

    for(int i=0;i<r+1;++i){
        for(int j=0;j<c+1;++j){
            A[i][j]=0;
        }
    }

    
    for(int i=0;i<r;++i){
        for(int j=0;j<c;++j){
            cin>>A[i][j];
            A[i][c] += A[i][j];
            A[r][j] += A[i][j];
            A[r][c] += A[i][j];
        }
    }

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",A[i][j]);
		}
		printf("%d\n",A[i][c]);
	}
	return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005
char str[N];
int judge(int i,int j){
    int f=0;
    if(str[i]=='b'&&str[j]=='d') f=1;
    if(str[i]=='d'&&str[j]=='b') f=1;
    if(str[i]=='p'&&str[j]=='q') f=1;
    if(str[i]=='q'&&str[j]=='p') f=1;
    return f;
}
int main()
{
    int i,n,flag=1;
    scanf("%s",str);
    n=strlen(str);
    for(i=0;i<n/2;++i){
        if(judge(i,n-1-i))
            ;
        else{
            flag=0;
            break;
        }
    }
    if(n%2) flag=0;
    puts(flag?"Yes":"No");
//    printf("%.9f\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;

int l[200005];

/*
l to r is valid
prefsum[r] - prefsum[l-1] == prefxor[r] ^ prefxor[l-1]
*/

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  ll ret = 0;
  int first = 0;
  int curr = 0;
  for(int i = 0; i < n; i++) {
    while(curr & l[i]) {
      curr &= ~l[first++];
    }
    curr |= l[i];
    ret += i-first+1;
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1024
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const double pi=3.1415926535897932384626433832;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,dist[105][105]={},ans=0,a[5005]={},b[5005]={},c[5005]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j) {
        dist[i][j]=inf;
      }
    }
  }
  for(int i=0; i<m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    dist[a[i]][b[i]]=dist[b[i]][a[i]]=c[i];
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
      }
    }
  }
  for(int i=0; i<m; i++) {
    if(dist[a[i]][b[i]]<c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int A,B;
	char S;
	cin>>A>>S>>B;
	if(S=='+')cout<<A+B;
	else cout<<A-B;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int a, b, c, ans = 0;
	
	cin>>a>>b>>c;
	
	ans += min(a+b,c);
	
	if(a+b>=c){
		ans = b+c;
	} else {
		ans = min(a+b,c)+b;
		ans += min((int)1,c - min(a+b,c));
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n;
double ans;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	vector<int> x(n),y(n);
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	int p[10];
	for(int i=0;i<n;i++) p[i]=i;
	do{
		double cur=0;
		for(int i=0;i+1<n;i++){
			double a=(double)((x[p[i]]-x[p[i+1]])*(x[p[i]]-x[p[i+1]])),b=(double)((y[p[i]]-y[p[i+1]])*(y[p[i]]-y[p[i+1]]));
			cur+=(sqrt(a+b)); 
		}
		ans+=cur;
	}while(next_permutation(p,p+n));
	double r=1;
	for(int i=2;i<=n;i++) r*=(double)(i);
	cout<<fixed<<setprecision(10)<<ans/r;
	re 0;
}

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

int main(){
  vector <int> vec1(9);
  vector <int> vec2(9);
int N;
int i;
 int j;
  int P;
  
  for(i=0;i<9;i++){
cin>>vec1.at(i);
    vec2.at(i)=0;
  }
cin >> N;
  for (i=0;i<N;i++){
    cin >>  P;
    j=0;
  	while(j<9){
      if (P==vec1.at(j)){
        vec2.at(j)=1;
        j=10;
      }
      j++;
    }
  }

 if(vec2.at(0)+vec2.at(1)+vec2.at(2)==3){
   cout<< "Yes" <<endl;
 }else if(vec2.at(3)+vec2.at(4)+vec2.at(5)==3){
cout << "Yes" << endl;
 }else if(vec2.at(6)+vec2.at(7)+vec2.at(8)==3){
cout << "Yes" << endl;
 }else if(vec2.at(0)+vec2.at(3)+vec2.at(6)==3){
cout << "Yes" << endl;
 }else if(vec2.at(1)+vec2.at(4)+vec2.at(7)==3){
cout << "Yes" << endl;
 }else if(vec2.at(2)+vec2.at(5)+vec2.at(8)==3){
cout << "Yes" << endl;
 }else if(vec2.at(0)+vec2.at(4)+vec2.at(8)==3){
cout << "Yes" << endl;
 }else if(vec2.at(2)+vec2.at(4)+vec2.at(6)==3){
cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
  
}


Measured memory_bytes: 256
from heapq import heappush, heappop

n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

td.sort(key=lambda x: x[1], reverse=True)

types = set()
can_remove = []
d_sm = 0

for t, d in td[:k]:
	d_sm += d
	if t in types:
		can_remove.append(d)
	else:
		types.add(t)

type_cnt = len(types)

ans = d_sm + type_cnt ** 2

left = []
for t, d in td[k:]:
	d = -d
	heappush(left, [d, t])

while can_remove and left:
	d, t = heappop(left)
	d = -d
	if t not in types:
		types.add(t)
		d_rmv = can_remove.pop()
		d_sm += d - d_rmv
		type_cnt += 1
		ans = max(ans, d_sm + type_cnt ** 2)

print(ans)


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

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

    int like_persons[m] = {};

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;

        if (n == 1) {
            cout << k << endl;
            return 0;
        }

        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            like_persons[--a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (like_persons[i] == n) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String s = nextString();
		String ans="";
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='1'){
				ans+="9";
			}else if(s.charAt(i)=='9'){
				ans+="1";
			}else{
				ans+=String.valueOf(s.charAt(i));
			}
		}





		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
fun main(arg: Array<String>) {
    val A = listOfLong().sorted()
    val allOdd = A.map { it % 2 != 0L }.all { it }
    println(if (allOdd) A[0] * A[1] else 0)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }

Measured memory_bytes: 37668
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll a[100000] = {};
  ll n, flag = 0, ans = 1, i;
  ll m = 1000000000 + 7;
  cin>>n;
  ll b[n];
  for(auto &x: b)
  {
      cin>>x;
      a[x]++;
      if(a[x]>2) flag++;
  }
  if(flag > 0)
  {
      cout<<0<<endl;
      return 0;
  }
  if(n%2 != 0 && a[0]>1)
  {
      cout<<0<<endl;
      return 0;
  }
    for(i = 0; i<n/2; i++)
    {
      ans*=2;
      ans%=m;
    }
    cout<<ans<<endl;

      return 0;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int>d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  sort(All(d));
  cout<< d[n/2]-d[n/2-1] <<endl;
}


Measured memory_bytes: 640
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
string s;ll cnt ,re=0,su,x,y,r[MAXN];
vi v;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s;
    cnt=0;
    FR(i,0,s.SZ)
    {
        r[s[i]-'a']++;
        re-=r[s[i]-'a'];
    }
    re+=(s.SZ*s.SZ+s.SZ)/2;
    cout<<re+1;
    return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val S = input.next().toCharArray()
    
    for (i in 0..(S.size - 1)) {
      S[i] = 'A'.plus((S[i].minus('A') + N) % 26);
    }
    
    println(S)
  }
}

Measured memory_bytes: 36532
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(int i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(int i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> H(N);
    ll maxval = 0;
    REP(i, N) {
        cin >> H[i];
        maxval = max(maxval, H[i]);
    }
    
    ll lb = 0;
    ll ub = (maxval+B-1)/B;
    
    while (lb+1 < ub) {
        ll m = lb + (ub-lb)/2;

        ll k = m;
        REP(i, N) {
            ll r = H[i] - m*B;
            if (r > 0)
                k -= (r+A-B-1)/(A-B);
        }
        
        if (k>=0) {
            ub = m;
        } else {
            lb = m;
        }
    }
    
    cout << ub << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=100;
int main()
{
  int n,i,res=1;
  int d[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> d[i];
  sort(d,d+n);
  for(i=1;i<n;i++)
    if(d[i]>d[i-1])
      res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, x) = get!(usize, u64);
    let aa = util::gets::<u64>();

    let mut ans = aa.iter().sum::<u64>();

    let mut arr = aa.clone();
    for i in 1..n + 1 {
        let mut next: Vec<u64> = (0..n)
            .map(|k| {
                if k == 0 {
                    min(arr[0], arr[n - 1])
                } else {
                    min(arr[k], arr[k - 1])
                }
            })
            .collect();

        ans = min(ans, next.iter().sum::<u64>() + i as u64 * x);
        arr = next;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A , B , C , D , L , R ;
  
  cin >> A >> B >> C >> D ;
  
  L = A + B ;
  R = C + D ;
  
  if ( L > R )
    cout << "Left" << endl ;
  
  else if ( R > L )
    cout << "Right" << endl ;
  
  else if ( L = R )
    cout << "Balanced" << endl ;
  
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n+1), sum(n+1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    if (i == 1) sum[i] = p[i];
    else sum[i] = sum[i-1] + p[i];
  }
  
  int M = 0, idx;
  for (int i = 1; i <= n-k+1; i++) {
    if (M < sum[i+k-1] - sum[i-1]) {
      M = sum[i+k-1] - sum[i-1];
      idx = i;
    }
  }
  
  double ans = 0;
  for (int i = idx; i <= idx+k-1; i++) {
    ans += (p[i]+1)/2.0;
  }
  
  cout << fixed << setprecision(7) << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int a=reader.nextInt();
        int b=reader.nextInt();
        int c=reader.nextInt();
        if((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&c!=a))
          System.out.println("Yes");
        else
            System.out.println("No");

    }
}


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

int main() {
    int n;
    cin >> n;
    set<ll>s;
    rep(i, 0, n){
        ll tempa;
        cin >> tempa;
        int a = s.size();
        s.insert(tempa);
        int b = s.size();
        if(b == a)s.erase(tempa);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
    cin>>s>>t;
    ll ans=INT_MAX;
    for(ll i=0;i<=s.size()-t.size();i++)
    {
        string t1=s.substr(i,t.size());
        ll ct=0;
        for(ll j=0;j<t.size();j++)
         if(t1[j]!=t[j])
         ct++;
         ans=min(ans,ct);
    }
    cout<<ans<<endl;
}

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

int main() {
int n;
cin >> n;
if(n %2 == 0){
	cout << n / 2 << endl;
}
else if(n % 2 == 1){
	cout << n / 2 +1 << endl;
}
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[][] C = new int[3][3];
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                C[i][j] = scan.nextInt();
            }
        }

        int min = C[0][0];
        for (int i=0; i<2; i++) {
            if (C[0][i] < min) min = C[0][i];
        }

        int check;
        for (int a1 = 0; a1 <= min; a1++) {
            int c11 = C[0][0] - a1;
            int a2 = C[1][0] - c11;
            int a3 = C[2][0] - c11;

            boolean flag = true;
            for (int i=1; i<3; i++) {
                check = C[0][i] - a1;
                if (C[1][i] - a2 != check || C[2][i] - a3 != check) {
                    flag = false;
                    break;
                }
            }

            if (flag == true) {
                System.out.println("Yes");
                System.exit(0);
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 23892
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
 // cout<<"Case #"<<ts<<": ";
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	 ll t=1,r,n,a,d,c,b,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,g,ts;
	 ll mod=1000000007;
	 char ch,chh;
	 double dans;
	 string str,ttr;
	 
//	 cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	     flag=0;sum=0;cnt=0;ans=0;k=0;maxx=0;minn=0;a=0;b=0;temp=0;
	    
	     cin >> n;
	   // ll arr[n];for(i=0;i<n;i++){cin>>arr[i];}
	     
	     while(n%2==0)
	     {
	         cnt++;
	         n=(n/2);
	     }
	     
	      ans+=(((sqrt(1+8*cnt))-1)/2);
	      
	      
	    //  cout<<ans<<endl;
	     
	     for(i=3;i<=sqrt(n);i+=2)
	     {  cnt=0;
	         while(n%i==0)
	         {
	             cnt++;
	             n=(n/i);
	         }
	         
	         if(cnt>0){//cout<<ans<<endl;
	         ans+=(((sqrt(1+8*cnt))-1)/2);}
	     }
	     if(n>2)
	     ans++;
	     
	     cout<<ans;
	    
	     ln
	 }
	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll mod=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


struct SegmentTree{
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1,-INF);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = max(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val){
        x += n-1;
        node[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1){
        if (r < 0) r = n;
        if(r <= a || b <= l) return -INF;
        if(a <= l && r <= b) return node[k];
        int vl = getmin(a, b, 2*k+1, l , (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2,r);
        return max(vl, vr);
    }
};




int main(){
    int n,k;cin >> n >> k;
    vector<int> x(6000002, 0),a(n);
    SegmentTree seg(x);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int t = 0;
        t = seg.getmin(max(0, a[i] - k), min(6000001, a[i] + k + 1));
        seg.update(a[i], t + 1);
    }
    cout << seg.getmin(0, 6000000) << endl;
    return 0;
}


Measured memory_bytes: 116784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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;

using namespace std;

template <class Abel>
class BIT
{
public:
  using F=function<Abel(Abel,Abel)>;
  F f;
  ll l;
  vector<Abel> bit;
  Abel m0;
  BIT(ll maxidx,F fu,Abel m0):f(fu),l(maxidx),m0(m0)
  {
    bit.assign(l,m0);
  }
  void update(ll idx,ll val)
  {
    while(idx<=l)
    {
      bit[idx]=f(bit[idx],val);
      idx+=idx & -idx;
    }
  }
  ll query(ll idx)
  {
    ll res=m0;
    while(idx>0)
    {
      res=f(bit[idx],res);
      idx-=idx& -idx;
    }
    return res;
  }
};
ll mod=1e9+7;
int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll> s(n);
  rep(i,n)cin>>s[i];
  s.erase(unique(all(s)),s.end());
  //rep(i,s.size())cout<<s[i];
  ll l=(ll)s.size();
  map<ll,vector<ll>> cidx;
  map<ll,ll> ns;
  vector<ll>tv;
  rep(i,l)
  {
    if(cidx.count(s[i])==0)
    {
      cidx[s[i]]=tv;
    }
    cidx[s[i]].push_back(i);
  }
  ll m0=0;
  BIT<ll>bt(400100,[&](ll a,ll b){ll res=a+b;if(res>mod){res-=mod;}return res;},m0);

  rep(i,l)
  {
    //cout<<i<<" "<<s[i]<<" ";
    ll tsum=(bt.query(i)+1)%mod;

    //cout<<tsum<<endl;
    auto nidx=upper_bound(all(cidx[s[i]]),i);

    if(nidx==cidx[s[i]].end())continue;
    bt.update(*nidx+1,(tsum)+ns[s[i]]);
    ns[s[i]]+=tsum;
    //cout<<tsum<<endl;

  }
  ll res=(bt.query(200010)+1)%mod;
  if(res<0)res+=mod;
  cout<<res<<endl;



  return 0;

}


Measured memory_bytes: 26880
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
//__int128
const int maxn = 2e5;
LL g[maxn], a[maxn], b[maxn];
LL gcd(LL a, LL b) {
	return b ? gcd(b, a % b) : a;
}

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	g[n] = a[n];
	for(int i = n - 1; i >= 1; --i){
		g[i] = gcd(g[i + 1], a[i]);
	}
	LL res = g[2];
	b[1] = a[1];
	for(int i = 2; i < n; ++i){
		res = max(gcd(b[i - 1], g[i + 1]), res);
		b[i] = gcd(a[i], b[i - 1]);
	}
	res = max(res, b[n - 1]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin>>n;
    ll ans;
    ans=(modpow(10, n, 1000000007)-2*modpow(9, n, 1000000007)+modpow(8, n, 1000000007)+2*1000000007)%1000000007;
    cout<<ans<<endl;

    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }

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

    ll ans =0;
    for(int i=0;i<N-K;i++){
        ans+=H[i];
    }

    cout << ans << endl;
}

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

const long long mod = 1000000007;

int main()
{
    long long n;
    std::cin>>n;
    std::vector<long long> v(n);
    for(long long i=0;i<n;i++)std::cin>>v[i];
    long long a=0,b=0,c=0;
    long long ans = 1;
    for(long long i=0;i<n;i++){
        long long cur = v[i];
        if(cur==a&&cur==b&&cur==c){ans *= 3;ans%=mod;a++;continue;}
        if(cur==a&&cur==b&&cur!=c){ans *= 2;ans%=mod;a++;continue;}
        if(cur==b&&cur==c&&cur!=a){ans *= 2;ans%=mod;b++;continue;}
        if(cur==c&&cur==a&&cur!=b){ans *= 2;ans%=mod;c++;continue;}
        if(cur==a&&cur!=b&&cur!=c){a++;continue;}
        if(cur==b&&cur!=c&&cur!=a){b++;continue;}
        if(cur==c&&cur!=a&&cur!=b){c++;continue;}
        if(cur!=c&&cur!=b&&cur!=a)ans = 0;;
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 1024
format_sec :: Integer -> String
format_sec s = formatted_s
    where
        hours = s `div` 3600
        minutes = s `div` 60 `mod` 60
        seconds = s `mod` 60
        formatted_s = (show hours) ++ ":" ++ (show minutes) ++ ":" ++ (show seconds)

main = do
    givenstr <- getLine
    putStrLn((format_sec . read) givenstr)

Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		char b = s.charAt(0);
		System.out.println(solve(b));
		in.close();
	}

	private static char solve(char b) {
		if (b == 'A')
			return 'T';
		else if (b == 'T')
			return 'A';
		else if (b == 'G')
			return 'C';
		else
			return 'G';
	}
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main(){
int a[5],k,m; 
bool aa=true;
for(int i=0; i<5; i++){
	cin>>a[i];
}
cin>>k;
for( int i =0; i<5 ;i++){
	for( int j =0; j<5 ;j++){
		m=a[i]-a[j];
		if(m>k){
			aa=false;
			break;
		}
	}		
}
if(aa){
	cout<<"Yay!";
}
else{
	cout<<":(";
}
}

Measured memory_bytes: 3068
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
# Bについてソート
AB = sorted(AB, key=lambda x: x[1])
time = 0
for job in AB:
    # Aを足す
    time += job[0]
    # 期限を過ぎてしまった場合
    if time > job[1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 48508
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        Set<Integer> set = new HashSet<>();
        int[] count = new int[25];
        count[0]++;
        set.add(0);
        for (int i = 0; i < n; i++) {
            int d = scanner.nextInt();
            set.add(d);
            count[d]++;
        }
        int m = 0;
        for (int i = 0; i < 25; i++) {
            if (count[i] == 1) {
                m++;
            }
            if (count[i] > 2) {
                System.out.println(0);
                return;
            }
            if (i > 12) {
                count[i] = count[24 - i];
            }
        }
        if (count[0] > 1 || count[12] > 1) {
            System.out.println(0);
            return;
        }
        int max = 0;
        for (int i = 0; i < 1 << m; i++) {
            List<Integer> list = new ArrayList<>();
            int index = 0;
            for (int j : set) {
                if (count[j] > 1) {
                    list.add(j);
                    list.add(24 - j);
                } else if ((i & index++) == 0) {
                    list.add(j);
                } else {
                    list.add(24 - j);
                }
            }
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < list.size(); j++) {
                for (int k = j + 1; k < list.size(); k++) {
                    int a = Math.abs(list.get(j) - list.get(k));
                    min = Math.min(min, Math.min(a, 24 - a));
                }
            }
            max = Math.max(max, min);
        }
        System.out.println(max);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;

void djk(const vector<vector<int>>&edges, vector<int>&memo,vector<int>&minid,int start) {
	queue<pair<int, int>>que;
	que.push(make_pair(start, 0));
	memo[start] = 0;
	minid[start] = start;
	while (!que.empty()) {
		auto atop(que.front());
		que.pop();
		for (auto e : edges[atop.first]) {
			const int nexttime = atop.second + 1;
			if (memo[e] > nexttime) {
				memo[e] = nexttime;
				que.push(make_pair(e, nexttime));
				minid[e] = min(e, minid[atop.first]);
			}
			else if (memo[e] == nexttime) {
				minid[e] = min(minid[e], minid[atop.first]);
			}
		}
	}
	return;
}

int main() {
	int nums[3];
	int N; cin >> N >> nums[0] >> nums[1] >> nums[2];
	map<int, int>mp;
	for (int j = 0; j < 3; ++j) {
		for (int i = 0; i < nums[j]; ++i) {	
			int n; cin >> n;
			n--; mp[n] = N + j;
		}
	}
	int M; cin >> M;
	vector<vector<int>>edges(N + 3);
	for (int i = 0; i < M; ++i) {
		int x, y; cin >> x >> y; x--; y--;
		int gx, gy;
		if (mp.find(x) == mp.end())gx = x;
		else gx = mp[x];
		if (mp.find(y) == mp.end())gy = y;
		else gy = mp[y];
		if (gx == gy)continue;
		edges[gx].push_back(gy);
		edges[gy].push_back(gx);
	}
	vector<vector<int>>memos(3,vector<int>(N+3,1e9));
	vector<vector<int>>froms(3,vector<int>(N+3,1e9));
	for (int i = 0; i < 3; ++i) {
		djk(edges, memos[i], froms[i], N + i);
	}
	pair<int, vector<int>>minids(make_pair(int(1e8),vector<int>(0)));
	for (int i = 0; i < N + 3; ++i) {
		if (mp.find(i) != mp.end())continue;
		else {
			int sum = 0;
			for (int j = 0; j < 3; ++j) {
				sum += memos[j][i];
			}
			if (sum < minids.first) {
				minids.first = sum;
				minids.second = vector<int>(1, i);
			}
			else if (sum == minids.first) {
				minids.second.emplace_back(i);
			}
		}
	}
	int ans = 1e8;
	for (auto id : minids.second) {
		for (int i = 0; i < 3; ++i) {
			ans = min(ans, froms[i][id]);
		}
	}
	for (int i = 0; i < N; ++i) {
		if (mp.find(i) != mp.end())ans = min(ans, i);
	}
	ans++;
	cout << minids.first <<" "<< ans << endl;
	return 0;
}

Measured memory_bytes: 8332
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
typedef long long ll;
using vi=vector<ll>;
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}

void solve() {
  ll n; cin>>n;
  ll happy[n+1][3],dp[n+1][3];
  REP(i,1,n+1)rep(j,3) cin>>happy[i][j];
  rep(k,3) dp[1][k]=happy[1][k];
  if(n>1){
    REP(i,1,n+1){
      dp[i+1][0]=max(dp[i][1],dp[i][2])+happy[i+1][0];
      dp[i+1][1]=max(dp[i][2],dp[i][0])+happy[i+1][1];
      dp[i+1][2]=max(dp[i][0],dp[i][1])+happy[i+1][2];
    }
  }
  ll last=0;
  rep(i,3) chmax(last,dp[n][i]);
  out(last);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	string s, t;
	cin >> n >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < n + 1; ++i) {
		if( s.substr(i) == t.substr(0, n - i) ) {
			ans = n + i;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
int a,b;
char op;
while (1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?'){
break;
}
else if(op=='+'){
printf("%d\n",a+b);
}
else if(op=='-'){
printf("%d\n",a-b);
}
else if(op=='*'){
printf("%d\n",a*b);
}
else if(op=='/'){
printf("%d\n",a/b);
}
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s,t;
	int a,b;
	cin >> s >> t >> a >> b;
	string k;
	cin >> k;
	if(k == s)--a;
	else --b;
	cout << a << ' ' << b << '\n';
}


Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        int[] w = { 0, 0, 0 };
        int[] k = { 0, 0, 0 };
        for(int i = 0; i < 10; i++)
        {
            int a = int.Parse(Console.ReadLine());
            for(int j = 0; j < 3; j++)
            {
                if (w[j] < a) { w[2] = a; break; }
            }
            Array.Sort(w);
            Array.Reverse(w);
        }
        for (int i = 0; i < 10; i++)
        {
            int a = int.Parse(Console.ReadLine());
            for (int j = 0; j < 3; j++)
            {
                if (k[j] < a) { k[2] = a; break; }
            }
            Array.Sort(k);
            Array.Reverse(k);
        }
        int b = w[0] + w[1] + w[2];
        int c = k[0] + k[1] + k[2];
        Console.WriteLine(b + " " + c);
    }
}

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

bool keta(int x){
    
    int count_keta = 0;
    
    while(x){
        count_keta++;
        x /= 10;
    }
    
    return count_keta%2; // count_keta%2 == 1
    
}


int main(void){
    
    int N;
    int ans = 0;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        if(keta(i)) ans++;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256