akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){

        Long L = nextLong();
        Long R = nextLong();

        Long min = 2019L;
        for(Long i=L; i<=R; i++){
            for(Long j=i+1L; j<=R; j++){
                min = Math.min((i*j)%2019, min);
                if(min == 0) break;
            }
            if(min == 0) break;
        }

        println(min);
    }

    static int nextInt(){
        return Integer.parseInt(sc.next());
    }
    static Long nextLong(){
        return Long.parseLong(sc.next());
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N==1)
  cout<<"Hello World"<<endl;
  else{
    int A,B;
    cin>> A >> B ;
    cout<<A+B<<endl;
  }
}
    

   
  
   
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define ll long long
#define INF 2e9
using namespace std;

void Main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+')
    cout << a + b << endl;
  else
    cout << a - b << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
using namespace std;

int main(){
    int n;

    cin >> n;

    int a[3][n + 1];

    a[1][0] = 0;
    a[2][0] = 0;

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

    vector<int> w1(n + 2, 0);
    vector<int> w2(n + 2, 0);

    for(int i = 0; i <= n; i++){
        w1[i + 1] = a[1][i] + w1[i];
        w2[i + 1] = a[2][i] + w2[i];
    }

    int maxv = 0;

    for(int k = 1; k <= n; k++){
        maxv = max(maxv, w1[k + 1] + w2[n + 1] - w2[k]);
    }

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

    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n = in(), k = in();
  vi h(n); cin >> h;
  int ans = 0;
  rep(i,n) if (h[i] >= k) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  int half = 0;
  if(n % 2 == 0){
      half = n / 2;
  }else {
      half = n / 2;
      ans--;
  }
  for(int i =0; i < n /2; i++){
      if(s[i] == s[i+n/2]){
          ans++;
      }
  }
  if(ans == n/2){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import copy
H, W, K = map(int,input().split())
c = [list(input()) for j in range(H)]
c_tmp =copy.deepcopy(c)


w_combs =[]
for i in range(2**W):
  w_comb = []
  for j in range(W):
    if (i >>j) & 1 :
      w_comb.append(j)
  w_combs.append(w_comb)

h_combs = []
for i in range(2**H):
  h_comb = []
  for j in range(H):
    if (i >>j) & 1 :
      h_comb.append(j)
  h_combs.append(h_comb)


ans = 0

for h_comb in h_combs:
  for w_comb in w_combs:
    c_tmp =copy.deepcopy(c)


    for w_one in w_comb:
      for y in range(H):
        c_tmp[y][w_one] = 'r'
    
    for h_one in h_comb:
      for x in range(W):
        c_tmp[h_one][x] = 'r'
    

    cnt_black = 0
    for row in c_tmp:
      for c_i in row:
        if c_i == '#':
          cnt_black +=1

    if cnt_black == K:
      ans +=1

print(ans)




Measured memory_bytes: 9296
/**
 *  author: mahfuzz
 *  created: 22.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    string ds = s;
    
    reverse(ds.begin(), ds.end());
    
    if(s == ds){
        int n = s.size();
        int a = (n - 1) / 2;
        int b = (n + 3) / 2;
        
        //cout << a  << " " << b << "\n";
        
        string s2 = "";
        
        for(int i = 0; i < a; i++){
            s2 += s[i];
        }
        //cout << s2 << "\n";
        string ds2 = s2;
        reverse(ds2.begin(), ds2.end());
        if(s2 == ds2){
            string s3 = "";
            for(int i = b-1; s[i]; i++){
                s3 += s[i];
            }
            //cout << s3 << "\n";
            string ds3 = s3;
            reverse(ds3.begin(), ds3.end());
            if(s3 == ds3){
                cout << "Yes\n";
                return 0;
            }
            
        }
    }
    
    cout << "No\n";
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
double n;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n;
	n/=3;
	cout<<fixed;
	cout<<setprecision(7)<<n*n*n;
	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
   ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
   ostr << "}";
   return ostr;}

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


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

 int N;
 cin >> N;
 int a[N][3];
 REP(i, N){
   REP(j, 3){
     cin >> a[i][j];
   }}


 int dp[N+100][3];
 REP(i, N+100){
   REP(j, 3){
     dp[i][j] = 0;
   }
 }

 REP(i, N){
   REP(j, 3){
     REP(k, 3){
       if (j != k){
       chmax(dp[i+1][k], dp[i][j] + a[i][k]);
       }}
   }
 }

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



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

const int maxn = 10;

long long n;
int a[maxn];
int b[maxn];
int ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
}

void solve(){
    int wow = 0;
    int wew = 0;
    do{
        wow++;
    }while(next_permutation(a, a + n));
    do{
        wew++;
    }while(next_permutation(b, b + n));
    ans = abs(wow - wew);
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    if(a == b){
        count++;
    }if(b == c){
        count++;
    }if(a == c){
        count++;
    }
    if(count < 2){
        cout << 3 - count << endl;
    }else{
        cout << 1 << endl;
    }
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;


int main()
{
	int a, b;
	cin >> a >> b;
	cout << round_int(a + b, 2) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin>>h[i];

    vector<int> isGood(n,true);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        isGood[a] = isGood[a] && h[a]>h[b];
        isGood[b] = isGood[b] && h[b]>h[a];
    }
    
    cout<<accumulate(isGood.begin(),isGood.end(),0)<<endl;
    return 0;
}


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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	double odd = ceil(n / 2.0);
	cout << odd / n << endl;
	return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;

chomp(my $num = <>);
chomp(my $input_text = <>);
my @text = split / /, $input_text;


my $j=1;

while(){
    my $i =0;
    while($i <= $#text){
        if($text[$i] % (2**$j) != 0 ){
            $j--;
            print $j;
            exit(0);
        }
        $i++;
    }
    $j++;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI 2 * acos(0)

#define maxn 400005

int n;
int MAX = 30000;

int main(){
	srand(1412);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	cin >> n;
	if(n == 3){
		cout << "2 5 63" << endl;
		return 0;
	}

	int num = min(n - (n & 1) - 2, 5000);
	int A = n - num;
	vector<int> res;
	for(int i = 1; i <= num; i++) res.pb(i * 6 - 3);
	ll sum = 0;
	for(int i = 1; i <= A - 1; i++) {
		res.pb(i * 2);
		sum += i * 2;
	}
	if((sum + (A * 2)) % 3 == 0){
		res.pb(A * 2);
	}
	else if((sum + (A * 2) + 2) % 3 == 0){
		res.pb(A * 2 + 2);
	} else res.pb(A * 2 + 4);

	sort(all(res));
	Rep(i, sz(res)) cout << res[i] << " "; cout << endl;

    return 0;
}


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


int main(){
	int N;
	int K;

	scanf("%d",&N);
	scanf("%d",&K);

	int sum = K;

	for(int i=1;i<N;i++){
		sum*=K-1;
	}

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

	return 0;
}

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

int main()
{
	int d;

	while(cin >> d)
	{
		int value=0,s=0;

		while(value != 600-d)
		{
			value += d;
			int line = value*value;
			s += line*d;
		}

		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
	char str[21];
	int i,k;
	for(i=0;i<=20;i++){
		str[i]='\0';
	}

	fgets(str,21,stdin);
	for(i=20;i>=0;i--){
		if(str[i]!='\0'){
			for(k=i;k>=0;k--){
				printf("%c",str[k]);
			}
			printf("\n");
			break;
		}
	}
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
	ll n, m ,k;
	cin>>n;
	vl dp(n + 1, 1);
	dp[1] = dp[2] = 0;
	for(ll i = 4; i <= n; i++)
	{
	    for(ll j = 3; j < i; j++)
	    {
	        if(i - j > 2)
	            dp[i] = (dp[i] + dp[i - j]) % MOD;
	    }
	    //cout<<i<<" "<<dp[i]<<"\n";
	}
	cout<<dp[n];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr int64_t INF = 1'010'000'000'000'000'017LL;

constexpr int64_t MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = asin(-1.0);
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define rep(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
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;
}

int main()
{
    int a, b, c = 1, d, n, m;
    cin >> n >> m;
     d = n;
    rep(i, m)
    {
        cin >> a >> b;
        c = max(c, a);
        d = min(d, b);
    }
    cout << max(0, d - c + 1)<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;

class DandA {
    static void Main(string[] args) {
        int a = ReadLineInt();
        bool rtn = false;
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (i* j == a) {
                    rtn = true;
                    break;
                }
            }
        }
        if (rtn) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }

    static string[] ary = new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }
 
 
int main() {
    ll h, w, m, a, b;
    cin >> h >> w >> m;
    vector<ll> l(h, 0), r(w, 0);
    map<P, ll> t;
    rep1(i, m){
        cin >> a >> b;
        a--;
        b--;
        l[a]++;
        r[b]++;
        P p = make_pair(a, b);
        t[p]++;
    }
    ll max_l = *max_element(l.begin(), l.end());
    ll max_r = *max_element(r.begin(), r.end());
    vector<ll> ndx_l, ndx_r;
    rep1(i, h) if (l[i] == max_l) ndx_l.push_back(i);
    rep1(i, w) if (r[i] == max_r) ndx_r.push_back(i);
    ll ans = max_l + max_r - 1;
    for (auto x: ndx_l){
        for (auto y: ndx_r){
            P p = make_pair(x, y);
            if (t[p]==0){
                ans = max_l + max_r;
                cout << ans << endl;
                return 0;
            }
        }
    } 
    cout << ans << endl;
}

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



int main(){
    int H,W;
    cin>>H>>W;
    vector<string> grid(H);
    for(int i=0; i<H; i++){
        cin>>grid.at(i);
    }
    vector<bool> tate(H,false);
    vector<bool> yoko(W,false);
    for(int j=0; j<H; j++){
        for(int k=0; k<W; k++){
            if((grid.at(j)).at(k) == '#'){
                tate.at(j) = true;
                yoko.at(k) = true;
            }
        }    
    }
    for(int i=0; i<H; i++){
        if(tate.at(i)){
            for(int j=0; j<W; j++){
                if(yoko.at(j)){
                    cout<<grid.at(i).at(j);
                }
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef int value_type; /* ソートするキーの型 */

double fabs(double a){
  if(a>=0)
    return a;
  else
    return -a;
}

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            i++; j--;
        }
        quicksort(a,left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}

int main(){
  int n,a[100000],result,tmp;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  if(n==2){
      if(a[0]<a[1]){
        tmp=a[1];
        a[1]=a[0];
        a[0]=tmp;
      }
      printf("%d %d\n",a[0],a[1]);
      return 0;
  }
  
  else
    quicksort(a,1,n-1);

  result=a[n-1];

  for(int i=0;i<n-1;i++){
    if(fabs((double)a[n-1]/2-a[i])<fabs((double)a[n-1]/2-result)&&a[i]!=0)
      result=a[i];
  }

  printf("%d %d\n",a[n-1],result);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int n, k;
VI nums;

void solve() {
	cin >> n >> k;
	nums.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	VI dp(n,0);
	dp[n-1] = 0;

	for(int i = n-2; i >= 0; i--) {
		int ans = INT_MAX;
		for(int j = 1; j+i <= n-1 && j <= k; j++) {
			ans = min(ans,abs(nums[i+j]-nums[i]) + dp[i+j]);
		}
		dp[i] = ans;
	}
	cout << dp[0];

}

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

	return 0;
}

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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

const int INF = 1e9;

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

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    vi raz(n+1, INF);
    vi pot(n+1, -1);
    priority_queue<pii> pq;
    raz[n] = 0;
    pq.push({0, -n});

    for(int i = n-1; ~i; --i)
    {
        if(s[i] == '1')
            continue;
        while(!pq.empty() && -pq.top().se > i + m)
            pq.pop();
        if(!pq.empty())
        {
            int taj = -pq.top().se;
            raz[i] = raz[taj] + 1;
            pot[i] = taj - i;
        }
        pq.push({-raz[i], -i});
    }

    if(raz[0] >= INF)
    {
        cout << -1 << "\n";
        exit(0);
    }

    int tren = 0;

    while(tren != n)
    {
        cout << pot[tren] << " ";
        tren += pot[tren];
    }
}


Measured memory_bytes: 5112
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
//UnionFind木
class UnionFind {
public:
	vector<int> par, sz;
	UnionFind(int n = 1) {
		init(n);
	}
	void init(int n) {
		par.resize(n); sz.resize(n);
		for (int i = 0; i < n; i++)par[i] = i, sz[i] = 1;
	}
	int root(int x) {
		if (par[x] == x)return x;
		else return par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int size(int x) {
		return sz[root(x)];
	}
	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y)return;
		par[y] = x;
		sz[x] += sz[y];
	}
};

int main() {
	int n, k, l;
	cin >> n >> k >> l;

	UnionFind rode(n), sub(n);
	rep(i, k) {
		int p, q; cin >> p >> q;
		rode.unite(p - 1, q - 1);
	}
	rep(i, l) {
		int r, s; cin >> r >> s;
		sub.unite(r - 1, s - 1);
	}

	map<pair<int, int>, int> ma;
	rep(i, n) {
		ma[mp(rode.root(i), sub.root(i))]++;
	}
	rep(i, n) {
		cout << ma[mp(rode.par[i], sub.par[i])] << (i == n - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int a,b;
	// nyuryoku
	cin >> a >> b;
	int ans = 0;
	if(a > b){
		ans += a;
		a--;
		ans += max(a,b);
	}else if(a == b){
		ans += 2*a;
	}else{
		ans += b;
		b--;
		ans += max(a,b);
	}
	// keisan
	cout << ans << endl;
	// syutsuryoku
}

Measured memory_bytes: 3572
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci V(N);
    set<int> odd;
    set<int> even;
    map<int,int> mp_odd;
    map<int,int> mp_even;
    REP(i,N) {
        cin >> V[i];
        if(i%2 == 0) {
            even.insert(V[i]);
            if(mp_even.count(V[i])) mp_even[V[i]]++;
            else mp_even[V[i]] = 1;
        }
        else {
            odd.insert(V[i]);
            if(mp_odd.count(V[i])) mp_odd[V[i]]++;
            else mp_odd[V[i]] = 1;
        }
    }

    vector<P> vec_even;
    vector<P> vec_odd;

    for(auto ret:mp_even) vec_even.push_back(P(ret.second,ret.first));
    for(auto ret:mp_odd) vec_odd.push_back(P(ret.second,ret.first));

    sort(vec_even.begin(),vec_even.end(),greater<P>());
    sort(vec_odd.begin(),vec_odd.end(),greater<P>());

    ll ans = 0;
    //cout << even.size() << " " << odd.size()<<endl;
    if(even.size() == 1 && odd.size() == 1) {
        for(int v: even) for(int w:odd) if(v == w) ans = N/2; else ans = 0;
    }
    if(even.size() == 1 && odd.size() > 1) {
        int v = vec_even[0].second;
        int w = vec_odd[0].second;
        if(v != w) ans = N/2-vec_odd[0].first;
        else ans = N/2 - vec_odd[1].first;
    } else if(even.size() > 1 && odd.size() == 1) {
        int v = vec_even[0].second;
        int w = vec_odd[0].second;
        if(v != w) ans = N/2-vec_even[0].first;
        else ans = N/2 - vec_even[1].first;
    } else if(even.size() > 1 && odd.size() > 1){
        int v = vec_even[0].second;
        int w = vec_odd[0].second;
        if(v != w) ans = N/2-vec_even[0].first + N/2-vec_odd[0].first;
        else ans = min(N-vec_even[0].first-vec_odd[1].first,N-vec_even[1].first-vec_odd[0].first);
    }

    cout << ans << endl;
}

Measured memory_bytes: 11132
#include<bits/stdc++.h>
using namespace std;
long long n,d,i,j,k,a[20][20],sq,dis,ans;
int main(){
    cin>>n>>d;
    for(i=1;i<=n;i++){
        for(j=1;j<=d;j++){
            cin>>a[i][j];
        }
    }
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            dis=0;
            for(k=1;k<=d;k++){
                dis+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            sq=sqrt(dis);
            if(sq*sq==dis) ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int N, H[100000], ans, mx;

int main() {
    cin >> N;
    rep(i, N) cin >> H[i];

    string ans = "Yes";
    rep(i, N) {
        if (H[i] < mx - 1) ans = "No";
        mx = max(mx, H[i]);
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     void unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k) return;

         par[t] = k;
         num[k] += num[t];
     }

     int size(int i) {
         return num[root(i)];
     }
};

struct edge{
    ll u,v,cost;
};

struct town{
    ll id,x,y;
};

signed main() {
    ll N;
    cin>>N;
    vector<town> v(N); // {x,y}
    rep(i,0,N){
        ll x,y;
        cin>>x>>y;
        v[i] = {i,x,y};
    }

    vector<edge> edges;
    sort(begin(v),end(v), [](const town &p, const town &q){return p.x < q.x; });
    rep(i,1,N)
        edges.push_back({v[i-1].id, v[i].id, v[i].x-v[i-1].x});
    sort(begin(v),end(v), [](const town &p, const town &q){return p.y < q.y; });
    rep(i,1,N)
        edges.push_back({v[i-1].id, v[i].id, v[i].y-v[i-1].y});
    sort(begin(edges),end(edges), [](const edge &p, const edge &q){return p.cost < q.cost; });

    ll ans=0;
    auto uf = UnionFind(N);
    for (auto e: edges){
        if (uf.same(e.u, e.v))
            continue;
        ans += e.cost;
        uf.unite(e.u, e.v);
        // printf("%d -> %d: %d\n",e.u,e.v,e.cost);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10864
package main

import (
  "fmt"
  "bufio"
  "os"
  "strconv"
)


func foo(a, b, c int) string {
  if a == b && a != c {
    return "Yes"
  }
  if a == c && a != b {
    return "Yes"
  }
  if b == c && a != b {
    return "Yes"
  }
  return "No"
}

// input process
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func nextText() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  // input
  sc.Split(bufio.ScanWords)
  a := nextInt()
  b := nextInt()
  c := nextInt()

  // output
  fmt.Println(foo(a, b, c))
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;


int add(int a, int b) { return a + b; }
int sub(int a, int b) { return a - b; }
int mul(int a, int b) { return a * b; }

int main()
{
	int (*ope[])(int, int) = { add, sub, mul };
	char* os[] = { "+", "-", "*" };

	int t[4];
	while (true)
	{
		scanf("%d %d %d %d", t, t+1, t+2, t+3);
		if (t[0] == 0 && t[1] == 0 && t[2] == 0 && t[3] == 0)
			break;

		int f = 0;
		int i, j, k;
		sort(t, t+4);
		do
		{
			for (i = 0; i < 3; ++i)
			{
				for (j = 0; j < 3; ++j)
				{
					for (k = 0; k < 3; ++k)
					{
						if (ope[k](ope[j](ope[i](t[0], t[1]), t[2]), t[3]) == 10)
						{
							f = 1;
							goto LoopEnd;
						}
						else if(ope[j](ope[i](t[0], t[1]), ope[k](t[2], t[3])) == 10)
						{
							f = 2;
							goto LoopEnd;
						}
					}
				}
			}
		} while (next_permutation(t, t+4));
LoopEnd:
		if (f == 1)
			printf("(((%d %s %d) %s %d ) %s %d)\n", t[0], os[i], t[1], os[j], t[2], os[k], t[3]);
		else if(f == 2)
			printf("((%d %s %d) %s (%d %s %d))\n", t[0], os[i], t[1], os[j], t[2], os[k], t[3]);
		else
			puts("0");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
using namespace std;
 
int main(){
 
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
 
    vector <string> str;
    string a;
    char ch;
    scanf("%c",&ch);
    for(int i=0;i<n;i++){
 
      assert(ch != ' '); 
      while(1){
    scanf("%c",&ch);
     
    if(ch == ' ') {
      str.push_back(a);
      a="";
      continue;
    }
    if(ch == '\n') {
      str.push_back(a);
      a="";
      break;
    }
    a += ch;
      }
 
    }
    cin >>a;
    vector <pair<int,string> > b;
    sort(str.begin(),str.end());
    for(int i=0;i<str.size();i++){
      if(a[0] == str[i][0]) {
    int cnt = 1;
    while(1) {
      if(i+1 == str.size()) break;
      if(str[i] == str[i+1])cnt++,i++;
      else break;
    }
    pair <int,string> t;
    t.first = -cnt;
    t.second = str[i];
      b.push_back(t);
      }
    }
     
    sort(b.begin(),b.end());
    for(int i=0;i<b.size();i++){
      if(i == 5) break;
      cout << b[i].second;
      if(i != b.size()-1) cout <<" ";
    }
    if(b.size() == 0) cout << "NA";
    cout << endl;
     
     
  }
  return 0;
}

Measured memory_bytes: 1296
#include<stdio.h>
int main(void){
    int a,b,i,n;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)break;
        for(i=1;i<=a;i++){
            for(n=1;n<=b;n++){
                if(n%2==1){
                    if(i%2==1)printf("#");
                    else printf(".");
                    }else{
                    if(i%2==1)printf(".");
                    else printf("#");
                    }
                }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v.at(i);
	int ans = 0;
	int now = 1;
	rep(i, n) {
		if (v.at(i) == now) {
			now++;
			continue;
		}else ans++;
	}
	if (ans == n) cout << -1 << endl;
	else cout << ans << endl;
	return 0;

}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}


ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}





// substr(start, len)

int main(){
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  while(true){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }

    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  // cout << setprecision(8) << ans << endl;  // For double
  // CHECK if it's possible to overflow!!
}

Measured memory_bytes: 3628
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10**10

for a in range(2**10):
    t = [(a>>b)&1 for b in range(10)]
    if 1 not in t:
        continue
    
    p = 0
    for i in range(N):
        p += P[i][sum(t[j] and F[i][j] for j in range(10))]

    ans = max(p, ans)

print(ans)

Measured memory_bytes: 9232
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const arr = input.split(/\n/);
let stack = "";
arr.forEach(item => {
  const rectangle = item.split(" ").map(Number);
  const h = rectangle[0];
  const w = rectangle[1];
  if(h === 0 && w === 0) return;
  for(let i = 0; i < h; i++) {
    let row = "";
    for(let j = 0; j < w; j++) {
      if(i === 0 || i === h - 1) {
        row += '#'
      } else {
        if (j === 0 || j === w - 1) {
          row += '#';
        } else {
          row += ".";
        }
      }
    }
    stack += row + "\n";
  }
  stack += "\n";
})
console.log(stack.trim() + "\n");


Measured memory_bytes: 18524
mod = 10**9+7
n = int(input())
A = list(map(int,input().split()))
c01 = [[0,0] for i in range(60)]
for a in A:
    for j in range(60):
        if a>>j &1:
            c01[j][1] += 1
        else:
            c01[j][0] += 1
ans = 0
for i in range(60):
    ans += 2**i *c01[i][0]*c01[i][1]
    ans%=mod
print(ans)


Measured memory_bytes: 122936
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[100005][4],dp[100005][4];
int main()
{
	scanf("%d",&n);
	memset(dp,-0x3f,sizeof(dp));dp[0][0]=0;
	for(int i=1;i<=n;++i) scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]);
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=3;++j) {
			for(int k=0;k<=4;++k) {
				if(k!=j) dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	printf("%d",max(max(dp[n][1],dp[n][2]),dp[n][3]));
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int n, m, q;
vector<int> a(52), b(52), c(52);
vector<ll> d(52);
ll ans = 0;

vector<int> vec(12, 1);

void dfs(int idx=1) {
  if(idx==n+1) {
    ll tmp = 0;
    rep(i, q) if(vec[b[i]]-vec[a[i]] == c[i]) tmp += d[i];
    chmax(ans, tmp);
    return;
  }

  for(int i = vec[idx-1]; i <= m; ++i) {
    vec[idx] = i;
    dfs(idx+1);
  }
}

int main()
{
  cin >> n >> m >> q;
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs();
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<ll>> matrix;
// O( n )
matrix identity(int n) {
    matrix A(n, vector<ll>(n));
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}
// O( n^3 )
matrix matmul(const matrix &A, const matrix &B, const ll mod) {
    matrix C(A.size(), vector<ll>(B[0].size()));
    for (int i = 0; i < (int)C.size(); ++i)
        for (int j = 0; j < (int)C[i].size(); ++j)
            for (int k = 0; k < (int)A[i].size(); ++k) {
                C[i][j] += A[i][k] * B[k][j];
                C[i][j] %= mod;
            }
    return C;
}
// O( n^3 log e )
matrix matpow(const matrix &A, ll e, const ll mod) {
    if (e == 0) return identity(A.size());
    if (e == 1) return A;
    if (e % 2 == 0) {
        matrix tmp = matpow(A, e/2, mod);
        return matmul(tmp, tmp, mod);
    } else {
        matrix tmp = matpow(A, e-1, mod);
        return matmul(A, tmp, mod);
    }
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  ll n,k;
  cin >> n >> k;
  vector<vector<ll>> a(n, vector<ll>(n,0));
  rep(i,n)rep(j,n){
    cin >> a[i][j];
  }
  a = matpow(a, k, mod);
  mint ans = 0;
  rep(i,n){
    rep(j,n){
      ans += a[i][j];
    }
  } 
  cout << ans.x << ln;
  return 0;
}

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

int main () {
  int a,b;
  cin >> a >> b;
  
  if (b==1) {
    cout << 0 << endl;
    return 0;
  }
  int xa=a;
  int count=1;
  while (xa<b) {
    count++;
    xa+=a-1;
  }
  cout << count << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include "string"
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s=="RRR"){
        cout << 3 <<endl;
        return 0;
    }
    if (s=="SRR"){
        cout << 2 << endl;
        return 0;
    }
    if(s=="RSR"){
        cout << 1 << endl;
        return 0;
    }
    if(s=="RRS"){
        cout << 2 << endl;
        return 0;
    }
    if(s=="SSR"){
        cout << 1 << endl;
    }
    if(s=="RSS"){
        cout << 1 << endl;
        return 0;
    }
    if(s=="SSS"){
        cout << 0 << endl;
        return 0;
    }
    if(s=="SRS"){
        cout << 1 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3248
N = int(input())
a = list(map(int,input().split()))
a.sort()
a_decending = a[::-1]
Alice = 0
Bob = 0

for i in range(N):
    if i % 2 == 0:
        Alice += a_decending[i]
    else:
        Bob += a_decending[i]
print(Alice - Bob)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
//typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
 
int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  ll a[x], b[y], c[z];
  
  for(int i=0; i<x; i++){
    cin >> a[i];
  }
  for(int i=0; i<y; i++){
    cin >> b[i];
  }
  for(int i=0; i<z; i++){
    cin >> c[i];
  }
  
  priority_queue<ll> q;
  for(int i=0; i<x; i++){
    for(int j=0; j<y; j++){
      q.push(a[i] + b[j]);
    }
  }
  //cout << "top" << endl;
  //cout << q.top() << endl;
  
  priority_queue<ll> q2;
  int count = 0;
  while(!q.empty()){
    count += 1;
    if (count>k) break;
    ll val = q.top();
    //cout << "val" << endl;
    //cout << val << endl;
    q.pop();
    for(int j=0; j<z; j++){
      q2.push(val + c[j]);
    }
  }
  
  for(int i=0; i<k; i++){
    ll val = q2.top();
    q2.pop();
    //cout << "ans" << endl;
    cout << val << endl;
  }
  
}

Measured memory_bytes: 43236